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 lint: migrating extern crate with #[macro_use] #52043

Open
nrc opened this issue Jul 4, 2018 · 11 comments
Open

edition lint: migrating extern crate with #[macro_use] #52043

nrc opened this issue Jul 4, 2018 · 11 comments
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. L-macro_use_extern_crate Lint: macro_use_extern_crate T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nrc
Copy link
Member

nrc commented Jul 4, 2018

The migration issue is that #[macro_use] extern crate foo; beings macros into scope from foo and extern crate is unidiomatic in the 2018 edition. local_inner_macros is the current solution but as discussed in #50911, we're not 100% that works.

@nrc nrc mentioned this issue Jul 4, 2018
15 tasks
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jul 12, 2018
This commit adds a lint to the compiler to warn against the `#[macro_use]`
directive as part of the `rust_2018_idioms` lint. This lint is turned off by
default and is only enabled when the `use_extern_macros` feature is also
enabled.

The lint here isn't fully fleshed out as it's just a simple warning rather than
suggestions of how to actually import the macro, but hopefully it's a good base
to start from!

cc rust-lang#52043
bors added a commit that referenced this issue Jul 13, 2018
rustc: Lint against `#[macro_use]` in 2018 idioms

This commit adds a lint to the compiler to warn against the `#[macro_use]`
directive as part of the `rust_2018_idioms` lint. This lint is turned off by
default and is only enabled when the `use_extern_macros` feature is also
enabled.

The lint here isn't fully fleshed out as it's just a simple warning rather than
suggestions of how to actually import the macro, but hopefully it's a good base
to start from!

cc #52043
@nikomatsakis
Copy link
Contributor

I can't tell what the status is here. We have a lint (landed in #52275) but as far as I can tell (playground) it does not fire. In fact, I get no warnings at all when using extern crate in Rust 2018, even with idiom lints enabled. Is that expected?

(We do appear to have stabilized use_extern_macros in #50911.)

@nikomatsakis
Copy link
Contributor

I don't think however that this needs to be a Rust 2018 RC2 blocker, since edition lints are not idiom enabled by default.

@nikomatsakis nikomatsakis removed this from the Edition 2018 RC 2 milestone Oct 17, 2018
@nikomatsakis
Copy link
Contributor

Clearing from milestone.

@pnkfelix
Copy link
Member

@nikomatsakis is there a specific team we can tag this with?
That, or can you remove the nomination? (Would the team be T-compiler, or is there a different group dedicated to idiom lints?)

@pnkfelix
Copy link
Member

pnkfelix commented Dec 6, 2018

I'm going to tag this with T-compiler, under the assumption that they will either address it or punt it to the appropriate other team.

@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 6, 2018
@pnkfelix
Copy link
Member

pnkfelix commented Dec 6, 2018

discussed at T-compiler meeting. @nikomatsakis says idiom lints are essentially "deferred". They want a working group focused on them; that, or T-compiler. But in any case, it doesn't need the nomination tag; we'll work our way through the queue of A-edition-2018-lints labelled things eventually

unnominating.

@Enselic Enselic added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Nov 19, 2023
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC L-macro_use_extern_crate Lint: macro_use_extern_crate and removed C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Jun 3, 2024
@joshtriplett joshtriplett added the I-lang-nominated Nominated for discussion during a lang team meeting. label Aug 26, 2024
@joshtriplett
Copy link
Member

This seems to have fallen through the cracks, and hasn't been looked at in years. We should consider whether, at this point, we can safely upgrade this lint to at least warn.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Oct 16, 2024

The behavior seems to be:

If you don't use any macros, you get a warning that #[macro_use] is not used.

If you do, the macro_use_extern_crate lint fires (but is allow-by-default).

I agree with @joshtriplett that we should at least warn and explain that this is deprecated.

@pnkfelix
Copy link
Member

pnkfelix commented Oct 16, 2024

Just to clarify (since this issue hasn't gotten updates and the dialogue from years past led me to think that the lint as-implemented as not working):

  • We have an allow-by-default macro_use_extern_crate lint.
  • It does not fire unless there is an invocation of a macro imported via #[macro_use] (which explains why niko's playground from 2018 was not firing).
  • We are generally in favor of making the lint warn-by-default instead of allow-by-default
  • We would also be in favor of a better UX overall (e.g. suggesting the necessary change to the new idiom).

@traviscross
Copy link
Contributor

@rustbot labels -I-lang-nominated

As @pnkfelix said above, we'd like to see a PR making this warn-by-default. We'll do the FCP on that PR, so please nominate it for us.

@rustbot rustbot removed the I-lang-nominated Nominated for discussion during a lang team meeting. label Oct 16, 2024
@fmease fmease added A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-edition-2018-lints labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-enhancement Category: An issue proposing an enhancement or a PR with one. L-macro_use_extern_crate Lint: macro_use_extern_crate T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants