From 935a99a4d1abfb517dfadf11fa29500348cc2b1c Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 12 Jan 2022 22:23:56 -0800 Subject: [PATCH] Add line breaks to make message easier to read --- compiler/rustc_typeck/src/check/op.rs | 6 ++-- src/test/ui/issues/issue-47377.stderr | 4 ++- src/test/ui/issues/issue-47380.stderr | 4 ++- src/test/ui/span/issue-39018.stderr | 28 ++++++++++++++----- .../ui/str/str-concat-on-double-ref.stderr | 4 ++- ...non-1-width-unicode-multiline-label.stderr | 4 ++- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_typeck/src/check/op.rs b/compiler/rustc_typeck/src/check/op.rs index 8bb0613f456f..be1b01ae2949 100644 --- a/compiler/rustc_typeck/src/check/op.rs +++ b/compiler/rustc_typeck/src/check/op.rs @@ -549,9 +549,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { is_assign: IsAssign, op: hir::BinOp, ) -> bool { - let str_concat_note = "String concatenation appends the string on the right to the \ - string on the left and may require reallocation. This \ - requires ownership of the string on the left."; + let str_concat_note = "String concatenation appends the string on the right to the +string on the left and may require reallocation. +This requires ownership of the string on the left."; let rm_borrow_msg = "remove the borrow to obtain an owned `String`"; let to_owned_msg = "use `to_owned()` to create an owned `String` from a string reference"; diff --git a/src/test/ui/issues/issue-47377.stderr b/src/test/ui/issues/issue-47377.stderr index 2e00de840870..97fbb53bd025 100644 --- a/src/test/ui/issues/issue-47377.stderr +++ b/src/test/ui/issues/issue-47377.stderr @@ -7,7 +7,9 @@ LL | let _a = b + ", World!"; | | `+` cannot be used to concatenate two `&str` strings | &str | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let _a = b.to_owned() + ", World!"; diff --git a/src/test/ui/issues/issue-47380.stderr b/src/test/ui/issues/issue-47380.stderr index fec64009444c..7a73d41a0351 100644 --- a/src/test/ui/issues/issue-47380.stderr +++ b/src/test/ui/issues/issue-47380.stderr @@ -7,7 +7,9 @@ LL | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; | | `+` cannot be used to concatenate two `&str` strings | &str | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr index 9054dd931ca2..9e466f3a9a05 100644 --- a/src/test/ui/span/issue-39018.stderr +++ b/src/test/ui/span/issue-39018.stderr @@ -7,7 +7,9 @@ LL | let x = "Hello " + "World!"; | | `+` cannot be used to concatenate two `&str` strings | &str | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let x = "Hello ".to_owned() + "World!"; @@ -62,7 +64,9 @@ LL | let _ = &a + &b; | &String | help: remove the borrow to obtain an owned `String` | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. error[E0369]: cannot add `String` to `&String` --> $DIR/issue-39018.rs:27:16 @@ -111,7 +115,9 @@ LL | let _ = e + &b; | | `+` cannot be used to concatenate two `&str` strings | &String | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let _ = e.to_owned() + &b; @@ -126,7 +132,9 @@ LL | let _ = e + d; | | `+` cannot be used to concatenate two `&str` strings | &String | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let _ = e.to_owned() + d; @@ -141,7 +149,9 @@ LL | let _ = e + &d; | | `+` cannot be used to concatenate two `&str` strings | &String | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let _ = e.to_owned() + &d; @@ -172,7 +182,9 @@ LL | let _ = c + &d; | | `+` cannot be used to concatenate two `&str` strings | &str | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let _ = c.to_owned() + &d; @@ -187,7 +199,9 @@ LL | let _ = c + d; | | `+` cannot be used to concatenate two `&str` strings | &str | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let _ = c.to_owned() + d; 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 e8b5c2bbd851..d239ec0d9fcc 100644 --- a/src/test/ui/str/str-concat-on-double-ref.stderr +++ b/src/test/ui/str/str-concat-on-double-ref.stderr @@ -7,7 +7,9 @@ LL | let c = a + b; | | `+` cannot be used to concatenate two `&str` strings | &String | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let c = a.to_owned() + b; 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 72005a889800..55e993db3d3d 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 @@ -7,7 +7,9 @@ LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔ | | `+` cannot be used to concatenate two `&str` strings | &str | - = note: String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left. + = note: String concatenation appends the string on the right to the + string on the left and may require reallocation. + This requires ownership of the string on the left. help: use `to_owned()` to create an owned `String` from a string reference | LL | let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";