947 Commits

Author SHA1 Message Date
Usman Akinyemi a677828c48 Add boxing suggestions for return expressions in impl Trait functions
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-04-26 17:43:40 +05:30
Usman Akinyemi 4fc64f4180 Add boxing suggestions for impl Trait return type mismatches
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-04-26 14:58:49 +05:30
Guillaume Gomez 8c3864b6cc Rollup merge of #155561 - cijiugechu:fix/need-type-info-underscore-wording, r=adwinwhite
Use singular wording for single _ placeholders in type suggestions

While looking this part of code, I noticed this FIXME and fixed it :)
2026-04-23 14:42:48 +02:00
Jonathan Brouwer 5abe5ea630 Rollup merge of #155546 - Unique-Usman:ua/impl_traits, r=estebank
Improve E0308 error message for `impl Trait` return mismatches

When a function returns `impl Trait`, all branches must return the same concrete type. Previously, the compiler showed:

    expected `First` because of return type

This was misleading, as it suggested the return type was `First`, rather than any single type implementing the trait.

Update the diagnostic to:

    expected a single type implementing `Value` because of return type

Also highlight the first return expression to make it clearer why subsequent returns do not match.
2026-04-21 20:42:50 +02:00
cijiugechu ffcbfc1cf4 Use singular wording for single _ placeholders in type suggestions 2026-04-20 22:21:51 +08:00
Muhtasim-Rasheed b1786813df Make E0284 generic argument suggestions more explicit 2026-04-20 16:46:57 +06:00
Usman Akinyemi 8b6f7fbd8d Improve E0308 error message for impl Trait return mismatches
When a function returns `impl Trait`, all branches must return the same
concrete type. Previously, the compiler showed:

    expected `First` because of return type

This was misleading, as it suggested the return type was `First`, rather
than any single type implementing the trait.

Update the diagnostic to:

    expected a single type implementing `Value` because of return type

Also highlight the first return expression to make it clearer why
subsequent returns do not match.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-04-20 13:59:39 +05:30
Zalathar 15fd168ee0 Tests for precise-capture through RPIT and TAIT 2026-04-14 21:14:10 +10:00
León Orell Valerian Liehr dda1ea0c43 Rename #[rustc_hidden_type_of_opaques] to #[rustc_dump_hidden_type_of_opaques] 2026-04-10 12:14:07 +02:00
Jonathan Brouwer 65745a1b95 Revert #152369 because of multiple regressions
The regressions are documented in the PR comments.
This reverts commit 2972b5e, reversing changes made to f908263.
2026-04-09 18:53:59 +02:00
Jacob Pratt 9ebe418dc6 Rollup merge of #153038 - pthariensflame:syncview-rename, r=Amanieu
core::sync: rename `Exclusive` to `SyncView` and make improvements

This PR implements the renaming of `core::sync::Exclusive` to `SyncView` as decided in rust-lang/rust#98407.  To preserve the ability to search for the old name, it adds `Exclusive` as a `doc_alias`.

It also makes the following additional changes:

- Converting the `get_mut` method to being an instance of `AsMut::as_mut`.  In the process, it makes both the new `impl AsMut` and the existing `impl AsRef` `const`, and it also renames `get_pin_mut` to `as_pin_mut` for consistency.  This direction follows a suggestion from rust-lang/rust#98407.
- Adding an `as_pin` method that can only be used when the wrapped type implements `Sync`, to complete the square of access methods.
- Making as many of the existing `impl`s `const` as possible; this involved making the existing `impl Default` no longer derived.
- Adding `impl`s for `AsyncFnOnce`, `AsyncFnMut`, and `AsyncFn`, akin to the existing `impls` for `FnOnce`, `FnMut`, and `Fn`.

It does not yet do the following, which may be desirable:

- Fixing/improving the documentation to address the concern pointed out in rust-lang/rust#146245.

It previously did the following, but this was removed after discussion:
- Adding an `impl` for (`const`) `Iterator`, which felt in line with the existing `impl`s for `Future` and `Coroutine`.
2026-04-09 02:31:08 -04:00
Jonathan Brouwer 2c77e2474e Rollup merge of #154866 - Kcang-gna:add-regression-test-for-#146514, r=Kivooeo
add regression test for #146514

Fixes: rust-lang/rust#146514
2026-04-07 17:26:35 +02:00
Kcang-gna 7ce2d51799 add regression test 2026-04-07 16:06:24 +08:00
Laine Taffin Altman 57d49652bf Update UI tests for SyncView rename 2026-04-06 18:10:08 -07:00
Edvin Bryntesson bd864efa70 bless tests and tidy
also removes E0452 and splits
`tests/rustdoc-ui/lints/renamed-lint-still-applies` into 2 tests

