summary refs log tree commit diff
path: root/src/test/ui/impl-trait/issues
AgeCommit message (Collapse)AuthorLines
2022-06-06Deactivate feature gate explicit_generic_args_with_impl_traitNick Cameron-50/+0
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-06-02add new `emit_inference_failure_err`lcnr-3/+18
2022-05-14Forbid nested opaque types to reference HRTB from opaque types.Camille GILLOT-98/+75
2022-05-02Add a regression test for #92305Yuki Okushi-0/+47
2022-04-28Revert diagnostic duplication and accidental stabilizationOli Scherer-14/+7
2022-04-27Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkovbors-3/+3
Perform lifetime resolution on the AST for lowering Lifetime resolution is currently implemented several times. Once during lowering in order to introduce in-band lifetimes, and once in the resolve_lifetimes query. However, due to the global nature of lifetime resolution and how it interferes with hygiene, it is better suited on the AST. This PR implements a first draft of lifetime resolution on the AST. For now, we specifically target named lifetimes and everything we need to remove lifetime resolution from lowering. Some diagnostics have already been ported, and sometimes made more precise using available hygiene information. Follow-up PRs will address in particular the resolution of anonymous lifetimes on the AST. We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes. r? `@petrochenkov`
2022-04-27Bless tests.Camille GILLOT-3/+3
2022-04-25Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLLmarmeladema-1/+5
2022-04-16Implementation for 65853Jack Huey-1/+8
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-4/+2
When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option<T> i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
2022-03-30Restore `impl Future<Output = Type>` to async blocksMichael Goulet-1/+1
2022-03-28Add another regression testOli Scherer-0/+27
2022-03-28Add regression testsOli Scherer-0/+494
2022-03-28Remove opaque type obligation and just register opaque types as they are ↵Oli Scherer-9/+4
encountered. This also registers obligations for the hidden type immediately.
2022-03-28Revert to inference variable based hidden type computation for RPITOli Scherer-12/+20
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-56/+168
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-27Update ui test outputGuillaume Gomez-0/+1
2022-03-22remove [async output] from impl FutureMichael Goulet-1/+1
2022-03-07diagnostics: only talk about `Cargo.toml` if running under CargoMichael Howell-1/+1
Fixes #94646
2022-03-03Cleanup feature gates.Camille GILLOT-3/+1
2022-02-17fix impl trait message, bless testsMichael Goulet-48/+24
2022-02-17Add more information to `impl Trait` deny errorMichael Goulet-24/+48
2022-02-12Update chalk testsMatthew Jasper-0/+1
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-135/+56
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-11Revert "Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obk"Oli Scherer-20/+8
This reverts commit 1f0a96862ac9d4c6ca3e4bb500c8b9eac4d83049, reversing changes made to bf242bb1199e25ca2274df5c4114e0c9436b74e9.
2022-02-11Revert "Fix regression from lazy opaque types"Oli Scherer-17/+2
This reverts commit 239f1e716dcb1e145b5df5f9439524c817d123b2.
2022-02-09Auto merge of #92306 - Aaron1011:opaque-type-op, r=oli-obkbors-8/+20
Improve opaque type higher-ranked region error message under NLL Currently, any higher-ranked region errors involving opaque types fall back to a generic "higher-ranked subtype error" message when run under NLL. This PR adds better error message handling for this case, giving us the same kinds of error messages that we currently get without NLL: ``` error: implementation of `MyTrait` is not general enough --> $DIR/opaque-hrtb.rs:12:13 | LL | fn foo() -> impl for<'a> MyTrait<&'a str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough | = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`... = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2` error: aborting due to previous error ``` To accomplish this, several different refactoring needed to be made: * We now have a dedicated `InstantiateOpaqueType` struct which implements `TypeOp`. This is used to invoke `instantiate_opaque_types` during MIR type checking. * `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is needed to report opaque type region errors. * We no longer assume that all `TypeOp`s correspond to canonicalized queries. This allows us to properly handle opaque type instantiation (which does not occur in a query) as a `TypeOp`. A new `ErrorInfo` associated type is used to determine what additional information is used during higher-ranked region error handling. * The body of `try_extract_error_from_fulfill_cx` has been moved out to a new function `try_extract_error_from_region_constraints`. This allows us to re-use the same error reporting code between canonicalized queries (which can extract region constraints directly from a fresh `InferCtxt`) and opaque type handling (which needs to take region constraints from the pre-existing `InferCtxt` that we use throughout MIR borrow checking).
2022-02-08Improve opaque type higher-ranked region error message under NLLAaron Hill-8/+20
Currently, any higher-ranked region errors involving opaque types fall back to a generic "higher-ranked subtype error" message when run under NLL. This PR adds better error message handling for this case, giving us the same kinds of error messages that we currently get without NLL: ``` error: implementation of `MyTrait` is not general enough --> $DIR/opaque-hrtb.rs:12:13 | LL | fn foo() -> impl for<'a> MyTrait<&'a str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MyTrait` is not general enough | = note: `impl MyTrait<&'2 str>` must implement `MyTrait<&'1 str>`, for any lifetime `'1`... = note: ...but it actually implements `MyTrait<&'2 str>`, for some specific lifetime `'2` error: aborting due to previous error ``` To accomplish this, several different refactoring needed to be made: * We now have a dedicated `InstantiateOpaqueType` struct which implements `TypeOp`. This is used to invoke `instantiate_opaque_types` during MIR type checking. * `TypeOp` is refactored to pass around a `MirBorrowckCtxt`, which is needed to report opaque type region errors. * We no longer assume that all `TypeOp`s correspond to canonicalized queries. This allows us to properly handle opaque type instantiation (which does not occur in a query) as a `TypeOp`. A new `ErrorInfo` associated type is used to determine what additional information is used during higher-ranked region error handling. * The body of `try_extract_error_from_fulfill_cx` has been moved out to a new function `try_extract_error_from_region_constraints`. This allows us to re-use the same error reporting code between canonicalized queries (which can extract region constraints directly from a fresh `InferCtxt`) and opaque type handling (which needs to take region constraints from the pre-existing `InferCtxt` that we use throughout MIR borrow checking).
2022-02-08Fix regression from lazy opaque typesOli Scherer-2/+17
2022-02-02Prevent two opaque types in their defining scopes from being defined via the ↵Oli Scherer-3/+59
other
2022-02-02Ensure we error in case of non-higher-kinded lifetimesOli Scherer-1/+48
2022-02-02Avoid an ICE in the presence of HKLOli Scherer-0/+15
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-61/+22
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2021-12-15update testslcnr-1/+6
2021-11-26Perform Sync check on static items in wf-check instead of during const checksOli Scherer-2/+2
2021-11-23Fix printing unit return ty, don't elaborate FnOnce unless we see itMichael Goulet-1/+1
2021-11-23Update test outputsMichael Goulet-2/+2
2021-11-18Print output ty for opaque future tyMichael Goulet-2/+2
2021-11-08Add a note about feature(explicit_generic_args_with_impl_trait) to the ↵Jakub Kądziołka-0/+6
relevant error message
2021-08-30Update test output for stable Rust 2021.Mara Bos-1/+1
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-1/+1
2021-07-27Remove min_tait and full_tait stderr dangling filesSantiago Pastorino-76/+0
2021-07-27Make all tests use type_alias_impl_trait feature instead of minSantiago Pastorino-12/+42
2021-07-27Use type_alias_impl_trait instead of min in compiler and libSantiago Pastorino-27/+5
2021-07-22Add regression tests for the impl_trait_in_bindings ICEsAlex Macleod-0/+221
2021-07-19Improve impl trait disallowed context error textSantiago Pastorino-4/+4
2021-07-18Remove impl_trait_in_bindings feature flagSantiago Pastorino-56/+37
2021-07-17Remove OpaqueTyOrigin::BindingSantiago Pastorino-46/+0
2021-06-29Bless UI testsFabian Wolff-0/+2
2021-05-16Add tracking issueJonas Schievink-0/+3