-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Point at type parameter that introduced unmet bound instead of full HIR node #115219
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat tempted to ask if you can also split out the two main responsibilities of this PR, either into different PRs, or into different commits. My understanding is that it's doing two things:
-
Introducing
variant_param_to_point_at
is causing us to callpoint_at_generic_if_possible
sooner thanblame_specific_arg_if_possible
. As I commented below, we don't need to addvariant_param_to_point_at
to do this -- just reorganizing the order of operation in thehir::ExprKind::Path(qpath)
arm. -
Registering additional WF obligations that have better cause codes via
add_required_obligations_for_hir
. This should be pretty ez to split out, but has nothing to do with the above afaict.
compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs
Outdated
Show resolved
Hide resolved
Registering redundant (but better cause-coded) obligations on bindings may have a perf implication, but it's probably thin. Worth testing now though. I wonder if we should do this somewhere more general though. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit c3d104657e284c71f963975e3c9c330943967111 with merge a0779a94a085d6466a9a3db3282a080353833847... |
Walk through full path in `point_at_path_if_possible` We already had sufficient information to point at the `[u8]` in `Option::<[u8]>::None` (the `fallback_param_to_point_at` parameter), we just were neither using it nor walking through hir paths sufficiently to encounter it. This should alleviate the need to add additional logic to extract params in a somewhat arbitrary manner of looking at the grandparent def path: rust-lang#115219 (comment) r? `@estebank`
LL | let _: <() as Trait>::P<String, String>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | ||
| | ||
note: required by a bound in `Trait::P` | ||
--> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15 | ||
| | ||
LL | type P<T: Copy, U: Copy>; | ||
| ^^^^ required by this bound in `Trait::P` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm certain that you're aware that the output isn't correct yet but I'm leaving this comment here anyways to ensure it doesn't get forgotten ^^' Thanks for working on this btw!
LL | let _: <() as Trait>::P<String, String>; | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | |
| | |
note: required by a bound in `Trait::P` | |
--> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15 | |
| | |
LL | type P<T: Copy, U: Copy>; | |
| ^^^^ required by this bound in `Trait::P` | |
LL | let _: <() as Trait>::P<String, String>; | |
| ^^^^^^ the trait `Copy` is not implemented for `String` | |
| | |
note: required by a bound in `Trait::P` | |
--> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15 | |
| | |
LL | type P<T: Copy, U: Copy>; | |
| ^^^^ required by this bound in `Trait::P` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is possibly a strange fallout of the way we do obligation deduplication in adjust_fulfillment_errors_for_expr_obligation
. I'm inclined to say "don't worry about it", since it only triggers when you have duplicated bounds like this on the same item...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second error is now gone from the removal of the select_where_possible call. I believe that we have some deduplication logic gone rogue that is silencing the trait bound error for the second parameter (likely because it looks like the same predicate?). I would like to fix that, but might have to be left as a future exercise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna open a separate issue for that later, basically uplifting #105306 (comment)
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
On the following example, point at `String` instead of the whole type: ``` error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/own-bound-span.rs:14:24 | LL | let _: <S as D>::P<String>; | ^^^^^^ the trait `Copy` is not implemented for `String` | note: required by a bound in `D::P` --> $DIR/own-bound-span.rs:4:15 | LL | type P<T: Copy>; | ^^^^ required by this bound in `D::P` ```
Finished benchmarking commit (a0779a94a085d6466a9a3db3282a080353833847): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 630.392s -> 630.853s (0.07%) |
error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied | ||
--> $DIR/repeated-supertrait-ambig.rs:34:37 | ||
--> $DIR/repeated-supertrait-ambig.rs:34:6 | ||
| | ||
LL | <dyn CompareToInts>::same_as(c, 22) | ||
| ---------------------------- ^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts` | ||
| | | ||
| required by a bound introduced by this call | ||
| ^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts` | ||
| | ||
= help: the following other types implement trait `CompareTo<T>`: | ||
<i64 as CompareTo<i64>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-existing: we don't explain where CompareTo
is coming from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
@bors r=compiler-errors |
☀️ Test successful - checks-actions |
Finished benchmarking commit (e877e2a): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: missing data |
instead of
instead of
Fix #105306.