diff options
Diffstat (limited to 'src/test/ui/mismatched_types/suggest-boxed-trait-objects-instead-of-impl-trait.fixed')
-rw-r--r-- | src/test/ui/mismatched_types/suggest-boxed-trait-objects-instead-of-impl-trait.fixed | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/mismatched_types/suggest-boxed-trait-objects-instead-of-impl-trait.fixed b/src/test/ui/mismatched_types/suggest-boxed-trait-objects-instead-of-impl-trait.fixed new file mode 100644 index 000000000..f30feaed0 --- /dev/null +++ b/src/test/ui/mismatched_types/suggest-boxed-trait-objects-instead-of-impl-trait.fixed @@ -0,0 +1,28 @@ +// run-rustfix + +#![allow(dead_code)] + +struct S; +struct Y; + +trait Trait {} + +impl Trait for S {} +impl Trait for Y {} + +fn foo() -> Box<dyn Trait> { + if true { + Box::new(S) + } else { + Box::new(Y) //~ ERROR `if` and `else` have incompatible types + } +} + +fn bar() -> Box<dyn Trait> { + match true { + true => Box::new(S), + false => Box::new(Y), //~ ERROR `match` arms have incompatible types + } +} + +fn main() {} |