Add feature gate tests.
This commit is contained in:
parent
2dc86a6450
commit
ac354cf5ce
5 changed files with 32 additions and 7 deletions
|
@ -685,7 +685,7 @@ declare_features! (
|
||||||
|
|
||||||
/// Allows upcasting trait objects via supertraits.
|
/// Allows upcasting trait objects via supertraits.
|
||||||
/// Trait upcasting is casting, e.g., `dyn Foo -> dyn Bar` where `Foo: Bar`.
|
/// Trait upcasting is casting, e.g., `dyn Foo -> dyn Bar` where `Foo: Bar`.
|
||||||
(active, trait_upcasting, "1.56.0", Some(65991), None),
|
(incomplete, trait_upcasting, "1.56.0", Some(65991), None),
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// feature-group-end: actual feature gates
|
// feature-group-end: actual feature gates
|
||||||
|
|
13
src/test/ui/feature-gates/feature-gate-trait_upcasting.rs
Normal file
13
src/test/ui/feature-gates/feature-gate-trait_upcasting.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
trait Foo {}
|
||||||
|
|
||||||
|
trait Bar: Foo {}
|
||||||
|
|
||||||
|
impl Foo for () {}
|
||||||
|
|
||||||
|
impl Bar for () {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let bar: &dyn Bar = &();
|
||||||
|
let foo: &dyn Foo = bar;
|
||||||
|
//~^ ERROR trait upcasting is experimental [E0658]
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
error[E0658]: trait upcasting is experimental
|
||||||
|
--> $DIR/feature-gate-trait_upcasting.rs:11:25
|
||||||
|
|
|
||||||
|
LL | let foo: &dyn Foo = bar;
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
= note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information
|
||||||
|
= help: add `#![feature(trait_upcasting)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
|
@ -6,5 +6,5 @@ struct Test {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let closure: Box<dyn Fn() + 'static> = Box::new(|| ());
|
let closure: Box<dyn Fn() + 'static> = Box::new(|| ());
|
||||||
let test = box Test { func: closure }; //~ ERROR mismatched types
|
let test = box Test { func: closure }; //~ ERROR trait upcasting is experimental [E0658]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
error[E0308]: mismatched types
|
error[E0658]: trait upcasting is experimental
|
||||||
--> $DIR/issue-11515.rs:9:33
|
--> $DIR/issue-11515.rs:9:33
|
||||||
|
|
|
|
||||||
LL | let test = box Test { func: closure };
|
LL | let test = box Test { func: closure };
|
||||||
| ^^^^^^^ expected trait `FnMut`, found trait `Fn`
|
| ^^^^^^^
|
||||||
|
|
|
|
||||||
= note: expected struct `Box<(dyn FnMut() + 'static)>`
|
= note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information
|
||||||
found struct `Box<(dyn Fn() + 'static)>`
|
= help: add `#![feature(trait_upcasting)]` to the crate attributes to enable
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0308`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue