about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNoah Lev <camelidcamel@gmail.com>2022-01-18 16:38:06 -0800
committerNoah Lev <camelidcamel@gmail.com>2022-01-18 16:38:06 -0800
commit7c4eca06871f83257f9f503c3a91a8946026133a (patch)
tree56c854c44e1c5b3add0e8289f72c15b0cd9641b2
parent7507fb6306d540a6f07f6f325d25925311b037a2 (diff)
downloadrust-7c4eca06871f83257f9f503c3a91a8946026133a.tar.gz
rust-7c4eca06871f83257f9f503c3a91a8946026133a.zip
Make suggestions verbose
-rw-r--r--compiler/rustc_typeck/src/check/op.rs10
-rw-r--r--src/test/ui/issues/issue-47377.stderr11
-rw-r--r--src/test/ui/issues/issue-47380.stderr11
-rw-r--r--src/test/ui/span/issue-39018.stderr72
-rw-r--r--src/test/ui/str/str-concat-on-double-ref.stderr11
-rw-r--r--src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr15
6 files changed, 84 insertions, 46 deletions
diff --git a/compiler/rustc_typeck/src/check/op.rs b/compiler/rustc_typeck/src/check/op.rs
index 82da66c09e4..81662b752b7 100644
--- a/compiler/rustc_typeck/src/check/op.rs
+++ b/compiler/rustc_typeck/src/check/op.rs
@@ -570,14 +570,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                     err.span_label(op.span, "`+` cannot be used to concatenate two `&str` strings");
                     err.note(str_concat_note);
                     if let hir::ExprKind::AddrOf(_, _, lhs_inner_expr) = lhs_expr.kind {
-                        err.span_suggestion(
+                        err.span_suggestion_verbose(
                             lhs_expr.span.until(lhs_inner_expr.span),
                             rm_borrow_msg,
                             "".to_owned(),
                             Applicability::MachineApplicable
                         );
                     } else {
-                        err.span_suggestion(
+                        err.span_suggestion_verbose(
                             lhs_expr.span.shrink_to_hi(),
                             to_owned_msg,
                             ".to_owned()".to_owned(),
@@ -608,7 +608,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                             lhs_sugg,
                             (rhs_expr.span.shrink_to_lo(), "&".to_owned()),
                         ];
-                        err.multipart_suggestion(sugg_msg, suggestions, Applicability::MachineApplicable);
+                        err.multipart_suggestion_verbose(
+                            sugg_msg,
+                            suggestions,
+                            Applicability::MachineApplicable,
+                        );
                     }
                     IsAssign::Yes => {
                         err.note(str_concat_note);
diff --git a/src/test/ui/issues/issue-47377.stderr b/src/test/ui/issues/issue-47377.stderr
index e4b907070a6..4f0fd948e76 100644
--- a/src/test/ui/issues/issue-47377.stderr
+++ b/src/test/ui/issues/issue-47377.stderr
@@ -2,13 +2,16 @@ error[E0369]: cannot add `&str` to `&str`
   --> $DIR/issue-47377.rs:4:14
    |
 LL |      let _a = b + ", World!";
-   |               --^ ---------- &str
-   |               |||
-   |               ||`+` cannot be used to concatenate two `&str` strings
-   |               |help: create an owned `String` from a string reference: `.to_owned()`
+   |               - ^ ---------- &str
+   |               | |
+   |               | `+` cannot be used to concatenate two `&str` strings
    |               &str
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |      let _a = b.to_owned() + ", World!";
+   |                +++++++++++
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-47380.stderr b/src/test/ui/issues/issue-47380.stderr
index 7ad369fcd0e..b04ac5536c4 100644
--- a/src/test/ui/issues/issue-47380.stderr
+++ b/src/test/ui/issues/issue-47380.stderr
@@ -2,13 +2,16 @@ error[E0369]: cannot add `&str` to `&str`
   --> $DIR/issue-47380.rs:3:35
    |
 LL |     println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!";
-   |                                      --^ ---------- &str
-   |                                      |||
-   |                                      ||`+` cannot be used to concatenate two `&str` strings
-   |                                      |help: create an owned `String` from a string reference: `.to_owned()`
+   |                                      - ^ ---------- &str
+   |                                      | |
+   |                                      | `+` cannot be used to concatenate two `&str` strings
    |                                      &str
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!";
+   |                                       +++++++++++
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr
index 9cfb015e753..e2e7ce1ed18 100644
--- a/src/test/ui/span/issue-39018.stderr
+++ b/src/test/ui/span/issue-39018.stderr
@@ -2,13 +2,16 @@ error[E0369]: cannot add `&str` to `&str`
   --> $DIR/issue-39018.rs:2:22
    |
 LL |     let x = "Hello " + "World!";
-   |             ---------^ -------- &str
-   |             |       ||
-   |             |       |`+` cannot be used to concatenate two `&str` strings
-   |             |       help: create an owned `String` from a string reference: `.to_owned()`
+   |             -------- ^ -------- &str
+   |             |        |
+   |             |        `+` cannot be used to concatenate two `&str` strings
    |             &str
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let x = "Hello ".to_owned() + "World!";
+   |                     +++++++++++
 
 error[E0369]: cannot add `World` to `World`
   --> $DIR/issue-39018.rs:8:26
@@ -57,9 +60,13 @@ LL |     let _ = &a + &b;
    |             |  |
    |             |  `+` cannot be used to concatenate two `&str` strings
    |             &String
-   |             help: remove the borrow to obtain an owned `String`
    |
    = note: string concatenation requires an owned `String` on the left
+help: remove the borrow to obtain an owned `String`
+   |
+LL -     let _ = &a + &b;
+LL +     let _ = a + &b;
+   | 
 
 error[E0369]: cannot add `String` to `&String`
   --> $DIR/issue-39018.rs:27:16
@@ -103,37 +110,46 @@ error[E0369]: cannot add `&String` to `&String`
   --> $DIR/issue-39018.rs:31:15
    |
 LL |     let _ = e + &b;
-   |             --^ -- &String
-   |             |||
-   |             ||`+` cannot be used to concatenate two `&str` strings
-   |             |help: create an owned `String` from a string reference: `.to_owned()`
+   |             - ^ -- &String
+   |             | |
+   |             | `+` cannot be used to concatenate two `&str` strings
    |             &String
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let _ = e.to_owned() + &b;
+   |              +++++++++++
 
 error[E0369]: cannot add `&str` to `&String`
   --> $DIR/issue-39018.rs:32:15
    |
 LL |     let _ = e + d;
-   |             --^ - &str
-   |             |||
-   |             ||`+` cannot be used to concatenate two `&str` strings
-   |             |help: create an owned `String` from a string reference: `.to_owned()`
+   |             - ^ - &str
+   |             | |
+   |             | `+` cannot be used to concatenate two `&str` strings
    |             &String
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let _ = e.to_owned() + d;
+   |              +++++++++++
 
 error[E0369]: cannot add `&&str` to `&String`
   --> $DIR/issue-39018.rs:33:15
    |
 LL |     let _ = e + &d;
-   |             --^ -- &&str
-   |             |||
-   |             ||`+` cannot be used to concatenate two `&str` strings
-   |             |help: create an owned `String` from a string reference: `.to_owned()`
+   |             - ^ -- &&str
+   |             | |
+   |             | `+` cannot be used to concatenate two `&str` strings
    |             &String
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let _ = e.to_owned() + &d;
+   |              +++++++++++
 
 error[E0369]: cannot add `&&str` to `&&str`
   --> $DIR/issue-39018.rs:34:16
@@ -155,25 +171,31 @@ error[E0369]: cannot add `&&str` to `&str`
   --> $DIR/issue-39018.rs:36:15
    |
 LL |     let _ = c + &d;
-   |             --^ -- &&str
-   |             |||
-   |             ||`+` cannot be used to concatenate two `&str` strings
-   |             |help: create an owned `String` from a string reference: `.to_owned()`
+   |             - ^ -- &&str
+   |             | |
+   |             | `+` cannot be used to concatenate two `&str` strings
    |             &str
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let _ = c.to_owned() + &d;
+   |              +++++++++++
 
 error[E0369]: cannot add `&str` to `&str`
   --> $DIR/issue-39018.rs:37:15
    |
 LL |     let _ = c + d;
-   |             --^ - &str
-   |             |||
-   |             ||`+` cannot be used to concatenate two `&str` strings
-   |             |help: create an owned `String` from a string reference: `.to_owned()`
+   |             - ^ - &str
+   |             | |
+   |             | `+` cannot be used to concatenate two `&str` strings
    |             &str
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let _ = c.to_owned() + d;
+   |              +++++++++++
 
 error: aborting due to 14 previous errors
 
diff --git a/src/test/ui/str/str-concat-on-double-ref.stderr b/src/test/ui/str/str-concat-on-double-ref.stderr
index 251bc7ac0ea..bd354679f78 100644
--- a/src/test/ui/str/str-concat-on-double-ref.stderr
+++ b/src/test/ui/str/str-concat-on-double-ref.stderr
@@ -2,13 +2,16 @@ error[E0369]: cannot add `&str` to `&String`
   --> $DIR/str-concat-on-double-ref.rs:4:15
    |
 LL |     let c = a + b;
-   |             --^ - &str
-   |             |||
-   |             ||`+` cannot be used to concatenate two `&str` strings
-   |             |help: create an owned `String` from a string reference: `.to_owned()`
+   |             - ^ - &str
+   |             | |
+   |             | `+` cannot be used to concatenate two `&str` strings
    |             &String
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let c = a.to_owned() + b;
+   |              +++++++++++
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr
index a97ecc4ce15..bf277362dba 100644
--- a/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr
+++ b/src/test/ui/terminal-width/non-1-width-unicode-multiline-label.stderr
@@ -1,14 +1,17 @@
 error[E0369]: cannot add `&str` to `&str`
   --> $DIR/non-1-width-unicode-multiline-label.rs:5:260
    |
-LL | ...྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎...࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
-   |                                                 ---------------^ -------------- &str
-   |                                                 |             ||
-   |                                                 |             |`+` cannot be used to concatenate two `&str` strings
-   |                                                 |             help: create an owned `String` from a string reference: `.to_owned()`
-   |                                                 &str
+LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇...࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
+   |                                                  -------------- ^ -------------- &str
+   |                                                  |              |
+   |                                                  |              `+` cannot be used to concatenate two `&str` strings
+   |                                                  &str
    |
    = note: string concatenation requires an owned `String` on the left
+help: create an owned `String` from a string reference
+   |
+LL |     let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";
+   |                                                                                                                                                                                         +++++++++++
 
 error: aborting due to previous error