Skip to content

Commit 0674eca

Browse files
committed
Make Diag::multipart_suggestions always verbose
1 parent 7dfc3e9 commit 0674eca

24 files changed

+187
-110
lines changed

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
11651165
self.push_suggestion(CodeSuggestion {
11661166
substitutions,
11671167
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
1168-
style: SuggestionStyle::ShowCode,
1168+
style: SuggestionStyle::ShowAlways,
11691169
applicability,
11701170
});
11711171
self

tests/ui/derives/deriving-copyclone.stderr

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ error[E0277]: the trait bound `B<C>: Copy` is not satisfied
22
--> $DIR/deriving-copyclone.rs:31:26
33
|
44
LL | is_copy(B { a: 1, b: C });
5-
| ------- ^
6-
| | |
7-
| | the trait `Copy` is not implemented for `B<C>`
8-
| | help: consider borrowing here: `&`
5+
| ------- ^ the trait `Copy` is not implemented for `B<C>`
6+
| |
97
| required by a bound introduced by this call
108
|
119
note: required for `B<C>` to implement `Copy`
@@ -18,15 +16,17 @@ note: required by a bound in `is_copy`
1816
|
1917
LL | fn is_copy<T: Copy>(_: T) {}
2018
| ^^^^ required by this bound in `is_copy`
19+
help: consider borrowing here
20+
|
21+
LL | is_copy(B { a: 1, b: &C });
22+
| +
2123

2224
error[E0277]: the trait bound `B<C>: Clone` is not satisfied
2325
--> $DIR/deriving-copyclone.rs:32:27
2426
|
2527
LL | is_clone(B { a: 1, b: C });
26-
| -------- ^
27-
| | |
28-
| | the trait `Clone` is not implemented for `B<C>`
29-
| | help: consider borrowing here: `&`
28+
| -------- ^ the trait `Clone` is not implemented for `B<C>`
29+
| |
3030
| required by a bound introduced by this call
3131
|
3232
note: required for `B<C>` to implement `Clone`
@@ -39,15 +39,17 @@ note: required by a bound in `is_clone`
3939
|
4040
LL | fn is_clone<T: Clone>(_: T) {}
4141
| ^^^^^ required by this bound in `is_clone`
42+
help: consider borrowing here
43+
|
44+
LL | is_clone(B { a: 1, b: &C });
45+
| +
4246

4347
error[E0277]: the trait bound `B<D>: Copy` is not satisfied
4448
--> $DIR/deriving-copyclone.rs:35:26
4549
|
4650
LL | is_copy(B { a: 1, b: D });
47-
| ------- ^
48-
| | |
49-
| | the trait `Copy` is not implemented for `B<D>`
50-
| | help: consider borrowing here: `&`
51+
| ------- ^ the trait `Copy` is not implemented for `B<D>`
52+
| |
5153
| required by a bound introduced by this call
5254
|
5355
note: required for `B<D>` to implement `Copy`
@@ -60,6 +62,10 @@ note: required by a bound in `is_copy`
6062
|
6163
LL | fn is_copy<T: Copy>(_: T) {}
6264
| ^^^^ required by this bound in `is_copy`
65+
help: consider borrowing here
66+
|
67+
LL | is_copy(B { a: 1, b: &D });
68+
| +
6369

6470
error: aborting due to 3 previous errors
6571

tests/ui/for/issue-20605.current.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
22
--> $DIR/issue-20605.rs:6:17
33
|
44
LL | for item in *things { *item = 0 }
5-
| -^^^^^^
6-
| |
7-
| the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
8-
| help: consider mutably borrowing here: `&mut`
5+
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
96
|
107
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
118
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`
9+
help: consider mutably borrowing here
10+
|
11+
LL | for item in &mut *things { *item = 0 }
12+
| ++++
1213

1314
error: aborting due to 1 previous error
1415

tests/ui/for/issue-20605.next.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
22
--> $DIR/issue-20605.rs:6:17
33
|
44
LL | for item in *things { *item = 0 }
5-
| -^^^^^^
6-
| |
7-
| the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
8-
| help: consider mutably borrowing here: `&mut`
5+
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
96
|
107
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
118
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`
9+
help: consider mutably borrowing here
10+
|
11+
LL | for item in &mut *things { *item = 0 }
12+
| ++++
1213

1314
error: aborting due to 1 previous error
1415

tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ error[E0308]: mismatched types
44
LL | async fn woopsie_async(&self) -> String {
55
| ------ expected `String` because of return type
66
LL | 42
7-
| ^^- help: try using a conversion method: `.to_string()`
8-
| |
9-
| expected `String`, found integer
7+
| ^^ expected `String`, found integer
8+
|
9+
help: try using a conversion method
10+
|
11+
LL | 42.to_string()
12+
| ++++++++++++
1013

1114
error: aborting due to 1 previous error
1215

tests/ui/inference/deref-suggestion.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ error[E0308]: mismatched types
22
--> $DIR/deref-suggestion.rs:8:9
33
|
44
LL | foo(s);
5-
| --- ^- help: try using a conversion method: `.to_string()`
6-
| | |
7-
| | expected `String`, found `&String`
5+
| --- ^ expected `String`, found `&String`
6+
| |
87
| arguments to this function are incorrect
98
|
109
note: function defined here
1110
--> $DIR/deref-suggestion.rs:5:4
1211
|
1312
LL | fn foo(_: String) {}
1413
| ^^^ ---------
14+
help: try using a conversion method
15+
|
16+
LL | foo(s.to_string());
17+
| ++++++++++++
1518

1619
error[E0308]: mismatched types
1720
--> $DIR/deref-suggestion.rs:14:10

tests/ui/repeat-expr/typo-in-repeat-expr-issue-80173.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ error[E0308]: mismatched types
3838
--> $DIR/typo-in-repeat-expr-issue-80173.rs:32:29
3939
|
4040
LL | let e = [String::new(), 10];
41-
| ^^- help: try using a conversion method: `.to_string()`
42-
| |
43-
| expected `String`, found integer
41+
| ^^ expected `String`, found integer
42+
|
43+
help: try using a conversion method
44+
|
45+
LL | let e = [String::new(), 10.to_string()];
46+
| ++++++++++++
4447

4548
error[E0308]: mismatched types
4649
--> $DIR/typo-in-repeat-expr-issue-80173.rs:36:19

tests/ui/static/bad-const-type.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0308]: mismatched types
22
--> $DIR/bad-const-type.rs:1:20
33
|
44
LL | static i: String = 10;
5-
| ^^- help: try using a conversion method: `.to_string()`
6-
| |
7-
| expected `String`, found integer
5+
| ^^ expected `String`, found integer
6+
|
7+
help: try using a conversion method
8+
|
9+
LL | static i: String = 10.to_string();
10+
| ++++++++++++
811

912
error: aborting due to 1 previous error
1013

tests/ui/suggestions/imm-ref-trait-object-literal.stderr

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ error[E0277]: the trait bound `S: Trait` is not satisfied
2121
--> $DIR/imm-ref-trait-object-literal.rs:13:7
2222
|
2323
LL | foo(s);
24-
| --- ^
25-
| | |
26-
| | the trait `Trait` is not implemented for `S`
27-
| | help: consider mutably borrowing here: `&mut`
24+
| --- ^ the trait `Trait` is not implemented for `S`
25+
| |
2826
| required by a bound introduced by this call
2927
|
3028
note: required by a bound in `foo`
3129
--> $DIR/imm-ref-trait-object-literal.rs:7:11
3230
|
3331
LL | fn foo<X: Trait>(_: X) {}
3432
| ^^^^^ required by this bound in `foo`
33+
help: consider mutably borrowing here
34+
|
35+
LL | foo(&mut s);
36+
| ++++
3537

3638
error: aborting due to 2 previous errors
3739

tests/ui/suggestions/issue-104961.stderr

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ error[E0277]: the trait bound `String: Pattern` is not satisfied
1818
--> $DIR/issue-104961.rs:9:19
1919
|
2020
LL | x.starts_with("hi".to_string())
21-
| ----------- -^^^^^^^^^^^^^^^
22-
| | |
23-
| | the trait `Pattern` is not implemented for `String`
24-
| | help: consider borrowing here: `&`
21+
| ----------- ^^^^^^^^^^^^^^^^ the trait `Pattern` is not implemented for `String`
22+
| |
2523
| required by a bound introduced by this call
2624
|
2725
= note: required for `String` to implement `Pattern`
2826
note: required by a bound in `core::str::<impl str>::starts_with`
2927
--> $SRC_DIR/core/src/str/mod.rs:LL:COL
28+
help: consider borrowing here
29+
|
30+
LL | x.starts_with(&"hi".to_string())
31+
| +
3032

3133
error: aborting due to 2 previous errors
3234

0 commit comments

Comments
 (0)