]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Test that cross-borrowing (implicitly converting from `Box<T>` to `&T`) is |
2 | // forbidden when `T` is a trait. | |
223e47cc | 3 | |
1a4d82fc | 4 | struct Foo; |
85aaf69f | 5 | trait Trait { fn foo(&self) {} } |
1a4d82fc | 6 | impl Trait for Foo {} |
223e47cc LB |
7 | |
8 | pub fn main() { | |
dc9dc135 XL |
9 | let x: Box<dyn Trait> = Box::new(Foo); |
10 | let _y: &dyn Trait = x; //~ ERROR E0308 | |
11 | //~| expected type `&dyn Trait` | |
12 | //~| found type `std::boxed::Box<dyn Trait>` | |
223e47cc | 13 | } |