From 0b8f192cfee2f107867e7b9a0b0f781a5cb48787 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Mon, 28 Jun 2021 11:22:47 -0700 Subject: Use multispan suggestions more often * Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often --- .../ui/impl-trait/does-not-live-long-enough.stderr | 2 +- .../dyn-trait-return-should-be-impl-trait.stderr | 72 ++++++++++++---------- 2 files changed, 41 insertions(+), 33 deletions(-) (limited to 'src/test/ui/impl-trait') diff --git a/src/test/ui/impl-trait/does-not-live-long-enough.stderr b/src/test/ui/impl-trait/does-not-live-long-enough.stderr index 468c2f36629..73fd5e8ded3 100644 --- a/src/test/ui/impl-trait/does-not-live-long-enough.stderr +++ b/src/test/ui/impl-trait/does-not-live-long-enough.stderr @@ -14,7 +14,7 @@ LL | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator Box { | -------------- 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 { | -------------- 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 { | -------------- 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 { | -------------- 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 { | -------------- 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 { | -------------- 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 { | -------------- 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 { | -------------- 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 -- cgit 1.4.1-3-g733a5