Commit Graph

221 Commits

Author SHA1 Message Date
Matthias Krüger
0d0b695b9f Rollup merge of #147269 - reddevilmidzy:ice-fix, r=petrochenkov
Add regression test for 123953

close: rust-lang/rust#123953
2025-10-03 21:10:32 +02:00
reddevilmidzy
fab9906c21 test: Add regression test for ICE when projecting associated types through dyn traits 2025-10-03 04:28:29 +09:00
Jules Bertholet
389907a17e Enforce E0719 only for trait aliases 2025-09-18 09:16:58 -04:00
Jynn Nelson
2adaa5dae2 Bump rustfix 0.8.1 -> 0.8.7
This commit can be replicated by running
`cargo update -p rustfix --precise 0.8.7 && x test ui --bless`.

---

The reasons this affects UI tests is as follows:
- The UI test suite runs rustc with
    `-Z deduplicate-diagnostics=no --error-format=json`,
  which means that rustc emits multiple errors containing identical
  suggestions. That caused the weird-looking code that had multiple `X: Copy` suggestions.
- Those suggestions are interpreted not by rustc itself, but by the
  `rustfix` library, maintained by cargo but published as a separate
  crates.io library and used by compiletest.
- Sometime between rustfix 0.8.1 and 0.8.7 (probably in cargo 14747, but
  it's hard to tell because rustfix's versioning doesn't match cargo's),
  rustfix got smarter and stopped applying duplicate suggestions.

Update rustfix to match cargo's behavior. Ideally, we would always share
a version of rustfix between cargo and rustc (perhaps with a path
dependency?), to make sure we are testing the behavior we ship. But for
now, just manually update it to match.

Note that the latest version of rustfix published to crates.io is 0.9.1,
not 0.8.7. But 0.9.1 is not the version used in cargo, which is 0.9.3.
Rather than trying to match versions exactly, I just updated rustfix to
the latest in the 0.8 branch.
2025-09-15 10:48:26 -07:00
Jacob Pratt
82bb6d523b Rollup merge of #145896 - Oneirical:uncountable-integer-10, r=jieyouxu
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#3 of Batch #2]

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
2025-09-13 03:26:02 -04:00
Oneirical
957fa10d50 Add test batch 3 2025-09-12 14:45:12 -04:00
Esteban Küber
049c32797b On E0277, point at type that doesn't implement bound
When encountering an unmet trait bound, point at local type that doesn't implement the trait:

```
error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied
  --> $DIR/issue-64855.rs:9:19
   |
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
   |                   ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `Foo` is not implemented for `Bar<T>`
  --> $DIR/issue-64855.rs:9:1
   |
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
   | ^^^^^^^^^^^^^^^^^
```
2025-08-22 17:55:15 +00:00
Karol Zwolak
d14b83e378 bless tests with new lint messages 2025-08-19 21:27:10 +02:00
Jacob Pratt
5bd4e832d3 Rollup merge of #144553 - Oneirical:uncountable-integer-4, r=jieyouxu
Rehome 32 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`

rust-lang/rust#143902 divided into smaller, easier to review chunks.

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
2025-08-10 15:43:52 -04:00
Oneirical
aa543963c6 Rehome tests/ui/issues/ tests [4/?] 2025-08-10 11:54:15 -04:00
Oneirical
7196d8cd66 Rehome tests/ui/issues/ tests [3/?] 2025-08-04 16:43:53 -04:00
León Orell Valerian Liehr
84ed70b69d Reword diagnostics about relaxed bounds in invalid contexts 2025-07-18 12:13:19 +02:00
León Orell Valerian Liehr
1df99f22d3 AST lowering: More robustly deal with relaxed bounds 2025-07-18 03:13:21 +02:00
Camille GILLOT
277b0ecf34 Remove hir::AssocItemKind. 2025-07-13 13:50:00 +00:00
Scott Schafer
d67bf6095a chore: Improve how the other suggestions message gets rendered 2025-07-10 08:00:20 -06:00
Oli Scherer
28f023c751 Use predicate spans instead of whole item spans 2025-06-30 08:45:43 +00:00
Oli Scherer
9b5d57d0a9 Unconditionally run check_item_type on all items 2025-06-30 08:06:08 +00:00
Guillaume Gomez
05b209d3a2 Rollup merge of #142417 - Kivooeo:tf12, r=jieyouxu
`tests/ui`: A New Order [12/N]

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@jieyouxu`
2025-06-29 12:29:55 +02:00
Kivooeo
aac948b702 cleaned up some tests 2025-06-28 16:24:17 +05:00
mejrs
b1d18129d1 Implement DesugaringKind::FormatLiteral 2025-06-22 10:58:25 +02:00
Matthias Krüger
4bf7765388 Rollup merge of #142477 - JonathanBrouwer:associated-type-suggestion, r=WaffleLapkin
Fix incorrect suggestion when calling an associated type with a type anchor

