Skip to content

Reject no_mangle on EII implementations#159173

Open
chenyukang wants to merge 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-159015-no-mangle-eii
Open

Reject no_mangle on EII implementations#159173
chenyukang wants to merge 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-159015-no-mangle-eii

Conversation

@chenyukang

@chenyukang chenyukang commented Jul 12, 2026

Copy link
Copy Markdown
Member

Fixes #159015

r? @bjorn3

@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 12, 2026
@chenyukang chenyukang force-pushed the yukang-fix-159015-no-mangle-eii branch from 23be887 to 9c36383 Compare July 12, 2026 08:25
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment thread compiler/rustc_passes/src/check_attr.rs Outdated
}

if let Some(no_mangle_span) =
find_attr!(attrs, NoMangle(no_mangle_span) => *no_mangle_span)

@bjorn3 bjorn3 Jul 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also reject #[export_name] and probably #[link_section].

View changes since the review

@bjorn3 bjorn3 added the F-extern_item_impls `#![feature(extern_item_impls)]` label Jul 12, 2026
@chenyukang chenyukang force-pushed the yukang-fix-159015-no-mangle-eii branch from 9c36383 to 81a1b49 Compare July 12, 2026 21:38
@rustbot

rustbot commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

@chenyukang chenyukang force-pushed the yukang-fix-159015-no-mangle-eii branch from 81a1b49 to c7cb405 Compare July 12, 2026 21:41
@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Maybe we ought to have an allowlist of attributes rather than error on these particular attributes? I'm also a bit worried about someone later down the line adding some new (possibly link related) attribute and not including it in this check.

@chenyukang chenyukang force-pushed the yukang-fix-159015-no-mangle-eii branch from c7cb405 to 8e3fe6d Compare July 12, 2026 23:43
@rustbot rustbot added the A-rustdoc-json Area: Rustdoc JSON backend label Jul 12, 2026
@chenyukang

chenyukang commented Jul 12, 2026

Copy link
Copy Markdown
Member Author

Maybe we ought to have an allowlist of attributes rather than error on these particular attributes? I'm also a bit worried about someone later down the line adding some new (possibly link related) attribute and not including it in this check.

maybe allowlist contains lint levels, cfg, doc, inline, cold, optimize, coveragesanitize, must_use, deprecated?

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustdoc-json Area: Rustdoc JSON backend F-extern_item_impls `#![feature(extern_item_impls)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

#[no_mangle] is not denied on EII definitions

5 participants