this is because of delayed warn lint being lost on compiler aborting on
error
2026-04-03 11:08:11 +02:00
León Orell Valerian Liehr dd96eff769 Sort pre-expansion gates and add more visible disclaimers 2026-04-01 17:01:58 +02:00
cyrgani d24ebcb47c rename some issues-* tests 2026-03-30 20:40:15 +00:00
Yuki Okushi 531631c7ad Make messages more generic 2026-03-28 16:18:11 +09:00
Jonathan Brouwer 7f8f600807 Rollup merge of #154257 - jdonszelmann:revert-eagerly-normalize-in-generalize, r=lcnr
Revert eagerly normalize in generalize

r? @lcnr

Reverts https://github.com/rust-lang/rust/pull/151746

We'll likely pull eager normalization out of generalization

Fixes rust-lang/rust#154173
Fixes rust-lang/rust#154244
2026-03-23 20:18:34 +01:00
Jana Dönszelmann e613b82e4e Revert "bless some tests"
This reverts commit 6edf58fab8.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann 1fa1611e9f Revert "address review"
This reverts commit d665c0b371.
2026-03-23 12:09:34 +01:00
cyrgani 9b0be7857a allow incomplete_features in most UI tests 2026-03-21 20:10:07 +00:00
bors ac7f9ec7da Auto merge of #151746 - jdonszelmann:eagerly-normalize-in-generalize, r=lcnr
Eagerly normalize in generalize

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/151746)*

r? @lcnr 

cc: https://github.com/rust-lang/trait-system-refactor-initiative/issues/262
2026-03-20 18:22:43 +00:00
Jana Dönszelmann d665c0b371 address review 2026-03-20 14:02:24 +01:00
Jonathan Brouwer 888990ba13 Rollup merge of #153967 - estebank:infer_must_implement, r=petrochenkov
Tweak wording of failed predicate in inference error

Special case message talking about `Predicate` that couldn't be satisfied when in inference errors so that we don't say "cannot satisfy `_: Trait`" and instead say "type must implement `Trait`".
2026-03-17 17:51:30 +01:00
ywxt 6a0ce16654 Ignore tests for the parallel frontend 2026-03-17 17:39:59 +08:00
Esteban Küber 9b1eb935bc Tweak wording of failed predicate in inference error
Special case message talking about `Predicate` that couldn't be satisfied when in inference errors so that we don't say "cannot satisfy `_: Trait`" and instead say "type must implement `Trait`".
2026-03-16 17:58:49 +00:00
John Kåre Alsaker fed57899b9 Remove value_from_cycle_error specialization for type_of 2026-03-13 18:52:26 +01:00
Nicholas Nethercote 3399ed3c9a Simplify type_of_opaque.
There is a bunch of complexity supporting the "cannot check whether the
hidden type of opaque type satisfies auto traits" error that shows up in
`tests/ui/impl-trait/auto-trait-leak.rs`. This is an obscure error that
shows up in a single test. If we are willing to downgrade that error
message to a cycle error, we can do the following.

- Simplify the `type_of_opaque` return value.
- Remove the `cycle_stash` query modifier.
- Remove the `CyclePlaceholder` type.
- Remove the `SelectionError::OpaqueTypeAutoTraitLeakageUnknown`
  variant.
- Remove a `FromCycleError` impl.
- Remove `report_opaque_type_auto_trait_leakage`.
- Remove the `StashKey::Cycle` variant.
- Remove the `CycleErrorHandling::Stash` variant.

That's a lot! I think this is a worthwhile trade-off.
2026-03-11 21:54:42 +11:00
Jonathan Brouwer 23e27344e9 Rollup merge of #153300 - fmease:test-attrs-tweaks, r=JonathanBrouwer
Tweak some of our internal `#[rustc_*]` TEST attributes

I think I might be the one who's used the internal TEST attrs `#[rustc_{dump_predicates,object_lifetime_default,outlives,variance}]` the most in recent times, I might even be the only one. As such I've noticed some recent-ish issues that haven't been fixed so far and which keep bothering me. Moreover I have a longstanding urge to rename several of these attributes which I couldn't contain anymore.

[`#[rustc_*]` TEST attributes](https://rustc-dev-guide.rust-lang.org/compiler-debugging.html#rustc_-test-attributes) are internal attributes that basically allow you to dump the output of specific queries for use in UI tests or for debugging purposes.

1. When some of these attributes were ported over to the new parsing API, their targets were unnecessarily restricted. I've kept encountering these incorrect "attribute cannot be used" errors all the while HIR analysis happily & correctly dumped the requested data below it. I've now relaxed their targets.
2. Since we now have target checking for the internal attributes I figured that it's unhelpful if we still intentionally crashed on invalid targets, so I've got rid of that.
3. I've always been annoyed that most of these (very old) attributes don't contain the word `dump` in their name (rendering their purpose non-obvious) and that some of their names diverge quite a bit from the corresponding query name. I've now rectified that. The new names take longer to type but it's still absolutely acceptable imo.

---

I haven't renamed all of the TEST attributes to follow the `rustc_dump_` scheme since that's quite tedious. If it's okay with you I'd like to postpone that (e.g., `rustc_{def_path,hidden_type…,layout,regions,symbol_name}`).

I've noticed that the parsers for TEST attrs are spread across `rustc_dump.rs`, `rustc_internal.rs` & `test_attrs.rs` which is a bit confusing. Since the new names are prefixed with `rustc_dump_` I've moved their parsers into `rustc_dump.rs` but of course they are still TEST attrs. IIRC, `test_attrs.rs` also contains non-`rustc_`-TEST attrs, so we can't just merge these two files. I guess that'll sort itself out in the future when I tackle the other internal TEST attrs.

r\? Jana || Jonathan
2026-03-04 19:30:39 +01:00
Jonathan Brouwer 1c44dbd580 Rollup merge of #152164 - mu001999-contrib:lint/unused_features, r=JonathanBrouwer
Lint unused features

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152164)*