`sugg_span` here is the span of the call expression.
That span here is the `<Self>::Assoc`, which is exactly what we need here (even though I would expect it to include the arguments, but I guess it doesn't)

r? ``@WaffleLapkin``
One commit with failing tests and one that fixes it for reviewability

closes rust-lang/rust#142473
2025-06-14 11:27:12 +02:00
Jonathan Brouwer
1d036f408e Fix incorrect suggestion when calling an associated type with a type anchor
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-14 00:08:28 +02:00
Jonathan Brouwer
c9995d2492 Failing test
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-14 00:08:02 +02:00
mejrs
c0e02e26b3 Unimplement unsized_locals 2025-06-13 01:16:36 +02:00
Jake Goulding
d35ad94849 Replace elided_named_lifetimes with mismatched_lifetime_syntaxes 2025-06-04 10:40:04 -04:00
Guillaume Gomez
cd0adc9d7b Rollup merge of #140370 - WaffleLapkin:unqualified, r=jdonszelmann
Improve diagnostics for usage of qualified paths within tuple struct exprs/pats

For patterns the old diagnostic was just incorrect, but I also added machine applicable suggestions.

For context, this special cases errors for `<T as Trait>::Assoc(..)` patterns and expressions (latter is just a call). Tuple struct patterns and expressions both live in the value namespace, so they are not forwarded through associated *types*.

r? ``@jdonszelmann``

cc ``@petrochenkov`` in https://github.com/rust-lang/rust/pull/80080#issuecomment-800630582 you were wondering why it doesn't work for types, that's why — tuple patterns are resolved in the value namespace.
2025-06-01 19:35:41 +02:00
Noratrieb
01503d0c1e Avoid extra path trimming in method not found error
Method errors have an extra check that force trim paths whenever the
normal string is longer than 10 characters, which can be quite unhelpful
when multiple items have the same name (for example an `Error`).

A user reported this force trimming as being quite unhelpful when they
had a method error where the precise path of the `Error` mattered.

The code uses `tcx.short_string` already to get the normal path, which
tries to be clever around trimming paths if necessary, so there is no
reason for this extra force trimming.
2025-05-24 23:31:07 +02:00
Matthias Krüger
3216098e53 Rollup merge of #140218 - fmease:hirtylo-clean-up-path-low, r=compiler-errors
HIR ty lowering: Clean up & refactor the lowering of type-relative paths

While rebasing #126651 I realized that HIR ty lowering could benefit from some *spring cleaning* now that it's been extended to handle RTN and mGCA paths.

More seriously, similar to my merged PR #118668 which unified the handling of all *associated item constraints* (assoc ty, const (ACE) & fn (RTN)), this PR (commit 695fcf517d) partially[^1] deduplicates the resolution code for all *type-relative paths* (assoc ty, const (mGCA) & fn (RTN)).

**Why**? DRY'ing that part of the code means PR #126651 will automatically support RTN paths like `Ty::AssocTy::assoc_fn(..)` and it also implies shared diagnostic code and thus better diagnostics for RTN.

---

The other commits represent cleanups, renamings, moves. More notably, I've renamed path lowering methods to be a lot more descriptive, so ones lowering `QPath(Resolved)` paths now have `_resolved_` in their name and ones lowering `QPath(TypeRelative)` paths now have `_type_relative_` in their name. This should make it stupidly obvious what their purpose is.

---

Best reviewed commit by commit. The changes are close to trivial but the diff might make it look hairier.
r? compiler-errors

[^1]: Sadly, I couldn't unify as much compared to the other PR without introducing unnecessary `unreachable!()`s or rendering the code otherwise illegible with flags and micro helper traits.
2025-05-22 16:02:28 +02:00
Matthias Krüger
8c14588fbb Rollup merge of #140208 - compiler-errors:wf-coinductive, r=lcnr
Make well-formedness predicates no longer coinductive

This PR makes well-formedness no longer coinductive. It was made coinductive in https://github.com/rust-lang/rust/pull/98542, but AFAICT this was only to fix UI tests since we stopped lowering `where Ty:` to an empty-region outlives predicate but to a WF predicate instead.

Arguably it should lower to something completely different, something like a "type mentioned no-op predicate", but well-formedness serves this purpose fine today, and since no code (according to crater) relies on this coinductive behavior, we'd like to avoid having to emulate it in the new solver.

Fixes #123456 (I didn't want to add a test since it seems low-value to have a ICE test for a fuzzer minimization that is basically garbage code.)

Fixes #109764 (not sure if this behavior is emulatable w/o coinductive WF?)

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/169

r? lcnr
2025-05-17 10:33:08 +02:00
León Orell Valerian Liehr
8c37c8c3e6 Preserve generic args in suggestions for ambiguous associated items
Most notably, this preserves the `(..)` of ambiguous RTN paths.
2025-05-06 17:04:03 +02:00
Michael Goulet
f2930001aa Use select in projection lookup 2025-04-30 18:07:52 +00:00
Vadim Petrochenkov
20faf8532b compiletest: Make diagnostic kind mandatory on line annotations 2025-04-30 10:44:24 +03:00
Michael Goulet
38c05a68ee Adjust tests 2025-04-29 03:07:24 +00:00
Michael Goulet
f918b89f61 Wf is not coinductive 2025-04-29 02:43:06 +00:00
Waffle Lapkin
bce7fe1818 Make error for tuple struct pat/expr w/ FQS clearer
1. Fix "expected" and the note for the pattern case
2. Add suggestions
2025-04-27 18:10:08 +02:00
Waffle Lapkin
5f294f099a Improve test for FQS tuple struct pat/expr
1. Better explain what the test tests
2. Test slightly more cases
2025-04-27 17:32:32 +02:00
Matthias Krüger
0de803c38d Rollup merge of #138632 - clubby789:stabilize-cfg-boolean-lit, r=davidtwco,Urgau,traviscross
Stabilize `cfg_boolean_literals`

Closes #131204
`@rustbot` labels +T-lang +I-lang-nominated
This will end up conflicting with the test in #138293 so whichever doesn't land first will need updating

--

# Stabilization Report

## General design

### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?

[RFC 3695](https://github.com/rust-lang/rfcs/pull/3695), none.

### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

None

### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those?

None

## Has a call-for-testing period been conducted? If so, what feedback was received?

Yes; only positive feedback was received.

## Implementation quality

### Summarize the major parts of the implementation and provide links into the code (or to PRs)

Implemented in [#131034](https://github.com/rust-lang/rust/pull/131034).

### Summarize existing test coverage of this feature

- [Basic usage, including `#[cfg()]`, `cfg!()` and `#[cfg_attr()]`](6d71251cf9/tests/ui/cfg/true-false.rs)
- [`--cfg=true/false` on the command line being accessible via `r#true/r#false`](6d71251cf9/tests/ui/cfg/raw-true-false.rs)
- [Interaction with the unstable `#[doc(cfg(..))]` feature](https://github.com/rust-lang/rust/tree/6d71251/tests/rustdoc-ui/cfg-boolean-literal.rs)
- [Denying `--check-cfg=cfg(true/false)`](https://github.com/rust-lang/rust/tree/6d71251/tests/ui/check-cfg/invalid-arguments.rs)
- Ensuring `--cfg false` on the command line doesn't change the meaning of `cfg(false)`: `tests/ui/cfg/cmdline-false.rs`
- Ensuring both `cfg(true)` and `cfg(false)` on the same item result in it being disabled: `tests/ui/cfg/both-true-false.rs`

### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?

The above mentioned issue; it should not block as it interacts with another unstable feature.

### What FIXMEs are still in the code for that feature and why is it ok to leave them there?

None

### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization
- `@clubby789` (RFC)
- `@Urgau` (Implementation in rustc)

### Which tools need to be adjusted to support this feature. Has this work been done?

`rustdoc`'s  unstable`#[doc(cfg(..)]` has been updated to respect it. `cargo` has been updated with a forward compatibility lint to enable supporting it in cargo once stabilized.

## Type system and execution rules

### What updates are needed to the reference/specification? (link to PRs when they exist)

A few lines to be added to the reference for configuration predicates, specified in the RFC.
2025-04-17 06:25:15 +02:00
Vadim Petrochenkov
93bee0789a UI tests: migrate remaining compile time error-patterns to line annotations
when possible.
2025-04-13 21:48:53 +03:00
Michael Goulet
830aeb6102 Use a query rather than recomputing the tail repeatedly 2025-04-09 20:26:58 +00:00
Vadim Petrochenkov
b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
Bennet Bleßmann
7dd57f085c update/bless tests 2025-04-06 21:41:47 +02:00
clubby789
303c1b45c2 Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
Vadim Petrochenkov
4d64990690 compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
Stuart Cook
781240939f Rollup merge of #138941 - compiler-errors:receiver-is-dispatchable-bounds, r=BoxyUwU
Do not mix normalized and unnormalized caller bounds when constructing param-env for `receiver_is_dispatchable`

See comments in code and in test I added.

r? `@BoxyUwU` since you reviewed the last PR, or reassign

Fixes #138937
2025-04-02 13:10:38 +11:00
Michael Goulet
4f2baaa9c6 Do not mix normalized and unnormalized caller bounds when constructing param-env for receiver_is_dispatchable 2025-03-30 02:39:19 +00:00
Vadim Petrochenkov
2dfd2a2a24 Remove attribute #[rustc_error] 2025-03-30 01:32:21 +03:00
Esteban Küber
f0b8e13b59 Do not suggest using -Zmacro-backtrace for builtin macros
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-14 19:50:03 +00:00
Michael Goulet
c170d0f12f Elaborate param-env built for checking DispatchFromDyn for dyn compat 2025-03-11 16:32:56 +00:00
Michael Goulet
06072468fe Fix associated type errors too 2025-03-03 23:53:42 +00:00
许杰友 Jieyou Xu (Joe)
50ed7f974b Rollup merge of #137599 - davidtwco:use-minicore-more, r=jieyouxu
tests: use minicore more

minicore makes it much easier to add new language items to all of the existing `no_core` tests.

Most of the remaining tests that *could* use minicore either fail because..

1. LLVM IR output changes and doesn't pass the test as written. I didn't look into these further.
2. The test has revisions w/ different compilation flags, expecting some to fail, and when using minicore, minicore is compiled with those flags and fails in the expected way because of the flags rather than the test, and that's considered a failure.

But these tests can be changed and make adding new language items a lot easier.

r? ```@jieyouxu```
2025-02-28 22:29:52 +08:00