Skip to content

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

Merged
merged 3 commits into from
Oct 2, 2017

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Oct 1, 2017

Fixes #44952.

r? @eddyb

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()]
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@eddyb
Copy link
Member

eddyb commented Oct 1, 2017

r=me w/ Self fixed (although I believe the current uses don't care)

@arielb1
Copy link
Contributor Author

arielb1 commented Oct 1, 2017

@eddyb

done

if let Some(idx) = (idx as usize).checked_sub(type_param_start) {
Some(&self.types[idx])
} else {
None
Copy link
Member

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]?

Copy link
Contributor Author

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.

@eddyb
Copy link
Member

eddyb commented Oct 2, 2017

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 2, 2017

📌 Commit 706e52e has been approved by eddyb

@bors
Copy link
Collaborator

bors commented Oct 2, 2017

⌛ Testing commit 706e52e with merge 0f0f5db...

bors added a commit that referenced this pull request Oct 2, 2017
handle nested generics in Generics::type_param/region_param

Fixes #44952.

r? @eddyb
@bors
Copy link
Collaborator

bors commented Oct 2, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 0f0f5db to master...

@bors bors merged commit 706e52e into rust-lang:master Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants