Skip to content

Commit 7ec002b

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 896b348 commit 7ec002b

File tree

20 files changed

+19
-76
lines changed

20 files changed

+19
-76
lines changed

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ declare_features! (
312312
(accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490)),
313313
/// Allows using non lexical lifetimes (RFC 2094).
314314
(accepted, nll, "1.63.0", Some(43234)),
315+
/// Allows the use of `no_sanitize` attribute.
316+
(accepted, no_sanitize, "CURRENT_RUSTC_VERSION", Some(39699)),
315317
/// Allows using `#![no_std]`.
316318
(accepted, no_std, "1.6.0", None),
317319
/// 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
@@ -486,10 +486,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
486486
),
487487
ungated!(track_caller, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes),
488488
ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, EncodeCrossCrate::No),
489-
gated!(
489+
ungated!(
490490
no_sanitize, Normal,
491491
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
492-
EncodeCrossCrate::No, experimental!(no_sanitize)
492+
EncodeCrossCrate::No
493493
),
494494
gated!(
495495
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
@@ -581,8 +581,6 @@ declare_features! (
581581
(unstable, new_range, "1.86.0", Some(123741)),
582582
/// Allows `#![no_core]`.
583583
(unstable, no_core, "1.3.0", Some(29639)),
584-
/// Allows the use of `no_sanitize` attribute.
585-
(unstable, no_sanitize, "1.42.0", Some(39699)),
586584
/// Allows using the `non_exhaustive_omitted_patterns` lint.
587585
(unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
588586
/// 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
#![feature(variant_count)]
132132
// tidy-alphabetical-end
133133
//
134+
// Features:
135+
#![cfg_attr(bootstrap, feature(no_sanitize))]
136+
//
134137
// Language features:
135138
// tidy-alphabetical-start
136139
#![feature(abi_unadjusted)]

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
#![allow(unused_features)]
264264
//
265265
// Features:
266+
#![cfg_attr(bootstrap, feature(no_sanitize))]
266267
#![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))]
267268
#![cfg_attr(
268269
all(target_vendor = "fortanix", target_env = "sgx"),

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)