Skip to content

Commit 48bc1dd

Browse files
committed
sanitizers: Stabilize the no_sanitize attribute
Stabilize the `no_sanitize` attribute so stable sanitizers can also be selectively disabled for annotated functions.
1 parent 74280ec commit 48bc1dd

File tree

20 files changed

+19
-78
lines changed

20 files changed

+19
-78
lines changed

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ declare_features! (
306306
(accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490)),
307307
/// Allows using non lexical lifetimes (RFC 2094).
308308
(accepted, nll, "1.63.0", Some(43234)),
309+
/// Allows the use of `no_sanitize` attribute.
310+
(accepted, no_sanitize, "CURRENT_RUSTC_VERSION", Some(39699)),
309311
/// Allows using `#![no_std]`.
310312
(accepted, no_std, "1.6.0", None),
311313
/// Allows defining identifiers beyond ASCII.

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
470470
),
471471
ungated!(track_caller, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes),
472472
ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, EncodeCrossCrate::No),
473-
gated!(
473+
ungated!(
474474
no_sanitize, Normal,
475475
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
476-
EncodeCrossCrate::No, experimental!(no_sanitize)
476+
EncodeCrossCrate::No
477477
),
478478
gated!(
479479
coverage, Normal, template!(OneOf: &[sym::off, sym::on]),

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,6 @@ declare_features! (
582582
(unstable, new_range, "1.86.0", Some(123741)),
583583
/// Allows `#![no_core]`.
584584
(unstable, no_core, "1.3.0", Some(29639)),
585-
/// Allows the use of `no_sanitize` attribute.
586-
(unstable, no_sanitize, "1.42.0", Some(39699)),
587585
/// Allows using the `non_exhaustive_omitted_patterns` lint.
588586
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
589587
/// Allows `for<T>` binders in where-clauses

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,8 +2403,6 @@ declare_lint! {
24032403
/// ### Example
24042404
///
24052405
/// ```rust
2406-
/// #![feature(no_sanitize)]
2407-
///
24082406
/// #[inline(always)]
24092407
/// #[no_sanitize(address)]
24102408
/// fn x() {}

library/core/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@
143143
#![feature(variant_count)]
144144
// tidy-alphabetical-end
145145
//
146+
// Features:
147+
#![cfg_attr(bootstrap, feature(no_sanitize))]
148+
//
146149
// Language features:
147150
// tidy-alphabetical-start
148151
#![feature(abi_unadjusted)]
@@ -181,7 +184,6 @@
181184
#![feature(negative_impls)]
182185
#![feature(never_type)]
183186
#![feature(no_core)]
184-
#![feature(no_sanitize)]
185187
#![feature(optimize_attribute)]
186188
#![feature(prelude_import)]
187189
#![feature(repr_simd)]

library/std/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@
261261
#![allow(unused_features)]
262262
//
263263
// Features:
264+
#![cfg_attr(bootstrap, feature(no_sanitize))]
264265
#![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))]
265266
#![cfg_attr(
266267
all(target_vendor = "fortanix", target_env = "sgx"),
@@ -309,7 +310,6 @@
309310
#![feature(needs_panic_runtime)]
310311
#![feature(negative_impls)]
311312
#![feature(never_type)]
312-
#![feature(no_sanitize)]
313313
#![feature(optimize_attribute)]
314314
#![feature(prelude_import)]
315315
#![feature(rustc_attrs)]

src/doc/unstable-book/src/language-features/no-sanitize.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/codegen/sanitizer/cfi/emit-type-checks-attr-no-sanitize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zunstable-options -Csanitize=cfi -Copt-level=0
55

66
#![crate_type = "lib"]
7-
#![feature(no_sanitize)]
87

98
#[no_sanitize(cfi)]
109
pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 {

tests/codegen/sanitizer/no-sanitize-inlining.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
//@[LSAN] compile-flags: -Zunstable-options -Csanitize=leak
1010

1111
#![crate_type = "lib"]
12-
#![feature(no_sanitize)]
13-
1412
// ASAN-LABEL: define void @test
1513
// ASAN: call {{.*}} @random_inline
1614
// ASAN: }

tests/codegen/sanitizer/scs-attr-check.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
//@ compile-flags: -Zunstable-options -Csanitize=shadow-call-stack
66

77
#![crate_type = "lib"]
8-
#![feature(no_sanitize)]
9-
108
// CHECK: ; sanitizer_scs_attr_check::scs
119
// CHECK-NEXT: ; Function Attrs:{{.*}}shadowcallstack
1210
pub fn scs() {}

0 commit comments

Comments
 (0)