about summary refs log tree commit diff
path: root/tests/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2025-08-20Rollup merge of #140794 - karolzwolak:allow-unused-doc-65464, r=davidtwcoJacob Pratt-7/+7
mention lint group in default level lint note ### Summary This PR updates lint diagnostics so that default-level notes now mention the lint group they belong to, if any. Fixes: rust-lang/rust#65464. ### Example ```rust fn main() { let x = 5; } ``` Before: ``` = note: `#[warn(unused_variables)]` on by default ``` After: ``` = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default ``` ### Unchanged Cases Messages remain the same when the lint level is explicitly set, e.g.: * Attribute on the lint `#[warn(unused_variables)]`: ``` note: the lint level is defined here LL | #[warn(unused_variables)] | ^^^^^^^^^^^^^^^^ ``` * Attribute on the group `#[warn(unused)]:`: ``` = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` ``` * CLI option `-W unused`: ``` = note: `-W unused-variables` implied by `-W unused` = help: to override `-W unused` add `#[allow(unused_variables)]` ``` * CLI option `-W unused-variables`: ``` = note: requested on the command line with `-W unused-variables` ```
2025-08-19bless tests with new lint messagesKarol Zwolak-7/+7
2025-08-16Properly recover from parenthesized use-bounds (precise capturing)León Orell Valerian Liehr-0/+22
2025-08-09Rollup merge of #145115 - lcnr:less-borrowck-tainting, r=compiler-errorsStuart Cook-0/+38
defer opaque type errors, generally greatly reduce tainting fixes the test for rust-lang/rust#135528, does not actually fix that issue properly. This is useful as it causes the migration to rust-lang/rust#139587 to be a lot easier.
2025-08-09Rollup merge of #145050 - lcnr:add-opaque-type-tests, r=lqdStuart Cook-0/+354
add member constraints tests taken from rust-lang/rust#139587.
2025-08-08borrowck: defer opaque type errorslcnr-0/+38
2025-08-08fix typoslcnr-3/+3
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2025-08-07Use `tcx.short_string()` in more diagnosticsEsteban Küber-8/+9
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). When we don't actually print out a shortened type we don't need the "use `--verbose`" note. On E0599 show type identity to avoid expanding the receiver's generic parameters. Unify wording on `long_ty_path` everywhere.
2025-08-07add opaque type member constraint testslcnr-1/+101
2025-08-07move member-constraints testslcnr-0/+254
2025-08-06Fortify generic param default checksLeón Orell Valerian Liehr-48/+19
2025-07-31Remove the witness type from coroutine argsMichael Goulet-22/+4
2025-07-31Stall coroutines based off of ty::Coroutine, not ty::CoroutineWitnessMichael Goulet-9/+6
2025-07-24Rollup merge of #144014 - dianne:edition-guide-links, r=estebankLeón Orell Valerian Liehr-11/+11
don't link to the nightly version of the Edition Guide in stable lints As reported in rust-lang/rust#143557 for `rust_2024_incompatible_pat`, most future-Edition-incompatibility lints link to the nightly version of the Edition Guide; the lints were written before their respective Editions (and their guides) stabilized. But now that Rusts 2021 and 2024 are stable, these lints are emitted on stable versions of the compiler, where it makes more sense to present users with links that don't say "nightly" in them. This does not change the link for `rust_2024_incompatible_pat`. That's handled in rust-lang/rust#144006.
2025-07-20Rollup merge of #144142 - compiler-errors:itib, r=fmeaseMatthias Krüger-0/+30
Add implicit sized bound to trait ascription types r? ```@fmease``` or reassign Thanks for catching this :) Fixes rust-lang/rust#144135
2025-07-18Rollup merge of #142693 - fmease:unbound-bettering, r=compiler-errorsMatthias Krüger-4/+4
More robustly deal with relaxed bounds and improve their diagnostics Scaffolding for https://github.com/rust-lang/rust/issues/135229 (CC https://github.com/rust-lang/rust/pull/135331) Fixes https://github.com/rust-lang/rust/issues/136944 (6th commit). Fixes https://github.com/rust-lang/rust/issues/142718 (8th commit).
2025-07-18Add implicit sized bound to trait ascription typesMichael Goulet-0/+30
2025-07-18Rollup merge of #144029 - lichuang:fix_issue_143740, r=compiler-errorsMatthias Krüger-14/+1
Fix wrong messages from methods with the same name from different traits fix issue https://github.com/rust-lang/rust/issues/143740
2025-07-18Reword diagnostic about relaxing non-`Sized` boundLeón Orell Valerian Liehr-4/+4
* The phrasing "only does something for" made sense back when this diagnostic was a (hard) warning. Now however, it's simply a hard error and thus completely rules out "doing something". * The primary message was way too long * The new wording more closely mirrors the wording we use for applying other bound modifiers (like `const` and `async`) to incompatible traits. * "all other traits are not bound by default" is no longer accurate under Sized Hierarchy. E.g., traits and assoc tys are (currently) bounded by `MetaSized` by default but can't be relaxed using `?MetaSized` (instead, you relax it by adding `PointeeSized`). * I've decided against adding any diagnositic notes or suggestions for now like "trait `Trait` can't be relaxed as it's not bound by default" which would be incorrect for `MetaSized` and assoc tys as mentioned above) or "consider changing `?MetaSized` to `PointeeSized`" as the Sized Hierarchy impl is still WIP)
2025-07-17Eagerly unify coroutine witness in old solverMichael Goulet-4/+13
2025-07-17fix: fix issue 143740, Wrong messages from compiler confusing methods with ↵codedump-14/+1
the same name from different traits
2025-07-17Rollup merge of #143914 - shepmaster:mismatched-lifetime-syntaxes-rewording, ↵Matthias Krüger-4/+5
r=traviscross,jieyouxu Reword mismatched-lifetime-syntaxes text based on feedback Key changes include: - Removal of the word "syntax" from the lint message. More accurately, it could have been something like "syntax group" or "syntax category", but avoiding it completely is easier. - The primary lint message now reflects exactly which mismatch is occurring, instead of trying to be general. A new `help` line is general across the mismatch kinds. - Suggestions have been reduced to be more minimal, no longer also changing non-idiomatic but unrelated aspects. - Suggestion text no longer mentions changes when those changes don't occur in that specific suggestion. r? ``@jieyouxu``
2025-07-16future-incompat lints: don't link to the nightly edition-guide versiondianne-11/+11
2025-07-14Reword mismatched-lifetime-syntaxes text based on feedbackJake Goulding-4/+5
Key changes include: - Removal of the word "syntax" from the lint message. More accurately, it could have been something like "syntax group" or "syntax category", but avoiding it completely is easier. - The primary lint message now reflects exactly which mismatch is occurring, instead of trying to be general. A new `help` line is general across the mismatch kinds. - Suggestions have been reduced to be more minimal, no longer also changing non-idiomatic but unrelated aspects. - Suggestion text no longer mentions changes when those changes don't occur in that specific suggestion.
2025-07-13update issue number for `const_trait_impl`Deadbeef-1/+1
2025-07-13compute all rpitit of a traitbohan-1/+35
2025-07-11Rollup merge of #143661 - Muscraft:other-suggestion-message, r=estebankMatthias Krüger-1/+1
chore: Improve how the other suggestions message gets rendered Note: This change is part of my ongoing work to use `annotate-snippets` as `rustc`'s emitter This change started as a way to remove some specialty code paths from `annotate-snippets`, by making the "and {} other candidates" message get rendered like a secondary message with no level, but turned into a fix for the message's Unicode output. Before this change, when using the Unicode output, the other suggestions message would get rendered outside of the main suggestion block, making it feel disconnected from what it was referring to. This change makes it so that the message is on the last line of the block, aligning its rendering with other secondary messages, and making it clear what the message is referring to. Before: ``` error[E0433]: failed to resolve: use of undeclared type `IntoIter` ╭▸ $DIR/issue-82956.rs:28:24 │ LL │ let mut iter = IntoIter::new(self); │ ━━━━━━━━ use of undeclared type `IntoIter` ╰╴ help: consider importing one of these structs ╭╴ LL + use std::array::IntoIter; ├╴ LL + use std::collections::binary_heap::IntoIter; ├╴ LL + use std::collections::btree_map::IntoIter; ├╴ LL + use std::collections::btree_set::IntoIter; ╰╴ and 9 other candidates ``` After: ``` error[E0433]: failed to resolve: use of undeclared type `IntoIter` ╭▸ $DIR/issue-82956.rs:28:24 │ LL │ let mut iter = IntoIter::new(self); │ ━━━━━━━━ use of undeclared type `IntoIter` ╰╴ help: consider importing one of these structs ╭╴ LL + use std::array::IntoIter; ├╴ LL + use std::collections::binary_heap::IntoIter; ├╴ LL + use std::collections::btree_map::IntoIter; ├╴ LL + use std::collections::btree_set::IntoIter; │ ╰ and 9 other candidates ```
2025-07-10Rollup merge of #143742 - estebank:borrow-suggestion, r=compiler-errorsTrevor Gross-3/+6
Rework borrowing suggestions to use `Expr` instead of just `Span` In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`. (We were already doing this, but only for a subset of cases.) This now better handles situations where parentheses and `<>` are needed for correct syntax (`&(foo + bar)`, `(&foo).bar()`, `<&Foo>::bar()`, etc.). Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases. (Instead of having two branches for emitting the suggestion, we now have a single one, using `Diag::multipart_suggestions` always.) Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`. Fix rust-lang/rust#143393. Make `Diag::multipart_suggestions` always verbose. CC rust-lang/rust#141973.
2025-07-10Make `Diag::multipart_suggestions` always verboseEsteban Küber-3/+6
2025-07-10chore: Improve how the other suggestions message gets renderedScott Schafer-1/+1
2025-07-08Constify `Fn*` traitsOli Scherer-30/+2
2025-07-08Rollup merge of #143570 - bvanjoi:issue-143560, r=compiler-errorsMatthias Krüger-1/+138
consider nested cases for duplicate RPITIT Fixes rust-lang/rust#143560 r? `@compiler-errors` cc `@Zoxc`
2025-07-07consider nested cases for duplicate RPITITbohan-1/+138
2025-07-07Point to correct argument in Func Call when Self type fails trait boundxizheyin-2/+6
When a trait bound fails due to the Self type parameter, adjust_fulfillment_errors now correctly points to the corresponding function argument instead of incorrectly pointing to other arguments. Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-06distinguish the duplicate item of rpititbohan-0/+83
2025-07-01Auto merge of #143287 - GuillaumeGomez:rollup-fdjcti9, r=GuillaumeGomezbors-0/+31
Rollup of 12 pull requests Successful merges: - rust-lang/rust#136801 (Implement `Random` for tuple) - rust-lang/rust#141867 (Describe Future invariants more precisely) - rust-lang/rust#142760 (docs(fs): Touch up grammar on lock api) - rust-lang/rust#143181 (Improve testing and error messages for malformed attributes) - rust-lang/rust#143210 (`tests/ui`: A New Order [19/N] ) - rust-lang/rust#143212 (`tests/ui`: A New Order [20/N]) - rust-lang/rust#143230 ([COMPILETEST-UNTANGLE 2/N] Make some compiletest errors/warnings/help more visually obvious) - rust-lang/rust#143240 (Port `#[rustc_object_lifetime_default]` to the new attribute parsing …) - rust-lang/rust#143255 (Do not enable LLD by default in the dist profile) - rust-lang/rust#143262 (mir: Mark `Statement` and `BasicBlockData` as `#[non_exhaustive]`) - rust-lang/rust#143269 (bootstrap: make comment more clear) - rust-lang/rust#143279 (Remove `ItemKind::descr` method) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-30Unconditionally run `check_item_type` on all itemsOli Scherer-47/+92
2025-06-30cleaned up some testsKivooeo-3/+5
2025-06-29moved & deleted some testsKivooeo-0/+29
2025-06-29Fix the span of trait bound modifier `[const]`León Orell Valerian Liehr-4/+4
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-11/+11
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27Report infer ty errors during hir ty loweringOli Scherer-1/+1
This centralizes the placeholder type error reporting in one location, but it also exposes the granularity at which we convert things from hir to ty more. E.g. previously infer types in where bounds were errored together with the function signature, but now they are independent.
2025-06-26Auto merge of #143057 - matthiaskrgr:rollup-bulih8o, r=matthiaskrgrbors-3/+50
Rollup of 8 pull requests Successful merges: - rust-lang/rust#124595 (Suggest cloning `Arc` moved into closure) - rust-lang/rust#139594 (Simplify `ObligationCauseCode::IfExpression`) - rust-lang/rust#141311 (make `tidy-alphabetical` use a natural sort) - rust-lang/rust#141648 ([rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion) - rust-lang/rust#142285 (tests: Do not run afoul of asm.validity.non-exhaustive in input-stats) - rust-lang/rust#142393 (Don't give APITs names with macro expansion placeholder fragments in it) - rust-lang/rust#142884 (StableMIR: Add method to retrieve body of coroutine) - rust-lang/rust#142981 (Make missing lifetime suggestion verbose) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-26Rollup merge of #142981 - compiler-errors:verbose-missing-suggestion, r=estebankMatthias Krüger-3/+6
Make missing lifetime suggestion verbose I keep seeing this suggestion when working on rustc, and it's annoying that it's inline. Part of https://github.com/rust-lang/rust/issues/141973. Feel free to close this if there's another PR already doing this. r? ``@estebank``
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-11/+11
2025-06-25Add edition checks for some tests that had divergent outputEsteban Küber-60/+606
In order to expose edition dependent divergences in some tests in the test suite, add explicit `edition` annotations. Some of these tests might require additional work to *avoid* the divergences, as they might have been unintentional. These are not exhaustive changes, purely opportunistic while looking at something else.
2025-06-25Don't give APITs names with macro expansion placeholder fragments in itMichael Goulet-0/+44
2025-06-24Make missing lifetime suggestion verboseMichael Goulet-3/+6
2025-06-24Rollup merge of #142883 - mominul:impl_in_bindings, r=lcnrMatthias Krüger-0/+36
Add impl_trait_in_bindings tests from #61773 This adds the [three test cases](https://github.com/rust-lang/rust/issues/61773#issuecomment-2952638727) from the rust-lang/rust#61773 as was suggested by ``@lcnr.`` I have merged the first two cases into one, named as `region-lifetimes.rs` r? ``@lcnr`` Closes rust-lang/rust#61773
2025-06-24Add impl_trait_in_bindings testsMuhammad Mominul Huque-0/+36