Skip to content

dcx.try_steal_modify_and_emit_err race #157659

@zetanumbers

Description

@zetanumbers

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parallel-compilerArea: parallel compilerA-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.D-diagnostic-infraDiagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions