-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Report more detailed reason why Index
impl is not satisfied
#110432
Report more detailed reason why Index
impl is not satisfied
#110432
Conversation
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
if let Some((_, index_ty, element_ty)) = | ||
self.find_and_report_unsatisfied_index_impl(expr.hir_id, base, base_t) | ||
{ | ||
self.demand_coerce(idx, idx_t, index_ty, None, AllowTwoPhase::No); |
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.
Why are we registering a coercion? To avoid ambiguities later?
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.
Mostly just copying the confirmation logic from the happy path. Leaving it unconstrained probably isn't great, but I haven't thought much about creating additional spurious errors from this.
let errors = ocx.select_where_possible(); | ||
// There should be at least one error reported. If not, we | ||
// will still delay a span bug in `report_fulfillment_errors`. | ||
Ok::<_, NoSolution>(( |
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.
If we are emitting an error, why are we committing inference constraints?
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.
Because otherwise we wouldn't be able to return a useful return type here for later typechecking to use. I guess we could return ty::Error
here or something, but I prefer recoveries to be as accurate as possible for downstream typechecking.
d56ef6c
to
8d75a8f
Compare
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
@cjgillot, I messed with the test a bit to justify what the index ty coercion and that |
@@ -0,0 +1,27 @@ | |||
use std::hash::Hash; |
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 would've marked this as // run-rustfix
but I cannot due to overlapping suggestion spans. I'll fix that in a different PR.
Thanks! |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#110432 (Report more detailed reason why `Index` impl is not satisfied) - rust-lang#110451 (Minor changes to `IndexVec::ensure_contains_elem` & related methods) - rust-lang#110476 (Delay a good path bug on drop for `TypeErrCtxt` (instead of a regular delayed bug)) - rust-lang#110498 (Switch to `EarlyBinder` for `collect_return_position_impl_trait_in_trait_tys`) - rust-lang#110507 (boostrap: print output during building tools) - rust-lang#110510 (Fix ICE for transmutability in candidate assembly) - rust-lang#110513 (make `non_upper_case_globals` lint not report trait impls) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
… r=cjgillot Tweak borrow suggestion span Avoids a `span_to_snippet` call when we don't need to surround the expression in parentheses. The fact that the suggestion was using the whole span of the expression rather than just appending a `&` was prevented me from using `// run-rustfix` in another PR (rust-lang#110432 (comment)). Also some drive-by renames of functions that have been annoying me for a bit.
… r=cjgillot Tweak borrow suggestion span Avoids a `span_to_snippet` call when we don't need to surround the expression in parentheses. The fact that the suggestion was using the whole span of the expression rather than just appending a `&` was prevented me from using `// run-rustfix` in another PR (rust-lang#110432 (comment)). Also some drive-by renames of functions that have been annoying me for a bit.
… r=cjgillot Tweak borrow suggestion span Avoids a `span_to_snippet` call when we don't need to surround the expression in parentheses. The fact that the suggestion was using the whole span of the expression rather than just appending a `&` was prevented me from using `// run-rustfix` in another PR (rust-lang#110432 (comment)). Also some drive-by renames of functions that have been annoying me for a bit.
… r=cjgillot Tweak borrow suggestion span Avoids a `span_to_snippet` call when we don't need to surround the expression in parentheses. The fact that the suggestion was using the whole span of the expression rather than just appending a `&` was prevented me from using `// run-rustfix` in another PR (rust-lang#110432 (comment)). Also some drive-by renames of functions that have been annoying me for a bit.
Fixes #110373