Skip to content

Commit 8e536af

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 970d047 commit 8e536af

File tree

19 files changed

+18
-73
lines changed

19 files changed

+18
-73
lines changed

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ declare_features! (
307307
(accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490)),
308308
/// Allows using non lexical lifetimes (RFC 2094).
309309
(accepted, nll, "1.63.0", Some(43234)),
310+
/// Allows the use of `no_sanitize` attribute.
311+
(accepted, no_sanitize, "CURRENT_RUSTC_VERSION", Some(39699)),
310312
/// Allows using `#![no_std]`.
311313
(accepted, no_std, "1.6.0", None),
312314
/// 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
@@ -475,10 +475,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
475475
),
476476
ungated!(track_caller, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes),
477477
ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, EncodeCrossCrate::No),
478-
gated!(
478+
ungated!(
479479
no_sanitize, Normal,
480480
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
481-
EncodeCrossCrate::No, experimental!(no_sanitize)
481+
EncodeCrossCrate::No
482482
),
483483
gated!(
484484
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
@@ -565,8 +565,6 @@ declare_features! (
565565
(unstable, never_type_fallback, "1.41.0", Some(65992)),
566566
/// Allows `#![no_core]`.
567567
(unstable, no_core, "1.3.0", Some(29639)),
568-
/// Allows the use of `no_sanitize` attribute.
569-
(unstable, no_sanitize, "1.42.0", Some(39699)),
570568
/// Allows using the `non_exhaustive_omitted_patterns` lint.
571569
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
572570
/// 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
// Do not check link redundancy on bootstraping phase
105105
#![allow(rustdoc::redundant_explicit_links)]
106106
#![warn(rustdoc::unescaped_backticks)]
107+
// FIXME: Remove after `no_sanitize` stabilization (along with `#![feature(no_sanitize)]`)
108+
#![allow(stable_features)]
107109
//
108110
// Library features:
109111
// tidy-alphabetical-start

library/std/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@
260260
#![deny(ffi_unwind_calls)]
261261
// std may use features in a platform-specific way
262262
#![allow(unused_features)]
263+
// FIXME: Remove after `no_sanitize` stabilization (along with `#![feature(no_sanitize)]`)
264+
#![allow(stable_features)]
263265
//
264266
// Features:
265267
#![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))]

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)