Skip to content

Commit

Permalink
add a test against rust-lang#100898
Browse files Browse the repository at this point in the history
  • Loading branch information
llogiq committed Jan 8, 2023
1 parent cf1d3d0 commit d23dce5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/ui/box_default.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
}
10 changes: 10 additions & 0 deletions tests/ui/box_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
};
}
8 changes: 7 additions & 1 deletion tests/ui/box_default.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d23dce5

Please sign in to comment.