-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Implement crate-level-only lints checking. #73300
Conversation
Some changes occurred in diagnostic error codes |
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
Also opened #73301 to track the sub-optimal error reporting. |
There are some other lints that are ignored in non-crate positions (like
|
61cfc0c
to
56f4ab7
Compare
oops, accidentally overwrote this branch with another, recovered. |
Re: breaking change, I'm open to downgrade this check to a warning if people think it's a better idea. I think the non-ascii-idents series of lints should be kept crate-level-only, otherwise will bring a lot of runtime-complexity here. I don't have any opinion on whether any other specific lint should be crate-level-only or not... EDIT: Thinking more about it, maybe it's possible to convert the two checks here to lints themselves. "Meta lints" lol. |
This can use the It's hard to diagnose this precisely enough for a hard error. |
It would be good to audit all lints and detect those using UPD: it's |
56f4ab7
to
c9bba88
Compare
I reimplemented this check, however it turns out to be a bigger change than i expected. But i've got it finished anyway. Let me leave a few notes here:
|
I'm not sure what do i need to do to the lint list above ... Should i add the crate_level_only flag to these lints? |
This comment has been minimized.
This comment has been minimized.
c9bba88
to
12ef4f6
Compare
This comment has been minimized.
This comment has been minimized.
12ef4f6
to
644410d
Compare
Nooo, not one more infra for invalid attributes, we already have two of those... The original version was almost ready for merging, it only needed changing the error into a lint and marking more lints with |
I the new version is mostly intended to fix #73301, then perhaps it's better submitted as a separate PR. |
6684a79
to
7f27320
Compare
Implementation looks good to me, except that I'd still prefer to reuse In theory, new lints still require an RFC, even if nobody remembers about it nowadays. |
7f27320
to
f633dd3
Compare
Sure, i've adjusted the code. Thanks! |
Thanks! |
📌 Commit f633dd3 has been approved by |
…petrochenkov Implement crate-level-only lints checking. This implements a crate_level_only flag on lints, and when it is true, it becomes an error when user tries to specify this flag upon nodes other than crate node. This also turns on this flag for all non_ascii_ident lints.
…arth Rollup of 13 pull requests Successful merges: - rust-lang#71568 (Document unsafety in slice/sort.rs) - rust-lang#72709 (`#[deny(unsafe_op_in_unsafe_fn)]` in liballoc) - rust-lang#73214 (Add asm!() support for hexagon) - rust-lang#73248 (save_analysis: improve handling of enum struct variant) - rust-lang#73257 (ty: projections in `transparent_newtype_field`) - rust-lang#73261 (Suggest `?Sized` when applicable for ADTs) - rust-lang#73300 (Implement crate-level-only lints checking.) - rust-lang#73334 (Note numeric literals that can never fit in an expected type) - rust-lang#73357 (Use `LocalDefId` for import IDs in trait map) - rust-lang#73364 (asm: Allow multiple template string arguments; interpret them as newline-separated) - rust-lang#73382 (Only display other method receiver candidates if they actually apply) - rust-lang#73465 (Add specialization of `ToString for char`) - rust-lang#73489 (Refactor hir::Place) Failed merges: r? @ghost
* when newer rust is used, iotedge-* fails with: with 1.47.0 and 1.46.0 rust_2018_idioms, triggers unused_attributes warning because rust_2018_idioms is for crate level only since: rust-lang/rust#73300 which is then an error because warnings are denied as well: | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target' (ignoring feature) | +v8' is not a recognized feature for this target (ignoring feature) | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/authentication.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(unused_attributes)]` implied by `#[deny(warnings)]` | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/certificate_manager.rs:1:27 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) with 1.43.0 it still fails due to use of deprecated description (since 1.42.0 with rust-lang/rust#66919) | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:248:54 | | | 248 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | | note: the lint level is defined here | --> iotedge/src/lib.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]` | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:302:54 | | | 302 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:375:54 | | | 375 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:457:54 | | | 457 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ you can either work around it by allowing warnings (deprecated and unused_attributes): find ${WORKDIR}/iotedge-${PV} -name "*.rs" -exec sed -i 's/idioms, warnings)/idioms)/g' {} \; or fix it properly in next iotedge release, or just select older rust version which doesn't trigger fatal error for this with: RUST_VERSION = "1.41.0" PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}" PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}" PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}" Signed-off-by: Martin Jansa <[email protected]>
* when newer rust is used, iotedge-* fails with: with 1.47.0 and 1.46.0 rust_2018_idioms, triggers unused_attributes warning because rust_2018_idioms is for crate level only since: rust-lang/rust#73300 which is then an error because warnings are denied as well: | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target' (ignoring feature) | +v8' is not a recognized feature for this target (ignoring feature) | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/authentication.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(unused_attributes)]` implied by `#[deny(warnings)]` | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/certificate_manager.rs:1:27 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) with 1.43.0 it still fails due to use of deprecated description (since 1.42.0 with rust-lang/rust#66919) | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:248:54 | | | 248 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | | note: the lint level is defined here | --> iotedge/src/lib.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]` | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:302:54 | | | 302 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:375:54 | | | 375 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:457:54 | | | 457 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ you can either work around it by allowing warnings (deprecated and unused_attributes): find ${WORKDIR}/iotedge-${PV} -name "*.rs" -exec sed -i 's/idioms, warnings)/idioms)/g' {} \; or fix it properly in next iotedge release, or just select older rust version which doesn't trigger fatal error for this with: RUST_VERSION = "1.41.0" PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}" PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}" PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}" Signed-off-by: Martin Jansa <[email protected]>
* when newer rust is used, iotedge-* fails with: with 1.47.0 and 1.46.0 rust_2018_idioms, triggers unused_attributes warning because rust_2018_idioms is for crate level only since: rust-lang/rust#73300 which is then an error because warnings are denied as well: | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target' (ignoring feature) | +v8' is not a recognized feature for this target (ignoring feature) | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/authentication.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(unused_attributes)]` implied by `#[deny(warnings)]` | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | | note: the lint level is defined here | --> edgelet-http/src/certificate_manager.rs:1:27 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/authentication.rs:3:9 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | error: deny(rust_2018_idioms) is ignored unless specified at crate level | --> edgelet-http/src/certificate_manager.rs:1:9 | | | 1 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^^^^^^^^^ | | ''+v8+v8' is not a recognized feature for this target' is not a recognized feature for this target (ignoring feature) | (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) | '+v8' is not a recognized feature for this target (ignoring feature) with 1.43.0 it still fails due to use of deprecated description (since 1.42.0 with rust-lang/rust#66919) | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:248:54 | | | 248 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | | note: the lint level is defined here | --> iotedge/src/lib.rs:3:27 | | | 3 | #![deny(rust_2018_idioms, warnings)] | | ^^^^^^^^ | = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]` | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:302:54 | | | 302 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:375:54 | | | 375 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ | | error: use of deprecated item 'std::error::Error::description': use the Display impl or to_string() | --> iotedge/src/support_bundle.rs:457:54 | | | 457 | let err_message = inspect.err().unwrap().description().to_owned(); | | ^^^^^^^^^^^ you can either work around it by allowing warnings (deprecated and unused_attributes): find ${WORKDIR}/iotedge-${PV} -name "*.rs" -exec sed -i 's/idioms, warnings)/idioms)/g' {} \; or fix it properly in next iotedge release, or just select older rust version which doesn't trigger fatal error for this with: RUST_VERSION = "1.41.0" PREFERRED_VERSION_rust-native ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-cross-${TARGET_ARCH} ?= "${RUST_VERSION}" PREFERRED_VERSION_rust-llvm-native ?= "${RUST_VERSION}" PREFERRED_VERSION_libstd-rs ?= "${RUST_VERSION}" PREFERRED_VERSION_cargo-native ?= "${RUST_VERSION}" Signed-off-by: Martin Jansa <[email protected]>
This implements a crate_level_only flag on lints, and when it is true, it becomes an error when user tries to specify this flag upon nodes other than crate node.
This also turns on this flag for all non_ascii_ident lints.