-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add checking for no_mangle to unsafe_code lint #72209
Conversation
r? @estebank |
|
@estebank any updates on this? |
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.
Sorry for the delay. We'll need to do a crater run with this to make sure we don't cause major regressions in the wild as this is being added to an existing lint. Beyond these nitpicks, it looks good to me.
src/librustc_lint/builtin.rs
Outdated
@@ -272,6 +272,32 @@ impl EarlyLintPass for UnsafeCode { | |||
}) | |||
} | |||
|
|||
ast::ItemKind::Fn(..) => { | |||
if attr::contains_name(&it.attrs, sym::no_mangle) { | |||
self.report_unsafe(cx, it.span, |lint| { |
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 we use it.name.span
instead here and in the other 2 places?
src/librustc_lint/builtin.rs
Outdated
ast::ItemKind::Fn(..) => { | ||
if attr::contains_name(&it.attrs, sym::no_mangle) { | ||
self.report_unsafe(cx, it.span, |lint| { | ||
lint.build("declaration of a `no_mangle` function").emit(); |
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.
Could we add a note
to explain why the annotation is problematic and or a link to the docs?
@estebank fixed the nitpicks. Are you able to trigger the crater run? |
@bors try (before crater run) |
⌛ Trying commit 36c75f4d7dc23bad408f0eb92cd30365434cf2a2 with merge 00bf438af9d3399b4145c87e4f9f6133e40fd673... |
☀️ Try build successful - checks-actions, checks-azure |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
LL | unsafe fn baz() {} | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | #[no_mangle] fn foo() {} | ||
| ^^^ |
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.
Could the lint span point to the attribute itself, rather than the identifier of the item being defined?
| ^^^ | |
| ^^^^^^^^^^^^ |
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.
Makes sense, I'll try to get this changed tomorrow.
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚨 Experiment 🆘 Can someone from the infra team check in on this? @rust-lang/infra |
@craterbot retry seems to have been spurious |
🚨 Error: failed to parse the command 🆘 If you have any trouble with Crater please ping |
@craterbot retry |
🛠️ Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
@rfcbot reviewed I'm nominated for lang team discussion next week to draw attention to this. |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
This comment has been minimized.
This comment has been minimized.
@estebank this is waiting for your final review. Looks ready imo 😃 |
📌 Commit fc8a3ad has been approved by |
Rollup of 11 pull requests Successful merges: - rust-lang#72209 (Add checking for no_mangle to unsafe_code lint) - rust-lang#80732 (Allow Trait inheritance with cycles on associated types take 2) - rust-lang#81697 (Add "every" as a doc alias for "all".) - rust-lang#81826 (Prefer match over combinators to make some Box methods inlineable) - rust-lang#81834 (Resolve typedef in HashMap lldb pretty-printer only if possible) - rust-lang#81841 ([rustbuild] Output rustdoc-json-types docs ) - rust-lang#81849 (Expand the docs for ops::ControlFlow a bit) - rust-lang#81876 (parser: Fix panic in 'const impl' recovery) - rust-lang#81882 (:arrow_up: rust-analyzer) - rust-lang#81888 (Fix pretty printer macro_rules with semicolon.) - rust-lang#81896 (Remove outdated comment in windows' mutex.rs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
fixes #72188
r? @estebank