Make some suggestions verbose

This commit is contained in:
Esteban Küber
2026-03-14 20:12:18 +00:00
parent 724c1a02e1
commit ff0ce4f5fa
4 changed files with 41 additions and 13 deletions
+6 -3
View File
@@ -1707,7 +1707,8 @@ pub enum TypeErrorAdditionalDiags {
#[suggestion(
"if you meant to write a byte literal, prefix with `b`",
code = "b'{code}'",
applicability = "machine-applicable"
applicability = "machine-applicable",
style = "verbose"
)]
MeantByteLiteral {
#[primary_span]
@@ -1717,7 +1718,8 @@ pub enum TypeErrorAdditionalDiags {
#[suggestion(
"if you meant to write a `char` literal, use single quotes",
code = "'{code}'",
applicability = "machine-applicable"
applicability = "machine-applicable",
style = "verbose"
)]
MeantCharLiteral {
#[primary_span]
@@ -1737,7 +1739,8 @@ pub enum TypeErrorAdditionalDiags {
#[suggestion(
"consider specifying the actual array length",
code = "{length}",
applicability = "maybe-incorrect"
applicability = "maybe-incorrect",
style = "verbose"
)]
ConsiderSpecifyingLength {
#[primary_span]
@@ -3,9 +3,14 @@ error[E0308]: mismatched types
|
LL | const NUMBERS: [u8; 3] = [10, 20];
| ------- ^^^^^^^^ expected an array with a size of 3, found one with a size of 2
| | |
| | help: consider specifying the actual array length: `2`
| |
| expected because of the type of the constant
|
help: consider specifying the actual array length
|
LL - const NUMBERS: [u8; 3] = [10, 20];
LL + const NUMBERS: [u8; 2] = [10, 20];
|
error: aborting due to 1 previous error
+14 -4
View File
@@ -3,18 +3,28 @@ error[E0308]: mismatched types
|
LL | const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
| ----------------------------- ^^^ expected an array with a size of 2, found one with a size of 1
| | |
| | help: consider specifying the actual array length: `1`
| |
| expected because of the type of the constant
|
help: consider specifying the actual array length
|
LL - const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
LL + const BLUB: [i32; 1] = [5];
|
error[E0308]: mismatched types
--> $DIR/const-array-oob-arith.rs:9:44
|
LL | const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
| ----------------------------- ^^^^^^^ expected an array with a size of 1, found one with a size of 2
| | |
| | help: consider specifying the actual array length: `2`
| |
| expected because of the type of the constant
|
help: consider specifying the actual array length
|
LL - const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
LL + const BOO: [i32; 2] = [5, 99];
|
error: aborting due to 2 previous errors
+14 -4
View File
@@ -3,18 +3,28 @@ error[E0308]: mismatched types
|
LL | let wrong: [u8; 3] = [10, 20];
| ------- ^^^^^^^^ expected an array with a size of 3, found one with a size of 2
| | |
| | help: consider specifying the actual array length: `2`
| |
| expected due to this
|
help: consider specifying the actual array length
|
LL - let wrong: [u8; 3] = [10, 20];
LL + let wrong: [u8; 2] = [10, 20];
|
error[E0308]: mismatched types
--> $DIR/array-len-mismatch.rs:9:26
|
LL | let wrong: [u8; 3] = returns_arr();
| ------- ^^^^^^^^^^^^^ expected an array with a size of 3, found one with a size of 2
| | |
| | help: consider specifying the actual array length: `2`
| |
| expected due to this
|
help: consider specifying the actual array length
|
LL - let wrong: [u8; 3] = returns_arr();
LL + let wrong: [u8; 2] = returns_arr();
|
error: aborting due to 2 previous errors