Fix diagnostic suggests adding type [type error]
Fixes #79040 Unresolved questions: Why does this change output the diagnostic twice? Why does the CI fail when the errors are pointed out (UI tests)?
This commit is contained in:
parent
1279b3b923
commit
d9d69212c3
5 changed files with 27 additions and 21 deletions
|
@ -659,7 +659,7 @@ fn infer_placeholder_type(
|
||||||
format!("{}: {}", item_ident, ty),
|
format!("{}: {}", item_ident, ty),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit_unless(matches!(ty.kind(), ty::Error(_)));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let mut diag = bad_placeholder_type(tcx, vec![span]);
|
let mut diag = bad_placeholder_type(tcx, vec![span]);
|
||||||
|
|
5
src/test/ui/79040.rs
Normal file
5
src/test/ui/79040.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
fn main() {
|
||||||
|
const FOO = "hello" + 1;
|
||||||
|
//^~ ERROR cannot add `{integer}` to `&str`
|
||||||
|
println!("{}", FOO);
|
||||||
|
}
|
19
src/test/ui/79040.stderr
Normal file
19
src/test/ui/79040.stderr
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
error[E0369]: cannot add `{integer}` to `&str`
|
||||||
|
--> $DIR/79040.rs:2:25
|
||||||
|
|
|
||||||
|
LL | const FOO = "hello" + 1;
|
||||||
|
| ------- ^ - {integer}
|
||||||
|
| |
|
||||||
|
| &str
|
||||||
|
|
||||||
|
error[E0369]: cannot add `{integer}` to `&str`
|
||||||
|
--> $DIR/79040.rs:2:25
|
||||||
|
|
|
||||||
|
LL | const FOO = "hello" + 1;
|
||||||
|
| ------- ^ - {integer}
|
||||||
|
| |
|
||||||
|
| &str
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0369`.
|
|
@ -14,11 +14,5 @@ LL | const B;
|
||||||
| |
|
| |
|
||||||
| help: provide a definition for the constant: `= <expr>;`
|
| help: provide a definition for the constant: `= <expr>;`
|
||||||
|
|
||||||
error: missing type for `const` item
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/item-free-const-no-body-semantic-fail.rs:6:7
|
|
||||||
|
|
|
||||||
LL | const B;
|
|
||||||
| ^ help: provide a type for the item: `B: [type error]`
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
|
||||||
|
|
||||||
|
|
|
@ -30,17 +30,5 @@ LL | static mut D;
|
||||||
| |
|
| |
|
||||||
| help: provide a definition for the static: `= <expr>;`
|
| help: provide a definition for the static: `= <expr>;`
|
||||||
|
|
||||||
error: missing type for `static` item
|
error: aborting due to 4 previous errors
|
||||||
--> $DIR/item-free-static-no-body-semantic-fail.rs:6:8
|
|
||||||
|
|
|
||||||
LL | static B;
|
|
||||||
| ^ help: provide a type for the item: `B: [type error]`
|
|
||||||
|
|
||||||
error: missing type for `static mut` item
|
|
||||||
--> $DIR/item-free-static-no-body-semantic-fail.rs:10:12
|
|
||||||
|
|
|
||||||
LL | static mut D;
|
|
||||||
| ^ help: provide a type for the item: `D: [type error]`
|
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue