Auto merge of #10181 - llogiq:test-box-default-10089, r=flip1995

add a test against #10089

This was just an oversight while doing the box default path trimming PR, so I'm adding it rather late than never.

---

changelog: none
This commit is contained in:
bors 2023-01-09 09:49:57 +00:00
commit 46981dca36
3 changed files with 27 additions and 1 deletions

View file

@ -54,4 +54,14 @@ impl Read for ImplementsDefault {
fn issue_9621_dyn_trait() {
let _: Box<dyn Read> = Box::<ImplementsDefault>::default();
issue_10089();
}
fn issue_10089() {
let _closure = || {
#[derive(Default)]
struct WeirdPathed;
let _ = Box::<WeirdPathed>::default();
};
}

View file

@ -54,4 +54,14 @@ impl Read for ImplementsDefault {
fn issue_9621_dyn_trait() {
let _: Box<dyn Read> = Box::new(ImplementsDefault::default());
issue_10089();
}
fn issue_10089() {
let _closure = || {
#[derive(Default)]
struct WeirdPathed;
let _ = Box::new(WeirdPathed::default());
};
}

View file

@ -84,5 +84,11 @@ error: `Box::new(_)` of default value
LL | let _: Box<dyn Read> = Box::new(ImplementsDefault::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<ImplementsDefault>::default()`
error: aborting due to 14 previous errors
error: `Box::new(_)` of default value
--> $DIR/box_default.rs:65:17
|
LL | let _ = Box::new(WeirdPathed::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::<WeirdPathed>::default()`
error: aborting due to 15 previous errors