Skip to content

Commit ac354cf

Browse files
committed
Add feature gate tests.
1 parent 2dc86a6 commit ac354cf

File tree

5 files changed

+32
-7
lines changed

5 files changed

+32
-7
lines changed

compiler/rustc_feature/src/active.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ declare_features! (
685685

686686
/// Allows upcasting trait objects via supertraits.
687687
/// Trait upcasting is casting, e.g., `dyn Foo -> dyn Bar` where `Foo: Bar`.
688-
(active, trait_upcasting, "1.56.0", Some(65991), None),
688+
(incomplete, trait_upcasting, "1.56.0", Some(65991), None),
689689

690690
// -------------------------------------------------------------------------
691691
// feature-group-end: actual feature gates
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait Foo {}
2+
3+
trait Bar: Foo {}
4+
5+
impl Foo for () {}
6+
7+
impl Bar for () {}
8+
9+
fn main() {
10+
let bar: &dyn Bar = &();
11+
let foo: &dyn Foo = bar;
12+
//~^ ERROR trait upcasting is experimental [E0658]
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0658]: trait upcasting is experimental
2+
--> $DIR/feature-gate-trait_upcasting.rs:11:25
3+
|
4+
LL | let foo: &dyn Foo = bar;
5+
| ^^^
6+
|
7+
= note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information
8+
= help: add `#![feature(trait_upcasting)]` to the crate attributes to enable
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/issues/issue-11515.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ struct Test {
66

77
fn main() {
88
let closure: Box<dyn Fn() + 'static> = Box::new(|| ());
9-
let test = box Test { func: closure }; //~ ERROR mismatched types
9+
let test = box Test { func: closure }; //~ ERROR trait upcasting is experimental [E0658]
1010
}

src/test/ui/issues/issue-11515.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error[E0308]: mismatched types
1+
error[E0658]: trait upcasting is experimental
22
--> $DIR/issue-11515.rs:9:33
33
|
44
LL | let test = box Test { func: closure };
5-
| ^^^^^^^ expected trait `FnMut`, found trait `Fn`
5+
| ^^^^^^^
66
|
7-
= note: expected struct `Box<(dyn FnMut() + 'static)>`
8-
found struct `Box<(dyn Fn() + 'static)>`
7+
= note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information
8+
= help: add `#![feature(trait_upcasting)]` to the crate attributes to enable
99

1010
error: aborting due to previous error
1111

12-
For more information about this error, try `rustc --explain E0308`.
12+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)