Skip to content

Commit f6a4277

Browse files
committed
Add comments and improve error message
1 parent 2aec0ab commit f6a4277

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
658658
gated!(
659659
unstable_feature_bound, Normal, template!(Word, List: "feat1, feat2, ..."),
660660
DuplicatesOk, EncodeCrossCrate::No, impl_stability,
661-
"allow unstable impl",
661+
"used internally to mark impl as unstable",
662662
),
663663
gated!(
664664
allow_internal_unsafe, Normal, template!(Word), WarnFollowing,

tests/ui/feature-gates/feature-gate-impl-stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ trait Foo{}
44
struct Bar;
55

66
#[unstable_feature_bound(feat_foo)]
7-
//~^ ERROR: allow unstable impl
7+
//~^ ERROR: used internally to mark impl as unstable
88
impl Foo for Bar{}
99

1010
fn main() {

tests/ui/feature-gates/feature-gate-impl-stability.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0658]: allow unstable impl
1+
error[E0658]: used internally to mark impl as unstable
22
--> $DIR/feature-gate-impl-stability.rs:6:1
33
|
44
LL | #[unstable_feature_bound(feat_foo)]

tests/ui/internal/unstable-feature-bound-no-effect.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@
44
#![feature(impl_stability)]
55
#![allow(dead_code)]
66

7+
/// If #[unstable(..)] and #[unstable_feature_name(..)] have the same symbol,
8+
/// The error should not be thrown as it can effectively mark an impl as unstable.
9+
///
10+
/// If the feature name in #[feature] does not exist in #[unstable_feature_bound(..)]
11+
/// an error should still be thrown because that feature will not be unstable.
12+
713
#[stable(feature = "a", since = "1.1.1" )]
814
trait Moo {}
915
#[stable(feature = "a", since = "1.1.1" )]
1016
trait Foo {}
1117
#[stable(feature = "a", since = "1.1.1" )]
18+
trait Boo {}
19+
#[stable(feature = "a", since = "1.1.1" )]
1220
pub struct Bar;
1321

1422

15-
// If #[unstable_feature_bound] and #[unstable] has different name,
16-
// It should throw an error.
1723
#[unstable(feature = "feat_moo", issue = "none" )]
1824
#[unstable_feature_bound(feat_foo)] //~^ ERROR: an `#[unstable]` annotation here has no effect
1925
impl Moo for Bar {}
@@ -22,4 +28,9 @@ impl Moo for Bar {}
2228
#[unstable_feature_bound(feat_foo)]
2329
impl Foo for Bar {}
2430

31+
32+
#[unstable(feature = "feat_foo", issue = "none" )]
33+
#[unstable_feature_bound(feat_foo, feat_bar)]
34+
impl Boo for Bar {}
35+
2536
fn main() {}

tests/ui/internal/unstable-feature-bound-no-effect.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: an `#[unstable]` annotation here has no effect
2-
--> $DIR/unstable-feature-bound-no-effect.rs:17:1
2+
--> $DIR/unstable-feature-bound-no-effect.rs:23:1
33
|
44
LL | #[unstable(feature = "feat_moo", issue = "none" )]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)