-
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
Issue warnings for late-bound regions in assoc type bindings and output types #32488
Issue warnings for late-bound regions in assoc type bindings and output types #32488
Conversation
69d9954
to
4c4e3fe
Compare
☔ The latest upstream changes (presumably #32496) made this pull request unmergeable. Please resolve the merge conflicts. |
{ | ||
let self_ty = obligation_trait_ref.self_ty(); | ||
let object_ty = selcx.infcx().shallow_resolve(self_ty); | ||
debug!("assemble_candidates_from_object_type(object_ty={:?})", |
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.
Name needs to be updated here.
OK, this looks good to me. Tiny nits, r=me after rebase. |
This is a step towards fixing rust-lang#32330. The full fix would be a breaking change, so we begin by issuing warnings for scenarios that will break.
We ought not to be affecting inference state when assembling candidates, so invoke select inside of a probe.
Before we would ignore a candidate if it happened to be an impl with a default type. This change makes us never add the impl in the first place. This seems largely equivalent, though there might be some subtle difference in that -- before -- we would have failed to normalize if there was a "trait-def-candidate" contending with an (opaque) impl candidate. This corresponds I guess to a case like `<<A as Trait>::B as Trait2>::C`, and the definition of `Trait` contains a clause. Pretty obscure, but it seems like it's... ok to favor the trait definition in such a case.
4c4e3fe
to
c534a14
Compare
@bors r=aturon |
📌 Commit c534a14 has been approved by |
Decided to revise this approach. Closing PR for now. |
This is part 1 of a series of patches to produce "future compatiblity" warnings for #32330. I have the actual fix in a branch, but I am planning to first land some patches so that we issue warnings for all the cases that will break once the fix is in place.
This particular PR issues a warning for fn types where a higher-ranked region appears only in the return type, such as
for<'a> fn() -> &'a i32
, as well as for where clauses where a HR region appears only in a binding, such asfor<'a> Fn() -> &'a i32
orfor<'a> Iterator<Item=&'a i32>
.I also included some a general refactoring of projection that makes the "assembling candidate" phase side-effect free, as intended. This is useful for the work that @soltanmm and I have been doing on plumbing obligations around but is otherwise kind of orthogonal.
r? @aturon
cc @arielb1