about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-01-15 11:14:05 -0800
committerEsteban Küber <esteban@kuber.com.ar>2020-01-16 09:49:14 -0800
commitd7a62124018ce8438caeedca203d39997f130b49 (patch)
tree1bbf6438d05290a84c4b8114fb99175edbc6eaf4 /src/test
parentc305ac31c09fdd5078fa0e69e718b4da10d9e354 (diff)
downloadrust-d7a62124018ce8438caeedca203d39997f130b49.tar.gz
rust-d7a62124018ce8438caeedca203d39997f130b49.zip
review comments
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr11
-rw-r--r--src/test/ui/impl-trait/equality.stderr4
-rw-r--r--src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr24
3 files changed, 23 insertions, 16 deletions
diff --git a/src/test/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr b/src/test/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr
index 3d0707c0916..ac101f8f3ce 100644
--- a/src/test/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr
+++ b/src/test/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr
@@ -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
diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr
index ceb32dd4cd3..a399fadbc5d 100644
--- a/src/test/ui/impl-trait/equality.stderr
+++ b/src/test/ui/impl-trait/equality.stderr
@@ -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
diff --git a/src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr b/src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr
index 87daab5ca7a..9859c73b7b1 100644
--- a/src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr
+++ b/src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr
@@ -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