]> git.proxmox.com Git - rustc.git/blame - src/test/ui/cross/cross-borrow-trait.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / cross / cross-borrow-trait.rs
CommitLineData
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 4struct Foo;
85aaf69f 5trait Trait { fn foo(&self) {} }
1a4d82fc 6impl Trait for Foo {}
223e47cc
LB
7
8pub fn main() {
dc9dc135
XL
9 let x: Box<dyn Trait> = Box::new(Foo);
10 let _y: &dyn Trait = x; //~ ERROR E0308
60c5eb7d
XL
11 //~| expected reference `&dyn Trait`
12 //~| found struct `std::boxed::Box<dyn Trait>`
223e47cc 13}