review comments
This commit is contained in:
parent
c305ac31c0
commit
d7a6212401
8 changed files with 205 additions and 217 deletions
|
|
@ -82,11 +82,18 @@ error[E0746]: return type cannot have an unboxed trait object
|
|||
LL | fn bal() -> dyn Trait {
|
||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= note: if trait `Trait` was object safe, you could return a trait object
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= note: if all the returned values were of the same type you could use `impl Trait` as the return type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= note: you can create a new `enum` with a variant for each returned type
|
||||
help: return a trait object instead
|
||||
|
|
||||
LL | fn bal() -> Box<dyn Trait> {
|
||||
LL | if true {
|
||||
LL | return Box::new(Struct);
|
||||
LL | }
|
||||
LL | Box::new(42)
|
||||
|
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ LL | 0_u32
|
|||
| ^^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
= note: to return `impl Trait`, all returned values must be of the same type
|
||||
= help: you can instead return a trait object using `Box<dyn Foo>`
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= help: you can instead return a trait object using `Box<dyn Foo>`
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
|
||||
error[E0277]: cannot add `impl Foo` to `u32`
|
||||
--> $DIR/equality.rs:24:11
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ LL | 1u32
|
|||
| ^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
= note: to return `impl Trait`, all returned values must be of the same type
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:13:16
|
||||
|
|
@ -29,10 +29,10 @@ LL | return 1u32;
|
|||
| ^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
= note: to return `impl Trait`, all returned values must be of the same type
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:22:9
|
||||
|
|
@ -47,10 +47,10 @@ LL | 1u32
|
|||
| ^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
= note: to return `impl Trait`, all returned values must be of the same type
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
|
||||
error[E0308]: `if` and `else` have incompatible types
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9
|
||||
|
|
@ -77,10 +77,10 @@ LL | _ => 1u32,
|
|||
| ^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
= note: to return `impl Trait`, all returned values must be of the same type
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:45:5
|
||||
|
|
@ -97,10 +97,10 @@ LL | | }
|
|||
| |_____^ expected `i32`, found `u32`
|
||||
|
|
||||
= note: to return `impl Trait`, all returned values must be of the same type
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:59:13
|
||||
|
|
@ -115,10 +115,10 @@ LL | 1u32
|
|||
| ^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
= note: to return `impl Trait`, all returned values must be of the same type
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
|
||||
= help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
|
||||
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
|
||||
= help: alternatively, create a new `enum` with a variant for each returned type
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue