-
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
Squash all lints tied to foreign macros by default #52467
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
a8a5491
to
e8bcc0c
Compare
r? @Manishearth |
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.
Looks good so far, but it should always output warnings for future incompatibility lints. Folks should know if their code will break, even if it's not something they can fix in their own crate.
@Manishearth indeed! That's why this is in the |
Ideally we'd still emit lints if the macro originates from a crate within the workspace. But that probably requires significant changes to tell us which crates belong to the same workspace |
src/librustc/lint/mod.rs
Outdated
/// Returns whether `span` originates in a foreign crate's external macro. | ||
/// | ||
/// This is used to test whether a lint should be entirely aborted above. | ||
fn in_external_macro(sess: &Session, span: Span) -> 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.
Can you make this public so we can reuse it from clippy?
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.
Certainly!
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.
lol missed that (was reviewing from phone)
r=me, with the function public
This commit polishes off this new function to compile on newer rustc as well as update and add a suite of test cases to work with this new check for lints.
e8bcc0c
to
8adf08c
Compare
📌 Commit 8adf08c has been approved by |
Squash all lints tied to foreign macros by default This PR is a continuation of #49755 (thanks for the initial jump-start @Dylan-DPC!) and is targeted at solving #48855. This change updates the lint infrastructure to, by default, ignore all lints emitted for code that originates in a foreign macro. For example if `println!("...")` injects some idiomatic warnings these are all ignored by default. The rationale here is that for almost all lints there's no action that can be taken if the code originates from a foreign lint. Closes #48855 Closes #52483 Closes #52479
☀️ Test successful - status-appveyor, status-travis |
This ends up breaking a bunch of clippy lints:
overall ISTM it might be better to make this a per-lint thing like how clippy does. Either way, clippy is going to opt out I think. |
@Manishearth should this check perhaps become a runtime check against a set stored in the session or lint context? That way Clippy would be able to register lints as "please issue a warning despite the foreign-macro-ness" |
I have made it a runtime check and added the two rustc exceptions as a proof of concept: https://github.com/rust-lang/rust/pull/52562/files#diff-837439bcaa26732bb48bcbb0c60716ccL586 |
they are no longer required due to rust-lang/rust#52467
they are no longer required due to rust-lang/rust#52467
This PR is a continuation of #49755 (thanks for the initial jump-start @Dylan-DPC!) and is targeted at solving #48855. This change updates the lint infrastructure to, by default, ignore all lints emitted for code that originates in a foreign macro. For example if
println!("...")
injects some idiomatic warnings these are all ignored by default. The rationale here is that for almost all lints there's no action that can be taken if the code originates from a foreign lint.Closes #48855
Closes #52483
Closes #52479