Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDisallow type/lifetime parameter shadowing. #459
Conversation
nikomatsakis
referenced this pull request
Nov 10, 2014
Closed
Shadowing lifetimes should be disallowed or linted #18824
This comment has been minimized.
This comment has been minimized.
|
Note: there was some (universally positive) discussion in a discuss thread already: http://discuss.rust-lang.org/t/preventing-lifetime-shadowing/784 |
This comment has been minimized.
This comment has been minimized.
|
Agree with this. |
This comment has been minimized.
This comment has been minimized.
Valloric
commented
Nov 10, 2014
|
|
This comment has been minimized.
This comment has been minimized.
TyOverby
commented
Nov 10, 2014
|
This was my number 1 pain point when learning about lifetimes. |
This comment has been minimized.
This comment has been minimized.
|
I would be interested to see a mention of hygiene/macro-generated type/lifetime parameters, e.g. the following would preferably be valid: macro_rules! method {
() => {
fn foo<'a>(&'a self) -> &'a int { unimplemented!() }
}
}
struct Foo<'a> { x: &'a int }
impl<'a> Foo<'a> {
method!()
} |
This comment has been minimized.
This comment has been minimized.
|
@huonw In general macros allow a kind of "shadowing" which isn't really shadowing, where internally the hygiene keeps the identifiers separate, but when something errors it is possible to get similar tautological errors ("expected Perhaps identifiers from macros should be visibly mangled in errors where this happens, or something? ( |
This comment has been minimized.
This comment has been minimized.
@Manishearth yes, I agree, I would just like this to be explicit in the RFC to ensure there's no ambiguity in the implementation. Disallowing shadowing could be interpreted as disallowing textual names that are the same (rather than the whole identifiers: name and hygiene), and, macros do not allow for completely arbitrary shadowing, e.g. writing |
This comment has been minimized.
This comment has been minimized.
|
Agreed; the RfC should explicitly mention that it's not going to change the pseudoshadowing that macros allow. |
This comment has been minimized.
This comment has been minimized.
|
This is a great idea. |
zwarich
assigned
nikomatsakis
Nov 13, 2014
This comment has been minimized.
This comment has been minimized.
|
We had someone hit this just today in IRC. They had I already voiced my support in Discuss, but let me emphasize again that this would be a good change. |
nrc
referenced this pull request
Nov 29, 2014
Closed
Tracking issue for RFC 459 - Disallow type/lifetime parameter shadowing #19390
This comment has been minimized.
This comment has been minimized.
|
We discussed this in (this week's meeting)[] and decided to accept. FTR, there was some debate about whether this should be a lint or a hard error (I personally pushed for a lint). We decided on a hard error because it is easier to implement and more conservative. We may (should) revisit this decision post-1.0. |
nikomatsakis commentedNov 10, 2014
Just what it says in the subject.
Rendered view.