Skip to content

Commit 01d0be9

Browse files
committed
Auto merge of #48851 - petrochenkov:genparattr, r=nikomatsakis
Stabilize attributes on generic parameters Closes #48848
2 parents 4bf76d6 + 1a2a234 commit 01d0be9

29 files changed

+45
-244
lines changed

src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
#![feature(fmt_internals)]
9898
#![feature(from_ref)]
9999
#![feature(fundamental)]
100-
#![feature(generic_param_attrs)]
100+
#![cfg_attr(stage0, feature(generic_param_attrs))]
101101
#![cfg_attr(stage0, feature(i128_type))]
102102
#![feature(lang_items)]
103103
#![feature(needs_allocator)]

src/libarena/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#![feature(alloc)]
2828
#![feature(core_intrinsics)]
2929
#![feature(dropck_eyepatch)]
30-
#![feature(generic_param_attrs)]
30+
#![cfg_attr(stage0, feature(generic_param_attrs))]
3131
#![cfg_attr(test, feature(test))]
3232

3333
#![allow(deprecated)]

src/librustc_typeck/diagnostics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3784,7 +3784,6 @@ that impl must be declared as an `unsafe impl.
37843784
Erroneous code example:
37853785
37863786
```compile_fail,E0569
3787-
#![feature(generic_param_attrs)]
37883787
#![feature(dropck_eyepatch)]
37893788
37903789
struct Foo<X>(X);

src/libstd/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
#![feature(float_from_str_radix)]
267267
#![feature(fn_traits)]
268268
#![feature(fnbox)]
269-
#![feature(generic_param_attrs)]
269+
#![cfg_attr(stage0, feature(generic_param_attrs))]
270270
#![feature(hashmap_internals)]
271271
#![feature(heap_api)]
272272
#![cfg_attr(stage0, feature(i128_type, i128))]

src/libsyntax/feature_gate.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ declare_features! (
288288
// rustc internal
289289
(active, compiler_builtins, "1.13.0", None, None),
290290

291-
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
292-
(active, generic_param_attrs, "1.11.0", Some(34761), None),
293-
294291
// Allows #[link(..., cfg(..))]
295292
(active, link_cfg, "1.14.0", Some(37406), None),
296293

@@ -566,6 +563,8 @@ declare_features! (
566563
(accepted, match_default_bindings, "1.26.0", Some(42640), None),
567564
// allow `'_` placeholder lifetimes
568565
(accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
566+
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
567+
(accepted, generic_param_attrs, "1.26.0", Some(48848), None),
569568
);
570569

571570
// If you change this, please modify src/doc/unstable-book as well. You must
@@ -1775,21 +1774,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
17751774
}
17761775
visit::walk_vis(self, vis);
17771776
}
1778-
1779-
fn visit_generic_param(&mut self, param: &'a ast::GenericParam) {
1780-
let (attrs, explain) = match *param {
1781-
ast::GenericParam::Lifetime(ref ld) =>
1782-
(&ld.attrs, "attributes on lifetime bindings are experimental"),
1783-
ast::GenericParam::Type(ref t) =>
1784-
(&t.attrs, "attributes on type parameter bindings are experimental"),
1785-
};
1786-
1787-
if !attrs.is_empty() {
1788-
gate_feature_post!(&self, generic_param_attrs, attrs[0].span, explain);
1789-
}
1790-
1791-
visit::walk_generic_param(self, param)
1792-
}
17931777
}
17941778

17951779
pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],

src/test/compile-fail/attrs-with-no-formal-in-generics-1.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// `#[oops]` is left dangling (that is, it is unattached, with no
1313
// formal binding following it).
1414

15-
#![feature(generic_param_attrs, rustc_attrs)]
16-
#![allow(dead_code)]
15+
#![feature(rustc_attrs)]
1716

1817
struct RefIntPair<'a, 'b>(&'a u32, &'b u32);
1918

src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// `#[oops]` is left dangling (that is, it is unattached, with no
1313
// formal binding following it).
1414

15-
#![feature(generic_param_attrs, rustc_attrs)]
16-
#![allow(dead_code)]
15+
#![feature(rustc_attrs)]
1716

1817
struct RefAny<'a, T>(&'a T);
1918

src/test/compile-fail/synthetic-param.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs, rustc_attrs)]
11+
#![feature(rustc_attrs)]
1212

1313
fn func<#[rustc_synthetic] T>(_: T) {}
1414

src/test/mir-opt/end_region_destruction_extents_1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// A scenario with significant destruction code extents (which have
1515
// suffix "dce" in current `-Z identify_regions` rendering).
1616

17-
#![feature(generic_param_attrs)]
1817
#![feature(dropck_eyepatch)]
1918

2019
fn main() {

src/test/run-pass/attr-on-generic-formals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// using `rustc_attrs` feature. There is a separate compile-fail/ test
1818
// ensuring that the attribute feature-gating works in this context.)
1919

20-
#![feature(generic_param_attrs, rustc_attrs)]
20+
#![feature(rustc_attrs)]
2121
#![allow(dead_code)]
2222

2323
struct StLt<#[rustc_lt_struct] 'a>(&'a u32);

src/test/run-pass/auxiliary/dropck_eyepatch_extern_crate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs)]
1211
#![feature(dropck_eyepatch)]
1312

1413
// The point of this test is to illustrate that the `#[may_dangle]`

src/test/run-pass/dropck-eyepatch-reorder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs)]
1211
#![feature(dropck_eyepatch)]
1312

