Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
henryboisdequin committed Mar 6, 2021
1 parent d9d6921 commit 7d3a6f1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
6 changes: 4 additions & 2 deletions compiler/rustc_typeck/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,18 +659,20 @@ fn infer_placeholder_type(
format!("{}: {}", item_ident, ty),
Applicability::MachineApplicable,
)
.emit_unless(matches!(ty.kind(), ty::Error(_)));
.emit_unless(ty.references_error());
}
None => {
let mut diag = bad_placeholder_type(tcx, vec![span]);
if !matches!(ty.kind(), ty::Error(_)) {

if !ty.references_error() {
diag.span_suggestion(
span,
"replace `_` with the correct type",
ty.to_string(),
Applicability::MaybeIncorrect,
);
}

diag.emit();
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/test/ui/79040.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ fn main() {}

const A: u8; //~ ERROR free constant item without body
const B; //~ ERROR free constant item without body
//~^ ERROR missing type for `const` item
2 changes: 0 additions & 2 deletions src/test/ui/parser/item-free-static-no-body-semantic-fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ fn main() {}

static A: u8; //~ ERROR free static item without body
static B; //~ ERROR free static item without body
//~^ ERROR missing type for `static` item

static mut C: u8; //~ ERROR free static item without body
static mut D; //~ ERROR free static item without body
//~^ ERROR missing type for `static mut` item
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ LL | static B;
| help: provide a definition for the static: `= <expr>;`

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

error: free static item without body
--> $DIR/item-free-static-no-body-semantic-fail.rs:10:1
--> $DIR/item-free-static-no-body-semantic-fail.rs:9:1
|
LL | static mut D;
| ^^^^^^^^^^^^-
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/typeck/issue-79040.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
const FOO = "hello" + 1; //~ ERROR cannot add `{integer}` to `&str`
//~^ ERROR cannot add `{integer}` to `&str`
println!("{}", FOO);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0369]: cannot add `{integer}` to `&str`
--> $DIR/79040.rs:2:25
--> $DIR/issue-79040.rs:2:25
|
LL | const FOO = "hello" + 1;
| ------- ^ - {integer}
| |
| &str

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

0 comments on commit 7d3a6f1

Please sign in to comment.