-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Don't suggest wrapping attr in unsafe if it may come from proc macro #149781
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
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
r? jdonszelmann |
| Some(unsafe_since) => path_span.edition() >= unsafe_since, | ||
| }; | ||
|
|
||
| let may_from_proc_macro = if diag_span.from_expansion() |
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_be_used_for_suggestions() might be more appropriate.
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 tried this but it will deny suggestion for macro-rules macros, see test https://github.com/mu001999-contrib/rust/blob/7d1090ba9a06c297f7977b5d8e76681511f3e952/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs
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 think such suggestions should still be emitted, how do you think about it?
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.
some smol nits, looks good otherwise!
|
Reminder, once the PR becomes ready for a review, use |
|
☔ The latest upstream changes (presumably #149798) made this pull request unmergeable. Please resolve the merge conflicts. |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot ready |
|
indeed, @bors r+ rollup |
…nszelmann Don't suggest wrapping attr in unsafe if it may come from proc macro Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?). Fixes rust-lang#149756
…nszelmann Don't suggest wrapping attr in unsafe if it may come from proc macro Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?). Fixes rust-lang#149756
Rollup of 12 pull requests Successful merges: - #147602 (Deduplicate higher-ranked lifetime capture errors in impl Trait) - #147725 (Remove -Zoom=panic) - #148294 (callconv: fix mips64 aggregate argument passing for C FFI) - #148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type) - #149417 (tidy: Detect outdated workspaces in workspace list) - #149458 (Run clippy on cg_gcc in CI) - #149679 (Restrict spe_acc to PowerPC SPE targets) - #149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro) - #149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std) - #149816 (Make typo in field and name suggestions verbose) - #149824 (Add a regression test for issue 145748) - #149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - #147725 (Remove -Zoom=panic) - #148294 (callconv: fix mips64 aggregate argument passing for C FFI) - #148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type) - #149458 (Run clippy on cg_gcc in CI) - #149679 (Restrict spe_acc to PowerPC SPE targets) - #149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro) - #149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std) - #149816 (Make typo in field and name suggestions verbose) - #149824 (Add a regression test for issue 145748) - #149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #149781 - mu001999-contrib:fix/149756, r=jdonszelmann Don't suggest wrapping attr in unsafe if it may come from proc macro Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?). Fixes #149756
|
Thanks for doing this, @mu001999! A suggestion for next time: for PRs that improve error messages I like to do it in two steps:
This makes reviewing easier, because it's really clear how the error message changed. |
Rollup of 10 pull requests Successful merges: - rust-lang/rust#147725 (Remove -Zoom=panic) - rust-lang/rust#148294 (callconv: fix mips64 aggregate argument passing for C FFI) - rust-lang/rust#148491 ( Correctly provide suggestions when encountering `async fn` with a `dyn Trait` return type) - rust-lang/rust#149458 (Run clippy on cg_gcc in CI) - rust-lang/rust#149679 (Restrict spe_acc to PowerPC SPE targets) - rust-lang/rust#149781 (Don't suggest wrapping attr in unsafe if it may come from proc macro) - rust-lang/rust#149795 (Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std) - rust-lang/rust#149816 (Make typo in field and name suggestions verbose) - rust-lang/rust#149824 (Add a regression test for issue 145748) - rust-lang/rust#149826 (compiletest: tidy up `adb_path`/`adb_test_dir` handling) r? `@ghost` `@rustbot` modify labels: rollup
Don't emit the suggestion if the span may come from proc macro. Check this with the snippet because we cannot check if the span is from macro-rules or proc-macro (maybe this can happen in the future?).
Fixes #149756