FCW Lint when using an ambiguously glob imported trait by LorrensP-2158466 · Pull Request #149058 · rust-lang/rust (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation45 Commits8 Checks12 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@LorrensP-2158466

Related to #147992.

Report a lint when using an ambiguously glob import trait, this is a FCW because this should not be allowed.

r? @petrochenkov

@petrochenkov

@LorrensP-2158466

@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

Nov 18, 2025

@rust-log-analyzer

This comment has been minimized.

@LorrensP-2158466

petrochenkov

@petrochenkov petrochenkov added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Nov 18, 2025

petrochenkov

@LorrensP-2158466

@LorrensP-2158466 LorrensP-2158466 changed the titleresolve: Consider all traits ambiguously glob imported to be in scope Lint when using an ambiguously glob imported trait

Nov 19, 2025

@LorrensP-2158466 LorrensP-2158466 changed the titleLint when using an ambiguously glob imported trait FCW Lint when using an ambiguously glob imported trait

Nov 19, 2025

@LorrensP-2158466

Addressed your comments and updated pr title and description.

@rustbot ready

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Nov 19, 2025

LorrensP-2158466

Comment on lines 735 to 740

| self.tcx.node_lint(AMBIGUOUS_TRAIT_GLOB_IMPORTS, segment.hir_id, |diag| { | | ------------------------------------------------------------------------------------------ | | diag.primary_message(format!("Use of ambiguously glob imported trait `{trait_name}`")) | | .span(segment.ident.span) | | .span_label(import_span, format!("`{trait_name}`imported ambiguously here")) | | .help(format!("Import `{trait_name}` explicitly")); | | }); |

Choose a reason for hiding this comment

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

Is it possible to add some kind of suggestion like:

Consider importing `{trait_name}` directly:
+ use m1::{trait_name};

petrochenkov

This was referenced

Nov 20, 2025

@LorrensP-2158466

@LorrensP-2158466

@petrochenkov

The implementation looks good to me, so I'll just start crater.
@bors try

rust-bors bot added a commit that referenced this pull request

Dec 3, 2025

@rust-bors

FCW Lint when using an ambiguously glob imported trait

@rust-bors

This comment has been minimized.

@rust-bors

☀️ Try build successful (CI)
Build commit: 47eaa3b (47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268, parent: 568b11762723b001bfa693d0f21c5dad01d4e813)

@petrochenkov

@craterbot

@bors

@LorrensP-2158466

Will crater fail because of this merge conflict?

@petrochenkov

@craterbot

🚧 Experiment pr-149058 is now running

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

@craterbot

🎉 Experiment pr-149058 is completed!
📊 5 regressed and 5 fixed (751500 total)
📊 2125 spurious results on the retry-regessed-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-149058/retry-regressed-list.txt

@petrochenkov

Sigh, I didn't notice that the lint is not set to deny-by-default, so we don't see how often it was hit from the regression list.

The crater run is not completely wasted though, could you download all the crater logs, including the passing ones, and grep them for ambiguous_glob_imported_trait manually?
And also debug the 5 regressed cases from the report above.
@rustbot author

@rustbot rustbot 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-review

Status: Awaiting review from the assignee but also interested parties.

labels

Dec 13, 2025

@rustbot

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@LorrensP-2158466

So grepping the all.tar.zst, total match count is 91, total crate/run count is 38 and per run:

crater_run/spurious-fixed/gh/pythcoiner/anali:4
crater_run/test-pass/gh/sulabhkatila/Lost:2
crater_run/build-fail/reg/veda-rs/1.0.0/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:1
crater_run/build-fail/reg/iop-sdk-wasm/0.0.16/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/build-fail/reg/flat_bit_set/0.1.0/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:1
crater_run/test-pass/gh/starci183/raydium-fork-with-transfer-hook:1
crater_run/build-fail/reg/otter/1.2.1/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/test-pass/reg/bacon/3.20.1/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/test-pass/gh/pchampin/sophia_rs:2
crater_run/test-pass/gh/JohnMartin95/sql_db_mapper:2
crater_run/test-pass/reg/sophia_api/0.9.0/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/test-pass/reg/dotnetdll/0.0.6/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/build-fail/gh/ruvnet/ruv-FANN:4
crater_run/build-fail/gh/zd87pl/ruv-FANN:4
crater_run/build-fail/gh/kostja-me/gtkamp:2
crater_run/test-pass/reg/impellers/0.4.0/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:9
crater_run/build-fail/gh/Internet-of-People/morpheus-rust:2
crater_run/test-pass/reg/stam-python/0.12.0/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/test-pass/gh/mvirkkunen/cnv:2
crater_run/test-pass/reg/mkv-element/0.3.1/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:1
crater_run/test-pass/reg/embedded-time/0.12.1/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/test-pass/reg/sql_db_mapper/0.1.0/try#47eaa3b85fbe5fa2b3b731b5fecdc5954cbfc268.txt:2
crater_run/test-pass/gh/Syrax-AI/raydium-clmm:1
crater_run/test-pass/gh/Canop/bacon:2
crater_run/test-pass/gh/innocent541/fe:2
crater_run/test-pass/gh/arthurkeeng/rust_chaining:2
crater_run/test-pass/gh/banr1/forked-fe:2
crater_run/test-pass/gh/utkarshmorwal/EduNft-Verify:2
crater_run/test-pass/gh/tommysr/trans-protocol:2
crater_run/test-pass/gh/RizkiePratama/hayai-playout:2
crater_run/test-pass/gh/pgebhardt/aoc2021:2
crater_run/test-pass/gh/coderedart/impellers:10
crater_run/test-pass/gh/bluenote-1577/rs-liftover:2
crater_run/test-pass/gh/frank-2023/raydium-clmm:1
crater_run/test-pass/gh/DeltaVThrust-NFT/DoNFT-Contracts-NEAR:2
crater_run/test-pass/gh/neivv/animosity:2
crater_run/test-pass/gh/thatmagicalcat/minecraft:2
crater_run/test-pass/gh/navicore/augorama-rs:2

Regarding the regressions I am not so sure.

[INFO] [stdout] error: proc macro panicked
[INFO] [stdout]    --> src/decimal.rs:107:1
[INFO] [stdout]     |
[INFO] [stdout] 107 | / eval! {
[INFO] [stdout] 108 | |     for self_type in ["SafeDec<D>","&SafeDec<D>"] {
[INFO] [stdout] 109 | |         // integer primitives
[INFO] [stdout] 110 | |         for impl_type in [
[INFO] [stdout] ...   |
[INFO] [stdout] 331 | | }
[INFO] [stdout]     | |_^
[INFO] [stdout]     |
[INFO] [stdout]     = help: message: Cargo project failed to compile or run.

However building/testing this project locally works just fine:

> cargo +stage1 test
test result: ok. 236 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

   Doc-tests safe_math

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

@LorrensP-2158466

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Dec 13, 2025

@petrochenkov

Could you write a proposal for lang team for making this change (mentioning various potential alternatives linked from #147992 and #144993)?
Some recent examples - #146972 (comment).
@rustbot author

@rustbot rustbot 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-review

Status: Awaiting review from the assignee but also interested parties.

labels

Dec 14, 2025

@LorrensP-2158466

Could you write a proposal for lang team for making this change (mentioning various potential alternatives linked from #147992 and #144993)?

Sure! I have some deadlines for school early on this week so I will do it after that.

Labels

S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.