Skip to content

treat no_mangle_generic_items as hard error instead of lint warning#154585

Open
HerrCai0907 wants to merge 2 commits into
rust-lang:mainfrom
HerrCai0907:fix/no_mangle_generic_items
Open

treat no_mangle_generic_items as hard error instead of lint warning#154585
HerrCai0907 wants to merge 2 commits into
rust-lang:mainfrom
HerrCai0907:fix/no_mangle_generic_items

Conversation

@HerrCai0907

@HerrCai0907 HerrCai0907 commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

View all comments

In rust-lang/miri#4929 (comment), rustc should reject the no_mangled generic function.
This PR treat is as a hard error

@rustbot rustbot added 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 Mar 30, 2026
@rustbot

This comment was marked as outdated.

@HerrCai0907

Copy link
Copy Markdown
Contributor Author

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned fmease Mar 30, 2026
@rustbot

rustbot commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@fmease fmease added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Mar 30, 2026
@oli-obk

oli-obk commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Please make it a hard error and not a lint at all if crater doesn't show any significant regressions.

For crater purposes this works.

@rust-bors

This comment was marked as off-topic.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2026
@oli-obk

This comment was marked as off-topic.

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 30, 2026
@oli-obk

oli-obk commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Mar 30, 2026
set no_mangle_generic_items deny by default
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ac4c361 (ac4c3613be2acd5395b65d85e5657b81e3c982f0, parent: 4cf5f9580233c36f6bc8db76e282ba8a1c1ea491)

@oli-obk

oli-obk commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

@craterbot check

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-154585 created and queued.
🤖 Automatically detected try build ac4c361
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 30, 2026
@craterbot

Copy link
Copy Markdown
Collaborator

🚧 Experiment pr-154585 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot

Copy link
Copy Markdown
Collaborator

🎉 Experiment pr-154585 is completed!
📊 5 regressed and 2 fixed (871888 total)
📊 5110 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-154585/retry-regressed-list.txt

@craterbot craterbot removed the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Apr 6, 2026
@RalfJung RalfJung added I-lang-nominated Nominated for discussion during a lang team meeting. S-waiting-on-t-lang Status: Awaiting decision from T-lang labels Jun 24, 2026
Comment on lines +49 to +52
assert_contains(&backtrace, "foo", "line-tables-only-helper.rs", 6);
}
assert_contains(&backtrace, "bar", "line-tables-only-helper.rs", 10);
assert_contains(&backtrace, "baz", "line-tables-only-helper.rs", 5);
assert_contains(&backtrace, "bar", "line-tables-only-helper.rs", 11);
assert_contains(&backtrace, "baz", "line-tables-only-helper.rs", 6);

@RalfJung RalfJung Jun 24, 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.

Suggested change
assert_contains(&backtrace, "foo", "line-tables-only-helper.rs", 6);
}
assert_contains(&backtrace, "bar", "line-tables-only-helper.rs", 10);
assert_contains(&backtrace, "baz", "line-tables-only-helper.rs", 5);
assert_contains(&backtrace, "bar", "line-tables-only-helper.rs", 11);
assert_contains(&backtrace, "baz", "line-tables-only-helper.rs", 6);
assert_contains(&backtrace, "foo", "line-tables-only-helper.rs", 12);
}
assert_contains(&backtrace, "bar", "line-tables-only-helper.rs", 8);
assert_contains(&backtrace, "baz", "line-tables-only-helper.rs", 4);

That's based on the CI messages, I'd suggest running the tests locally though.

View changes since the review

@traviscross traviscross added I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang I-lang-radar Items that are on lang's radar and will need eventual work or consideration. labels Jun 25, 2026
@traviscross

Copy link
Copy Markdown
Contributor

Makes sense to me. Thanks @HerrCai0907, @oli-obk, and @RalfJung. I propose we make this a hard error and accept this (minimal) observed breakage.

@rfcbot fcp merge lang

@rust-rfcbot

rust-rfcbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. and removed needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Jun 25, 2026
@ehuss

ehuss commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

There is a waiting docs PR at rust-lang/reference#1904. Am I correct that the new rule should state the following?

r[abi.no_mangle.generic]
It is an error to use `no_mangle` on an item with generic type or constant parameters.

@RalfJung

Copy link
Copy Markdown
Member

Yes that sounds right. (Though IMO the reference should list where the attribute is allowed, not where it is forbidden.)

@traviscross traviscross added the needs-reference-pr This language change needs an approved Reference PR to proceed. label Jun 25, 2026
@tmandry

tmandry commented Jul 1, 2026

Copy link
Copy Markdown
Member

@rfcbot reviewed

@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Jul 1, 2026
@scottmcm

scottmcm commented Jul 1, 2026

Copy link
Copy Markdown
Member

Agreed. Obviously can't work and easy to describe the error rule -- easier than giving it a meaning -- so 👍

@rfcbot reviewed

@traviscross traviscross removed the S-waiting-on-t-lang Status: Awaiting decision from T-lang label Jul 1, 2026
@rust-rfcbot rust-rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jul 1, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@rust-rfcbot rust-rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jul 1, 2026
@nikomatsakis

Copy link
Copy Markdown
Contributor

@rfcbot reviewed

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jul 11, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@RalfJung

Copy link
Copy Markdown
Member

@HerrCai0907 could you please rebase, and deal with the CI failures?
All the paperwork for this PR is done, we just have to get the implementation in shape. :)

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-reference-pr This language change needs an approved Reference PR to proceed. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-lang Relevant to the language team to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.