Part of #154314
There is a possible race for this dcx.try_steal_modify_and_emit_err call:
|
let guar = cx |
|
.dcx() |
|
.try_steal_modify_and_emit_err(ty_span, StashKey::ItemNoType, |err| { |
|
if !ty.references_error() { |
|
// Only suggest adding `:` if it was missing (and suggested by parsing diagnostic). |
|
let colon = if ty_span == item_ident.span.shrink_to_hi() { ":" } else { "" }; |
|
|
|
// 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. |
|
if let Suggestions::Enabled(suggestions) = &mut err.suggestions { |
|
suggestions.clear(); |
|
} |
|
|
|
if let Some(ty) = ty.make_suggestable(tcx, false, None) { |
|
err.span_suggestion( |
|
ty_span, |
|
format!("provide a type for the {kind}"), |
|
with_types_for_suggestion!(format!("{colon} {ty}")), |
|
Applicability::MachineApplicable, |
|
); |
|
} else { |
|
with_forced_trimmed_paths!(err.span_note( |
|
body_span, |
|
format!("however, the inferred type `{ty}` cannot be named"), |
|
)); |
|
} |
|
} |
|
}) |
Such that inferred type for a diagnostic suggestion can vary between different compilations on the parallel front-end.
Part of #154314
There is a possible race for this
dcx.try_steal_modify_and_emit_errcall:rust/compiler/rustc_hir_analysis/src/collect/type_of.rs
Lines 437 to 464 in a962594
Such that inferred type for a diagnostic suggestion can vary between different compilations on the parallel front-end.