rust-lang / rust

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

strange rust_2018_idioms warning on code comment in clippy codebase #51881

Open matthiaskrgr opened 6 years ago

matthiaskrgr commented 6 years ago
git clone http://github.com/rust-lang-nursery/rust-clippy/
cd rust-clippy
git checkout 656b26ea4f2b330ea5b9cb3cb38545587eac8f7f
cargo check --all-targets --all-features 

=>

....
warning: `extern crate` is not idiomatic in the new edition
 --> src/lib.rs:1:1
  |
1 | // error-pattern:cargo-clippy
  | ^ help: convert it to a `use`
  |
note: lint level defined here
 --> src/lib.rs:8:9
  |
8 | #![warn(rust_2018_idioms)]
  |         ^^^^^^^^^^^^^^^^
  = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]

this is confusing because the highlighted line is a code comment and seems unrelated to the extern crate keyword.

rustc 1.28.0-nightly (cd494c1f0 2018-06-27)

link to file: https://github.com/rust-lang-nursery/rust-clippy/blob/656b26ea4f2b330ea5b9cb3cb38545587eac8f7f/src/lib.rs

oli-obk commented 6 years ago

I'd assume this is the 2015 prelude's extern crate std; item.

najamelan commented 6 years ago

I get this warning consistently from RLS-preview in crates that don't have extern crate. I have edition = 2018 in cargo.toml. I do not get this warning when compiling from the command line with cargo build.

Mark-Simulacrum commented 6 years ago

cc @nrc for the change between RLS and CLI behavior

nikomatsakis commented 5 years ago

Removing from the release milestone, as functional Idiom Lints are not part of our Rust 2018 release goals. But we oughta' fix this =)

Enselic commented 11 months ago

Triage: The reproducer does not work any longer with Rust 1.74, but I get a bunch of other errors, so hard to say if the reported problem has been fixed. Here is the current output:

Click to expand ```console $ cargo check --all-targets --all-features warning: the cargo feature `edition` has been stabilized in the 1.31 release and is no longer necessary to be listed in the manifest See https://doc.rust-lang.org/cargo/reference/manifest.html#the-edition-field for more information about using this feature. Updating crates.io index Compiling proc-macro2 v1.0.69 Compiling unicode-ident v1.0.12 Compiling libc v0.2.150 Compiling serde v1.0.192 Checking memchr v2.6.4 Compiling serde_json v1.0.108 Checking gimli v0.28.0 Checking adler v1.0.2 Checking cfg-if v1.0.0 Compiling semver-parser v0.7.0 Checking rustc-demangle v0.1.23 Compiling pulldown-cmark v0.1.2 Checking ryu v1.0.15 Checking itoa v1.0.9 Compiling syn v1.0.109 Checking tinyvec_macros v0.1.1 Checking unicode-width v0.1.11 Checking unicode-bidi v0.3.13 Checking matches v0.1.10 Compiling ansi_term v0.11.0 Checking regex-syntax v0.8.2 Compiling unicode-xid v0.2.4 Checking percent-encoding v1.0.1 Checking tinyvec v1.6.0 Compiling failure_derive v0.1.8 Checking miniz_oxide v0.7.1 Checking either v1.9.0 Checking bitflags v0.9.1 Checking getopts v0.2.21 Checking itertools v0.7.11 Checking cfg-if v0.1.10 Checking if_chain v0.1.3 Checking lazy_static v1.4.0 Checking regex-syntax v0.6.29 Checking quine-mc_cluskey v0.2.4 Checking log v0.4.20 Compiling compiletest_rs v0.3.26 Checking diff v0.1.13 Compiling clippy-mini-macro-test v0.2.0 (/home/martin/src/rust-clippy/mini-macro) error[E0557]: feature has been removed --> mini-macro/src/lib.rs:1:24 | 1 | #![feature(proc_macro, proc_macro_non_items)] | ^^^^^^^^^^^^^^^^^^^^ feature has been removed | = note: subsumed by `#![feature(proc_macro_hygiene)]` error[E0658]: use of unstable library feature 'proc_macro_quote' --> mini-macro/src/lib.rs:8:5 | 8 | quote!( | ^^^^^ | = note: see issue #54722 for more information error[E0554]: `#![feature]` may not be used on the stable release channel --> mini-macro/src/lib.rs:1:1 | 1 | #![feature(proc_macro, proc_macro_non_items)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: the feature `proc_macro` has been stable since `1.29.0` and no longer requires an attribute to enable error[E0658]: use of unstable library feature 'proc_macro_quote' --> mini-macro/src/lib.rs:4:31 | 4 | use proc_macro::{TokenStream, quote}; | ^^^^^ | = note: see issue #54722 for more information warning: the feature `proc_macro` has been stable since 1.29.0 and no longer requires an attribute to enable --> mini-macro/src/lib.rs:1:12 | 1 | #![feature(proc_macro, proc_macro_non_items)] | ^^^^^^^^^^ | = note: `#[warn(stable_features)]` on by default Some errors have detailed explanations: E0554, E0557, E0658. For more information about an error, try `rustc --explain E0554`. warning: `clippy-mini-macro-test` (lib) generated 1 warning error: could not compile `clippy-mini-macro-test` (lib) due to 4 previous errors; 1 warning emitted warning: build failed, waiting for other jobs to finish... ```