1
Fork 0

Rollup merge of #133151 - tyrone-wu:trim-fn-ptr-whitespace, r=compiler-errors

Trim extra whitespace in fn ptr suggestion span

Trim extra whitespace when suggesting removal of invalid qualifiers when parsing function pointer type.

Fixes: #133083

---

I made a comment about the format of the diagnostic error message in https://github.com/rust-lang/rust/issues/133083#issuecomment-2480047875. I think the `.label` may be a little redundant if the diagnostic only highlights the bad qualifier instead of the entire `TyKind::BareFn` span. If it makes sense, I can include it in this PR.
This commit is contained in:
Matthias Krüger 2025-01-28 14:23:20 +01:00 committed by GitHub
commit c0005f1560
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 96 additions and 52 deletions

View file

@ -2830,9 +2830,10 @@ pub(crate) struct DynAfterMut {
pub(crate) struct FnPointerCannotBeConst {
#[primary_span]
pub span: Span,
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
#[label]
pub qualifier: Span,
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
pub suggestion: Span,
}
#[derive(Diagnostic)]
@ -2840,9 +2841,10 @@ pub(crate) struct FnPointerCannotBeConst {
pub(crate) struct FnPointerCannotBeAsync {
#[primary_span]
pub span: Span,
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
#[label]
pub qualifier: Span,
#[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")]
pub suggestion: Span,
}
#[derive(Diagnostic)]