Skip to content

clang: Only match the attribute name when detecting function attributes. - #3520

Merged
emilio merged 1 commit into
rust-lang:mainfrom
emilio:noreturn-fix
Oct 13, 2026
Merged

emilio merged 1 commit into
rust-lang:mainfrom
emilio:noreturn-fix

Conversation

@emilio

@emilio emilio commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Rebase of #3516, but without risking a merge commit.

When an attribute comes from a macro, libclang reports an extent that starts at the attribute in the macro definition but ends at the expansion site. Tokenizing that range lexes everything in between, so has_attrs saw the _Noreturn from an unrelated #define and marked a deprecated function as -> !. If the macro lives in another file, the range spans two files and tokenizes to nothing, so a real _Noreturn behind such a macro was missed.

Only look at the first token at the start of the attribute's extent, which is the attribute name and is lexed from the right place either way.

Fixes #3496

When an attribute comes from a macro, libclang reports an extent that
starts at the attribute in the macro definition but ends at the
expansion site. Tokenizing that range lexes everything in between, so
`has_attrs` saw the `_Noreturn` from an unrelated `#define` and marked a
deprecated function as `-> !`. If the macro lives in another file, the
range spans two files and tokenizes to nothing, so a real `_Noreturn`
behind such a macro was missed.

Only look at the first token at the start of the attribute's extent,
which is the attribute name and is lexed from the right place either way.

Fixes rust-lang#3496
@emilio
emilio enabled auto-merge October 13, 2026 11:33
@emilio
emilio added this pull request to the merge queue Oct 13, 2026
Merged via the queue into rust-lang:main with commit 2a68e88 Oct 13, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No-return detection is triggered on unrelated attributes

2 participants