Skip to content

Conversation

@Veykril
Copy link
Member

@Veykril Veykril commented Dec 17, 2020

There is a slight problem with this which is also noted in a FIXME now but LifetimeParameters of these ForLifetime where clauses allocate the lifetimes in the corresponding arena as if they were lifetimes of the item itself and not just the clause they belong to. I wasn't entirely sure what I could do about this but given nothing really uses lifetimes like that currently I figured it might be fine? Open to suggestions for that problem.

bound: LifetimeRef,
},
ForLifetime {
lifetimes: Box<[LifetimeRef]>,
Copy link
Member

Choose a reason for hiding this comment

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

these should just be Names, I think; they're not references to existing lifetimes, but defining new ones

.map_or_else(Name::missing, |lt| Name::new_lifetime(&lt));
let param = LifetimeParamData { name: name.clone() };
// FIXME: allocating the lifetime here means it looks like this lifetime belongs to the entire item
// but it only belongs to the bounded type-param
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'm not sure giving these lifetimes a LifetimeParamId at all is the correct approach, since they're not parameters of the item. (There's another place where new lifetime names can be defined, namely for<'x> fn() function pointer types, and I think these two should work the same.)

Copy link
Member

Choose a reason for hiding this comment

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

Also, while shadowing an existing lifetime is disallowed, you can easily have the same lifetime twice on an item this way:

fn foo<T, U>() where for<'b> U: 'b, for<'b> T: 'b {}

Copy link
Member Author

Choose a reason for hiding this comment

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

Well the main reason for giving them LifetimeParamIds is that for reference search we need to be able to address them as code_model::LifetimeParams, which is backed by a LifetimeParamId. And technically they are LifetimeParams right? Just with a smaller scope. Though I can't really think of a way to solve this problem, so I guess it's better to just not support reference search for these for the time being.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't really know how to model this yet either, and I think supporting reference search for these is probably not super important right now.

Copy link
Member Author

@Veykril Veykril Dec 17, 2020

Choose a reason for hiding this comment

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

Yea I agree, will remove those parts for now then. 👍

@matklad
Copy link
Contributor

matklad commented Dec 19, 2020

r? @flodiebold

@flodiebold
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Dec 20, 2020

@bors bors bot merged commit eefbae7 into rust-lang:master Dec 20, 2020
@Veykril Veykril deleted the hrtb branch December 21, 2020 10:10
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