]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / impl-trait / dyn-trait-return-should-be-impl-trait.stderr
index 00145d10ed7a20acbb0f29adc45b27231f724961..0d4f82bfc153f8170424e57b0af322ed45e45460 100644 (file)
@@ -50,7 +50,7 @@ LL | fn bap() -> Trait { Struct }
 help: use `impl Trait` as the return type, as all return paths are of type `Struct`, which implements `Trait`
    |
 LL | fn bap() -> impl Trait { Struct }
-   |             ^^^^^^^^^^
+   |             ~~~~~~~~~~
 
 error[E0746]: return type cannot have an unboxed trait object
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13
@@ -62,7 +62,7 @@ LL | fn ban() -> dyn Trait { Struct }
 help: use `impl Trait` as the return type, as all return paths are of type `Struct`, which implements `Trait`
    |
 LL | fn ban() -> impl Trait { Struct }
-   |             ^^^^^^^^^^
+   |             ~~~~~~~~~~
 
 error[E0746]: return type cannot have an unboxed trait object
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13
@@ -73,15 +73,15 @@ LL | fn bak() -> dyn Trait { unimplemented!() }
 help: use some type `T` that is `T: Sized` as the return type if all return paths have the same type
    |
 LL | fn bak() -> T { unimplemented!() }
-   |             ^
+   |             ~
 help: use `impl Trait` as the return type if all return paths have the same type but you want to expose only the trait in the signature
    |
 LL | fn bak() -> impl Trait { unimplemented!() }
-   |             ^^^^^^^^^^
+   |             ~~~~~~~~~~
 help: use a boxed trait object if all return paths implement trait `Trait`
    |
 LL | fn bak() -> Box<dyn Trait> { unimplemented!() }
-   |             ^^^^^^^^^^^^^^
+   |             ~~~~~~~~~~~~~~
 
 error[E0746]: return type cannot have an unboxed trait object
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13
@@ -95,11 +95,11 @@ LL | fn bal() -> dyn Trait {
    = note: you can create a new `enum` with a variant for each returned type
 help: return a boxed trait object instead
    |
-LL | fn bal() -> Box<dyn Trait> {
+LL ~ fn bal() -> Box<dyn Trait> {
 LL |     if true {
-LL |         return Box::new(Struct);
+LL ~         return Box::new(Struct);
 LL |     }
-LL |     Box::new(42)
+LL ~     Box::new(42)
    |
 
 error[E0308]: `if` and `else` have incompatible types
@@ -126,11 +126,11 @@ LL | fn bax() -> dyn Trait {
    = note: you can create a new `enum` with a variant for each returned type
 help: return a boxed trait object instead
    |
-LL | fn bax() -> Box<dyn Trait> {
+LL ~ fn bax() -> Box<dyn Trait> {
 LL |     if true {
-LL |         Box::new(Struct)
+LL ~         Box::new(Struct)
 LL |     } else {
-LL |         Box::new(42)
+LL ~         Box::new(42)
    |
 
 error[E0308]: mismatched types
@@ -140,14 +140,15 @@ LL | fn bam() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 LL |     if true {
 LL |         return Struct;
-   |                ^^^^^^
-   |                |
-   |                expected struct `Box`, found struct `Struct`
-   |                help: store this in the heap by calling `Box::new`: `Box::new(Struct)`
+   |                ^^^^^^ expected struct `Box`, found struct `Struct`
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
               found struct `Struct`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |         return Box::new(Struct);
+   |                +++++++++      +
 
 error[E0308]: mismatched types
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:5
@@ -156,14 +157,15 @@ LL | fn bam() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 ...
 LL |     42
-   |     ^^
-   |     |
-   |     expected struct `Box`, found integer
-   |     help: store this in the heap by calling `Box::new`: `Box::new(42)`
+   |     ^^ expected struct `Box`, found integer
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
                 found type `{integer}`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |     Box::new(42)
+   |     +++++++++  +
 
 error[E0308]: mismatched types
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:40:16
@@ -172,14 +174,15 @@ LL | fn baq() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 LL |     if true {
 LL |         return 0;
-   |                ^
-   |                |
-   |                expected struct `Box`, found integer
-   |                help: store this in the heap by calling `Box::new`: `Box::new(0)`
+   |                ^ expected struct `Box`, found integer
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
                 found type `{integer}`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |         return Box::new(0);
+   |                +++++++++ +
 
 error[E0308]: mismatched types
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:5
@@ -188,14 +191,15 @@ LL | fn baq() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 ...
 LL |     42
-   |     ^^
-   |     |
-   |     expected struct `Box`, found integer
-   |     help: store this in the heap by calling `Box::new`: `Box::new(42)`
+   |     ^^ expected struct `Box`, found integer
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
                 found type `{integer}`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |     Box::new(42)
+   |     +++++++++  +
 
 error[E0308]: mismatched types
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:46:9
@@ -204,14 +208,15 @@ LL | fn baz() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 LL |     if true {
 LL |         Struct
-   |         ^^^^^^
-   |         |
-   |         expected struct `Box`, found struct `Struct`
-   |         help: store this in the heap by calling `Box::new`: `Box::new(Struct)`
+   |         ^^^^^^ expected struct `Box`, found struct `Struct`
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
               found struct `Struct`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |         Box::new(Struct)
+   |         +++++++++      +
 
 error[E0308]: mismatched types
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9
@@ -220,14 +225,15 @@ LL | fn baz() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 ...
 LL |         42
-   |         ^^
-   |         |
-   |         expected struct `Box`, found integer
-   |         help: store this in the heap by calling `Box::new`: `Box::new(42)`
+   |         ^^ expected struct `Box`, found integer
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
                 found type `{integer}`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |         Box::new(42)
+   |         +++++++++  +
 
 error[E0308]: mismatched types
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:53:9
@@ -236,14 +242,15 @@ LL | fn baw() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 LL |     if true {
 LL |         0
-   |         ^
-   |         |
-   |         expected struct `Box`, found integer
-   |         help: store this in the heap by calling `Box::new`: `Box::new(0)`
+   |         ^ expected struct `Box`, found integer
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
                 found type `{integer}`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |         Box::new(0)
+   |         +++++++++ +
 
 error[E0308]: mismatched types
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9
@@ -252,14 +259,15 @@ LL | fn baw() -> Box<dyn Trait> {
    |             -------------- expected `Box<(dyn Trait + 'static)>` because of return type
 ...
 LL |         42
-   |         ^^
-   |         |
-   |         expected struct `Box`, found integer
-   |         help: store this in the heap by calling `Box::new`: `Box::new(42)`
+   |         ^^ expected struct `Box`, found integer
    |
    = note: expected struct `Box<(dyn Trait + 'static)>`
                 found type `{integer}`
    = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
+help: store this in the heap by calling `Box::new`
+   |
+LL |         Box::new(42)
+   |         +++++++++  +
 
 error[E0746]: return type cannot have an unboxed trait object
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:60:13
@@ -271,7 +279,7 @@ LL | fn bat() -> dyn Trait {
 help: use `impl Trait` as the return type, as all return paths are of type `{integer}`, which implements `Trait`
    |
 LL | fn bat() -> impl Trait {
-   |             ^^^^^^^^^^
+   |             ~~~~~~~~~~
 
 error[E0746]: return type cannot have an unboxed trait object
   --> $DIR/dyn-trait-return-should-be-impl-trait.rs:66:13
@@ -283,7 +291,7 @@ LL | fn bay() -> dyn Trait {
 help: use `impl Trait` as the return type, as all return paths are of type `{integer}`, which implements `Trait`
    |
 LL | fn bay() -> impl Trait {
-   |             ^^^^^^^^^^
+   |             ~~~~~~~~~~
 
 error: aborting due to 20 previous errors