Skip to content

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

Closed
@jdonszelmann

Description

@jdonszelmann
Contributor

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

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Mar 3, 2025
added a commit that references this issue on Jun 18, 2025

Auto merge of #138165 - jdonszelmann:inline, r=oli-obk

1bb3352
added a commit that references this issue on Jun 23, 2025
8b0ab19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Participants

    @jdonszelmann@rustbot

    Issue actions

      Diagnostics error in interaction between `#[optimize(..)]` and `#[no_sanitize(..)]` · Issue #137950 · rust-lang/rust