Apply resolve_vars_if_possible to returned types for more accurate suggestions

This commit is contained in:
Esteban Küber 2020-01-24 11:47:54 -08:00
parent 34d51b3378
commit d493dccef7
3 changed files with 12 additions and 8 deletions

View file

@ -59,15 +59,15 @@ fn baw() -> Box<dyn Trait> {
// Suggest using `impl Trait`
fn bat() -> dyn Trait { //~ ERROR E0746
if true {
return 0u32;
return 0;
}
42u32
42
}
fn bay() -> dyn Trait { //~ ERROR E0746
if true {
0u32
0
} else {
42u32
42
}
}

View file

@ -249,7 +249,7 @@ LL | fn bat() -> dyn Trait {
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: return `impl Trait` instead, as all return paths are of type `u32`, which implements `Trait`
help: return `impl Trait` instead, as all return paths are of type `{integer}`, which implements `Trait`
|
LL | fn bat() -> impl Trait {
| ^^^^^^^^^^
@ -261,7 +261,7 @@ LL | fn bay() -> dyn Trait {
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
help: return `impl Trait` instead, as all return paths are of type `u32`, which implements `Trait`
help: return `impl Trait` instead, as all return paths are of type `{integer}`, which implements `Trait`
|
LL | fn bay() -> impl Trait {
| ^^^^^^^^^^