Skip to content

Remove the #[no_sanitize] attribute in favor of #[sanitize(xyz = "on|off")] #142681

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

1c3t3a
Copy link
Member

@1c3t3a 1c3t3a commented Jun 18, 2025

This came up during the sanitizer stabilization (#123617). Instead of a #[no_sanitize(xyz)] attribute, we would like to have a #[sanitize(xyz = "on|off")] attribute, which is more powerful and allows to be extended in the future (instead
of just focusing on turning sanitizers off). The implementation is done according to what was discussed on Zulip).

The new attribute also works on modules, traits and impl items and thus enables usage as the following:

#[sanitize(address = "off")]
mod foo {
    fn unsanitized(..) {}

    #[sanitize(address = "on")]
    fn sanitized(..) {}
}

trait MyTrait {
  #[sanitize(address = "off")]
  fn unsanitized_default(..) {}
}

#[sanitize(thread = "off")]
impl MyTrait for () {
    ...
}

r? @rcvalle

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-rustc-dev-guide Area: rustc-dev-guide PG-exploit-mitigations Project group: Exploit mitigations 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 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.

cc @BoxyUwU, @jieyouxu, @Kobzol

triagebot.toml has been modified, there may have been changes to the review queue.

cc @davidtwco, @wesleywiser

Some changes occurred in src/doc/unstable-book/src/language-features/no-sanitize.md

cc @rust-lang/project-exploit-mitigations, @rcvalle

Some changes occurred in tests/codegen/sanitizer

cc @rcvalle

Some changes occurred in tests/ui/sanitizer

cc @rcvalle

Some changes occurred in compiler/rustc_codegen_ssa/src/codegen_attrs.rs

cc @jdonszelmann

@rcvalle
Copy link
Member

rcvalle commented Jun 18, 2025

Thank you very much for your time and work on this, @1c3t3a! Much appreciated.

@rcvalle
Copy link
Member

rcvalle commented Jun 18, 2025

@rust-log-analyzer

This comment has been minimized.

@1c3t3a 1c3t3a force-pushed the sanitize-off-on branch from 5f8e6ee to 0302657 Compare June 18, 2025 16:03
@rust-log-analyzer

This comment has been minimized.

@1c3t3a 1c3t3a force-pushed the sanitize-off-on branch from 0302657 to a2216db Compare June 18, 2025 17:07
@Darksonn
Copy link
Contributor

It doesn't matter for me, but should we make this change gradually by supporting both for some time?

@1c3t3a
Copy link
Member Author

1c3t3a commented Jun 18, 2025

It doesn't matter for me, but should we make this change gradually by supporting both for some time?

That's possible for sure, I put stuff into different commits for that reason and I can just drop the middle commit to have both exist in parallel.

What's the reason for having both at the same time? An easier migration period?

@traviscross
Copy link
Contributor

traviscross commented Jun 19, 2025

We generally do not make such efforts to migrate usage of nightly features without a specific known good reason to do so. (Let us know of course if there is one, e.g. if this affects RfL in some way.)

@bors
Copy link
Collaborator

bors commented Jun 20, 2025

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

@ojeda
Copy link
Contributor

ojeda commented Jul 1, 2025

e.g. if this affects RfL in some way.

We don't use #[no_sanitize] in mainline (nor in -next) at the moment.

@1c3t3a
Copy link
Member Author

1c3t3a commented Jul 14, 2025

I rebased the change to make review easier.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@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.

Note that if this is a built-in attribute, then IIUC #[sanitize] (even if unstably gated) could introduce new name resolution ambiguities with user macros or derive macro attributes and thus technically break existing user code. See for instance #143834. cf. #134963.

// tests/ui/whatever_subdir/test.rs

//@ proc-macro: my_derive.rs
//@ edition: 2024

use my_derive::MyDerive;

#[derive(MyDerive)]
#[sanitize]
//~^ ERROR `sanitize` is ambiguous
pub struct Foo;

fn main() {}
// tests/ui/whatever_subdir/auxiliary/my_derive.rs

//@ edition: 2024

extern crate proc_macro;
use proc_macro::{Span, TokenStream};

#[proc_macro_derive(
    MyDerive,
    attributes(
        sanitize
    )
)]
pub fn derive_custom(_item: TokenStream) -> TokenStream {
    TokenStream::new()
}

You can still observe this for #[no_sanitize] too, if you switch sanitize for no_sanitize in the above test case.

