Skip to content

Diagnostics error in interaction between #[optimize(..)] and #[no_sanitize(..)] #137950

Closed
@jdonszelmann

Description

@jdonszelmann

Code

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=eaaf800ea55d5e224c36354bacddc6e3

#![feature(no_sanitize)]
#![feature(optimize_attribute)]

#[no_sanitize(address)]
#[inline(always)]
#[optimize(speed)]
pub fn hello() {
    
}

Current output

Compiling playground v0.0.1 (/playground)
warning: `no_sanitize` will have no effect after inlining
 --> src/lib.rs:4:1
  |
4 | #[no_sanitize(address)]
  | ^^^^^^^^^^^^^^^^^^^^^^^
  |
note: inlining requested here
 --> src/lib.rs:6:1
  |
6 | #[optimize(speed)]
  | ^^^^^^^^^^^^^^^^^^
  = note: `#[warn(inline_no_sanitize)]` on by default

warning: `playground` (lib) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.38s

Desired output

Compiling playground v0.0.1 (/playground)
warning: `no_sanitize` will have no effect after inlining
 --> src/lib.rs:4:1
  |
4 | #[no_sanitize(address)]
  | ^^^^^^^^^^^^^^^^^^^^^^^
  |
note: inlining requested here
 --> src/lib.rs:6:1
  |
5 | #[inline(always)]
  | ^^^^^^^^^^^^^^^^^^
  = note: `#[warn(inline_no_sanitize)]` on by default

warning: `playground` (lib) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.38s

Rationale and extra context

This is simply a bug. I wasn't even sure if I wanted to report it since I'm working on the code anyway and will simply remove it at some point with a test. No need to do anything, but I wanted something to point to when I fix it.

@rustbot claim
@rustbot label +A-attributes -needs-triage

Other cases

Rust Version

nightly (dw, I'll fix it myself)

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions