Skip to content

Commit 99cd982

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 d3d029c commit 99cd982

File tree

19 files changed

+18
-75
lines changed

19 files changed

+18
-75
lines changed

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ declare_features! (
309309
(accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490)),
310310
/// Allows using non lexical lifetimes (RFC 2094).
311311
(accepted, nll, "1.63.0", Some(43234)),
312+
/// Allows the use of `no_sanitize` attribute.
313+
(accepted, no_sanitize, "CURRENT_RUSTC_VERSION", Some(39699)),
312314
/// Allows using `#![no_std]`.
313315
(accepted, no_std, "1.6.0", None),
314316
/// 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
@@ -476,10 +476,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
476476
),
477477
ungated!(track_caller, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes),
478478
ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, EncodeCrossCrate::No),
479-
gated!(
479+
ungated!(
480480
no_sanitize, Normal,
481481
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
482-
EncodeCrossCrate::No, experimental!(no_sanitize)
482+
EncodeCrossCrate::No
483483
),
484484
gated!(
485485
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
@@ -572,8 +572,6 @@ declare_features! (
572572
(unstable, never_type_fallback, "1.41.0", Some(65992)),
573573
/// Allows `#![no_core]`.
574574
(unstable, no_core, "1.3.0", Some(29639)),
575-
/// Allows the use of `no_sanitize` attribute.
576-
(unstable, no_sanitize, "1.42.0", Some(39699)),
577575
/// Allows using the `non_exhaustive_omitted_patterns` lint.
578576
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
579577
/// 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
@@ -2440,8 +2440,6 @@ declare_lint! {
24402440
/// ### Example
24412441
///
24422442
/// ```rust
2443-
/// #![feature(no_sanitize)]
2444-
///
24452443
/// #[inline(always)]
24462444
/// #[no_sanitize(address)]
24472445
/// fn x() {}

library/core/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
#![feature(variant_count)]
140140
// tidy-alphabetical-end
141141
//
142+
// Features:
143+
#![cfg_attr(bootstrap, feature(no_sanitize))]
144+
//
142145
// Language features:
143146
// tidy-alphabetical-start
144147
#![feature(abi_unadjusted)]
@@ -177,7 +180,6 @@
177180
#![feature(negative_impls)]
178181
#![feature(never_type)]
179182
#![feature(no_core)]
180-
#![feature(no_sanitize)]
181183
#![feature(optimize_attribute)]
182184
#![feature(prelude_import)]
183185
#![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"),
@@ -304,7 +305,6 @@
304305
#![feature(needs_panic_runtime)]
305306
#![feature(negative_impls)]
306307
#![feature(never_type)]
307-
#![feature(no_sanitize)]
308308
#![feature(optimize_attribute)]
309309
#![feature(prelude_import)]
310310
#![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)