Skip to content

set no_mangle_generic_items deny by default#154585

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

set no_mangle_generic_items deny by default#154585
HerrCai0907 wants to merge 2 commits intorust-lang:mainfrom
HerrCai0907:fix/no_mangle_generic_items

Conversation

@HerrCai0907
Copy link
Copy Markdown

In rust-lang/miri#4929 (comment), rustc should reject the no_mangled generic function.
This PR change the default behavior from warn to deny.

@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
Author

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned fmease Mar 30, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 30, 2026

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
Copy link
Copy Markdown
Contributor

oli-obk commented Mar 30, 2026

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
Copy link
Copy Markdown
Contributor

oli-obk commented Mar 30, 2026

@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
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 30, 2026

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

@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Mar 30, 2026

@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
@craterbot craterbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 6, 2026
@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Apr 8, 2026

I reached out to the jni-mangle author, who used a generic function with no_mangle in a test file, but never actually called it (it wouldn't mangle anyway).

The rxdp failure is because (while there are no generics involved in the function signature) the body uses the generic parameter T from the impl block. (well the failure happens regardless of use in the body, but that's why the functions can't be free functions). I opened a PR to fix it, but the crate also has no dependents, no release in 5 years and the last change to the repo was 3 years ago.

So, let's turn this lint into a hard error. Then we need to write an explainer for T-lang and then we can nominate it.

@oli-obk oli-obk added T-lang Relevant to the language team S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 10, 2026

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---
failures:

---- [ui] tests/ui/backtrace/line-tables-only.rs stdout ----

error: test did not exit with success! code=Some(101) so test would pass with `run-fail`
status: exit status: 101
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/backtrace/line-tables-only" && RUSTC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="4" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/backtrace/line-tables-only/a"
stdout: none
--- stderr -------------------------------
Backtrace [
    { fn: "<std::backtrace::Backtrace>::create" },
    { fn: "line_tables_only_helper::capture_backtrace::{closure#0}", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 17 },
    { fn: "line_tables_only_helper::baz::<line_tables_only_helper::capture_backtrace::{closure#0}>", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 4 },
    { fn: "line_tables_only_helper::bar::<line_tables_only_helper::capture_backtrace::{closure#0}>", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 8 },
    { fn: "line_tables_only_helper::foo::<line_tables_only_helper::capture_backtrace::{closure#0}>", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 12 },
    { fn: "capture_backtrace", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 17 },
    { fn: "main", file: "/checkout/tests/ui/backtrace/line-tables-only.rs", line: 43 },
    { fn: "call_once<fn(), ()>", file: "/rustc/FAKE_PREFIX/library/core/src/ops/function.rs", line: 250 },
    { fn: "__rust_begin_short_backtrace<fn(), ()>", file: "/rustc/FAKE_PREFIX/library/std/src/sys/backtrace.rs", line: 166 },
    { fn: "std::rt::lang_start::<()>::{closure#0}", file: "/rustc/FAKE_PREFIX/library/std/src/rt.rs", line: 206 },
    { fn: "std::rt::lang_start_internal" },
    { fn: "main" },
    { fn: "__libc_start_main" },
    { fn: "_start" },
]
Backtrace [
    { fn: "<std::backtrace::Backtrace>::create" },
    { fn: "line_tables_only_helper::capture_backtrace::{closure#0}", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 17 },
    { fn: "line_tables_only_helper::baz::<line_tables_only_helper::capture_backtrace::{closure#0}>", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 4 },
    { fn: "line_tables_only_helper::bar::<line_tables_only_helper::capture_backtrace::{closure#0}>", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 8 },
    { fn: "line_tables_only_helper::foo::<line_tables_only_helper::capture_backtrace::{closure#0}>", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 12 },
    { fn: "capture_backtrace", file: "/checkout/tests/ui/backtrace/auxiliary/line-tables-only-helper.rs", line: 17 },
    { fn: "main", file: "/checkout/tests/ui/backtrace/line-tables-only.rs", line: 43 },
    { fn: "call_once<fn(), ()>", file: "/rustc/FAKE_PREFIX/library/core/src/ops/function.rs", line: 250 },
    { fn: "__rust_begin_short_backtrace<fn(), ()>", file: "/rustc/FAKE_PREFIX/library/std/src/sys/backtrace.rs", line: 166 },
    { fn: "std::rt::lang_start::<()>::{closure#0}", file: "/rustc/FAKE_PREFIX/library/std/src/rt.rs", line: 206 },
    { fn: "std::rt::lang_start_internal" },
    { fn: "main" },
    { fn: "__libc_start_main" },
    { fn: "_start" },
]

thread 'main' (36099) panicked at /checkout/tests/ui/backtrace/line-tables-only.rs:38:5:
backtrace does not contain expected line 11
stack backtrace:

@@ -1,4 +1,4 @@
#![allow(unused_imports, unused_attributes, no_mangle_generic_items)]
Copy link
Copy Markdown
Member

@RalfJung RalfJung Apr 10, 2026

Choose a reason for hiding this comment

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

View changes since the review

This looks like we should keep allowing the lint here until this is a hard error.

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.

Oh, the PR title is outdated. It is a hard error now, I see. Please update the PR title and description.

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

Labels

needs-fcp This change is insta-stable, or significant enough to need a team FCP 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants