Skip to content

rustc: don't visit lifetime parameters through visit_lifetime. #51215

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 2 commits into from
May 30, 2018

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented May 30, 2018

Ideally we'd also not use the Lifetime struct for parameters, but I'll leave that to @varkor (#48149).
Fixes #51185 (discovered while auditing all the visit_lifetime implementations).
r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 30, 2018
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I made an optional recommendation but r=me either way.

@@ -733,7 +733,16 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v TyPar
pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam) {
match *param {
GenericParam::Lifetime(ref ld) => {
visitor.visit_lifetime(&ld.lifetime);
visitor.visit_id(ld.lifetime.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, is there no visit_lifetime_def? Can we make one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't have visit_type_def. Seems a shame, but ok.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's visit_generic_param - handling just one kind of parameter is generally a bug.


for param in &generics.params {
match *param {
hir::GenericParam::Lifetime(ref lifetime_def) => {
if !lifetime_def.bounds.is_empty() {
// `'a: 'b` means both `'a` and `'b` are referenced
appears_in_where_clause.visit_generic_param(param);
appears_in_where_clause.regions.insert(lifetime_def.lifetime.name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we had a visit_lifetime_def, we could handle this within the visit impl, which seems like it'd be nicer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd be wrong, because it'd also apply on nested for's but we only want the outermost params. I almost moved this check to the loop below.

@eddyb
Copy link
Member Author

eddyb commented May 30, 2018

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented May 30, 2018

📌 Commit df45c4f has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2018
@Mark-Simulacrum
Copy link
Member

@bors p=1 this is blocking #48149

@bors
Copy link
Collaborator

bors commented May 30, 2018

🔒 Merge conflict

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2018
@eddyb eddyb force-pushed the visit-for-a-lifetime branch from df45c4f to 5c76b64 Compare May 30, 2018 17:29
@eddyb
Copy link
Member Author

eddyb commented May 30, 2018

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented May 30, 2018

📌 Commit 5c76b64 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 30, 2018
@bors
Copy link
Collaborator

bors commented May 30, 2018

⌛ Testing commit 5c76b64 with merge 5d0631a...

bors added a commit that referenced this pull request May 30, 2018
 rustc: don't visit lifetime parameters through visit_lifetime.

Ideally we'd also not use the `Lifetime` struct for parameters, but I'll leave that to @varkor (#48149).
Fixes #51185 (discovered while auditing all the `visit_lifetime` implementations).
r? @nikomatsakis
@bors
Copy link
Collaborator

bors commented May 30, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 5d0631a to master...

@bors bors merged commit 5c76b64 into rust-lang:master May 30, 2018
@eddyb eddyb deleted the visit-for-a-lifetime branch May 30, 2018 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants