Skip to content

Commit 40069bb

Browse files
authored
Rollup merge of rust-lang#40150 - topecongiro:compile-fail-test-cfg-target-has-atomic, r=alexcrichton
Add compile test for cfg_target_has_atomic Issue rust-lang#39059. I am concerned about whether the test is excessive.
2 parents 9b55f53 + 3bffc9e commit 40069bb

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type="rlib"]
12+
#![no_core]
13+
14+
extern "rust-intrinsic" {
15+
fn atomic_xadd<T>(dst: *mut T, src: T) -> T;
16+
}
17+
18+
#[lang = "sized"]
19+
trait Sized {}
20+
#[lang = "copy"]
21+
trait Copy {}
22+
23+
#[cfg(target_has_atomic = "8")]
24+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
25+
pub unsafe fn atomic_u8(x: *mut u8) {
26+
atomic_xadd(x, 1);
27+
atomic_xadd(x, 1);
28+
}
29+
#[cfg(target_has_atomic = "8")]
30+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
31+
pub unsafe fn atomic_i8(x: *mut i8) {
32+
atomic_xadd(x, 1);
33+
}
34+
#[cfg(target_has_atomic = "16")]
35+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
36+
pub unsafe fn atomic_u16(x: *mut u16) {
37+
atomic_xadd(x, 1);
38+
}
39+
#[cfg(target_has_atomic = "16")]
40+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
41+
pub unsafe fn atomic_i16(x: *mut i16) {
42+
atomic_xadd(x, 1);
43+
}
44+
#[cfg(target_has_atomic = "32")]
45+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
46+
pub unsafe fn atomic_u32(x: *mut u32) {
47+
atomic_xadd(x, 1);
48+
}
49+
#[cfg(target_has_atomic = "32")]
50+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
51+
pub unsafe fn atomic_i32(x: *mut i32) {
52+
atomic_xadd(x, 1);
53+
}
54+
#[cfg(target_has_atomic = "64")]
55+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
56+
pub unsafe fn atomic_u64(x: *mut u64) {
57+
atomic_xadd(x, 1);
58+
}
59+
#[cfg(target_has_atomic = "64")]
60+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
61+
pub unsafe fn atomic_i64(x: *mut i64) {
62+
atomic_xadd(x, 1);
63+
}
64+
#[cfg(target_has_atomic = "ptr")]
65+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
66+
pub unsafe fn atomic_usize(x: *mut usize) {
67+
atomic_xadd(x, 1);
68+
}
69+
#[cfg(target_has_atomic = "ptr")]
70+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
71+
pub unsafe fn atomic_isize(x: *mut isize) {
72+
atomic_xadd(x, 1);
73+
}
74+
75+
fn main() {
76+
cfg!(target_has_atomic = "8");
77+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
78+
cfg!(target_has_atomic = "16");
79+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
80+
cfg!(target_has_atomic = "32");
81+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
82+
cfg!(target_has_atomic = "64");
83+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
84+
cfg!(target_has_atomic = "ptr");
85+
//~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
86+
}

src/tools/tidy/src/features.rs

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ pub fn check(path: &Path, bad: &mut bool) {
168168
// FIXME get this whitelist empty.
169169
let whitelist = vec![
170170
"abi_ptx", "simd",
171-
"cfg_target_has_atomic",
172171
"stmt_expr_attributes",
173172
"cfg_target_thread_local", "unwind_attributes",
174173
];

0 commit comments

Comments
 (0)