mirror of
https://github.com/rust-lang/rust
synced 2024-09-06 01:11:17 +00:00
19 lines
352 B
Rust
19 lines
352 B
Rust
// Check that we do not allow casts or coercions
|
|
// to object unsafe trait objects by ref
|
|
|
|
#![feature(object_safe_for_dispatch)]
|
|
|
|
trait Trait: Sized {}
|
|
|
|
struct S;
|
|
|
|
impl Trait for S {}
|
|
|
|
fn takes_trait(t: &dyn Trait) {}
|
|
|
|
fn main() {
|
|
&S as &dyn Trait; //~ ERROR E0038
|
|
let t: &dyn Trait = &S; //~ ERROR E0038
|
|
takes_trait(&S); //~ ERROR E0038
|
|
}
|