error: malformed `no_sanitize` attribute input
  --> /home/joe/repos/rust/tests/ui/bitbuffer_derive/test.rs:7:1
   |
LL | #[no_sanitize]
   | ^^^^^^^^^^^^^^ help: must be of the form: `#[no_sanitize(address, kcfi, memory, thread)]`

error[E0659]: `no_sanitize` is ambiguous
  --> /home/joe/repos/rust/tests/ui/bitbuffer_derive/test.rs:7:3
   |
LL | #[no_sanitize]
   |   ^^^^^^^^^^^ ambiguous name
   |
   = note: ambiguous because of a name conflict with a builtin attribute
   = note: `no_sanitize` could refer to a built-in attribute

error[E0658]: the `#[no_sanitize]` attribute is an experimental feature
  --> /home/joe/repos/rust/tests/ui/bitbuffer_derive/test.rs:7:1
   |
LL | #[no_sanitize]
   | ^^^^^^^^^^^^^^
   |
   = note: see issue #39699 <https://github.com/rust-lang/rust/issues/39699> for more information
   = help: add `#![feature(no_sanitize)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0658, E0659.
For more information about an error, try `rustc --explain E0658`.

Or just

macro_rules! sanitize {
    () => {
        /* .. */
    };
}

pub(crate) use sanitize; // `use` here becomes ambiguous

fn main() {}

I imagine no_sanitize is much less likely to collide with something a user would write (not an argument against this change, just an observation re. technically a breaking change).

I don't know how much of a concern for breakage this is in practice, a crater run may or may not be a good idea. If the breakage is deemed acceptable, then this should get relnotes.

@bors
Copy link
Collaborator

bors commented Jul 14, 2025

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

1c3t3a added 3 commits July 14, 2025 16:37
This change implements the #[sanitize(..)] attribute, which opts to
replace the currently unstable #[no_sanitize]. Essentially the new
attribute works similar as #[no_sanitize], just with more flexible
options regarding where it is applied. E.g. it is possible to turn
a certain sanitizer either on or off:
`#[sanitize(address = "on|off")]`

This attribute now also applies to more places, e.g. it is possible
to turn off a sanitizer for an entire module or impl block:
```rust
\#[sanitize(address = "off")]
mod foo {
    fn unsanitized(..) {}

    #[sanitize(address = "on")]
    fn sanitized(..) {}
}

\#[sanitize(thread = "off")]
impl MyTrait for () {
    ...
}
```

This attribute is enabled behind the unstable `sanitize` feature.
This removes the #[no_sanitize] attribute, which was behind an unstable
feature named no_sanitize. Instead, we introduce the sanitize attribute
which is more powerful and allows to be extended in the future (instead
of just focusing on turning sanitizers off).
…ress

To do it the same as how clang disables address sanitizer, we now
disable ASAN on sanitize(kernel_address = "off") and KASAN on
sanitize(address = "off").

The same was added to clang in https://reviews.llvm.org/D44981.
@1c3t3a 1c3t3a force-pushed the sanitize-off-on branch from bb98641 to a466546 Compare July 14, 2025 16:55
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
+    |
+ LL | #![feature(no_sanitize)]
+    |            ^^^^^^^^^^^ feature has been removed
+    |
+    = note: removed in CURRENT_RUSTC_VERSION; see <https://github.com/rust-lang/rust/pull/1234> for more information
+    = note: renamed to sanitize(xyz = "on|off")
+ 
1 error: `cfg` is not followed by parentheses
2   --> $DIR/malformed-attrs.rs:102:1
3    |

53 LL | #[coverage(on)]
54    |           ++++
55 
- error: malformed `no_sanitize` attribute input
-   --> $DIR/malformed-attrs.rs:92:1
-    |
- LL | #[no_sanitize]
-    | ^^^^^^^^^^^^^^ help: must be of the form: `#[no_sanitize(address, kcfi, memory, thread)]`
- 
62 error: malformed `proc_macro` attribute input
63   --> $DIR/malformed-attrs.rs:99:1
64    |

---
+    |              expected a string literal here
+    |
+ help: try changing it to one of the following valid forms of the attribute
+    |
+ LL - #[must_use = 1]
+ LL + #[must_use = "reason"]
+    |
+ LL - #[must_use = 1]
+ LL + #[must_use]
+    |
+ 
+ error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
+   --> $DIR/malformed-attrs.rs:128:1
+    |
+ LL | #[rustc_layout_scalar_valid_range_start]
+    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    | |
+    | expected this to be a list
+    | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
+ 
+ error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input
+   --> $DIR/malformed-attrs.rs:130:1
+    |
+ LL | #[rustc_layout_scalar_valid_range_end]
+    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    | |
+    | expected this to be a list
+    | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
+ 
+ error[E0565]: malformed `marker` attribute input
+   --> $DIR/malformed-attrs.rs:155:1
+    |
+ LL | #[marker = 3]
+    | ^^^^^^^^^---^
+    | |        |
+    | |        didn't expect any arguments here
+    | help: must be of the form: `#[marker]`
+ 
+ error[E0565]: malformed `fundamental` attribute input
+   --> $DIR/malformed-attrs.rs:157:1
+    |
+ LL | #[fundamental()]
+    | ^^^^^^^^^^^^^--^
+    | |            |
+    | |            didn't expect any arguments here
+    | help: must be of the form: `#[fundamental]`
+ 
+ error[E0565]: malformed `ffi_pure` attribute input
+   --> $DIR/malformed-attrs.rs:165:5
+    |
+ LL |     #[unsafe(ffi_pure = 1)]
+    |     ^^^^^^^^^^^^^^^^^^---^^
+    |     |                 |
+    |     |                 didn't expect any arguments here
+    |     help: must be of the form: `#[ffi_pure]`
+ 
+ error[E0539]: malformed `link_ordinal` attribute input
+   --> $DIR/malformed-attrs.rs:167:5
+    |
+ LL |     #[link_ordinal]
+    |     ^^^^^^^^^^^^^^^
+    |     |
+    |     expected this to be a list
+    |     help: must be of the form: `#[link_ordinal(ordinal)]`
+ 
+ error[E0565]: malformed `ffi_const` attribute input
+   --> $DIR/malformed-attrs.rs:171:5
+    |
+ LL |     #[unsafe(ffi_const = 1)]
+    |     ^^^^^^^^^^^^^^^^^^^---^^
+    |     |                  |
+    |     |                  didn't expect any arguments here
+    |     help: must be of the form: `#[ffi_const]`
+ 
+ error[E0565]: malformed `automatically_derived` attribute input
+   --> $DIR/malformed-attrs.rs:191:1
+    |
+ LL | #[automatically_derived = 18]
+    | ^^^^^^^^^^^^^^^^^^^^^^^^----^
+    | |                       |
+    | |                       didn't expect any arguments here
+    | help: must be of the form: `#[automatically_derived]`
+ 
+ error[E0565]: malformed `non_exhaustive` attribute input
+   --> $DIR/malformed-attrs.rs:197:1
+    |
+ LL | #[non_exhaustive = 1]
---
+    |
+ LL |     #[type_const = 1]
+    |     ^^^^^^^^^^^^^---^
+    |     |            |
+    |     |            didn't expect any arguments here
+    |     help: must be of the form: `#[type_const]`
+ 
274 error[E0539]: malformed `export_name` attribute input
275   --> $DIR/malformed-attrs.rs:32:1
276    |

463    | |                     didn't expect any arguments here
464    | help: must be of the form: `#[no_implicit_prelude]`
465 
- error[E0539]: malformed `must_use` attribute input
-   --> $DIR/malformed-attrs.rs:119:1
-    |
- LL | #[must_use = 1]
-    | ^^^^^^^^^^^^^-^
-    |              |
-    |              expected a string literal here
-    |
- help: try changing it to one of the following valid forms of the attribute
-    |
- LL - #[must_use = 1]
- LL + #[must_use = "reason"]
-    |
- LL - #[must_use = 1]
- LL + #[must_use]
-    |
- 
- error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
-   --> $DIR/malformed-attrs.rs:128:1
-    |
- LL | #[rustc_layout_scalar_valid_range_start]
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    | |
-    | expected this to be a list
-    | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
- 
- error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input
-   --> $DIR/malformed-attrs.rs:130:1
-    |
- LL | #[rustc_layout_scalar_valid_range_end]
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    | |
-    | expected this to be a list
-    | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
- 
- error[E0565]: malformed `marker` attribute input
-   --> $DIR/malformed-attrs.rs:155:1
-    |
- LL | #[marker = 3]
-    | ^^^^^^^^^---^
-    | |        |
-    | |        didn't expect any arguments here
-    | help: must be of the form: `#[marker]`
- 
- error[E0565]: malformed `fundamental` attribute input
-   --> $DIR/malformed-attrs.rs:157:1
-    |
- LL | #[fundamental()]
-    | ^^^^^^^^^^^^^--^
-    | |            |
-    | |            didn't expect any arguments here
-    | help: must be of the form: `#[fundamental]`
- 
- error[E0565]: malformed `ffi_pure` attribute input
-   --> $DIR/malformed-attrs.rs:165:5
-    |
- LL |     #[unsafe(ffi_pure = 1)]
-    |     ^^^^^^^^^^^^^^^^^^---^^
-    |     |                 |
-    |     |                 didn't expect any arguments here
-    |     help: must be of the form: `#[ffi_pure]`
- 
- error[E0539]: malformed `link_ordinal` attribute input
-   --> $DIR/malformed-attrs.rs:167:5
-    |
- LL |     #[link_ordinal]
-    |     ^^^^^^^^^^^^^^^
-    |     |
-    |     expected this to be a list
-    |     help: must be of the form: `#[link_ordinal(ordinal)]`
- 
- error[E0565]: malformed `ffi_const` attribute input
-   --> $DIR/malformed-attrs.rs:171:5
-    |
- LL |     #[unsafe(ffi_const = 1)]
-    |     ^^^^^^^^^^^^^^^^^^^---^^
-    |     |                  |
-    |     |                  didn't expect any arguments here
-    |     help: must be of the form: `#[ffi_const]`
- 
- error[E0565]: malformed `automatically_derived` attribute input
-   --> $DIR/malformed-attrs.rs:191:1
-    |
- LL | #[automatically_derived = 18]
-    | ^^^^^^^^^^^^^^^^^^^^^^^^----^
-    | |                       |
-    | |                       didn't expect any arguments here
-    | help: must be of the form: `#[automatically_derived]`
- 
- error[E0565]: malformed `non_exhaustive` attribute input
-   --> $DIR/malformed-attrs.rs:197:1
-    |
- LL | #[non_exhaustive = 1]
---
-    |
- LL |     #[type_const = 1]
-    |     ^^^^^^^^^^^^^---^
-    |     |            |
-    |     |            didn't expect any arguments here
-    |     help: must be of the form: `#[type_const]`
- 
573 error: attribute should be applied to `const fn`
574   --> $DIR/malformed-attrs.rs:34:1
575    |

656    = note: expected unit type `()`
657               found coroutine `{coroutine@$DIR/malformed-attrs.rs:111:23: 111:25}`
658 
- error: aborting due to 75 previous errors; 3 warnings emitted
+ error: aborting due to 76 previous errors; 3 warnings emitted
660 
- Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805.
---
+    |
+ LL | #![feature(no_sanitize)]
+    |            ^^^^^^^^^^^ feature has been removed
+    |
+    = note: removed in CURRENT_RUSTC_VERSION; see <https://github.com/rust-lang/rust/pull/1234> for more information
+    = note: renamed to sanitize(xyz = "on|off")
+ 
+ error: cannot find attribute `no_sanitize` in this scope
+   --> $DIR/malformed-attrs.rs:92:3
+    |
+ LL | #[no_sanitize]
---
+    |              expected a string literal here
+    |
+ help: try changing it to one of the following valid forms of the attribute
+    |
+ LL - #[must_use = 1]
+ LL + #[must_use = "reason"]
+    |
+ LL - #[must_use = 1]
+ LL + #[must_use]
+    |
+ 
+ error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
+   --> $DIR/malformed-attrs.rs:128:1
+    |
+ LL | #[rustc_layout_scalar_valid_range_start]
+    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    | |
+    | expected this to be a list
+    | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
+ 
+ error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input
+   --> $DIR/malformed-attrs.rs:130:1
+    |
+ LL | #[rustc_layout_scalar_valid_range_end]
+    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    | |
+    | expected this to be a list
+    | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
+ 
+ error[E0565]: malformed `marker` attribute input
+   --> $DIR/malformed-attrs.rs:155:1
+    |
+ LL | #[marker = 3]
+    | ^^^^^^^^^---^
+    | |        |
+    | |        didn't expect any arguments here
+    | help: must be of the form: `#[marker]`
+ 
+ error[E0565]: malformed `fundamental` attribute input
+   --> $DIR/malformed-attrs.rs:157:1
+    |
+ LL | #[fundamental()]
+    | ^^^^^^^^^^^^^--^
+    | |            |
+    | |            didn't expect any arguments here
+    | help: must be of the form: `#[fundamental]`
+ 
+ error[E0565]: malformed `ffi_pure` attribute input
+   --> $DIR/malformed-attrs.rs:165:5
+    |
+ LL |     #[unsafe(ffi_pure = 1)]
+    |     ^^^^^^^^^^^^^^^^^^---^^
+    |     |                 |
+    |     |                 didn't expect any arguments here
+    |     help: must be of the form: `#[ffi_pure]`
+ 
+ error[E0539]: malformed `link_ordinal` attribute input
+   --> $DIR/malformed-attrs.rs:167:5
+    |
+ LL |     #[link_ordinal]
+    |     ^^^^^^^^^^^^^^^
+    |     |
+    |     expected this to be a list
+    |     help: must be of the form: `#[link_ordinal(ordinal)]`
+ 
+ error[E0565]: malformed `ffi_const` attribute input
+   --> $DIR/malformed-attrs.rs:171:5
+    |
+ LL |     #[unsafe(ffi_const = 1)]
+    |     ^^^^^^^^^^^^^^^^^^^---^^
+    |     |                  |
+    |     |                  didn't expect any arguments here
+    |     help: must be of the form: `#[ffi_const]`
+ 
+ error[E0565]: malformed `automatically_derived` attribute input
+   --> $DIR/malformed-attrs.rs:191:1
+    |
+ LL | #[automatically_derived = 18]
+    | ^^^^^^^^^^^^^^^^^^^^^^^^----^
+    | |                       |
+    | |                       didn't expect any arguments here
+    | help: must be of the form: `#[automatically_derived]`
+ 
+ error[E0565]: malformed `non_exhaustive` attribute input
+   --> $DIR/malformed-attrs.rs:197:1
+    |
+ LL | #[non_exhaustive = 1]
---
+    |
+ LL |     #[type_const = 1]
+    |     ^^^^^^^^^^^^^---^
+    |     |            |
+    |     |            didn't expect any arguments here
+    |     help: must be of the form: `#[type_const]`
+ 
+ error: aborting due to 76 previous errors; 3 warnings emitted
+ Some errors have detailed explanations: E0308, E0463, E0539, E0557, E0565, E0658, E0805.


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args attributes/malformed-attrs.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/attributes/malformed-attrs.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/attributes/malformed-attrs" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0557]: feature has been removed
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:14:12
   |
LL | #![feature(no_sanitize)]
   |            ^^^^^^^^^^^ feature has been removed
   |
   = note: removed in CURRENT_RUSTC_VERSION; see <https://github.com/rust-lang/rust/pull/1234> for more information
   = note: renamed to sanitize(xyz = "on|off")

error: `cfg` is not followed by parentheses
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:102:1
   |
LL | #[cfg]
   | ^^^^^^ help: expected syntax is: `cfg(/* predicate */)`

error: malformed `cfg_attr` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:104:1
   |
LL | #[cfg_attr]
---
   |
LL | extern crate wloop;
   | ^^^^^^^^^^^^^^^^^^^ can't find crate

error: malformed `omit_gdb_pretty_printer_section` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:26:1
   |
LL | #![omit_gdb_pretty_printer_section = 1]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![omit_gdb_pretty_printer_section]`

error: malformed `windows_subsystem` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:29:1
   |
LL | #![windows_subsystem]
   | ^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![windows_subsystem = "windows|console"]`

error: malformed `crate_name` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:74:1
   |
LL | #[crate_name]
   | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]`

error: malformed `coverage` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:90:1
   |
LL | #[coverage]
---

error: malformed `proc_macro` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:99:1
   |
LL | #[proc_macro = 18]
   | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro]`

error: malformed `instruction_set` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:106:1
   |
LL | #[instruction_set]
   | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]`

error: malformed `patchable_function_entry` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:108:1
   |
LL | #[patchable_function_entry]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]`

error: malformed `coroutine` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:111:5
   |
LL |     #[coroutine = 63] || {}
   |     ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[coroutine]`

error: malformed `proc_macro_attribute` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:116:1
   |
LL | #[proc_macro_attribute = 19]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro_attribute]`

error: malformed `proc_macro_derive` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:123:1
   |
LL | #[proc_macro_derive]
   | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]`

error: malformed `must_not_suspend` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:132:1
   |
LL | #[must_not_suspend()]
   | ^^^^^^^^^^^^^^^^^^^^^
   |
help: the following are the possible correct uses
   |
LL - #[must_not_suspend()]
LL + #[must_not_suspend = "reason"]
   |
LL - #[must_not_suspend()]
LL + #[must_not_suspend]
   |

error: malformed `cfi_encoding` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:134:1
   |
LL | #[cfi_encoding]
   | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]`

error: malformed `linkage` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:173:5
   |
LL |     #[linkage]
   |     ^^^^^^^^^^ help: must be of the form: `#[linkage = "external|internal|..."]`

error: malformed `allow` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:178:1
   |
LL | #[allow]
   | ^^^^^^^^ help: must be of the form: `#[allow(lint1, lint2, ..., /*opt*/ reason = "...")]`

error: malformed `expect` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:180:1
   |
LL | #[expect]
   | ^^^^^^^^^ help: must be of the form: `#[expect(lint1, lint2, ..., /*opt*/ reason = "...")]`

error: malformed `warn` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:182:1
   |
LL | #[warn]
   | ^^^^^^^ help: must be of the form: `#[warn(lint1, lint2, ..., /*opt*/ reason = "...")]`

error: malformed `deny` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:184:1
   |
LL | #[deny]
   | ^^^^^^^ help: must be of the form: `#[deny(lint1, lint2, ..., /*opt*/ reason = "...")]`

error: malformed `forbid` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:186:1
   |
LL | #[forbid]
   | ^^^^^^^^^ help: must be of the form: `#[forbid(lint1, lint2, ..., /*opt*/ reason = "...")]`

error: malformed `debugger_visualizer` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:188:1
   |
LL | #[debugger_visualizer]
   | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]`

error: malformed `thread_local` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:203:1
   |
LL | #[thread_local()]
   | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]`

error: malformed `no_link` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:207:1
   |
LL | #[no_link()]
   | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]`

error: malformed `macro_use` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:209:1
   |
LL | #[macro_use = 1]
   | ^^^^^^^^^^^^^^^^
   |
help: the following are the possible correct uses
   |
LL - #[macro_use = 1]
LL + #[macro_use(name1, name2, ...)]
   |
LL - #[macro_use = 1]
LL + #[macro_use]
   |

---
   |
LL | #[allow_internal_unsafe = 1]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[allow_internal_unsafe]`

error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:99:1
   |
LL | #[proc_macro = 18]
   | ^^^^^^^^^^^^^^^^^^

error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:116:1
   |
LL | #[proc_macro_attribute = 19]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:123:1
   |
LL | #[proc_macro_derive]
   | ^^^^^^^^^^^^^^^^^^^^

---
   |
LL | #[allow_internal_unsafe = 1]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(allow_internal_unsafe)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:43:1
   |
LL | #[doc]
   | ^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
   = note: `#[deny(ill_formed_attribute_input)]` on by default

error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:76:1
   |
LL | #[doc]
   | ^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:83:1
   |
LL | #[link]
   | ^^^^^^^
   |
---
   |              expected a string literal here
   |
help: try changing it to one of the following valid forms of the attribute
   |
LL - #[must_use = 1]
LL + #[must_use = "reason"]
   |
LL - #[must_use = 1]
LL + #[must_use]
   |

error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:128:1
   |
LL | #[rustc_layout_scalar_valid_range_start]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   | |
   | expected this to be a list
   | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`

error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:130:1
   |
LL | #[rustc_layout_scalar_valid_range_end]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   | |
   | expected this to be a list
   | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`

error[E0565]: malformed `marker` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:155:1
   |
LL | #[marker = 3]
   | ^^^^^^^^^---^
   | |        |
   | |        didn't expect any arguments here
   | help: must be of the form: `#[marker]`

error[E0565]: malformed `fundamental` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:157:1
   |
LL | #[fundamental()]
   | ^^^^^^^^^^^^^--^
   | |            |
   | |            didn't expect any arguments here
   | help: must be of the form: `#[fundamental]`

error[E0565]: malformed `ffi_pure` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:165:5
   |
LL |     #[unsafe(ffi_pure = 1)]
   |     ^^^^^^^^^^^^^^^^^^---^^
   |     |                 |
   |     |                 didn't expect any arguments here
   |     help: must be of the form: `#[ffi_pure]`

error[E0539]: malformed `link_ordinal` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:167:5
   |
LL |     #[link_ordinal]
   |     ^^^^^^^^^^^^^^^
   |     |
   |     expected this to be a list
   |     help: must be of the form: `#[link_ordinal(ordinal)]`

error[E0565]: malformed `ffi_const` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:171:5
   |
LL |     #[unsafe(ffi_const = 1)]
   |     ^^^^^^^^^^^^^^^^^^^---^^
   |     |                  |
   |     |                  didn't expect any arguments here
   |     help: must be of the form: `#[ffi_const]`

error[E0565]: malformed `automatically_derived` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:191:1
   |
LL | #[automatically_derived = 18]
   | ^^^^^^^^^^^^^^^^^^^^^^^^----^
   | |                       |
   | |                       didn't expect any arguments here
   | help: must be of the form: `#[automatically_derived]`

error[E0565]: malformed `non_exhaustive` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:197:1
   |
LL | #[non_exhaustive = 1]
---
   |
LL |     #[type_const = 1]
   |     ^^^^^^^^^^^^^---^
   |     |            |
   |     |            didn't expect any arguments here
   |     help: must be of the form: `#[type_const]`

error[E0539]: malformed `export_name` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:32:1
   |
LL | #[unsafe(export_name)]
   | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]`

error: `rustc_allow_const_fn_unstable` expects a list of feature names
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:34:1
   |
LL | #[rustc_allow_const_fn_unstable]
---
LL | #[rustc_confusables]
   | ^^^^^^^^^^^^^^^^^^^^
   | |
   | expected this to be a list
   | help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]`

error[E0539]: malformed `deprecated` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:41:1
   |
LL | #[deprecated = 5]
   | ^^^^^^^^^^^^^^^-^
   |                |
   |                expected a string literal here
   |
help: try changing it to one of the following valid forms of the attribute
   |
LL - #[deprecated = 5]
LL + #[deprecated = "reason"]
   |
LL - #[deprecated = 5]
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")]
   |
LL - #[deprecated = 5]
LL + #[deprecated]
   |

error[E0539]: malformed `rustc_macro_transparency` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:46:1
   |
LL | #[rustc_macro_transparency]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_macro_transparency = "transparent|semitransparent|opaque"]`

error[E0539]: malformed `repr` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:48:1
   |
LL | #[repr]
   | ^^^^^^^
   | |
   | expected this to be a list
   | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`

error[E0565]: malformed `rustc_as_ptr` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:51:1
   |
LL | #[rustc_as_ptr = 5]
   | ^^^^^^^^^^^^^^^---^
   | |              |
   | |              didn't expect any arguments here
   | help: must be of the form: `#[rustc_as_ptr]`

error[E0539]: malformed `align` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:56:1
   |
LL | #[align]
   | ^^^^^^^^
   | |
   | expected this to be a list
   | help: must be of the form: `#[align(<alignment in bytes>)]`

error[E0539]: malformed `optimize` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:58:1
   |
LL | #[optimize]
   | ^^^^^^^^^^^
   | |
   | expected this to be a list
   | help: must be of the form: `#[optimize(size|speed|none)]`

error[E0565]: malformed `cold` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:60:1
   |
LL | #[cold = 1]
   | ^^^^^^^---^
   | |      |
   | |      didn't expect any arguments here
   | help: must be of the form: `#[cold]`

error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:62:1
   |
LL | #[must_use()]
   | ^^^^^^^^^^^^^

---

error[E0539]: malformed `export_name` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:70:1
   |
LL | #[export_name()]
   | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]`

error[E0805]: malformed `used` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:72:1
   |
LL | #[used()]
   | ^^^^^^--^
   |       |
   |       expected a single argument here
   |
help: try changing it to one of the following valid forms of the attribute
   |
LL | #[used(compiler|linker)]
   |        +++++++++++++++
LL - #[used()]
LL + #[used]
   |

error[E0539]: malformed `target_feature` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:79:1
   |
LL | #[target_feature]
   | ^^^^^^^^^^^^^^^^^
   | |
   | expected this to be a list
   | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]`

error[E0565]: malformed `export_stable` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:81:1
   |
LL | #[export_stable = 1]
---
error[E0539]: malformed `link_name` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:86:1
   |
LL | #[link_name]
   | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]`

error[E0539]: malformed `link_section` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:88:1
   |
LL | #[link_section]
   | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]`

error[E0565]: malformed `no_implicit_prelude` attribute input
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:97:1
   |
