Skip to content
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

Tweak spans for trait bounds on associated types #85799

Closed
wants to merge 4 commits into from

Conversation

estebank
Copy link
Contributor

@estebank estebank commented May 29, 2021

Provide more information on projection failure, by pointing at the associated type (the note on line 16 and the use of a note instead of a label on line 27 are new):

error[E0271]: type mismatch resolving `<ModelT as Vehicle>::Color == Blue`
  --> src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs:31:10
   |
31 | fn b() { blue_car(ModelT); } //~ ERROR type mismatch
   |          ^^^^^^^^ type mismatch resolving `<ModelT as Vehicle>::Color == Blue`
   |
note: expected this to be `Blue`
  --> src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs:16:40
   |
16 | impl Vehicle for ModelT { type Color = Black; }
   |                                        ^^^^^
note: required by a bound in `blue_car`
  --> src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs:27:19
   |
27 | fn blue_car<C:Car<Color=Blue>>(c: C) {
   |                   ^^^^^^^^^^ required by this bound in `blue_car`

We are now pointing at the two places where the user can change things to make them compile: the trait bound and the associated type. We can't know for sure which of the two would be more appropriate on each case (although we already provide some suggestions when an extra trait bound would fix things), so instead we just put all the cards on the table and let the user decide for themselves with all the information at their disposal.

Reminded about this by the recent closing of #57663.

@rust-highfive
Copy link
Collaborator

r? @varkor

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 29, 2021
@rust-log-analyzer

This comment has been minimized.

@estebank estebank marked this pull request as ready for review May 30, 2021 02:27
|
LL | type Item<'a>: std::ops::Deref<Target = T>;
| ---------- required by this bound in `UnsafeCopy::Item`
...
LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T {
| - this type parameter
LL | type Item<'a> = T;
| ^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
| ^ expected type parameter `T`, found associated type
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems somewhat confusing, but thankfully we provide a structured suggestion.

LL | let v = Unit2.m(
| ^ expected struct `Unit4`, found associated type
| ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (<Unit2 as Ty<'r>>::V,)>>::O == <_ as Ty<'r>>::V`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's quite a mouthful 😬

@hellow554
Copy link
Contributor

You are truly amazing. Thank you for making the suggestion even better! ❤️

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors

This comment has been minimized.

@varkor
Copy link
Member

varkor commented Jun 30, 2021

I don't have time to review this right now. Going to reassign to r? @pnkfelix, as they've already taken a look at it. Apologies for taking so long to get around to this.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Dec 14, 2021

☀️ Try build successful - checks-actions
Build commit: bcb46bf6598f6d916def946b3df130355704bfa0 (bcb46bf6598f6d916def946b3df130355704bfa0)

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (76d48c2e95803f4154d13bfa62b71ed9ba7d2d1d): comparison url.

Summary: This change led to very large relevant regressions 😿 in compiler performance.

  • Very large regression in instruction counts (up to 12.3% on full builds of diesel)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking 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 led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 14, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (76d48c2e95803f4154d13bfa62b71ed9ba7d2d1d): comparison url.

Summary: This change led to very large relevant regressions 😿 in compiler performance.

  • Very large regression in instruction counts (up to 12.3% on full builds of diesel)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking 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 led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

@estebank
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 15, 2021
@bors
Copy link
Contributor

bors commented Dec 15, 2021

⌛ Trying commit 979937e with merge 041d85b0a9a7ac359e1292be7168d6b5c0508d26...

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.debug-assertions := True
configure: rust.overflow-checks := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
skip untracked path cpu-usage.csv during rustfmt invocations
skip untracked path src/doc/book/ during rustfmt invocations
skip untracked path src/doc/rust-by-example/ during rustfmt invocations
skip untracked path src/llvm-project/ during rustfmt invocations
Diff in /checkout/compiler/rustc_middle/src/ty/mod.rs at line 752:
     pub constness: BoundConstness,
 
     pub polarity: ImplPolarity,
-
     // pub implicit: ImplicitBound,
 
 
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2018" "--unstable-features" "--skip-children" "--check" "/checkout/compiler/rustc_middle/src/ty/consts/valtree.rs" "/checkout/compiler/rustc_middle/src/ty/consts/int.rs" "/checkout/compiler/rustc_middle/src/ty/consts/kind.rs" "/checkout/compiler/rustc_middle/src/ty/relate.rs" "/checkout/compiler/rustc_middle/src/ty/mod.rs" "/checkout/compiler/rustc_middle/src/ty/context.rs" "/checkout/compiler/rustc_middle/src/ty/vtable.rs" "/checkout/compiler/rustc_middle/src/ty/binding.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.

@bors
Copy link
Contributor

bors commented Dec 15, 2021

☀️ Try build successful - checks-actions
Build commit: 041d85b0a9a7ac359e1292be7168d6b5c0508d26 (041d85b0a9a7ac359e1292be7168d6b5c0508d26)

@rust-timer
Copy link
Collaborator

Queued 041d85b0a9a7ac359e1292be7168d6b5c0508d26 with parent 2f4da62, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (041d85b0a9a7ac359e1292be7168d6b5c0508d26): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking 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 led to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Dec 15, 2021
@jackh726
Copy link
Member

jackh726 commented Jan 6, 2022

Going to mark this as waiting on author. Seems like it needs a rebase and perf fix.

@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 6, 2022
@joelpalmer joelpalmer added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 1, 2022
@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 27, 2022
@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 11, 2022
@Dylan-DPC
Copy link
Member

Closing this as it has bitrotted

@Dylan-DPC Dylan-DPC closed this May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.