Skip to content

Commit 21b5c1d

Browse files
authored
Rollup merge of rust-lang#61660 - petrochenkov:nocusta, r=Centril
Minimize use of `#![feature(custom_attribute)]` Some preparations before resurrecting rust-lang#57921.
2 parents 2410b4d + ee189ae commit 21b5c1d

File tree

71 files changed

+656
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+656
-721
lines changed

src/doc/rustc/src/lints/listing/warn-by-default.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,19 +728,17 @@ This lint detects attributes that were not used by the compiler. Some
728728
example code that triggers this lint:
729729

730730
```rust
731-
#![feature(custom_attribute)]
732-
733-
#![mutable_doc]
731+
#![macro_export]
734732
```
735733

736734
This will produce:
737735

738736
```text
739737
warning: unused attribute
740-
--> src/main.rs:4:1
738+
--> src/main.rs:1:1
741739
|
742-
4 | #![mutable_doc]
743-
| ^^^^^^^^^^^^^^^
740+
1 | #![macro_export]
741+
| ^^^^^^^^^^^^^^^^
744742
|
745743
```
746744

src/liballoc/alloc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ extern "Rust" {
1515
// them from the `#[global_allocator]` attribute if there is one, or uses the
1616
// default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
1717
// otherwise.
18-
#[allocator]
18+
#[cfg_attr(bootstrap, allocator)]
19+
#[cfg_attr(not(bootstrap), rustc_allocator)]
1920
#[rustc_allocator_nounwind]
2021
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
2122
#[rustc_allocator_nounwind]

src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#![feature(coerce_unsized)]
8080
#![feature(dispatch_from_dyn)]
8181
#![feature(core_intrinsics)]
82-
#![feature(custom_attribute)]
82+
#![cfg_attr(bootstrap, feature(custom_attribute))]
8383
#![feature(dropck_eyepatch)]
8484
#![feature(exact_size_is_empty)]
8585
#![feature(fmt_internals)]

src/libcore/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
#![feature(concat_idents)]
7676
#![feature(const_fn)]
7777
#![feature(const_fn_union)]
78-
#![feature(custom_attribute)]
7978
#![feature(doc_cfg)]
8079
#![feature(doc_spotlight)]
8180
#![feature(extern_types)]

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,7 @@ bitflags! {
25742574
/// `#[cold]`: a hint to LLVM that this function, when called, is never on
25752575
/// the hot path.
25762576
const COLD = 1 << 0;
2577-
/// `#[allocator]`: a hint to LLVM that the pointer returned from this
2577+
/// `#[rustc_allocator]`: a hint to LLVM that the pointer returned from this
25782578
/// function is never null.
25792579
const ALLOCATOR = 1 << 1;
25802580
/// `#[unwind]`: an indicator that this function may unwind despite what

src/librustc_codegen_llvm/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![feature(box_syntax)]
1111
#![feature(const_cstr_unchecked)]
1212
#![feature(crate_visibility_modifier)]
13-
#![feature(custom_attribute)]
1413
#![feature(extern_types)]
1514
#![feature(in_band_lifetimes)]
1615
#![allow(unused_attributes)]

src/librustc_codegen_ssa/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(box_patterns)]
44
#![feature(box_syntax)]
55
#![feature(core_intrinsics)]
6-
#![feature(custom_attribute)]
76
#![feature(libc)]
87
#![feature(rustc_diagnostic_macros)]
98
#![feature(stmt_expr_attributes)]

src/librustc_codegen_utils/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![feature(box_patterns)]
99
#![feature(box_syntax)]
1010
#![feature(core_intrinsics)]
11-
#![feature(custom_attribute)]
1211
#![feature(never_type)]
1312
#![feature(nll)]
1413
#![allow(unused_attributes)]

src/librustc_errors/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
22

3-
#![feature(custom_attribute)]
43
#![allow(unused_attributes)]
54
#![cfg_attr(unix, feature(libc))]
65
#![feature(nll)]

src/librustc_save_analysis/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
2-
#![feature(custom_attribute)]
32
#![feature(nll)]
43
#![deny(rust_2018_idioms)]
54
#![deny(internal)]

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,7 @@ fn codegen_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> Codegen
24452445
for attr in attrs.iter() {
24462446
if attr.check_name(sym::cold) {
24472447
codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD;
2448-
} else if attr.check_name(sym::allocator) {
2448+
} else if attr.check_name(sym::rustc_allocator) {
24492449
codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR;
24502450
} else if attr.check_name(sym::unwind) {
24512451
codegen_fn_attrs.flags |= CodegenFnAttrFlags::UNWIND;

src/libsyntax/feature_gate.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,16 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
13311331
"internal implementation detail",
13321332
cfg_fn!(rustc_attrs))),
13331333

1334+
(sym::rustc_allocator, Whitelisted, template!(Word), Gated(Stability::Unstable,
1335+
sym::rustc_attrs,
1336+
"internal implementation detail",
1337+
cfg_fn!(rustc_attrs))),
1338+
1339+
(sym::rustc_dummy, Normal, template!(Word /* doesn't matter*/), Gated(Stability::Unstable,
1340+
sym::rustc_attrs,
1341+
"used by the test suite",
1342+
cfg_fn!(rustc_attrs))),
1343+
13341344
// FIXME: #14408 whitelist docs since rustdoc looks at them
13351345
(
13361346
sym::doc,
@@ -1957,12 +1967,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
19571967
}
19581968

19591969
match attr_info {
1960-
Some(&(name, _, template, _)) => self.check_builtin_attribute(
1961-
attr,
1962-
name,
1963-
template
1964-
),
1965-
None => if let Some(TokenTree::Token(token)) = attr.tokens.trees().next() {
1970+
// `rustc_dummy` doesn't have any restrictions specific to built-in attributes.
1971+
Some(&(name, _, template, _)) if name != sym::rustc_dummy =>
1972+
self.check_builtin_attribute(attr, name, template),
1973+
_ => if let Some(TokenTree::Token(token)) = attr.tokens.trees().next() {
19661974
if token == token::Eq {
19671975
// All key-value attributes are restricted to meta-item syntax.
19681976
attr.parse_meta(self.context.parse_sess).map_err(|mut err| err.emit()).ok();

src/libsyntax_pos/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#![feature(const_fn)]
1313
#![feature(crate_visibility_modifier)]
14-
#![feature(custom_attribute)]
1514
#![feature(nll)]
1615
#![feature(non_exhaustive)]
1716
#![feature(optin_builtin_traits)]

src/libsyntax_pos/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ symbols! {
513513
rust_2018_preview,
514514
rust_begin_unwind,
515515
rustc,
516+
rustc_allocator,
516517
rustc_allocator_nounwind,
517518
rustc_allow_const_fn_ptr,
518519
rustc_args_required_const,
@@ -526,6 +527,7 @@ symbols! {
526527
rustc_diagnostic_macros,
527528
rustc_dirty,
528529
rustc_doc_only_macro,
530+
rustc_dummy,
529531
rustc_dump_env_program_clauses,
530532
rustc_dump_program_clauses,
531533
rustc_dump_user_substs,

src/libterm/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
#![deny(rust_2018_idioms)]
3939

4040
#![cfg_attr(windows, feature(libc))]
41-
// Handle rustfmt skips
42-
#![feature(custom_attribute)]
43-
#![allow(unused_attributes)]
4441

4542
use std::io::prelude::*;
4643
use std::io::{self, Stdout, Stderr};

src/test/codegen/function-arguments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ignore-tidy-linelength
33

44
#![crate_type = "lib"]
5-
#![feature(custom_attribute)]
5+
#![feature(rustc_attrs)]
66

77
pub struct S {
88
_field: [i32; 8],
@@ -146,7 +146,7 @@ pub fn enum_id_2(x: Option<u8>) -> Option<u8> {
146146

147147
// CHECK: noalias i8* @allocator()
148148
#[no_mangle]
149-
#[allocator]
149+
#[rustc_allocator]
150150
pub fn allocator() -> *const i8 {
151151
std::ptr::null()
152152
}

src/test/pretty/attr-fn-inner.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
// pp-exact
21
// Testing that both the inner item and next outer item are
32
// preserved, and that the first outer item parsed in main is not
43
// accidentally carried over to each inner function
54

6-
#![feature(custom_attribute)]
5+
// pp-exact
6+
7+
#![feature(rustc_attrs)]
78

89
fn main() {
9-
#![inner_attr]
10-
#[outer_attr]
10+
#![rustc_dummy]
11+
#[rustc_dummy]
1112
fn f() { }
1213

13-
#[outer_attr]
14+
#[rustc_dummy]
1415
fn g() { }
1516
}

src/test/pretty/attr-literals.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
// pp-exact
21
// Tests literals in attributes.
32

4-
#![feature(custom_attribute)]
3+
// pp-exact
4+
5+
#![feature(rustc_attrs)]
56

67
fn main() {
7-
#![hello("hi", 1, 2, 1.012, pi = 3.14, bye, name("John"))]
8-
#[align = 8]
8+
#![rustc_dummy("hi", 1, 2, 1.012, pi = 3.14, bye, name("John"))]
9+
#[rustc_dummy = 8]
910
fn f() { }
1011

11-
#[vector(1, 2, 3)]
12+
#[rustc_dummy(1, 2, 3)]
1213
fn g() { }
1314
}

0 commit comments

Comments
 (0)