Fixes rust-lang/rust#44232
Fixes rust-lang/rust#151752

---

This PR records used features through query side effect, then reports unsued features finally.
2026-03-04 19:30:36 +01:00
mu001999 0436634084 Remove unused features in tests 2026-03-04 08:06:45 +08:00
Jonathan Brouwer 87bd517707 Rollup merge of #153034 - arferreira:fix-trivial-bound-diagnostic, r=Kivooeo
Remove unhelpful hint from trivial bound errors

The `= help: see issue #48214` hint on trivial bound errors isn't useful, most users hitting these errors aren't trying to use the `trivial_bounds` feature. The `disabled_nightly_features` call already handles suggesting the feature gate on nightly.

Closes rust-lang/rust#152872
2026-03-03 07:14:15 +01:00
León Orell Valerian Liehr 6af78890bc Rename #![rustc_variance_of_opaques] to #![rustc_dump_variances_of_opaques] 2026-03-02 19:31:15 +01:00
Jonathan Brouwer 3ff038e5ea Rollup merge of #153216 - lqd:polonius-soundness-tests, r=Kivooeo
mark two polonius tests as known-bug

As described in https://github.com/rust-lang/rust/issues/153215, we want to track these two tests in case anything changes and when/if other fixes land.

As discussed in this week's meeting, r? @jackh726 (or anyone)
2026-02-28 12:52:58 +01:00
Rémy Rakic c9b2784731 mark two polonius tests as known-bug
As tracked in the soundness issue 153215.
2026-02-28 11:08:02 +01:00
reddevilmidzy 97748ad557 Improve cross-crate trait impl param mismatch suggestions 2026-02-28 05:29:28 +00:00
Jana Dönszelmann 6edf58fab8 bless some tests 2026-02-26 14:53:57 +01:00
Guillaume Gomez b55f6e3e67 Migrate rustc_lint to use TyCtxt::emit_diag_node_span_lint 2026-02-24 20:12:42 +01:00
arferreira d3bd9e6103 Remove unhelpful hint from trivial bound errors 2026-02-24 00:04:45 -05:00
Stuart Cook 565d1bb950 Rollup merge of #151744 - enthropy7:fix-refining-impl-trait-rtn, r=davidtwco
fix refining_impl_trait suggestion with return_type_notation

using `#![feature(return_type_notation)] `on top of `refining_impl_trait` made the lint suggest a pretty wild “wrap the body in `<Self as Trait>::f(..)”` fix instead of the simple “just copy the return type from the trait”. this patch makes the lint always suggest the plain return-type replacement based on the trait signature (by grabbing the original snippet when possible), so you don’t get RTN-style desugarings in the help

new test here

fixes rust-lang/rust#151663
2026-02-23 13:31:59 +11:00
Esteban Küber 37684bdfc5 Make all multipart suggestions verbose
The ShowAlways style of suggestions is usually easier to understand than the inline style.
2026-02-18 18:33:35 +00:00
Esteban Küber c73b3d20c6 Unify wording of resolve error
Remove "failed to resolve" and use the same format we use in other resolution errors "cannot find `name`".

```
error[E0433]: cannot find `nonexistent` in `existent`
  --> $DIR/custom_attr_multisegment_error.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ could not find `nonexistent` in `existent`
```
2026-02-17 16:51:44 +00:00
Ralf Jung 5e65109f21 add write_box_via_move intrinsic and use it for vec!
This allows us to get rid of box_new entirely
2026-02-16 17:27:40 +01:00
enthropy7 bcde3fc780 fix refining_impl_trait suggestion with return_type_notation 2026-02-06 16:14:09 +03:00
Esteban Küber 4a27be6972 Do not mention -Zmacro-backtrace for std macros that are a wrapper around a compiler intrinsic 2026-01-26 17:34:31 +00:00
zedddie 2dbcc72d85 clean up some tests 2026-01-22 19:50:00 +01:00
zedddie 3815b05ccd move some tests 2026-01-22 19:50:00 +01:00
León Orell Valerian Liehr 9b861ace46 Generalize diag for missing assoc types to account for assoc consts 2026-01-21 12:53:46 +01:00
Oli Scherer a3359bdd4f Compile-Time Reflection MVP: tuples 2026-01-08 11:41:00 +00:00