-
Notifications
You must be signed in to change notification settings - Fork 13.3k
handle nested generics in Generics::type_param/region_param #44959
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
Conversation
src/librustc/ty/mod.rs
Outdated
param: &ParamTy, | ||
tcx: TyCtxt<'a, 'gcx, 'tcx>) -> &TypeParameterDef { | ||
if let Some(idx) = param.idx.checked_sub(self.parent_count() as u32) { | ||
&self.types[idx as usize - self.has_self as usize - self.regions.len()] |
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.
This doesn't seem to take into account the fact that Self
is at index 0
before 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.
How are you supposed to detect 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.
has_self
and the index is 0
.
r=me w/ |
done |
src/librustc/ty/mod.rs
Outdated
if let Some(idx) = (idx as usize).checked_sub(type_param_start) { | ||
Some(&self.types[idx]) | ||
} else { | ||
None |
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 not assert_eq!((idx, self.has_self), (0, true));
followed by &self.types[0]
?
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.
idx
of 1 is also mapped to 1 - 1 = 0
, so I don't think &self.types[0]
is correct here and Self
doesn't have a TypeParameterDef
.
@bors r+ |
📌 Commit 706e52e has been approved by |
☀️ Test successful - status-appveyor, status-travis |
Fixes #44952.
r? @eddyb