Skip to content

Conversation

kadiwa4
Copy link
Contributor

@kadiwa4 kadiwa4 commented Feb 19, 2024

unsafe_code already warns about things that don't involve the unsafe keyword, e.g. #[no_mangle]. This makes it warn on core::arch::global_asm too.

Fixes #103078

@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2024

r? @michaelwoerister

rustbot has assigned @michaelwoerister.
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 Feb 19, 2024
@asquared31415
Copy link
Contributor

global_asm! can do the same set of things to cause UB that #[no_mangle] can, and more, so this makes sense from a consistency standpoint.

@Noratrieb
Copy link
Member

makes sense
@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 20, 2024

📌 Commit dc7a016 has been approved by Nilstrieb

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 Feb 20, 2024
@@ -9,8 +9,6 @@ error[E0472]: inline assembly is unsupported on this target
|
LL | global_asm!("");
| ^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
Copy link
Member

Choose a reason for hiding this comment

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

nice diagnostic improvement here from the span change 👍

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#121167 (resolve: Scale back unloading of speculatively loaded crates)
 - rust-lang#121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121278 (Remove the "codegen" profile from bootstrap)
 - rust-lang#121286 (Rename `ConstPropLint` to `KnownPanicsLint`)
 - rust-lang#121291 (target: Revert default to the medium code model on LoongArch targets)
 - rust-lang#121302 (Remove `RefMutL` hack in `proc_macro::bridge`)
 - rust-lang#121318 (Trigger `unsafe_code` lint on invocations of `global_asm`)

Failed merges:

 - rust-lang#121206 (Top level error handling)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d61adbf into rust-lang:master Feb 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup merge of rust-lang#121318 - kadiwa4:no_assembly_in_supposedly_safe_code, r=Nilstrieb

Trigger `unsafe_code` lint on invocations of `global_asm`

`unsafe_code` already warns about things that don't involve the `unsafe` keyword, e.g. `#[no_mangle]`. This makes it warn on `core::arch::global_asm` too.

Fixes rust-lang#103078
@rustbot rustbot added this to the 1.78.0 milestone Feb 20, 2024
@kadiwa4 kadiwa4 deleted the no_assembly_in_supposedly_safe_code branch February 20, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

deny(unsafe_code) should prevent global_asm! usage.
6 participants