Skip to content
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

Edition hygiene in lints #52038

Closed
nrc opened this issue Jul 3, 2018 · 3 comments
Closed

Edition hygiene in lints #52038

nrc opened this issue Jul 3, 2018 · 3 comments
Labels
A-edition-2018-lints Area: Lints supporting the 2018 edition A-rust-2018-preview Area: The 2018 edition preview

Comments

@nrc
Copy link
Member

nrc commented Jul 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

@nrc nrc added the A-edition-2018-lints Area: Lints supporting the 2018 edition label Jul 3, 2018
@alexcrichton alexcrichton added this to the Rust 2018 Preview 2 milestone Jul 11, 2018
@alexcrichton
Copy link
Member

Bumping this to the release candidate milestone for 2018

@Mark-Simulacrum Mark-Simulacrum added the A-rust-2018-preview Area: The 2018 edition preview label Jul 31, 2018
@alexcrichton
Copy link
Member

@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.

@Enselic
Copy link
Member

Enselic commented Oct 12, 2023

Triage: By now this seems very unlikely to ever be implemented. The effort to implement this is big, but the benefit is small. Let's close as won't fix rather than keep this open forever.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018-lints Area: Lints supporting the 2018 edition A-rust-2018-preview Area: The 2018 edition preview
Projects
None yet
Development

No branches or pull requests

4 participants