Make sure to ignore elided lifetimes when pointing at args for fulfillment errors#132935
Make sure to ignore elided lifetimes when pointing at args for fulfillment errors#132935bors merged 1 commit intorust-lang:masterfrom
Conversation
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
| | | ||
| = help: the trait `X<'_, T>` is implemented for `(S,)` | ||
|
|
||
| error[E0277]: the trait bound `for<'b> i32: X<'b, i32>` is not satisfied |
There was a problem hiding this comment.
We have a duplicated error here b/c we can only refine one of two copies of this fulfillment error: one that comes from well-formedness, and one that comes from the predicates_of query.
I think it's fine to ignore this regression, since it's a net improvement for other errors.
| --> $DIR/hr-associated-type-bound-param-3.rs:18:5 | ||
| --> $DIR/hr-associated-type-bound-param-3.rs:18:18 | ||
| | | ||
| LL | <(i32,) as X<(i32,)>>::f("abc"); |
There was a problem hiding this comment.
This is a great example of the bug. We have X<'a, T> above, but have only specified the type parameter. Since we were basically trying to index at 1 into a list of 1, we would fail. Now we properly adjust the index to account for the lifetime not being there :D
| | | ||
| LL | <(i32,) as X<i32>>::f("abc"); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` | ||
| | ^^^ the trait `Clone` is not implemented for `str` |
There was a problem hiding this comment.
This feels like a worse error? The carets point to i32 but the text talks about str, feels very confusing.
There was a problem hiding this comment.
This is a preexisting consequence of the algorithm. I'm just fixing an off-by-N bug.
| | | ||
| LL | <i32 as X<Box<i32>>>::f("abc"); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` | ||
| | ^^^^^^^^ the trait `Clone` is not implemented for `str` |
| | | ||
| LL | impl_hr::<T>(); | ||
| | ^^^^^^^^^^^^^^ the trait `for<'a> Trait<'a, '_>` is not implemented for `T` | ||
| | ^ the trait `for<'a> Trait<'a, '_>` is not implemented for `T` |
There was a problem hiding this comment.
This one is better, the carets point to T which matches the error text.
|
@bors r+ rollup |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#132651 (Remove attributes from generics in built-in derive macros) - rust-lang#132668 (Feature gate yield expressions not in 2024) - rust-lang#132771 (test(configure): cover `parse_args` in `src/bootstrap/configure.py`) - rust-lang#132895 (Generalize `NonNull::from_raw_parts` per ACP362) - rust-lang#132914 (Update grammar in std::cell docs.) - rust-lang#132927 (Consolidate type system const evaluation under `traits::evaluate_const`) - rust-lang#132935 (Make sure to ignore elided lifetimes when pointing at args for fulfillment errors) - rust-lang#132941 (Subtree update of `rust-analyzer`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132935 - compiler-errors:arg-math, r=nnethercote Make sure to ignore elided lifetimes when pointing at args for fulfillment errors See the comment I left in the code. --- If we have something like: ``` fn foo<'a, T: 'a + BoundThatIsNotSatisfied>() {} ``` And the user turbofishes just the type args: ``` foo::<()>(); ``` Then if we try pointing at `()` (i.e. the type argument for `T`), we don't actually consider the possibility that the lifetimes may have been left out of the turbofish. We try indexing incorrectly into the HIR args, and bail on the suggestion.
See the comment I left in the code.
If we have something like:
And the user turbofishes just the type args:
Then if we try pointing at
()(i.e. the type argument forT), we don't actually consider the possibility that the lifetimes may have been left out of the turbofish. We try indexing incorrectly into the HIR args, and bail on the suggestion.