about summary refs log tree commit diff
path: root/tests/ui/traits
AgeCommit message (Collapse)AuthorLines
2024-02-06Rollup merge of #120396 - estebank:method-on-unbounded-type-param, r=nnethercoteMatthias Krüger-0/+89
Account for unbounded type param receiver in suggestions When encountering ```rust fn f<T>(a: T, b: T) -> std::cmp::Ordering { a.cmp(&b) //~ ERROR E0599 } ``` output ``` error[E0599]: no method named `cmp` found for type parameter `T` in the current scope --> $DIR/method-on-unbounded-type-param.rs:2:7 | LL | fn f<T>(a: T, b: T) -> std::cmp::Ordering { | - method `cmp` not found for this type parameter LL | a.cmp(&b) | ^^^ method cannot be called on `T` due to unsatisfied trait bounds | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering { | +++++ LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ ``` Fix #120186.
2024-02-05new solver: improve normalization of `Pointee::Metadata`Lukas Markeffsky-0/+2
2024-02-05old solver: improve normalization of `Pointee::Metadata`Lukas Markeffsky-0/+54
2024-02-05Stop bailing out from compilation just because there were incoherent traitsOli Scherer-15/+89
2024-02-04Auto merge of #120649 - matthiaskrgr:rollup-ek80j61, r=matthiaskrgrbors-37/+17
Rollup of 8 pull requests Successful merges: - #119759 (Add FileCheck annotations to dataflow-const-prop tests) - #120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - #120473 (Only suggest removal of `as_*` and `to_` conversion methods on E0308) - #120540 (add test for try-block-in-match-arm) - #120547 (`#![feature(inline_const_pat)]` is no longer incomplete) - #120552 (Correctly check `never_type` feature gating) - #120555 (put pnkfelix (me) back on the review queue.) - #120556 (Improve the diagnostics for unused generic parameters) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-03Rollup merge of #120531 - oli-obk:track_errors7, r=estebankMatthias Krüger-2/+10
Remove a bunch of `has_errors` checks that have no meaningful or the wrong effect r? `@nnethercote`
2024-02-03No need to validate_alias_bound_self_from_param_env in ↵Michael Goulet-15/+1
assemble_alias_bound_candidates
2024-02-02Normalize the whole PolyTypeOutlivesPredicate, more simplificationsMichael Goulet-2/+2
2024-02-02Normalize type outlives obligations in NLLMichael Goulet-0/+31
2024-02-02Use deeply_normalize_with_skipped_universes in when processing type outlivesMichael Goulet-1/+8
2024-02-01review comment: change wordingEsteban Küber-6/+6
2024-02-01On E0277 be clearer about implicit `Sized` bounds on type params and assoc typesEsteban Küber-33/+13
``` error[E0277]: the size for values of type `[i32]` cannot be known at compilation time --> f100.rs:2:33 | 2 | let _ = std::mem::size_of::<[i32]>(); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i32]` note: required by an implicit `Sized` bound in `std::mem::size_of` --> /home/gh-estebank/rust/library/core/src/mem/mod.rs:312:22 | 312 | pub const fn size_of<T>() -> usize { | ^ required by the implicit `Sized` requirement on this bound in `size_of` ``` Fix #120178.
2024-01-31Remove a has_errors check that doesn't actually prevent noisy follow up errorsOli Scherer-2/+10
2024-01-31Rollup merge of #120472 - Nilstrieb:die, r=compiler-errorsNadrieril-63/+0
Make duplicate lang items fatal Prevents terminal spam.
2024-01-31Rollup merge of #120469 - estebank:issue-40120, r=TaKO8KiNadrieril-26/+26
Provide more context on derived obligation error primary label 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-30Provide more context on derived obligation error primary labelEsteban Küber-26/+26
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-30Account for non-overlapping unmet trait bounds in suggestionEsteban Küber-6/+16
When a method not found on a type parameter could have been provided by any of multiple traits, suggest each trait individually, instead of a single suggestion to restrict the type parameter with *all* of them. Before: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` help: consider restricting the type parameters to satisfy the trait bounds | LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord { | +++++++++++++++++++++++++ ``` After: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering { | +++++ LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ ``` Fix #108428.
2024-01-30Auto merge of #119101 - compiler-errors:outlives, r=lcnrbors-3/+48
Normalize region obligation in lexical region resolution with next-gen solver This normalizes region obligations when we `resolve_regions`, since they may be unnormalized with deferred projection equality. It's pretty hard to add tests that exercise this without also triggering MIR borrowck errors (because we don't normalize there yet). I've added one test with two revisions that should test that we both 1. normalize region obligations in the param env, and 2. normalize registered region obligations during lexical region resolution.
2024-01-30fix rebaseEsteban Küber-13/+4
2024-01-30Account for unbounded type param receiver in suggestionsEsteban Küber-8/+8
When encountering ```rust fn f<T>(a: T, b: T) -> std::cmp::Ordering { a.cmp(&b) //~ ERROR E0599 } ``` output ``` error[E0599]: no method named `cmp` found for type parameter `T` in the current scope --> $DIR/method-on-unbounded-type-param.rs:2:7 | LL | fn f<T>(a: T, b: T) -> std::cmp::Ordering { | - method `cmp` not found for this type parameter LL | a.cmp(&b) | ^^^ method cannot be called on `T` due to unsatisfied trait bounds | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering { | +++++ LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ ``` Fix #120186.
2024-01-30Add test for method on unbounded type parameter receiverEsteban Küber-0/+98
2024-01-30Rollup merge of #120476 - compiler-errors:lang-items-yeet, r=NilstriebGuillaume Gomez-31/+0
Remove some unnecessary check logic for lang items in HIR typeck Obvious bugs with `#[no_core]` do not deserve customized recovery logic, since they are bugs we do not expect users to ever encounter, and if users are experimenting with `#[no_core]`, they should really be familiar with the compiler implementation. These error recoveries are implemented now only where issues have been reported in the past, rather than systematically validating lang items. See https://github.com/rust-lang/compiler-team/issues/620 > In particular, one-off fixes for particular assumptions about lang items or intrinsics that introduce additional complexity into the compiler are not accepted. r? Nilstrieb
2024-01-30Rollup merge of #120293 - estebank:issue-102629, r=nnethercoteGuillaume Gomez-31/+18
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-30Rollup merge of #120400 - estebank:bound-error-cleanup, r=oli-obkGuillaume Gomez-4/+1
Bound errors span label cleanup Consolidate span labels for "this type doesn't satisfy a bound" for more compact diagnostic output.
2024-01-30Auto merge of #119744 - lcnr:assemble-only-rigid, r=compiler-errorsbors-13/+85
only assemble alias bound candidates for rigid aliases fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/77 This also causes `<Wrapper<?0> as Trait>::Unwrap: Trait` to always be ambig, as we now normalize the self type before checking whether it is an inference variable. I cannot think of an approach to the underlying issues here which does not require the "may-define means must-define" restriction for opaque types. Going to go ahead with this and added this restriction to the tracking issue for the new solver to make sure we don't stabilize it without getting types + lang signoff here. r? `@compiler-errors`
2024-01-30Apply suggestions from reviewMichael Goulet-0/+20
2024-01-30Add a testMichael Goulet-0/+22
2024-01-30Deeply normalize when processing registered region obligationsMichael Goulet-3/+6
2024-01-29Remove some unnecessary check logic for lang items in HIR typeckMichael Goulet-31/+0
2024-01-29Delete now-useless testNilstrieb-48/+0
The test was using an internal feature which doesn't really matter, but more importantly, we're now fatally exiting after the duplicate lang item, so this tests nothing.
2024-01-29Make duplicate lang items fatalNilstrieb-18/+3
Prevents terminal spam.
2024-01-29Avoid ICE in trait without `dyn` lintEsteban Küber-11/+3
Do not attempt to provide an accurate suggestion for `impl Trait` in bare trait types when linting. Instead, only do the object safety check when an E0782 is already going to be emitted in the 2021 edition. Fix #120241.
2024-01-29bye bye `assemble_candidates_via_self_ty`lcnr-13/+85
2024-01-27Update tests.Markus Reiter-1/+1
2024-01-26Rollup merge of #120378 - lcnr:normalize-ast, r=compiler-errorsMatthias Krüger-25/+41
always normalize `LoweredTy` in the new solver I currently expect us to stop using alias bound candidates of normalizable aliases due to https://github.com/rust-lang/trait-system-refactor-initiative/issues/77 by landing https://github.com/rust-lang/rust/pull/119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc #113473 previous attempt The infer var replacement for ambiguous projections can in very rare cases: - weaken inference https://github.com/rust-lang/trait-system-refactor-initiative/issues/81 - strengthen inference https://github.com/rust-lang/trait-system-refactor-initiative/issues/7 I do not expect this impact on inference to significantly affect real crates. r? ``@compiler-errors``
2024-01-26Use only one label for multiple unsatisfied bounds on type (typeck)Esteban Küber-4/+1
2024-01-26remove unnecessary testlcnr-22/+0
2024-01-26move alias-relate testslcnr-1/+1
2024-01-26next-solver: normalize in `LoweredTy::from_raw`lcnr-2/+40
2024-01-25blessMichal Nazarewicz-0/+1
2024-01-24Deduplicate more sized errors on call exprsEsteban Küber-31/+18
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 regression testOli Scherer-0/+69
2024-01-22Revert "Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin"Oli Scherer-90/+199
This reverts commit 6d2b84b3ed7848fd91b8d6151d4451b3103ed816, reversing changes made to 73bc12199ea8c7651ed98b069c0dd6b0bb5fabcf.
2024-01-16Auto merge of #119947 - compiler-errors:old-solver-instantiate-response, r=lcnrbors-0/+94
Make sure to instantiate placeholders correctly in old solver When creating the query substitution guess for an input placeholder type like `!1_T` (in universe 1), we were guessing the response substitution with something like `!0_T`. This failed to unify with `!1_T`, causing an ICE. This PR reworks the query substitution guess code to work a bit more like the new solver. I'm *pretty* sure this is correct, though I'd really appreciate some scrutiny from someone (*cough* lcnr) who knows a bit more about query instantiation :) Fixes #119941 r? lcnr
2024-01-13Add a simpler testMichael Goulet-0/+45
2024-01-13Make sure to instantiate placeholders correctly in old solverMichael Goulet-0/+49
2024-01-13Auto merge of #119088 - George-lewis:glewis/suggest-upgrading-compiler, ↵bors-0/+6
r=Nilstrieb Suggest Upgrading Compiler for Gated Features This PR addresses #117318 I have a few questions: 1. Do we want to specify the current version and release date of the compiler? I have added this in via environment variables, which I found in the code for the rustc cli where it handles the `--version` flag a. How can I handle the changing message in the tests? 3. Do we want to only show this message when the compiler is old? a. How can we determine when the compiler is old? I'll wait until we figure out the message to bless the tests
2024-01-13Bless testsGeorge-lewis-0/+6
Update tests
2024-01-13Rollup merge of #119896 - oli-obk:variance_ice, r=compiler-errorsMatthias Krüger-0/+37
Taint `_` placeholder types in trait impl method signatures We report an error right below for them, but that kind of broken type can cause subsequent ICEs. fixes #119867
2024-01-12Taint `_` placeholder typesOli Scherer-0/+37