summary refs log tree commit diff
path: root/tests/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2024-01-30Provide more context on derived obligation error primary labelEsteban Küber-10/+10
Expand the primary span of E0277 when the immediate unmet bound is not what the user wrote: ``` error[E0277]: the trait bound `i32: Bar` is not satisfied --> f100.rs:6:6 | 6 | <i32 as Foo>::foo(); | ^^^ the trait `Bar` is not implemented for `i32`, which is required by `i32: Foo` | help: this trait has no implementations, consider adding one --> f100.rs:2:1 | 2 | trait Bar {} | ^^^^^^^^^ note: required for `i32` to implement `Foo` --> f100.rs:3:14 | 3 | impl<T: Bar> Foo for T {} | --- ^^^ ^ | | | unsatisfied trait bound introduced here ``` Fix #40120.
2024-01-30Rollup merge of #120293 - estebank:issue-102629, r=nnethercoteGuillaume Gomez-22/+4
Deduplicate more sized errors on call exprs Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-24Account for expected `dyn Trait` found `impl Trait`Esteban Küber-0/+61
2024-01-24On E0308 involving `dyn Trait`, mention trait objectsEsteban Küber-0/+2
When encountering a type mismatch error involving `dyn Trait`, mention the existence of boxed trait objects if the other type involved implements `Trait`. Partially addresses #102629.
2024-01-24Deduplicate more sized errors on call exprsEsteban Küber-22/+4
Change the implicit `Sized` `Obligation` `Span` for call expressions to include the whole expression. This aids the existing deduplication machinery to reduce the number of errors caused by a single unsized expression.
2024-01-22Add some testsOli Scherer-0/+39
2024-01-20Auto merge of #119821 - oli-obk:reveal_all_const_evals, r=lcnrbors-0/+172
Always use RevealAll for const eval queries implements what is described in https://github.com/rust-lang/rust/pull/116803#discussion_r1364089471 Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types. New tests are copied from https://github.com/rust-lang/rust/pull/101478
2024-01-19Always use RevealAll for const eval queriesOli Scherer-0/+172
2024-01-18Rollup merge of #119869 - oli-obk:track_errors2, r=matthewjasperMatthias Krüger-2/+26
replace `track_errors` usages with bubbling up `ErrorGuaranteed` more of the same as https://github.com/rust-lang/rust/pull/117449 (removing `track_errors`)
2024-01-17Use FnOnceOutput instead of FnOnce where expectedOli Scherer-0/+99
2024-01-17Move `check_mod_impl_wf` query call out of track_errors and bubble errors up ↵Oli Scherer-2/+26
instead.
2024-01-15Rollup merge of #119818 - oli-obk:even_more_follow_up_errors3, r=compiler-errorsMatthias Krüger-17/+14
Silence some follow-up errors [3/x] this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449 Keep error types around, even in obligations. These help silence follow-up errors, as we now figure out that some types (most notably inference variables) are equal to an error type. But it also allows figuring out more types in the presence of errors, possibly causing more errors.
2024-01-13Bless testsGeorge-lewis-0/+5
Update tests
2024-01-13Don't consider delayed bugs for `-Ztreat-err-as-bug`.Nicholas Nethercote-12/+10
`-Ztreat-err-as-bug` treats normal errors and delayed bugs equally, which can lead to some really surprising results. This commit changes `-Ztreat-err-as-bug` so it ignores delayed bugs, unless they get promoted to proper bugs and are printed. This feels to me much simpler and more logical. And it simplifies the implementation: - The `-Ztreat-err-as-bug` check is removed from in `DiagCtxt::{delayed_bug,span_delayed_bug}`. - `treat_err_as_bug` doesn't need to count delayed bugs. - The `-Ztreat-err-as-bug` panic message is simpler, because it doesn't have to mention delayed bugs. Output of delayed bugs is now more consistent. They're always printed the same way. Previously when they triggered `-Ztreat-err-as-bug` they would be printed slightly differently, via `span_bug` in `span_delayed_bug` or `delayed_bug`. A minor behaviour change: the "no errors encountered even though `span_delayed_bug` issued" printed before delayed bugs is now a note rather than a bug. This is done so it doesn't get counted as an error that might trigger `-Ztreat-err-as-bug`, which would be silly. This means that if you use `-Ztreat-err-as-bug=1` and there are no normal errors but there are delayed bugs, the first delayed bug will be shown (and the panic will happen after it's printed). Also, I have added a second note saying "those delayed bugs will now be shown as internal compiler errors". I think this makes it clearer what is happening, because the whole concept of delayed bugs is non-obvious. There are some test changes. - equality-in-canonical-query.rs: Minor output changes, and the error count reduces by one because the "no errors encountered even though `span_delayed_bug` issued" message is no longer counted as an error. - rpit_tait_equality_in_canonical_query.rs: Ditto. - storage-live.rs: The query stack disappears because these delayed bugs are now printed at the end, rather than when they are created. - storage-return.rs, span_delayed_bug.rs: now need `-Zeagerly-emit-delayed-bugs` because they need the delayed bugs emitted immediately to preserve behaviour.
2024-01-12Rollup merge of #119817 - compiler-errors:normalize-opaques, r=lcnrGuillaume Gomez-2/+19
Remove special-casing around `AliasKind::Opaque` when structurally resolving in new solver This fixes a few inconsistencies around where we don't eagerly resolve opaques to their (locally-defined) hidden types in the new solver. It essentially allows this code to work: ```rust fn main() { type Tait = impl Sized; struct S { i: i32, } let x: Tait = S { i: 0 }; println!("{}", x.i); } ``` Since `Tait` is defined in `main`, we are able to poke through the type of `x` with deref. r? lcnr
2024-01-11Remove special-casing around aliaskind in new solverMichael Goulet-2/+19
2024-01-11Keep error types around, even in obligations.Oli Scherer-17/+14
These help silence follow up errors
2024-01-11Use the right level with `-Ztreat-err-as-bug`.Nicholas Nethercote-1/+1
Errors in `DiagCtxtInner::emit_diagnostic` are never set to `Level::Bug`, because the condition never succeeds, because `self.treat_err_as_bug()` is called *before* the error counts are incremented. This commit switches to `self.treat_next_err_as_bug()`, fixing the problem. This changes the error message output to actually say "internal compiler error".
2024-01-09Avoid silencing relevant follow-up errorsOli Scherer-27/+277
2024-01-08Make cycle error more resilient to where it startsMichael Goulet-40/+55
Also don't recomment recursive_async crate anymore Co-authored-by: lcnr <rust@lcnr.de>
2024-01-08Point out source of recursionMichael Goulet-5/+5
2024-01-08Don't check for recursion in generator witness fieldsMichael Goulet-37/+11
2024-01-07Split note, fix const/static impl trait errorMichael Goulet-100/+200
2024-01-07Make ImplTraitPosition display more descriptiveMichael Goulet-13/+13
2024-01-05Use `resolutions(()).effective_visiblities` to avoid cycle errorsMichael Goulet-0/+106
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-1/+1
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-1/+1
2024-01-02Reorder `check_item_type` diagnostics so they occur next to the ↵Oli Scherer-13/+22
corresponding `check_well_formed` diagnostics
2023-12-29add non-regression test for issue 114325Rémy Rakic-0/+55
2023-12-28Rollup merge of #119376 - msrd0:regression-test-106630, r=petrochenkovMatthias Krüger-0/+33
Add regression test for #106630 This PR adds a regression test for #106630. I was unsure where exactly to place the test or how to test it locally so please let me know if I should change something.
2023-12-28Add regression test for #106630Dominic-0/+33
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-1/+1
2023-12-19rename to verbose-internalsjyn-1/+1
2023-12-14update use of feature flagslcnr-11/+11
2023-12-13Tweak `short_ty_string` to reduce number of filesEsteban Küber-2/+2
When shortening types and writing them to disk, make `short_ty_string` capable of reusing the same file, instead of writing a file per shortened type.
2023-12-12Rollup merge of #117914 - estebank:issue-85843, r=wesleywiserMatthias Krüger-1/+1
On borrow return type, suggest borrowing from arg or owned return type When we encounter a function with a return type that has an anonymous lifetime with no argument to borrow from, besides suggesting the `'static` lifetime we now also suggest changing the arguments to be borrows or changing the return type to be an owned type. ``` error[E0106]: missing lifetime specifier --> $DIR/variadic-ffi-6.rs:7:6 | LL | ) -> &usize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | ) -> &'static usize { | +++++++ help: instead, you are more likely to want to change one of the arguments to be borrowed... | LL | x: &usize, | + help: ...or alternatively, to want to return an owned value | LL - ) -> &usize { LL + ) -> usize { | ``` Fix #85843.
2023-12-10Auto merge of #116952 - compiler-errors:lifetime_capture_rules_2024, r=TaKO8Kibors-6/+93
Implement 2024-edition lifetime capture rules RFC Implements rust-lang/rfcs#3498.
2023-12-07recurse into refs when comparing tys for diagnosticsjyn-6/+6
2023-12-05Enable new capture rules by default on edition 2024Michael Goulet-9/+39
2023-12-05Add test for implicitly capturing late-bound var with new capture rulesMichael Goulet-0/+23
2023-12-05Add lifetime_capture_rules_2024Michael Goulet-6/+40
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-25Don't ICE when encountering placeholders in implied bounds computationMichael Goulet-0/+14
2023-11-24Manual find replace updatesNilstrieb-2/+2
2023-11-24Show number in error message even for one errorNilstrieb-110/+110
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-20On borrow return type, suggest borrowing from arg or owned return typeEsteban Küber-1/+1
When we encounter a function with a return type that has an anonymous lifetime with no argument to borrow from, besides suggesting the `'static` lifetime we now also suggest changing the arguments to be borrows or changing the return type to be an owned type. ``` error[E0106]: missing lifetime specifier --> $DIR/variadic-ffi-6.rs:7:6 | LL | ) -> &usize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | ) -> &'static usize { | +++++++ help: instead, you are more likely to want to change one of the arguments to be borrowed... | LL | x: &usize, | + help: ...or alternatively, to want to return an owned value | LL - ) -> &usize { LL + ) -> usize { | ``` Fix #85843.
2023-11-20self ty infer ambiguity: add proof tree candlcnr-2/+0
2023-11-17Auto merge of #117278 - lcnr:try-normalize-ty, r=compiler-errorsbors-15/+48
new solver normalization improvements cool beans At the core of this PR is a `try_normalize_ty` which stops for rigid aliases by using `commit_if_ok`. Reworks alias-relate to fully normalize both the lhs and rhs and then equate the resulting rigid (or inference) types. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/68 by avoiding the exponential blowup. Also supersedes #116369 by only defining opaque types if the hidden type is rigid. I removed the stability check in `EvalCtxt::evaluate_goal` due to https://github.com/rust-lang/trait-system-refactor-initiative/issues/75. While I personally have opinions on how to fix it, that still requires further t-types/`@nikomatsakis` buy-in, so I removed that for now. Once we've decided on our approach there, we can revert this commit. r? `@compiler-errors`
2023-11-15Auto merge of #117878 - gavinleroy:proper-depth-check, r=lcnrbors-0/+2
Fix depth check in ProofTreeVisitor. The hack to cutoff overflows and cycles in the new trait solver was incorrect. We want to inspect everything with depth [0..10]. This fix exposed a previously unseen bug, which caused the compiler to ICE when invoking `trait_ref` on a non-assoc type projection. I simply added the guard in the `AmbiguityCausesVisitor`, and updated the expected output for the `auto-trait-coherence` test which now includes the extra note: ```text | = note: upstream crates may add a new impl of trait `std::marker::Send` for type `OpaqueType` in future versions ``` r? `@lcnr`
2023-11-14finish `RegionKind` renamelcnr-2/+2
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`