]> git.proxmox.com Git - rustc.git/blob - tests/ui/cross/cross-borrow-trait.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / cross / cross-borrow-trait.rs
1 // Test that cross-borrowing (implicitly converting from `Box<T>` to `&T`) is
2 // forbidden when `T` is a trait.
3
4 struct Foo;
5 trait Trait { fn foo(&self) {} }
6 impl Trait for Foo {}
7
8 pub fn main() {
9 let x: Box<dyn Trait> = Box::new(Foo);
10 let _y: &dyn Trait = x; //~ ERROR E0308
11 //~| expected reference `&dyn Trait`
12 //~| found struct `Box<dyn Trait>`
13 }