-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Don't call query_normalize
when reporting similar impls
#113005
Conversation
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
normalized_impl_candidates_and_similarities.sort(); | ||
normalized_impl_candidates_and_similarities.dedup(); | ||
let mut impl_candidates = impl_candidates.to_vec(); | ||
impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref)); |
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.
Is this useful? report
sorts everything again.
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.
Removed the sort in report
-- that should fix the weird rendering and also actually make this sort meaningful. It does have a lot of fallout, but the changes are either neutral or slightly better suggestions.
Great! |
…ze, r=cjgillot Don't call `query_normalize` when reporting similar impls Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well. The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions: ``` error[E0277]: the trait bound `[X; 35]: Default` is not satisfied --> /home/gh-compiler-errors/test.rs:4:5 | 4 | <[X; 35] as Default>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: &[T] &mut [T] [T; 32] [T; core::::array::{impl#30}::{constant#0}] [T; core::::array::{impl#31}::{constant#0}] [T; core::::array::{impl#32}::{constant#0}] [T; core::::array::{impl#33}::{constant#0}] [T; core::::array::{impl#34}::{constant#0}] and 27 others ``` So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#113005 (Don't call `query_normalize` when reporting similar impls) - rust-lang#113064 (std: edit [T]::swap docs) - rust-lang#113138 (Add release notes for 1.71.0) - rust-lang#113217 (resolve typerelative ctors to adt) - rust-lang#113254 (Use consistent formatting in Readme) - rust-lang#113482 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
Firstly, It's sketchy to be using
query_normalize
at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types inty::ParamEnv::empty()
, which is kinda sketchy as well.The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions:
So just fold the impls with a
BottomUpFolder
that callsty::Const::eval
. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.