Skip to content

Rework how the disallowed qualifier in function type diagnostics are generated#142302

Merged
bors merged 2 commits intorust-lang:masterfrom
JonathanBrouwer:invalid-const-token
Jun 14, 2025
Merged

Rework how the disallowed qualifier in function type diagnostics are generated#142302
bors merged 2 commits intorust-lang:masterfrom
JonathanBrouwer:invalid-const-token

Conversation

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@JonathanBrouwer JonathanBrouwer commented Jun 10, 2025

This pull request fixes two independent issues:

  1. When qualifiers of a function type ptr are in the wrong order and one of them is async/const (not permitted on function types), the diagnostic suggests removing the incorrect qualifier. Fixes invalid token removal suggested on unsafe const fn() type #142268, which is an issue created by Trim extra whitespace in fn ptr suggestion span #133151. This is fixed by moving the check into parse_fn_front_matter, where better span information is available to generate the right suggestions.
  2. When qualifiers of a function type ptr are in the wrong order and one of them is async/const (not permitted on function types), cargo fix crashes because "cannot replace slice of data that was already replaced". This is fixed by not generating a suggestion for the "wrong order" diagnostic if the "disallowed qualifier" diagnostic is triggered.

There is a commit with failing tests so the test diff is clearer
r? @jdonszelmann

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invalid token removal suggested on unsafe const fn() type

4 participants