diff --git a/src/test/ui/box/issue-82446.rs b/src/test/ui/box/issue-82446.rs new file mode 100644 index 0000000000000..2960f7fbc2121 --- /dev/null +++ b/src/test/ui/box/issue-82446.rs @@ -0,0 +1,15 @@ +// https://github.com/rust-lang/rust/issues/82446 +// Spurious 'help: store this in the heap' regression test +trait MyTrait {} + +struct Foo { + val: Box +} + +fn make_it(val: &Box) { + Foo { + val //~ ERROR [E0308] + }; +} + +fn main() {} diff --git a/src/test/ui/box/issue-82446.stderr b/src/test/ui/box/issue-82446.stderr new file mode 100644 index 0000000000000..0374737957e48 --- /dev/null +++ b/src/test/ui/box/issue-82446.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/issue-82446.rs:11:9 + | +LL | val + | ^^^ expected struct `Box`, found reference + | + = note: expected struct `Box<(dyn MyTrait + 'static)>` + found reference `&Box<(dyn MyTrait + 'static)>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`.