Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upEdition hygiene in lints #52038
Comments
nrc
added
the
A-edition-2018-lints
label
Jul 3, 2018
alexcrichton
added this to the Rust 2018 Preview 2 milestone
Jul 11, 2018
This comment has been minimized.
This comment has been minimized.
|
Bumping this to the release candidate milestone for 2018 |
alexcrichton
modified the milestones:
Rust 2018 Preview 2,
Rust 2018 RC
Jul 31, 2018
Mark-Simulacrum
added
the
A-rust-2018-preview
label
Jul 31, 2018
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis and I talked about this and didn't reach a whole lot of conclusions and/or solutions. Some of this issue is just about edition hygiene in general, but other parts of it are about lints themselves. Some problematic test cases we could think of are: // 2015 crate
macro_rules! foo {
() => (fn async() {})
}
// 2018 crate
foo!(); // what happens?or // 2015 crate
macro_rules! foo {
($x:ident) => (fn $x() {})
}
// 2018 crate
foo!(async); // what happens?or // 2015
macro_rules! foo {
() => {
fn bar() {
use ::x::y; // can this resolve to `crate::x::y` when invoked in a 2018 crate?
}
}
}it's not entirely clear what the compiler should be doing here unfortunately! @nikomatsakis that while #50999 is one strategy there's one other primary strategy (which I didn't quite follow well enough to write down here). The quick notes on the two strategies were "pick a best spot" or "pick another spot", presumably for figuring out which edition is relevant in macro-expanded code. What we did conclude, however, was that this issue doesn't actually seem very pressing. Basically none of the prominent macros in the ecosystem will run into this issue and we've received no known reports about this issue. In that sense our thinking currently is punt on this until it comes up. When it comes up there's likely a fix we can apply backwards-compatibly, and additionally if this comes up in the wild it will help us to select amongst the various strategies for resolving this issue. As a result I'm going to remove this from all milestones. |
nrc commentedJul 3, 2018
Edition lints should be hygienic, that is, if a macro is declared in a 2018 crate and used in a 2015 crate, then the expanded macro should not trigger any lints.
There is a PR, #50999, but there are questions about the details of hygiene (see also #50122 and #50376).
The next step is probably to define and write-up the high-level approach.
cc @nikomatsakis @petrochenkov