LL | #[no_implicit_prelude = 23]
   | ^^^^^^^^^^^^^^^^^^^^^^----^
   | |                     |
   | |                     didn't expect any arguments here
   | help: must be of the form: `#[no_implicit_prelude]`

error: attribute should be applied to `const fn`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:34:1
   |
LL |   #[rustc_allow_const_fn_unstable]
---
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
   |
   = help: only `message`, `note` and `label` are allowed as options

error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:53:1
   |
LL | #[inline = 5]
   | ^^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:94:1
   |
LL | #[ignore()]
   | ^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
##[error]  --> /checkout/tests/ui/attributes/malformed-attrs.rs:223:1
   |
LL | #[ignore = 1]
   | ^^^^^^^^^^^^^
   |
---
LL |     #[coroutine = 63] || {}
   |                       ^^^^^ expected `()`, found coroutine
   |
   = note: expected unit type `()`
              found coroutine `{coroutine@/checkout/tests/ui/attributes/malformed-attrs.rs:111:23: 111:25}`

error: aborting due to 76 previous errors; 3 warnings emitted

Some errors have detailed explanations: E0308, E0463, E0539, E0557, E0565, E0658, E0805.
For more information about an error, try `rustc --explain E0308`.
---

4 LL | #![feature(no_sanitize)]
5    |            ^^^^^^^^^^^ feature has been removed
6    |
-    = note: removed in CURRENT_RUSTC_VERSION (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/1234> for more information
+    = note: removed in CURRENT_RUSTC_VERSION; see <https://github.com/rust-lang/rust/pull/1234> for more information
8    = note: renamed to sanitize(xyz = "on|off")
9 
10 error[E0658]: the `#[sanitize]` attribute is an experimental feature


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args feature-gates/feature-gate-sanitize.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/feature-gates/feature-gate-sanitize.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-sanitize" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0557]: feature has been removed
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-sanitize.rs:2:12
   |
LL | #![feature(no_sanitize)] //~ ERROR feature has been removed
   |            ^^^^^^^^^^^ feature has been removed
   |
   = note: removed in CURRENT_RUSTC_VERSION; see <https://github.com/rust-lang/rust/pull/1234> for more information
   = note: renamed to sanitize(xyz = "on|off")

error[E0658]: the `#[sanitize]` attribute is an experimental feature
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-sanitize.rs:4:1
   |
LL | #[sanitize(address = "on")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #39699 <https://github.com/rust-lang/rust/issues/39699> for more information
   = help: add `#![feature(sanitize)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0557, E0658.
For more information about an error, try `rustc --explain E0557`.

@traviscross
Copy link
Contributor

@rustbot labels +T-lang +needs-fcp
cc @rust-lang/lang

Given that this is breaking, we should review and FCP. Let's do that crater run, since we'll need it for our review.

@bors2 try

@rustbot rustbot added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. T-lang Relevant to the language team labels Jul 14, 2025
@rust-bors
Copy link

rust-bors bot commented Jul 14, 2025

⌛ Trying commit a466546 with merge 4949cf2

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jul 14, 2025
Remove the `#[no_sanitize]` attribute in favor of `#[sanitize(xyz = "on|off")]`

This came up during the sanitizer stabilization (#123617). Instead of a `#[no_sanitize(xyz)]` attribute, we would like to have a `#[sanitize(xyz = "on|off")]` attribute, which is more powerful and allows to be extended in the future (instead
of just focusing on turning sanitizers off). The implementation is done according to what was [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/343119-project-exploit-mitigations/topic/Stabilize.20the.20.60no_sanitize.60.20attribute/with/495377292)).

The new attribute also works on modules, traits and impl items and thus enables usage as the following:
```rust
#[sanitize(address = "off")]
mod foo {
    fn unsanitized(..) {}

    #[sanitize(address = "on")]
    fn sanitized(..) {}
}

trait MyTrait {
  #[sanitize(address = "off")]
  fn unsanitized_default(..) {}
}

#[sanitize(thread = "off")]
impl MyTrait for () {
    ...
}
```

r? `@rcvalle`
@traviscross
Copy link
Contributor

Since this produces a user-visible effect on stable Rust, it feels like we should be documenting this somehow in the Reference. We'll talk about how we might want to do that on the lang-docs side.

cc @ehuss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-rustc-dev-guide Area: rustc-dev-guide needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. PG-exploit-mitigations Project group: Exploit mitigations 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. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants