diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-03-02 11:25:00 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-03-02 11:25:00 -0800 |
| commit | edbbfad88f67b789bca682e4f2c4a58ac4dc81cb (patch) | |
| tree | d79b2a7890e235d3bb51f4b008d699942d7f4455 /src/test/ui | |
| parent | c1d2d83ca3b5155468ab96b09a7c54568449b137 (diff) | |
| download | rust-edbbfad88f67b789bca682e4f2c4a58ac4dc81cb.tar.gz rust-edbbfad88f67b789bca682e4f2c4a58ac4dc81cb.zip | |
Suggest removal of `&` when borrowing macro and appropriate
Fix #58815.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/block-result/issue-5500.stderr | 5 | ||||
| -rw-r--r-- | src/test/ui/diverging-tuple-parts-39485.stderr | 10 | ||||
| -rw-r--r-- | src/test/ui/suggestions/format-borrow.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/suggestions/format-borrow.stderr | 27 |
4 files changed, 45 insertions, 3 deletions
diff --git a/src/test/ui/block-result/issue-5500.stderr b/src/test/ui/block-result/issue-5500.stderr index 0d9c9d8143d..6a13b31fe93 100644 --- a/src/test/ui/block-result/issue-5500.stderr +++ b/src/test/ui/block-result/issue-5500.stderr @@ -4,7 +4,10 @@ error[E0308]: mismatched types LL | fn main() { | - expected `()` because of default return type LL | &panic!() - | ^^^^^^^^^ expected (), found reference + | ^^^^^^^^^ + | | + | expected (), found reference + | help: consider removing the borrow: `panic!()` | = note: expected type `()` found type `&_` diff --git a/src/test/ui/diverging-tuple-parts-39485.stderr b/src/test/ui/diverging-tuple-parts-39485.stderr index c399650d325..3457549a752 100644 --- a/src/test/ui/diverging-tuple-parts-39485.stderr +++ b/src/test/ui/diverging-tuple-parts-39485.stderr @@ -1,13 +1,19 @@ error[E0308]: mismatched types --> $DIR/diverging-tuple-parts-39485.rs:8:5 | -LL | fn g() { - | - help: try adding a return type: `-> &_` LL | &panic!() //~ ERROR mismatched types | ^^^^^^^^^ expected (), found reference | = note: expected type `()` found type `&_` +help: try adding a return type + | +LL | fn g() -> &_ { + | ^^^^^ +help: consider removing the borrow + | +LL | panic!() //~ ERROR mismatched types + | ^^^^^^^^ error[E0308]: mismatched types --> $DIR/diverging-tuple-parts-39485.rs:12:5 diff --git a/src/test/ui/suggestions/format-borrow.rs b/src/test/ui/suggestions/format-borrow.rs new file mode 100644 index 00000000000..63930e7f787 --- /dev/null +++ b/src/test/ui/suggestions/format-borrow.rs @@ -0,0 +1,6 @@ +fn main() { + let a: String = &String::from("a"); + //~^ ERROR mismatched types + let b: String = &format!("b"); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/suggestions/format-borrow.stderr b/src/test/ui/suggestions/format-borrow.stderr new file mode 100644 index 00000000000..44bb11faa7f --- /dev/null +++ b/src/test/ui/suggestions/format-borrow.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> $DIR/format-borrow.rs:2:21 + | +LL | let a: String = &String::from("a"); + | ^^^^^^^^^^^^^^^^^^ + | | + | expected struct `std::string::String`, found reference + | help: consider removing the borrow: `String::from("a")` + | + = note: expected type `std::string::String` + found type `&std::string::String` + +error[E0308]: mismatched types + --> $DIR/format-borrow.rs:4:21 + | +LL | let b: String = &format!("b"); + | ^^^^^^^^^^^^^ + | | + | expected struct `std::string::String`, found reference + | help: consider removing the borrow: `format!("b")` + | + = note: expected type `std::string::String` + found type `&std::string::String` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. |
