rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.23k stars 12.7k forks source link

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

Open nrc opened 6 years ago

nrc commented 6 years ago

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.

nikomatsakis commented 6 years ago

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 https://github.com/rust-lang/rust/pull/50911.)

nikomatsakis commented 6 years ago

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 commented 6 years ago

Clearing from milestone.

pnkfelix commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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.

joshtriplett commented 2 months ago

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 commented 2 weeks ago

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=fd8f7c2bb6a4eb66a0f74bd5dae2a4c7

nikomatsakis commented 2 weeks ago

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 commented 2 weeks ago

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):

traviscross commented 2 weeks ago

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