1413
// The point of this test is to test uses of `#[may_dangle]` attribute

src/test/run-pass/dropck-eyepatch.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs)]
1211
#![feature(dropck_eyepatch)]
1312

1413
// The point of this test is to illustrate that the `#[may_dangle]`

src/test/ui/dropck/auxiliary/dropck_eyepatch_extern_crate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs)]
1211
#![feature(dropck_eyepatch)]
1312

1413
// This is a support file for ../dropck-eyepatch-extern-crate.rs

src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs)]
1211
#![feature(dropck_eyepatch)]
1312

1413
// This test ensures that a use of `#[may_dangle]` is rejected if

src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
2-
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:32:1
2+
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:31:1
33
|
44
LL | / impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> {
55
LL | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
@@ -10,7 +10,7 @@ LL | | }
1010
| |_^
1111

1212
error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
13-
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:38:1
13+
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:37:1
1414
|
1515
LL | / impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> {
1616
LL | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute

src/test/ui/dropck/dropck-eyepatch-reorder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs)]
1211
#![feature(dropck_eyepatch)]
1312

1413
// The point of this test is to test uses of `#[may_dangle]` attribute

src/test/ui/dropck/dropck-eyepatch-reorder.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0597]: `c` does not live long enough
2-
--> $DIR/dropck-eyepatch-reorder.rs:57:20
2+
--> $DIR/dropck-eyepatch-reorder.rs:56:20
33
|
44
LL | dt = Dt("dt", &c);
55
| ^ borrowed value does not live long enough
@@ -10,7 +10,7 @@ LL | }
1010
= note: values in a scope are dropped in the opposite order they are created
1111

1212
error[E0597]: `c` does not live long enough
13-
--> $DIR/dropck-eyepatch-reorder.rs:59:20
13+
--> $DIR/dropck-eyepatch-reorder.rs:58:20
1414
|
1515
LL | dr = Dr("dr", &c);
1616
| ^ borrowed value does not live long enough
@@ -21,7 +21,7 @@ LL | }
2121
= note: values in a scope are dropped in the opposite order they are created
2222

2323
error[E0597]: `c` does not live long enough
24-
--> $DIR/dropck-eyepatch-reorder.rs:67:29
24+
--> $DIR/dropck-eyepatch-reorder.rs:66:29
2525
|
2626
LL | pt = Pt("pt", &c_long, &c);
2727
| ^ borrowed value does not live long enough
@@ -32,7 +32,7 @@ LL | }
3232
= note: values in a scope are dropped in the opposite order they are created
3333

3434
error[E0597]: `c` does not live long enough
35-
--> $DIR/dropck-eyepatch-reorder.rs:69:29
35+
--> $DIR/dropck-eyepatch-reorder.rs:68:29
3636
|
3737
LL | pr = Pr("pr", &c_long, &c);
3838
| ^ borrowed value does not live long enough

src/test/ui/dropck/dropck-eyepatch.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generic_param_attrs)]
1211
#![feature(dropck_eyepatch)]
1312

1413
// The point of this test is to illustrate that the `#[may_dangle]`

src/test/ui/dropck/dropck-eyepatch.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0597]: `c` does not live long enough
2-
--> $DIR/dropck-eyepatch.rs:80:20
2+
--> $DIR/dropck-eyepatch.rs:79:20
33
|
44
LL | dt = Dt("dt", &c);
55
| ^ borrowed value does not live long enough
@@ -10,7 +10,7 @@ LL | }
1010
= note: values in a scope are dropped in the opposite order they are created
1111

1212
error[E0597]: `c` does not live long enough
13-
--> $DIR/dropck-eyepatch.rs:82:20
13+
--> $DIR/dropck-eyepatch.rs:81:20
1414
|
1515
LL | dr = Dr("dr", &c);
1616
| ^ borrowed value does not live long enough
@@ -21,7 +21,7 @@ LL | }
2121
= note: values in a scope are dropped in the opposite order they are created
2222

2323
error[E0597]: `c` does not live long enough
24-
--> $DIR/dropck-eyepatch.rs:90:29
24+
--> $DIR/dropck-eyepatch.rs:89:29
2525
|
2626
LL | pt = Pt("pt", &c_long, &c);
2727
| ^ borrowed value does not live long enough
@@ -32,7 +32,7 @@ LL | }
3232
= note: values in a scope are dropped in the opposite order they are created
3333

3434
error[E0597]: `c` does not live long enough
35-
--> $DIR/dropck-eyepatch.rs:92:29
35+
--> $DIR/dropck-eyepatch.rs:91:29
3636
|
3737
LL | pr = Pr("pr", &c_long, &c);
3838
| ^ borrowed value does not live long enough

src/test/ui/feature-gate-custom_attribute2.rs

-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@
1010

1111
// This test ensures that attributes on formals in generic parameter
1212
// lists are included when we are checking for unstable attributes.
13-
//
14-
// Note that feature(generic_param_attrs) *is* enabled here. We are
15-
// checking feature-gating of the attributes themselves, not the
16-
// capability to parse such attributes in that context.
1713

1814
// gate-test-custom_attribute
1915

20-
#![feature(generic_param_attrs)]
21-
#![allow(dead_code)]
22-
2316
struct StLt<#[lt_struct] 'a>(&'a u32);
2417
//~^ ERROR The attribute `lt_struct` is currently unknown to the compiler
2518
struct StTy<#[ty_struct] I>(I);

0 commit comments

Comments
 (0)