Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize attributes on generic parameters #48851

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
#![feature(fmt_internals)]
#![feature(from_ref)]
#![feature(fundamental)]
#![feature(generic_param_attrs)]
#![cfg_attr(stage0, feature(generic_param_attrs))]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(iter_rfold)]
#![feature(lang_items)]
Expand Down
2 changes: 1 addition & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(generic_param_attrs)]
#![cfg_attr(stage0, feature(generic_param_attrs))]
#![cfg_attr(test, feature(test))]

#![allow(deprecated)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3784,7 +3784,6 @@ that impl must be declared as an `unsafe impl.
Erroneous code example:

```compile_fail,E0569
#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

struct Foo<X>(X);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
#![feature(float_from_str_radix)]
#![feature(fn_traits)]
#![feature(fnbox)]
#![feature(generic_param_attrs)]
#![cfg_attr(stage0, feature(generic_param_attrs))]
#![feature(hashmap_internals)]
#![feature(heap_api)]
#![cfg_attr(stage0, feature(i128_type, i128))]
Expand Down
20 changes: 2 additions & 18 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ declare_features! (
// rustc internal
(active, compiler_builtins, "1.13.0", None, None),

// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
(active, generic_param_attrs, "1.11.0", Some(34761), None),

// Allows #[link(..., cfg(..))]
(active, link_cfg, "1.14.0", Some(37406), None),

Expand Down Expand Up @@ -566,6 +563,8 @@ declare_features! (
(accepted, match_default_bindings, "1.26.0", Some(42640), None),
// allow `'_` placeholder lifetimes
(accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
// Allows attributes on lifetime/type formal parameters in generics (RFC 1327)
(accepted, generic_param_attrs, "1.26.0", Some(48848), None),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. This should be 1.27 now.

);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1775,21 +1774,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
visit::walk_vis(self, vis);
}

fn visit_generic_param(&mut self, param: &'a ast::GenericParam) {
let (attrs, explain) = match *param {
ast::GenericParam::Lifetime(ref ld) =>
(&ld.attrs, "attributes on lifetime bindings are experimental"),
ast::GenericParam::Type(ref t) =>
(&t.attrs, "attributes on type parameter bindings are experimental"),
};

if !attrs.is_empty() {
gate_feature_post!(&self, generic_param_attrs, attrs[0].span, explain);
}

visit::walk_generic_param(self, param)
}
}

pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
Expand Down
3 changes: 1 addition & 2 deletions src/test/compile-fail/attrs-with-no-formal-in-generics-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// `#[oops]` is left dangling (that is, it is unattached, with no
// formal binding following it).

#![feature(generic_param_attrs, rustc_attrs)]
#![allow(dead_code)]
#![feature(rustc_attrs)]

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

Expand Down
3 changes: 1 addition & 2 deletions src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
// `#[oops]` is left dangling (that is, it is unattached, with no
// formal binding following it).

#![feature(generic_param_attrs, rustc_attrs)]
#![allow(dead_code)]
#![feature(rustc_attrs)]

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

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/synthetic-param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs, rustc_attrs)]
#![feature(rustc_attrs)]

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

Expand Down
1 change: 0 additions & 1 deletion src/test/mir-opt/end_region_destruction_extents_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// A scenario with significant destruction code extents (which have
// suffix "dce" in current `-Z identify_regions` rendering).

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/attr-on-generic-formals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// using `rustc_attrs` feature. There is a separate compile-fail/ test
// ensuring that the attribute feature-gating works in this context.)

#![feature(generic_param_attrs, rustc_attrs)]
#![feature(rustc_attrs)]
#![allow(dead_code)]

struct StLt<#[rustc_lt_struct] 'a>(&'a u32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

// The point of this test is to illustrate that the `#[may_dangle]`
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/dropck-eyepatch-reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

// The point of this test is to test uses of `#[may_dangle]` attribute
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/dropck-eyepatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

// The point of this test is to illustrate that the `#[may_dangle]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

// This is a support file for ../dropck-eyepatch-extern-crate.rs
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

// This test ensures that a use of `#[may_dangle]` is rejected if
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:32:1
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:31:1
|
LL | / impl<#[may_dangle] A, B: fmt::Debug> Drop for Pt<A, B> {
LL | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
Expand All @@ -10,7 +10,7 @@ LL | | }
| |_^

error[E0569]: requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:38:1
--> $DIR/dropck-eyepatch-implies-unsafe-impl.rs:37:1
|
LL | / impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> {
LL | | //~^ ERROR requires an `unsafe impl` declaration due to `#[may_dangle]` attribute
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/dropck/dropck-eyepatch-reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

// The point of this test is to test uses of `#[may_dangle]` attribute
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/dropck/dropck-eyepatch-reorder.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0597]: `c` does not live long enough
--> $DIR/dropck-eyepatch-reorder.rs:57:20
--> $DIR/dropck-eyepatch-reorder.rs:56:20
|
LL | dt = Dt("dt", &c);
| ^ borrowed value does not live long enough
Expand All @@ -10,7 +10,7 @@ LL | }
= note: values in a scope are dropped in the opposite order they are created

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

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

error[E0597]: `c` does not live long enough
--> $DIR/dropck-eyepatch-reorder.rs:69:29
--> $DIR/dropck-eyepatch-reorder.rs:68:29
|
LL | pr = Pr("pr", &c_long, &c);
| ^ borrowed value does not live long enough
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/dropck/dropck-eyepatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_param_attrs)]
#![feature(dropck_eyepatch)]

// The point of this test is to illustrate that the `#[may_dangle]`
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/dropck/dropck-eyepatch.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0597]: `c` does not live long enough
--> $DIR/dropck-eyepatch.rs:80:20
--> $DIR/dropck-eyepatch.rs:79:20
|
LL | dt = Dt("dt", &c);
| ^ borrowed value does not live long enough
Expand All @@ -10,7 +10,7 @@ LL | }
= note: values in a scope are dropped in the opposite order they are created

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

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

error[E0597]: `c` does not live long enough
--> $DIR/dropck-eyepatch.rs:92:29
--> $DIR/dropck-eyepatch.rs:91:29
|
LL | pr = Pr("pr", &c_long, &c);
| ^ borrowed value does not live long enough
Expand Down
7 changes: 0 additions & 7 deletions src/test/ui/feature-gate-custom_attribute2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@

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

// gate-test-custom_attribute

#![feature(generic_param_attrs)]
#![allow(dead_code)]

struct StLt<#[lt_struct] 'a>(&'a u32);
//~^ ERROR The attribute `lt_struct` is currently unknown to the compiler
struct StTy<#[ty_struct] I>(I);
Expand Down
Loading