1
Fork 0

Improve diagnostic for E0178 (bad + in type)

Namely, use a more sensical primary span.
Don't pretty-print AST nodes for the diagnostic message. Why:
* It's lossy (e.g., it doesn't replicate trailing `+`s in trait objects.
* It's prone to leak error nodes (printed as `(/*ERROR*/)`) since
  the LHS can easily represent recovered code (e.g., `fn(i32?) + T`).
This commit is contained in:
León Orell Valerian Liehr 2025-04-15 07:44:24 +02:00
parent 8887af72a0
commit 6242335fdb
No known key found for this signature in database
GPG key ID: D17A07215F68E713
14 changed files with 51 additions and 52 deletions

View file

@ -30,7 +30,6 @@ pub(crate) struct AmbiguousPlus {
#[derive(Diagnostic)]
#[diag(parse_maybe_recover_from_bad_type_plus, code = E0178)]
pub(crate) struct BadTypePlus {
pub ty: String,
#[primary_span]
pub span: Span,
#[subdiagnostic]