Skip to content

Represent lifetimes as Names instead of Idents #12451

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 1 commit into from
Feb 23, 2014

Conversation

edwardw
Copy link
Contributor

@edwardw edwardw commented Feb 21, 2014

Closes #7743.

@huonw
Copy link
Member

huonw commented Feb 22, 2014

FWIW, do we really want lifetimes to be non-hygienic? i.e. should

macro_rules! foo ( ($t: ty) => { fn foo<'a>(a: &'a int, b: $t) { ... } })

foo!(&'a int)

be valid?

(This is particularly important if we ever get macros being able to expand to methods (#4621), in which case the above with &'a self instead of a: &'a int would do weird/bad things with

impl<'a> Foo<'a> {
     foo!(&'a int) // meant to be Foo's 'a.
}

)

(Sorry to be annoying about hygiene...)

@huonw
Copy link
Member

huonw commented Feb 22, 2014

That said, reverting this patch shouldn't be particularly hard if we do implement hygiene for them later...

@bors bors closed this Feb 23, 2014
@bors bors merged commit 7607332 into rust-lang:master Feb 23, 2014
@edwardw edwardw deleted the ident-2-name branch February 23, 2014 17:05
@pnkfelix
Copy link
Member

I'm inclined to agree with @huonw here: As his example illustrates, a macro can expand into a fn that binds a lifetime. This leads me to think that lifetimes should respect hygiene. (I guess I mention this only because huon has already said that macros-expanding into methods are a potential future motivation, but I would think that the current motivations are sufficient.)

I do not understand the motivation outlined in the description on #7743: "This will allow them to be safely compared without fear of runtime-fail." Is this just talking about when writing rustc internal code? Or writing macro expanders?

In any case I'd prefer runtime-fail over having active footguns that are hidden by lack of hygiene.

@jbclements can you elaborate?

@edwardw
Copy link
Contributor Author

edwardw commented Feb 27, 2014

If a decision is made, I can always revert this patch. One caveat is since #12338 has turned lifetime renaming on, we may hit ast.rs#L67.

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.

easy fix: lifetimes should contain Name's, not idents
5 participants