Skip to content

Commit 7d3a6f1

Browse files
address comments
1 parent d9d6921 commit 7d3a6f1

7 files changed

+13
-14
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -659,18 +659,20 @@ fn infer_placeholder_type(
659659
format!("{}: {}", item_ident, ty),
660660
Applicability::MachineApplicable,
661661
)
662-
.emit_unless(matches!(ty.kind(), ty::Error(_)));
662+
.emit_unless(ty.references_error());
663663
}
664664
None => {
665665
let mut diag = bad_placeholder_type(tcx, vec![span]);
666-
if !matches!(ty.kind(), ty::Error(_)) {
666+
667+
if !ty.references_error() {
667668
diag.span_suggestion(
668669
span,
669670
"replace `_` with the correct type",
670671
ty.to_string(),
671672
Applicability::MaybeIncorrect,
672673
);
673674
}
675+
674676
diag.emit();
675677
}
676678
}

src/test/ui/79040.rs

-5
This file was deleted.

src/test/ui/parser/item-free-const-no-body-semantic-fail.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ fn main() {}
44

55
const A: u8; //~ ERROR free constant item without body
66
const B; //~ ERROR free constant item without body
7-
//~^ ERROR missing type for `const` item

src/test/ui/parser/item-free-static-no-body-semantic-fail.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ fn main() {}
44

55
static A: u8; //~ ERROR free static item without body
66
static B; //~ ERROR free static item without body
7-
//~^ ERROR missing type for `static` item
87

98
static mut C: u8; //~ ERROR free static item without body
109
static mut D; //~ ERROR free static item without body
11-
//~^ ERROR missing type for `static mut` item

src/test/ui/parser/item-free-static-no-body-semantic-fail.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ LL | static B;
1515
| help: provide a definition for the static: `= <expr>;`
1616

1717
error: free static item without body
18-
--> $DIR/item-free-static-no-body-semantic-fail.rs:9:1
18+
--> $DIR/item-free-static-no-body-semantic-fail.rs:8:1
1919
|
2020
LL | static mut C: u8;
2121
| ^^^^^^^^^^^^^^^^-
2222
| |
2323
| help: provide a definition for the static: `= <expr>;`
2424

2525
error: free static item without body
26-
--> $DIR/item-free-static-no-body-semantic-fail.rs:10:1
26+
--> $DIR/item-free-static-no-body-semantic-fail.rs:9:1
2727
|
2828
LL | static mut D;
2929
| ^^^^^^^^^^^^-

src/test/ui/typeck/issue-79040.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
const FOO = "hello" + 1; //~ ERROR cannot add `{integer}` to `&str`
3+
//~^ ERROR cannot add `{integer}` to `&str`
4+
println!("{}", FOO);
5+
}

src/test/ui/79040.stderr renamed to src/test/ui/typeck/issue-79040.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0369]: cannot add `{integer}` to `&str`
2-
--> $DIR/79040.rs:2:25
2+
--> $DIR/issue-79040.rs:2:25
33
|
44
LL | const FOO = "hello" + 1;
55
| ------- ^ - {integer}
66
| |
77
| &str
88

99
error[E0369]: cannot add `{integer}` to `&str`
10-
--> $DIR/79040.rs:2:25
10+
--> $DIR/issue-79040.rs:2:25
1111
|
1212
LL | const FOO = "hello" + 1;
1313
| ------- ^ - {integer}

0 commit comments

Comments
 (0)