Skip to content
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 hard error and migration lint for unsafe attrs #126177

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

carbotaniuman
Copy link
Contributor

More implementation work for #123757

This adds the migration lint for unsafe attributes, as well as making it a hard error in Rust 2024.

@rustbot
Copy link
Collaborator

rustbot commented Jun 8, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 8, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this. The implementation looks good to me overall, I just have some questions and nits.

compiler/rustc_lint_defs/src/builtin.rs Outdated Show resolved Hide resolved
@@ -364,6 +364,10 @@ parse_inner_doc_comment_not_permitted = expected outer doc comment
.label_does_not_annotate_this = the inner doc comment doesn't annotate this {$item}
.sugg_change_inner_to_outer = to annotate the {$item}, change the doc comment from inner to outer style

parse_invalid_attr_unsafe = `{$name}` is not an unsafe attribute
.suggestion = remove the `unsafe(...)`
.note = extraneous unsafe is not allowed in attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: should this say something like "unsafe attribute block is not permitted for safe attributes"?

This comment was marked as resolved.

compiler/rustc_parse/messages.ftl Show resolved Hide resolved
compiler/rustc_parse/src/validate_attr.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/validate_attr.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/validate_attr.rs Outdated Show resolved Hide resolved
@jieyouxu
Copy link
Contributor

jieyouxu commented Jun 9, 2024

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2024
@jieyouxu jieyouxu added L-unsafe_attr_outside_unsafe Lint: unsafe_attr_outside_unsafe F-unsafe_attributes `#![feature(unsafe_attributes)]` labels Jun 9, 2024
@carbotaniuman
Copy link
Contributor Author

@rustbot reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 16, 2024
Copy link
Contributor

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this. The implementation looks good to me! Just one nit on the lint docs then r=me.

compiler/rustc_lint_defs/src/builtin.rs Outdated Show resolved Hide resolved
@@ -364,6 +364,10 @@ parse_inner_doc_comment_not_permitted = expected outer doc comment
.label_does_not_annotate_this = the inner doc comment doesn't annotate this {$item}
.sugg_change_inner_to_outer = to annotate the {$item}, change the doc comment from inner to outer style

parse_invalid_attr_unsafe = `{$name}` is not an unsafe attribute
.suggestion = remove the `unsafe(...)`
.note = extraneous unsafe is not allowed in attributes

This comment was marked as resolved.

@jieyouxu
Copy link
Contributor

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 16, 2024
@bors
Copy link
Contributor

bors commented Jun 17, 2024

☔ The latest upstream changes (presumably #126569) made this pull request unmergeable. Please resolve the merge conflicts.

@jieyouxu
Copy link
Contributor

jieyouxu commented Jun 17, 2024

r=me with a rebase, but not going to block on the tiny comment nit.

@rust-log-analyzer

This comment has been minimized.

@carbotaniuman
Copy link
Contributor Author

@rustbot reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 24, 2024
Copy link
Contributor

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jieyouxu
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 24, 2024

📌 Commit a23917c has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 24, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 24, 2024
…r=jieyouxu

Add hard error and migration lint for unsafe attrs

More implementation work for rust-lang#123757

This adds the migration lint for unsafe attributes, as well as making it a hard error in Rust 2024.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 24, 2024
…kingjubilee

Rollup of 9 pull requests

Successful merges:

 - rust-lang#126177 (Add hard error and migration lint for unsafe attrs)
 - rust-lang#126298 (Promote loongarch64-unknown-linux-musl to Tier 2 with host tools)
 - rust-lang#126455 (For [E0308]: mismatched types, when expr is in an arm's body, not add semicolon ';' at the end of it.)
 - rust-lang#126754 (Implement `use<>` formatting in rustfmt)
 - rust-lang#126807 (std::unix::fs: copy simplification for apple.)
 - rust-lang#126845 (Weekly `cargo update`)
 - rust-lang#126849 (Fix 32-bit Arm reg classes by hierarchically sorting them)
 - rust-lang#126854 (std::unix::os::home_dir: fallback's optimisation.)
 - rust-lang#126861 (Migrate `run-make/invalid-library` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 24, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#126177 (Add hard error and migration lint for unsafe attrs)
 - rust-lang#126298 (Promote loongarch64-unknown-linux-musl to Tier 2 with host tools)
 - rust-lang#126455 (For [E0308]: mismatched types, when expr is in an arm's body, not add semicolon ';' at the end of it.)
 - rust-lang#126754 (Implement `use<>` formatting in rustfmt)
 - rust-lang#126807 (std::unix::fs: copy simplification for apple.)
 - rust-lang#126845 (Weekly `cargo update`)
 - rust-lang#126849 (Fix 32-bit Arm reg classes by hierarchically sorting them)
 - rust-lang#126854 (std::unix::os::home_dir: fallback's optimisation.)
 - rust-lang#126888 (Remove stray println from rustfmt's `rewrite_static`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9a591ea into rust-lang:master Jun 24, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 24, 2024
Rollup merge of rust-lang#126177 - carbotaniuman:unsafe_attr_errors, r=jieyouxu

Add hard error and migration lint for unsafe attrs

More implementation work for rust-lang#123757

This adds the migration lint for unsafe attributes, as well as making it a hard error in Rust 2024.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-unsafe_attributes `#![feature(unsafe_attributes)]` L-unsafe_attr_outside_unsafe Lint: unsafe_attr_outside_unsafe S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants