diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 5746c28a2ab2..a128f8d31a13 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -1165,7 +1165,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { self.push_suggestion(CodeSuggestion { substitutions, msg: self.subdiagnostic_message_to_diagnostic_message(msg), - style: SuggestionStyle::ShowCode, + style: SuggestionStyle::ShowAlways, applicability, }); self diff --git a/tests/ui/derives/deriving-copyclone.stderr b/tests/ui/derives/deriving-copyclone.stderr index 707a63ba28d2..befff8802804 100644 --- a/tests/ui/derives/deriving-copyclone.stderr +++ b/tests/ui/derives/deriving-copyclone.stderr @@ -2,10 +2,8 @@ error[E0277]: the trait bound `B: Copy` is not satisfied --> $DIR/deriving-copyclone.rs:31:26 | LL | is_copy(B { a: 1, b: C }); - | ------- ^ - | | | - | | the trait `Copy` is not implemented for `B` - | | help: consider borrowing here: `&` + | ------- ^ the trait `Copy` is not implemented for `B` + | | | required by a bound introduced by this call | note: required for `B` to implement `Copy` @@ -18,15 +16,17 @@ note: required by a bound in `is_copy` | LL | fn is_copy(_: T) {} | ^^^^ required by this bound in `is_copy` +help: consider borrowing here + | +LL | is_copy(B { a: 1, b: &C }); + | + error[E0277]: the trait bound `B: Clone` is not satisfied --> $DIR/deriving-copyclone.rs:32:27 | LL | is_clone(B { a: 1, b: C }); - | -------- ^ - | | | - | | the trait `Clone` is not implemented for `B` - | | help: consider borrowing here: `&` + | -------- ^ the trait `Clone` is not implemented for `B` + | | | required by a bound introduced by this call | note: required for `B` to implement `Clone` @@ -39,15 +39,17 @@ note: required by a bound in `is_clone` | LL | fn is_clone(_: T) {} | ^^^^^ required by this bound in `is_clone` +help: consider borrowing here + | +LL | is_clone(B { a: 1, b: &C }); + | + error[E0277]: the trait bound `B: Copy` is not satisfied --> $DIR/deriving-copyclone.rs:35:26 | LL | is_copy(B { a: 1, b: D }); - | ------- ^ - | | | - | | the trait `Copy` is not implemented for `B` - | | help: consider borrowing here: `&` + | ------- ^ the trait `Copy` is not implemented for `B` + | | | required by a bound introduced by this call | note: required for `B` to implement `Copy` @@ -60,6 +62,10 @@ note: required by a bound in `is_copy` | LL | fn is_copy(_: T) {} | ^^^^ required by this bound in `is_copy` +help: consider borrowing here + | +LL | is_copy(B { a: 1, b: &D }); + | + error: aborting due to 3 previous errors diff --git a/tests/ui/for/issue-20605.current.stderr b/tests/ui/for/issue-20605.current.stderr index 289dca289aeb..1a66cb414649 100644 --- a/tests/ui/for/issue-20605.current.stderr +++ b/tests/ui/for/issue-20605.current.stderr @@ -2,13 +2,14 @@ error[E0277]: `dyn Iterator` is not an iterator --> $DIR/issue-20605.rs:6:17 | LL | for item in *things { *item = 0 } - | -^^^^^^ - | | - | the trait `IntoIterator` is not implemented for `dyn Iterator` - | help: consider mutably borrowing here: `&mut` + | ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator` | = note: the trait bound `dyn Iterator: IntoIterator` is not satisfied = note: required for `dyn Iterator` to implement `IntoIterator` +help: consider mutably borrowing here + | +LL | for item in &mut *things { *item = 0 } + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/for/issue-20605.next.stderr b/tests/ui/for/issue-20605.next.stderr index 289dca289aeb..1a66cb414649 100644 --- a/tests/ui/for/issue-20605.next.stderr +++ b/tests/ui/for/issue-20605.next.stderr @@ -2,13 +2,14 @@ error[E0277]: `dyn Iterator` is not an iterator --> $DIR/issue-20605.rs:6:17 | LL | for item in *things { *item = 0 } - | -^^^^^^ - | | - | the trait `IntoIterator` is not implemented for `dyn Iterator` - | help: consider mutably borrowing here: `&mut` + | ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator` | = note: the trait bound `dyn Iterator: IntoIterator` is not satisfied = note: required for `dyn Iterator` to implement `IntoIterator` +help: consider mutably borrowing here + | +LL | for item in &mut *things { *item = 0 } + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr index 856c92217b92..4c429624e0bf 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr @@ -4,9 +4,12 @@ error[E0308]: mismatched types LL | async fn woopsie_async(&self) -> String { | ------ expected `String` because of return type LL | 42 - | ^^- help: try using a conversion method: `.to_string()` - | | - | expected `String`, found integer + | ^^ expected `String`, found integer + | +help: try using a conversion method + | +LL | 42.to_string() + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/inference/deref-suggestion.stderr b/tests/ui/inference/deref-suggestion.stderr index 8ccd28198afc..027902a9f31e 100644 --- a/tests/ui/inference/deref-suggestion.stderr +++ b/tests/ui/inference/deref-suggestion.stderr @@ -2,9 +2,8 @@ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:8:9 | LL | foo(s); - | --- ^- help: try using a conversion method: `.to_string()` - | | | - | | expected `String`, found `&String` + | --- ^ expected `String`, found `&String` + | | | arguments to this function are incorrect | note: function defined here @@ -12,6 +11,10 @@ note: function defined here | LL | fn foo(_: String) {} | ^^^ --------- +help: try using a conversion method + | +LL | foo(s.to_string()); + | ++++++++++++ error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:14:10 diff --git a/tests/ui/repeat-expr/typo-in-repeat-expr-issue-80173.stderr b/tests/ui/repeat-expr/typo-in-repeat-expr-issue-80173.stderr index ce2022374f7f..9f31a731fed7 100644 --- a/tests/ui/repeat-expr/typo-in-repeat-expr-issue-80173.stderr +++ b/tests/ui/repeat-expr/typo-in-repeat-expr-issue-80173.stderr @@ -38,9 +38,12 @@ error[E0308]: mismatched types --> $DIR/typo-in-repeat-expr-issue-80173.rs:32:29 | LL | let e = [String::new(), 10]; - | ^^- help: try using a conversion method: `.to_string()` - | | - | expected `String`, found integer + | ^^ expected `String`, found integer + | +help: try using a conversion method + | +LL | let e = [String::new(), 10.to_string()]; + | ++++++++++++ error[E0308]: mismatched types --> $DIR/typo-in-repeat-expr-issue-80173.rs:36:19 diff --git a/tests/ui/static/bad-const-type.stderr b/tests/ui/static/bad-const-type.stderr index 807cd2f7a25a..8573a11ef291 100644 --- a/tests/ui/static/bad-const-type.stderr +++ b/tests/ui/static/bad-const-type.stderr @@ -2,9 +2,12 @@ error[E0308]: mismatched types --> $DIR/bad-const-type.rs:1:20 | LL | static i: String = 10; - | ^^- help: try using a conversion method: `.to_string()` - | | - | expected `String`, found integer + | ^^ expected `String`, found integer + | +help: try using a conversion method + | +LL | static i: String = 10.to_string(); + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/imm-ref-trait-object-literal.stderr b/tests/ui/suggestions/imm-ref-trait-object-literal.stderr index 62f1c03e9aaa..4b770d572c56 100644 --- a/tests/ui/suggestions/imm-ref-trait-object-literal.stderr +++ b/tests/ui/suggestions/imm-ref-trait-object-literal.stderr @@ -21,10 +21,8 @@ error[E0277]: the trait bound `S: Trait` is not satisfied --> $DIR/imm-ref-trait-object-literal.rs:13:7 | LL | foo(s); - | --- ^ - | | | - | | the trait `Trait` is not implemented for `S` - | | help: consider mutably borrowing here: `&mut` + | --- ^ the trait `Trait` is not implemented for `S` + | | | required by a bound introduced by this call | note: required by a bound in `foo` @@ -32,6 +30,10 @@ note: required by a bound in `foo` | LL | fn foo(_: X) {} | ^^^^^ required by this bound in `foo` +help: consider mutably borrowing here + | +LL | foo(&mut s); + | ++++ error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/issue-104961.stderr b/tests/ui/suggestions/issue-104961.stderr index 6f02c125cadf..0d229e6dada5 100644 --- a/tests/ui/suggestions/issue-104961.stderr +++ b/tests/ui/suggestions/issue-104961.stderr @@ -18,15 +18,17 @@ error[E0277]: the trait bound `String: Pattern` is not satisfied --> $DIR/issue-104961.rs:9:19 | LL | x.starts_with("hi".to_string()) - | ----------- -^^^^^^^^^^^^^^^ - | | | - | | the trait `Pattern` is not implemented for `String` - | | help: consider borrowing here: `&` + | ----------- ^^^^^^^^^^^^^^^^ the trait `Pattern` is not implemented for `String` + | | | required by a bound introduced by this call | = note: required for `String` to implement `Pattern` note: required by a bound in `core::str::::starts_with` --> $SRC_DIR/core/src/str/mod.rs:LL:COL +help: consider borrowing here + | +LL | x.starts_with(&"hi".to_string()) + | + error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/issue-52820.stderr b/tests/ui/suggestions/issue-52820.stderr index a67d75014171..de2c9542f611 100644 --- a/tests/ui/suggestions/issue-52820.stderr +++ b/tests/ui/suggestions/issue-52820.stderr @@ -13,10 +13,13 @@ error[E0308]: mismatched types --> $DIR/issue-52820.rs:13:17 | LL | brains: guts.clone(), - | ^^^^^-----^^ - | | | - | | help: try using a conversion method: `to_string` - | expected `String`, found `&str` + | ^^^^^^^^^^^^ expected `String`, found `&str` + | +help: try using a conversion method + | +LL - brains: guts.clone(), +LL + brains: guts.to_string(), + | error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/issue-53692.stderr b/tests/ui/suggestions/issue-53692.stderr index 469a538411fb..10ebb30a5b24 100644 --- a/tests/ui/suggestions/issue-53692.stderr +++ b/tests/ui/suggestions/issue-53692.stderr @@ -2,24 +2,31 @@ error[E0308]: mismatched types --> $DIR/issue-53692.rs:7:33 | LL | let items_clone: Vec = ref_items.clone(); - | -------- ^^^^^^^^^^-----^^ - | | | | - | | | help: try using a conversion method: `to_vec` - | | expected `Vec`, found `&[i32]` + | -------- ^^^^^^^^^^^^^^^^^ expected `Vec`, found `&[i32]` + | | | expected due to this | = note: expected struct `Vec` found reference `&[i32]` +help: try using a conversion method + | +LL - let items_clone: Vec = ref_items.clone(); +LL + let items_clone: Vec = ref_items.to_vec(); + | error[E0308]: mismatched types --> $DIR/issue-53692.rs:14:26 | LL | let string: String = s.clone(); - | ------ ^^-----^^ - | | | | - | | | help: try using a conversion method: `to_string` - | | expected `String`, found `&str` + | ------ ^^^^^^^^^ expected `String`, found `&str` + | | | expected due to this + | +help: try using a conversion method + | +LL - let string: String = s.clone(); +LL + let string: String = s.to_string(); + | error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/issue-59819.stderr b/tests/ui/suggestions/issue-59819.stderr index 43acf9549c29..ab91961192ff 100644 --- a/tests/ui/suggestions/issue-59819.stderr +++ b/tests/ui/suggestions/issue-59819.stderr @@ -28,10 +28,14 @@ error[E0308]: mismatched types --> $DIR/issue-59819.rs:34:21 | LL | let g: String = f; - | ------ ^- help: try using a conversion method: `.to_string()` - | | | - | | expected `String`, found `Bar` + | ------ ^ expected `String`, found `Bar` + | | | expected due to this + | +help: try using a conversion method + | +LL | let g: String = f.to_string(); + | ++++++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/issue-62843.stderr b/tests/ui/suggestions/issue-62843.stderr index c3480a8e396e..c3c0360b3a9d 100644 --- a/tests/ui/suggestions/issue-62843.stderr +++ b/tests/ui/suggestions/issue-62843.stderr @@ -2,15 +2,17 @@ error[E0277]: the trait bound `String: Pattern` is not satisfied --> $DIR/issue-62843.rs:4:32 | LL | println!("{:?}", line.find(pattern)); - | ---- -^^^^^^ - | | | - | | the trait `Pattern` is not implemented for `String` - | | help: consider borrowing here: `&` + | ---- ^^^^^^^ the trait `Pattern` is not implemented for `String` + | | | required by a bound introduced by this call | = note: required for `String` to implement `Pattern` note: required by a bound in `core::str::::find` --> $SRC_DIR/core/src/str/mod.rs:LL:COL +help: consider borrowing here + | +LL | println!("{:?}", line.find(&pattern)); + | + error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-83943.stderr b/tests/ui/suggestions/issue-83943.stderr index 1a085368485c..e714a126f4a6 100644 --- a/tests/ui/suggestions/issue-83943.stderr +++ b/tests/ui/suggestions/issue-83943.stderr @@ -6,11 +6,14 @@ LL | | "A".to_string() | | --------------- expected because of this LL | | } else { LL | | "B" - | | ^^^- help: try using a conversion method: `.to_string()` - | | | - | | expected `String`, found `&str` + | | ^^^ expected `String`, found `&str` LL | | }; | |_____- `if` and `else` have incompatible types + | +help: try using a conversion method + | +LL | "B".to_string() + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-84973-2.stderr b/tests/ui/suggestions/issue-84973-2.stderr index 914307008efc..74995a0500ac 100644 --- a/tests/ui/suggestions/issue-84973-2.stderr +++ b/tests/ui/suggestions/issue-84973-2.stderr @@ -2,10 +2,8 @@ error[E0277]: the trait bound `i32: Tr` is not satisfied --> $DIR/issue-84973-2.rs:11:9 | LL | foo(a); - | --- ^ - | | | - | | the trait `Tr` is not implemented for `i32` - | | help: consider mutably borrowing here: `&mut` + | --- ^ the trait `Tr` is not implemented for `i32` + | | | required by a bound introduced by this call | note: required by a bound in `foo` @@ -13,6 +11,10 @@ note: required by a bound in `foo` | LL | fn foo(i: T) {} | ^^ required by this bound in `foo` +help: consider mutably borrowing here + | +LL | foo(&mut a); + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/issue-84973-negative.stderr b/tests/ui/suggestions/issue-84973-negative.stderr index e3e6296890ff..ce838bce09e7 100644 --- a/tests/ui/suggestions/issue-84973-negative.stderr +++ b/tests/ui/suggestions/issue-84973-negative.stderr @@ -17,10 +17,8 @@ error[E0277]: the trait bound `f32: Tr` is not satisfied --> $DIR/issue-84973-negative.rs:11:9 | LL | bar(b); - | --- ^ - | | | - | | the trait `Tr` is not implemented for `f32` - | | help: consider borrowing here: `&` + | --- ^ the trait `Tr` is not implemented for `f32` + | | | required by a bound introduced by this call | note: required by a bound in `bar` @@ -28,6 +26,10 @@ note: required by a bound in `bar` | LL | fn bar(t: T) {} | ^^ required by this bound in `bar` +help: consider borrowing here + | +LL | bar(&b); + | + error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/issue-84973.stderr b/tests/ui/suggestions/issue-84973.stderr index 5ca91c544dbd..c5e1958e030f 100644 --- a/tests/ui/suggestions/issue-84973.stderr +++ b/tests/ui/suggestions/issue-84973.stderr @@ -2,10 +2,8 @@ error[E0277]: the trait bound `Fancy: SomeTrait` is not satisfied --> $DIR/issue-84973.rs:6:24 | LL | let o = Other::new(f); - | ---------- ^ - | | | - | | the trait `SomeTrait` is not implemented for `Fancy` - | | help: consider borrowing here: `&` + | ---------- ^ the trait `SomeTrait` is not implemented for `Fancy` + | | | required by a bound introduced by this call | note: required by a bound in `Other::<'a, G>::new` @@ -16,6 +14,10 @@ LL | G: SomeTrait, LL | { LL | pub fn new(g: G) -> Self { | --- required by a bound in this associated function +help: consider borrowing here + | +LL | let o = Other::new(&f); + | + error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/only-suggest-removal-of-conversion-method-calls.stderr b/tests/ui/suggestions/only-suggest-removal-of-conversion-method-calls.stderr index c721ceb11463..ed94ebd27ffd 100644 --- a/tests/ui/suggestions/only-suggest-removal-of-conversion-method-calls.stderr +++ b/tests/ui/suggestions/only-suggest-removal-of-conversion-method-calls.stderr @@ -5,9 +5,12 @@ LL | fn get_name() -> String { | ------ expected `String` because of return type ... LL | your_name.trim() - | ^^^^^^^^^^^^^^^^- help: try using a conversion method: `.to_string()` - | | - | expected `String`, found `&str` + | ^^^^^^^^^^^^^^^^ expected `String`, found `&str` + | +help: try using a conversion method + | +LL | your_name.trim().to_string() + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-adding-reference-to-trait-assoc-item.stderr b/tests/ui/suggestions/suggest-adding-reference-to-trait-assoc-item.stderr index 146d6705243a..485015a98f2a 100644 --- a/tests/ui/suggestions/suggest-adding-reference-to-trait-assoc-item.stderr +++ b/tests/ui/suggestions/suggest-adding-reference-to-trait-assoc-item.stderr @@ -2,19 +2,23 @@ error[E0277]: the trait bound `&mut usize: Default` is not satisfied --> $DIR/suggest-adding-reference-to-trait-assoc-item.rs:13:9 | LL | foo(Default::default()); - | -^^^^^^^^^^^^^^^^^ - | | - | the trait `Default` is not implemented for `&mut usize` - | help: consider mutably borrowing here: `&mut` + | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `&mut usize` + | +help: consider mutably borrowing here + | +LL | foo(&mut Default::default()); + | ++++ error[E0277]: the trait bound `&usize: Default` is not satisfied --> $DIR/suggest-adding-reference-to-trait-assoc-item.rs:14:9 | LL | bar(Default::default()); - | -^^^^^^^^^^^^^^^^^ - | | - | the trait `Default` is not implemented for `&usize` - | help: consider borrowing here: `&` + | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `&usize` + | +help: consider borrowing here + | +LL | bar(&Default::default()); + | + error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/suggest-imm-mut-trait-implementations.stderr b/tests/ui/suggestions/suggest-imm-mut-trait-implementations.stderr index b3a0c68450e6..f2eb651eaa42 100644 --- a/tests/ui/suggestions/suggest-imm-mut-trait-implementations.stderr +++ b/tests/ui/suggestions/suggest-imm-mut-trait-implementations.stderr @@ -22,10 +22,8 @@ error[E0277]: the trait bound `B: Trait` is not satisfied --> $DIR/suggest-imm-mut-trait-implementations.rs:21:9 | LL | foo(b); - | --- ^ - | | | - | | the trait `Trait` is not implemented for `B` - | | help: consider borrowing here: `&` + | --- ^ the trait `Trait` is not implemented for `B` + | | | required by a bound introduced by this call | note: required by a bound in `foo` @@ -33,15 +31,17 @@ note: required by a bound in `foo` | LL | fn foo(_: X) {} | ^^^^^ required by this bound in `foo` +help: consider borrowing here + | +LL | foo(&b); + | + error[E0277]: the trait bound `C: Trait` is not satisfied --> $DIR/suggest-imm-mut-trait-implementations.rs:22:9 | LL | foo(c); - | --- ^ - | | | - | | the trait `Trait` is not implemented for `C` - | | help: consider mutably borrowing here: `&mut` + | --- ^ the trait `Trait` is not implemented for `C` + | | | required by a bound introduced by this call | note: required by a bound in `foo` @@ -49,6 +49,10 @@ note: required by a bound in `foo` | LL | fn foo(_: X) {} | ^^^^^ required by this bound in `foo` +help: consider mutably borrowing here + | +LL | foo(&mut c); + | ++++ error: aborting due to 3 previous errors diff --git a/tests/ui/switched-expectations.stderr b/tests/ui/switched-expectations.stderr index cc5767474002..e235c2da1f73 100644 --- a/tests/ui/switched-expectations.stderr +++ b/tests/ui/switched-expectations.stderr @@ -2,9 +2,12 @@ error[E0308]: mismatched types --> $DIR/switched-expectations.rs:3:30 | LL | let ref string: String = var; - | ^^^- help: try using a conversion method: `.to_string()` - | | - | expected `String`, found `i32` + | ^^^ expected `String`, found `i32` + | +help: try using a conversion method + | +LL | let ref string: String = var.to_string(); + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr index cc5ca471788d..8f5b937e586a 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -61,10 +61,8 @@ error[E0277]: `dummy2::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:48:13 | LL | is_send(Box::new(TestType)); - | ------- -^^^^^^^^^^^^^^^^^ - | | | - | | the trait `Send` is not implemented for `Unique` - | | help: consider borrowing here: `&` + | ------- ^^^^^^^^^^^^^^^^^^ the trait `Send` is not implemented for `Unique` + | | | required by a bound introduced by this call | = note: the trait bound `Unique: Send` is not satisfied @@ -76,6 +74,10 @@ note: required by a bound in `is_send` | LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` +help: consider borrowing here + | +LL | is_send(&Box::new(TestType)); + | + error[E0277]: `dummy3::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:56:13 diff --git a/tests/ui/typeck/conversion-methods.stderr b/tests/ui/typeck/conversion-methods.stderr index a9b5078ccdde..fa8928f1454c 100644 --- a/tests/ui/typeck/conversion-methods.stderr +++ b/tests/ui/typeck/conversion-methods.stderr @@ -2,28 +2,40 @@ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:5:41 | LL | let _tis_an_instants_play: String = "'Tis a fond Ambush—"; - | ------ ^^^^^^^^^^^^^^^^^^^^^- help: try using a conversion method: `.to_string()` - | | | - | | expected `String`, found `&str` + | ------ ^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `&str` + | | | expected due to this + | +help: try using a conversion method + | +LL | let _tis_an_instants_play: String = "'Tis a fond Ambush—".to_string(); + | ++++++++++++ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:6:40 | LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise"); - | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: try using a conversion method: `.to_path_buf()` - | | | - | | expected `PathBuf`, found `&Path` + | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `PathBuf`, found `&Path` + | | | expected due to this + | +help: try using a conversion method + | +LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise").to_path_buf(); + | ++++++++++++++ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:9:40 | LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here - | ------ ^- help: try using a conversion method: `.to_string()` - | | | - | | expected `String`, found integer + | ------ ^ expected `String`, found integer + | | | expected due to this + | +help: try using a conversion method + | +LL | let _but_should_the_play: String = 2.to_string(); // Perhaps surprisingly, we suggest .to_string() here + | ++++++++++++ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:12:47