Change:
Reproducible with stable and nightly compilers. : : Maybe this is a duplicated of but I'm not sure as the example there is more complex. : <details<summary<strongBacktrace</strong</summary<p</p</details<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
Regressed in 1.52.0. The error in 1.51.0 wasn't so great either though, but at least it didn't ICE:
Regression in nightly-2021-03-08 (too long ago to get build artifacts per commit). That's the commit range .... Possibly related to an interaction between (which seems to have landed in that commit range) and dtorck?
claim
Assigning priority as discussed in the of the Prioritization Working Group. label -I-prioritize +P-high

Discussion:
// us to improve in typeck so we do that now. match tcx.sess.diagnostic().steal_diagnostic(span, StashKey::ItemNoType) { Some(mut err) => { <del> // The parser provided a sub-optimal `HasPlaceholders` suggestion for the type. // We are typeck and have the real type, so remove that and suggest the actual type. err.suggestions.clear(); // Suggesting unnameable types won't help. let mut mk_nameable = MakeNameable::new(tcx); let ty = mk_nameable.fold_ty(ty); let sugg_ty = if mk_nameable.success { Some(ty) } else { None }; if let Some(sugg_ty) = sugg_ty { err.span_suggestion( span, &format!("provide a type for the {item}", item = kind), format!("{}: {}", item_ident, sugg_ty), Applicability::MachineApplicable, ); } else { err.span_note( tcx.hir().body(body_id).value.span, &format!("however, the inferred type `{}` cannot be named", ty.to_string()), ); </del> <ins> if !ty.references_error() { // The parser provided a sub-optimal `HasPlaceholders` suggestion for the type. // We are typeck and have the real type, so remove that and suggest the actual type. err.suggestions.clear(); // Suggesting unnameable types won't help. let mut mk_nameable = MakeNameable::new(tcx); let ty = mk_nameable.fold_ty(ty); let sugg_ty = if mk_nameable.success { Some(ty) } else { None }; if let Some(sugg_ty) = sugg_ty { err.span_suggestion( span, &format!("provide a type for the {item}", item = kind), format!("{}: {}", item_ident, sugg_ty), Applicability::MachineApplicable, ); } else { err.span_note( tcx.hir().body(body_id).value.span, &format!("however, the inferred type `{}` cannot be named", ty.to_string()), ); } </ins> } <del> err.emit_unless(ty.references_error()); </del> <ins> err.emit(); </ins> } None => { let mut diag = bad_placeholder_type(tcx, vec![span], kind);

<ins> fn main() { const EMPTY_ARRAY = []; //~^ missing type for `const` item } </ins>

<ins> error: missing type for `const` item --> $DIR/issue-89574.rs:2:11 | LL |     const EMPTY_ARRAY = []; |           ^^^^^^^^^^^ help: provide a type for the item: `EMPTY_ARRAY: <type>` error: aborting due to previous error </ins>

const A: u8; //~ ERROR free constant item without body const B; //~ ERROR free constant item without body <ins> //~^ ERROR missing type for `const` item </ins>

|        | |        help: provide a definition for the constant: `= <expr>;` <del> error: aborting due to 2 previous errors </del> <ins> error: missing type for `const` item --> $DIR/item-free-const-no-body-semantic-fail.rs:6:7 | LL | const B; |       ^ help: provide a type for the item: `B: <type>` error: aborting due to 3 previous errors </ins>

static A: u8; //~ ERROR free static item without body static B; //~ ERROR free static item without body <ins> //~^ ERROR missing type for `static` item </ins> static mut C: u8; //~ ERROR free static item without body static mut D; //~ ERROR free static item without body <ins> //~^ ERROR missing type for `static mut` item </ins>

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

|                 help: provide a definition for the static: `= <expr>;` error: free static item without body <del> --> $DIR/item-free-static-no-body-semantic-fail.rs:9:1 </del> <ins> --> $DIR/item-free-static-no-body-semantic-fail.rs:10:1 </ins> | LL | static mut D; | ^^^^^^^^^^^^- |             | |             help: provide a definition for the static: `= <expr>;` <del> error: aborting due to 4 previous errors </del> <ins> error: missing type for `static` item --> $DIR/item-free-static-no-body-semantic-fail.rs:6:8 | LL | static B; |        ^ help: provide a type for the item: `B: <type>` 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: aborting due to 6 previous errors </ins>

fn main() { const FOO = "hello" + 1; //~ ERROR cannot add `{integer}` to `&str` <del> //~^ ERROR cannot add `{integer}` to `&str` </del> <ins> //~^ missing type for `const` item </ins> println!("{}", FOO); }

|                 | |                 &str <del> error[E0369]: cannot add `{integer}` to `&str` --> $DIR/issue-79040.rs:2:25 </del> <ins> error: missing type for `const` item --> $DIR/issue-79040.rs:2:11 </ins> | LL |     const FOO = "hello" + 1; <del> |                 ------- ^ - {integer} |                 | |                 &str </del> <ins> |           ^^^ help: provide a type for the item: `FOO: <type>` </ins> error: aborting due to 2 previous errors