-
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
Internal lints take 2 #59316
Internal lints take 2 #59316
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
dd43979
to
16264e2
Compare
impl lgtm now |
It seems like the If I try to activate the lint group, I get an unknown lint error:
|
That's very curious. There's probably a hack that makes if stage != "0" {
cmd.arg("-Zunstable-options");
} to rust/src/bootstrap/bin/rustc.rs Line 285 in 86466a3 |
Ping from triage, @flip1995 ^ |
Will get to this today / Monday. |
16264e2
to
c592b86
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
c592b86
to
223f7c5
Compare
196c89b
to
ebde526
Compare
☔ The latest upstream changes (presumably #59657) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small nits, then this lgtm. Are you planning on doing this to any furhter crates? If not, please remove WIP
from the title and rebase.
I thought about adding |
For |
3edc722
to
5422111
Compare
…li-obk Internal lints take 2 cc rust-lang#58701 cc rust-lang#49509 TODO: Add `#![warn(internal)]` to crates (and fix violations) Crates depending on `rustc_data_structures` - [x] librustc_resolve - [x] librustc_driver - [x] librustc_passes - [x] librustc_metadata - [x] librustc_interface - [x] librustc_save_analysis - [x] librustc_lint - [x] librustc - [x] librustc_incremental - [x] librustc_codegen_utils - [x] libarena - [x] librustc_target - [x] librustc_allocator - [x] librustc_privacy - [x] librustc_traits - [x] librustc_borrowck - [x] libsyntax - [x] librustc_codegen_ssa - [x] libsyntax_ext - [x] librustc_errors - [x] librustc_mir - [x] libsyntax_pos - [x] librustc_typeck Crates with `feature(rustc_private)` Excluding crates, which are already in the list above. Also excluding tools and tests. - [ ] ~~libstd~~ - [x] libfmt_macros - [x] librustdoc r? @oli-obk
…li-obk Internal lints take 2 cc rust-lang#58701 cc rust-lang#49509 TODO: Add `#![warn(internal)]` to crates (and fix violations) Crates depending on `rustc_data_structures` - [x] librustc_resolve - [x] librustc_driver - [x] librustc_passes - [x] librustc_metadata - [x] librustc_interface - [x] librustc_save_analysis - [x] librustc_lint - [x] librustc - [x] librustc_incremental - [x] librustc_codegen_utils - [x] libarena - [x] librustc_target - [x] librustc_allocator - [x] librustc_privacy - [x] librustc_traits - [x] librustc_borrowck - [x] libsyntax - [x] librustc_codegen_ssa - [x] libsyntax_ext - [x] librustc_errors - [x] librustc_mir - [x] libsyntax_pos - [x] librustc_typeck Crates with `feature(rustc_private)` Excluding crates, which are already in the list above. Also excluding tools and tests. - [ ] ~~libstd~~ - [x] libfmt_macros - [x] librustdoc r? @oli-obk
Rollup of 6 pull requests Successful merges: - #59316 (Internal lints take 2) - #59663 (Be more direct about borrow contract) - #59664 (Updated the documentation of spin_loop and spin_loop_hint) - #59666 (Updated the environment description in rustc.) - #59669 (Reduce repetition in librustc(_lint) wrt. impl LintPass by using macros) - #59677 (rustfix coverage: Skip UI tests with non-json error-format) Failed merges: r? @ghost
|
||
/// Check if a `DefId`'s path matches the given absolute type path usage. | ||
// Uplifted from rust-lang/rust-clippy | ||
pub fn match_path<'a, 'tcx>(self, tcx: TyCtxt<'a, 'tcx, 'tcx>, path: &[&str]) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for not noticing this until now, but such functionality doesn't belong on DefId
, not even TyCtxt
IMO.
Could we move this to the lint context, instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will do this tomorrow/Saturday!
…anishearth Move match_path from DefId to lint::LateContext cc rust-lang#59316 (comment) r? @eddyb
…anishearth Move match_path from DefId to lint::LateContext cc rust-lang#59316 (comment) r? @eddyb
This uplifts `get_def_path` from Clippy. This is a follow up on the implementation of internal lints: rust-lang#59316 The internal lint implementation also copied the implementation of the `AbsolutePathPrinter`. To get rid of this code duplication this also uplifts the `get_def_path` function from Clippy. This also renames `match_path` to `match_def_path`, as it was originally named in Clippy.
…ishearth Uplift `get_def_path` from Clippy cc rust-lang/rust-clippy#3926 cc rust-lang#59738 This uplifts `get_def_path` from Clippy. This is a follow up on the implementation of internal lints: rust-lang#59316 The internal lint implementation also copied the implementation of the `AbsolutePathPrinter`. To get rid of this code duplication this also uplifts the `get_def_path` function from Clippy. This also renames `match_path` to `match_def_path`, as it was originally named in Clippy. r? @Manishearth
…ishearth Uplift `get_def_path` from Clippy cc rust-lang/rust-clippy#3926 cc rust-lang#59738 This uplifts `get_def_path` from Clippy. This is a follow up on the implementation of internal lints: rust-lang#59316 The internal lint implementation also copied the implementation of the `AbsolutePathPrinter`. To get rid of this code duplication this also uplifts the `get_def_path` function from Clippy. This also renames `match_path` to `match_def_path`, as it was originally named in Clippy. r? @Manishearth
This uplifts `get_def_path` from Clippy. This is a follow up on the implementation of internal lints: rust-lang#59316 The internal lint implementation also copied the implementation of the `AbsolutePathPrinter`. To get rid of this code duplication this also uplifts the `get_def_path` function from Clippy. This also renames `match_path` to `match_def_path`, as it was originally named in Clippy.
@@ -109,6 +108,9 @@ pub fn create_session( | |||
let codegen_backend = get_codegen_backend(&sess); | |||
|
|||
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); | |||
if sess.unstable_options() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was it guarded by unstable_options()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because every lint, that is registered will be run, which is bad performance wise (for normal users) and can be easily prevented. We decided to not introduce a new -Z
option and just use the unstable_options
flag. #58701 (comment) #59316 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lints are useless outside of the compiler or clippy. Exposing them to stable would mean we'd need to support the name (or the lint existing) forever, even if the lint might disappear if the compiler datastructures change beyond the point where the lint is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, GitHub collapsed that comment.
I was wondering if there is better solution for Clippy and possibly other projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not gating on whether the crate is compiled to be unstable with the feature rustc_private
?
…ishearth Uplift `get_def_path` from Clippy cc rust-lang/rust-clippy#3926 cc rust-lang#59738 This uplifts `get_def_path` from Clippy. This is a follow up on the implementation of internal lints: rust-lang#59316 The internal lint implementation also copied the implementation of the `AbsolutePathPrinter`. To get rid of this code duplication this also uplifts the `get_def_path` function from Clippy. This also renames `match_path` to `match_def_path`, as it was originally named in Clippy. r? @Manishearth
Implement another internal lints cc rust-lang#49509 This adds ~~two~~ one internal lint~~s~~: 1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc rust-lang#59669 2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in rust-lang#49509~~ ~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~ TODO (not directly relevant for review): - [ ] rust-lang#59316 (comment) (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb) - [x] rust-lang#61735 (comment) - [x] Check explicitly for the `{declare,impl}_lint_pass!` macros r? @oli-obk
Implement another internal lints cc rust-lang#49509 This adds ~~two~~ one internal lint~~s~~: 1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc rust-lang#59669 2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in rust-lang#49509~~ ~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~ TODO (not directly relevant for review): - [ ] rust-lang#59316 (comment) (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb) - [x] rust-lang#61735 (comment) - [x] Check explicitly for the `{declare,impl}_lint_pass!` macros r? @oli-obk
Implement another internal lints cc rust-lang#49509 This adds ~~two~~ one internal lint~~s~~: 1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc rust-lang#59669 2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in rust-lang#49509~~ ~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~ TODO (not directly relevant for review): - [ ] rust-lang#59316 (comment) (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb) - [x] rust-lang#61735 (comment) - [x] Check explicitly for the `{declare,impl}_lint_pass!` macros r? @oli-obk
cc #58701
cc #49509
TODO: Add
#![warn(internal)]
to crates (and fix violations)Crates depending on
rustc_data_structures
Crates with
feature(rustc_private)
Excluding crates, which are already in the list above. Also excluding tools and tests.
libstdr? @oli-obk