Skip to content

Commit e075586

Browse files
committed
add tests and fix comments
1 parent 03733ca commit e075586

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

compiler/rustc_feature/src/active.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ declare_features! (
533533
///
534534
/// NOTE: A limited form of `union U { ... }` was accepted in 1.19.0.
535535
(active, untagged_unions, "1.13.0", Some(55149), None),
536-
/// Allows using the `#[used(retain)]` attribute.
537-
(active, used_with_arg, "1.60.0", None, None),
536+
/// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute.
537+
(active, used_with_arg, "1.60.0", Some(00000), None),
538538
/// Allows `extern "wasm" fn`
539539
(active, wasm_abi, "1.53.0", Some(83788), None),
540540
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
324324
ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
325325
ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
326326
ungated!(no_mangle, Normal, template!(Word), WarnFollowing),
327-
ungated!(used, Normal, template!(Word, List: "used"), WarnFollowing),
327+
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing),
328328

329329
// Limits:
330330
ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),

src/test/codegen/used_with_arg.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-flags: -O
2+
3+
#![crate_type = "lib"]
4+
#![feature(used_with_arg)]
5+
6+
// CHECK: @llvm.used = appending global [1 x i8*]
7+
#[used(linker)]
8+
static mut USED_LINKER: [usize; 1] = [0];
9+
10+
// CHECK-NEXT: @llvm.compiler.used = appending global [1 x i8*]
11+
#[used(compiler)]
12+
static mut USED_COMPILER: [usize; 1] = [0];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[used(linker)] //~ ERROR `#[used(linker)]` is currently unstable
2+
static mut USED_LINKER: [usize; 1] = [0];
3+
4+
#[used(compiler)] //~ ERROR `#[used(compiler)]` is currently unstable
5+
static mut USED_COMPILER: [usize; 1] = [0];
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0658]: `#[used(linker)]` is currently unstable
2+
--> $DIR/feature-gate-used_with_arg.rs:1:1
3+
|
4+
LL | #[used(linker)]
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
= help: add `#![feature(used_with_arg)]` to the crate attributes to enable
8+
9+
error[E0658]: `#[used(compiler)]` is currently unstable
10+
--> $DIR/feature-gate-used_with_arg.rs:4:1
11+
|
12+
LL | #[used(compiler)]
13+
| ^^^^^^^^^^^^^^^^^
14+
|
15+
= help: add `#![feature(used_with_arg)]` to the crate attributes to enable
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)