-
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
nll type annotations in multisegment path #55093
nll type annotations in multisegment path #55093
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
d5eba13
to
63f5057
Compare
☔ The latest upstream changes (presumably #54858) made this pull request unmergeable. Please resolve the merge conflicts. |
At some point, I had thought to use this code to handle equality comparisons for the `IfEq` verify bounds; at that point, we might not have had an infcx to talk about. But we wound up doing "SCC representatives" instead, so that's fine.
This used to be public, then I made it private in a previous PR, but there really wasn't a strong need for that.
We used to use a kind of "home-grown" variant where we tracked the value of each canonical variable.
The name is not great. Nor is the existence of this code great. It should be merged with the main "type relating code" at some point.
(long lines)
049f1e6
to
7ce2e7a
Compare
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.
LGTM. Not sure how confident I am reviewing a PR of this size though.
r? @pnkfelix |
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.
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.
hooray for the new UserTypeAnnotation
enum! I hope this will make the corresponding visit methods easier to grok
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.
Eeek regarding e7ed997; its a shame we couldn't continue keeping the contents of nll_relate
hidden away under rustc_mir::borrow_check::nll
...
src/librustc/ty/subst.rs
Outdated
pub substs: &'tcx Substs<'tcx>, | ||
|
||
/// The self-type, in the case of a `<T>::Item` path (when applied | ||
/// to an inherent impl). See `UserSubsts` below. |
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 don't understand where the reader is meant to be led by the "See UserSubsts
below."
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.
(Probably a typo for UserSelfTy
.)
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.
yes, fixing
struct A<'a> { x: &'a u32 } | ||
|
||
impl<'a> A<'a> { | ||
fn new<'b, T>(x: &'a u32, y: T) -> Self { |
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 is there a 'b
here?
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 see the same thing occuring in the other tests. To be honest I had thought that we didn't allow unreferenced lifetimes in generic binders ... but I guess that is just a lint, when it comes to lifetimes...?)
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.
copy and paste error, I think
|
||
fn foo<'a>() { | ||
let v = 22; | ||
let x = A::<'a>::new(&v, 22); |
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 think you and I mirrored each other on our respective PR's; there should be an //~ ERROR
on this line, right?
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.
Eep yes, will add.
I had a slew of nits. But none of them should block landing this PR, and frankly, I want to rebase my own work pronto on top of this. |
@bors r+ |
📌 Commit 7ce2e7a has been approved by |
@bors p=1 -- lots of stuff wants to build on this |
@bors r=pnkfelix p=1 |
📌 Commit b70b4a6 has been approved by |
…, r=pnkfelix nll type annotations in multisegment path This turned out to be sort of tricky. The problem is that if you have a path like ``` <Foo<&'static u32>>::bar ``` and it comes from an impl like `impl<T> Foo<T>` then the self-type the user gave doesn't *directly* map to the substitutions that the impl wants. To handle this, then, we have to preserve not just the "user-given substs" we used to do, but also a "user-given self-ty", which we have to apply later. This PR makes those changes. It also removes the code from NLL relate-ops that handled canonical variables and moves to use normal inference variables instead. This simplifies a few things and gives us a bit more flexibility (for example, I predict we are going to have to start normalizing at some point, and it would be easy now). r? @matthewjasper -- you were just touching this code, do you feel comfortable reviewing this? Fixes #54574
☀️ Test successful - status-appveyor, status-travis |
This turned out to be sort of tricky. The problem is that if you have a path like
and it comes from an impl like
impl<T> Foo<T>
then the self-type the user gave doesn't directly map to the substitutions that the impl wants. To handle this, then, we have to preserve not just the "user-given substs" we used to do, but also a "user-given self-ty", which we have to apply later. This PR makes those changes.It also removes the code from NLL relate-ops that handled canonical variables and moves to use normal inference variables instead. This simplifies a few things and gives us a bit more flexibility (for example, I predict we are going to have to start normalizing at some point, and it would be easy now).
r? @matthewjasper -- you were just touching this code, do you feel comfortable reviewing this?
Fixes #54574