about summary refs log tree commit diff
path: root/tests/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
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
2025-06-22Implement DesugaringKind::FormatLiteralmejrs-5/+2
2025-06-20Rollup merge of #142485 - mu001999-contrib:dead-code/adt-pattern, r=petrochenkovTrevor Gross-4/+6
Marks ADT live if it appears in pattern Marks ADT live if it appears in pattern, it implies the construction of the ADT. 1. Then we can detect unused private ADTs impl `Default`, without special logics for `Default` and other std traits. 2. We can also remove `rustc_trivial_field_reads` on `Default`, and the logic in `should_ignore_item` (introduced by rust-lang/rust#126302). Fixes rust-lang/rust#120770 Extracted from rust-lang/rust#128637. r? `@petrochenkov`
2025-06-18Bless/update tests.Mara Bos-6/+6
2025-06-14Marks ADT live if it appears in patternMu001999-4/+6
2025-06-12Auto merge of #142127 - compiler-errors:nested-goals-certainty, r=lcnrbors-20/+46
Apply nested goals certainty to `InspectGoals` for normalizes-to ...so that normalizes-to goals don't have `Certainty::Yes` even if they have nested goals which don't hold. r? lcnr
2025-06-11Auto merge of #142358 - matthiaskrgr:rollup-fxe6m7k, r=matthiaskrgrbors-3/+6
Rollup of 9 pull requests Successful merges: - rust-lang/rust#141967 (Configure bootstrap backport nominations through triagebot) - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose) - rust-lang/rust#142272 (tests: Change ABIs in tests to more future-resilient ones) - rust-lang/rust#142282 (Only run `citool` tests on the `auto` branch) - rust-lang/rust#142297 (Implement `//@ needs-target-std` compiletest directive) - rust-lang/rust#142298 (Make loongarch-none target maintainers more easily pingable) - rust-lang/rust#142306 (Dont unwrap and re-wrap typing envs) - rust-lang/rust#142324 (Remove unneeded `FunctionCx` from some codegen methods) - rust-lang/rust#142328 (feat: Add `bit_width` for unsigned integer types) Failed merges: - rust-lang/rust#141639 (Expose discriminant values in stable_mir) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-11Auto merge of #141763 - lcnr:fixme-gamer, r=BoxyUwUbors-4/+1
`FIXME(-Znext-solver)` triage r? `@BoxyUwU`
2025-06-09Make E0621 missing lifetime suggestion verboseEsteban Küber-3/+6
``` error[E0621]: explicit lifetime required in the type of `x` --> $DIR/42701_one_named_and_one_anonymous.rs:10:9 | LL | &*x | ^^^ lifetime `'a` required | help: add explicit lifetime `'a` to the type of `x` | LL | fn foo2<'a>(a: &'a Foo, x: &'a i32) -> &'a i32 { | ++ ```
2025-06-09Apply nested goals certainty to InspectGoals for normalizes-toMichael Goulet-20/+46
2025-06-05Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, ↵bors-28/+13
r=traviscross,jieyouxu Add a new `mismatched-lifetime-syntaxes` lint The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is: - Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples: ```rust // Lint will warn about these fn(v: ContainsLifetime) -> ContainsLifetime<'_>; fn(&'static u8) -> &u8; ``` - Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule: ```rust // Lint will not warn about these fn(&u8) -> &'_ u8; fn(&'_ u8) -> &u8; fn(&u8) -> ContainsLifetime<'_>; ``` - Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler. --- This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-04Replace `elided_named_lifetimes` with `mismatched_lifetime_syntaxes`Jake Goulding-28/+13
2025-06-03Run wfcheck in one big loop instead of per moduleOli Scherer-21/+21
2025-06-03`FIXME(-Znext-solver)` triagelcnr-4/+1
Co-authored-by: Michael Goulet <michael@errs.io>
2025-05-27Use more detailed spans in dyn compat errors within bodiesOli Scherer-6/+76
2025-05-26Deduplicate dyn compatibility violations due to coercionMichael Goulet-81/+4
2025-05-25Rollup merge of #141512 - Noratrieb:stop-trimming-this-much, r=compiler-errorsGuillaume Gomez-8/+8
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-24Avoid extra path trimming in method not found errorNoratrieb-8/+8
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-23Do not try to confirm non-dyn compatible methodMichael Goulet-37/+1
2025-05-21Rollup merge of #141308 - spastorino:fix-rpitit-error-reporting-ice, ↵Matthias Krüger-0/+34
r=nnethercote Do not call name() on rpitit assoc_item Fixes #141143 r? `@nnethercote`
2025-05-20Do not call name() on rpitit assoc_itemSantiago Pastorino-0/+34
2025-05-20Just error on recursive opaque ty in HIR typeckMichael Goulet-149/+61
2025-05-16Rollup merge of #140834 - lcnr:apit-folder, r=compiler-errorsMatthias Krüger-89/+0
move (or remove) some impl Trait tests Probably not actually worth the effort, so I am stopping here :sweat_smile:
2025-05-09Merge typeck loop with static/const item eval loopOli Scherer-8/+8
2025-05-09move (and remove) impl Trait testslcnr-89/+0
2025-05-05Auto merge of #140453 - Zoxc:next-disambiguator, r=oli-obkbors-12/+12
Remove global `next_disambiguator` state and handle it with a `DisambiguatorState` type This removes `Definitions.next_disambiguator` as it doesn't guarantee deterministic def paths when `create_def` is called in parallel. Instead a new `DisambiguatorState` type is passed as a mutable reference to `create_def` to help create unique def paths. `create_def` calls with distinct `DisambiguatorState` instances must ensure that that the def paths are unique without its help. Anon associated types did rely on this global state for uniqueness and are changed to use (method they're defined in + their position in the method return type) as the `DefPathData` to ensure uniqueness. This also means that the method they're defined in appears in error messages, which is nicer. `DefPathData::NestedStatic` is added to use for nested data inside statics instead of reusing `DefPathData::AnonConst` to avoid conflicts with those. cc `@oli-obk`
2025-05-04compiletest: Support matching on non-json lines in compiler outputVadim Petrochenkov-4/+5
and migrate most of remaining `error-pattern`s to it.
2025-05-03Rollup merge of #140568 - moxian:reg-140545, r=compiler-errorsMatthias Krüger-0/+29
Add regression test for #140545 Closes #140545 I am not very knowledgable about the typesystem internals, so I couldn't come up with a good name for the test. But I'm happy to move it to a more appropriate place if there is one (`tests/ui/impl-trait/non-defining-uses` maybe?) r? types (or reroll as appropriate if this is not actually a T-types issue; i'm clueless)
2025-05-02Add a regression testmoxian-0/+29
for #140545
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-49/+55
2025-04-29Remove global `next_disambiguator` state and handle it with a ↵John Kåre Alsaker-12/+12
`DisambiguatorState` type
2025-04-28Do not compute type_of for impl item if impl where clauses are unsatisfiedMichael Goulet-0/+32
2025-04-25Don't use item name to look up associated item from trait itemMichael Goulet-0/+49
2025-04-20Don't compute name of associated item if it's an RPITITMichael Goulet-0/+62
2025-04-17Rollup merge of #139854 - fmease:modern-diag-for-lt-in-ty, r=davidtwcoMatthias Krüger-6/+8
Improve parse errors for stray lifetimes in type position While technically & syntactically speaking lifetimes do begin[^1] types in type contexts (this essentially excludes generic argument lists) and require a following `+` to form a complete type (`'a +` denotes a bare trait object type), the likelihood that a user meant to write a lifetime-prefixed bare trait object type in *modern* editions (Rust ≥2021) when placing a lifetime into a type context is incredibly low (they would need to add at least three tokens to turn it into a *semantically* well-formed TOT: `'a` → `dyn 'a + Trait`). Therefore let's *lie* in modern editions (just like in PR https://github.com/rust-lang/rust/pull/131239, a precedent if you will) by stating "*expected type, found lifetime*" in such cases which is a lot more a approachable, digestible and friendly compared to "*lifetime in trait object type must be followed by `+`*" (as added in PR https://github.com/rust-lang/rust/pull/69760). I've also added recovery for "ampersand-less" reference types (e.g., `'a ()`, `'a mut Ty`) in modern editions because it was trivial to do and I think it's not unlikely to occur in practice. Fixes #133413. [^1]: For example, in the context of decl macros, this implies that a lone `'a` always matches syntax fragment `ty` ("even if" there's a later macro matcher expecting syntax fragment `lifetime`). Rephrased, lifetimes (in type contexts) *commit* to the type parser.
2025-04-15Don't compute name of associated item if it's an RPITITMichael Goulet-0/+21
2025-04-15Improve diagnostic for E0178 (bad `+` in type)León Orell Valerian Liehr-6/+8
Namely, use a more sensical primary span. Don't pretty-print AST nodes for the diagnostic message. Why: * It's lossy (e.g., it doesn't replicate trailing `+`s in trait objects. * It's prone to leak error nodes (printed as `(/*ERROR*/)`) since the LHS can easily represent recovered code (e.g., `fn(i32?) + T`).
2025-04-14add RPITIT tests: method compat auto trait leakagelcnr-0/+224
2025-04-14move testslcnr-0/+0
2025-04-14do not leak auto traits in item boundslcnr-0/+36