resolve: Extend ambiguous_import_visibilities deprecation lint to glob-vs-glob ambiguities rust-lang/rust#154149

Open

31 comments and reviews loaded in 1.21s

petrochenkov Avatar
petrochenkov on 2026-03-20 17:34:03 UTC · edited
petrochenkov Avatar
petrochenkov on 2026-03-20 17:34:03 UTC · edited
View on GitHub

View all comments

Continuation of #149596, implementation of this comment #149596 (comment) in particular.
FCP for the lint in general - #149596 (comment).
#152498 is reverted as a part of the change, but fixes are applied to keep the tests added in that PR working.

To implement this we have to have to track the most and the least visible declarations in an ambiguous glob set.

Part of #153961.
r? @yaahc maybe

👍1
petrochenkov Avatar
petrochenkov commented on 2026-03-20 17:35:13 UTC
compiler/rustc_middle/src/middle/privacy.rs
189 && let ItemKind::Use(_, UseKind::Glob) = item.kind
190 {
191 // Glob import visibilities can be increasee by other
192 // more public glob imports in cases of ambiguity.
petrochenkov Avatar petrochenkov on 2026-03-20 17:35:13 UTC
View on GitHub

This is a fix for #151124.

petrochenkov Avatar
petrochenkov commented on 2026-03-20 17:35:35 UTC
compiler/rustc_resolve/src/effective_visibilities.rs
183 183 tcx,
184 184 );
185 if let Some(max_vis_decl) = decl.ambiguity_vis_max.get() {
186 // Avoid the most visible import in an ambiguous glob set being reported as unused.
petrochenkov Avatar petrochenkov on 2026-03-20 17:35:35 UTC
View on GitHub

This is a fix for #152004.

petrochenkov Avatar
petrochenkov commented on 2026-03-20 17:36:39 UTC
compiler/rustc_resolve/src/imports.rs
515 524
516 525 if let Some(binding) = resolution.binding()
517 && old_decl != Some(binding)
526 && (old_decl != Some(binding) || old_vis != Some(binding.vis()))
petrochenkov Avatar petrochenkov on 2026-03-20 17:36:39 UTC
View on GitHub

And this is a fix for #152347.
Here we are triggering the glob re-fetching on visibility updates.

rustbot Avatar
rustbot on 2026-03-20 17:52:48 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-03-20 17:52:48 UTC · hidden as outdated
View on GitHub

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.

petrochenkov Avatar
petrochenkov on 2026-03-20 17:52:58 UTC
petrochenkov Avatar
petrochenkov on 2026-03-20 17:52:58 UTC
View on GitHub

@bors try

rust-bors Avatar
rust-bors on 2026-03-20 17:53:03 UTC · hidden as outdated
rust-bors Avatar
rust-bors on 2026-03-20 17:53:03 UTC · hidden as outdated
View on GitHub

⌛ Trying commit 8c30e81 with merge 4907eac

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/23355702102

rust-log-analyzer Avatar
rust-log-analyzer on 2026-03-20 18:41:56 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-03-20 18:41:56 UTC · hidden as outdated
View on GitHub

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

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set2.sh"
+ /scripts/stage_2_test_set2.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-03-05/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---

test result: FAILED. 69 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.02s

all doctests ran in 2.92s; merged doctests compilation took 1.87s
error: doctest failed, to rerun pass `-p rustc_lint_defs --doc`
Bootstrap failed while executing `--stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:29:37
  local time: Fri Mar 20 18:26:41 UTC 2026
  network time: Fri, 20 Mar 2026 18:26:41 GMT
##[error]Process completed with exit code 1.
rust-bors Avatar
rust-bors on 2026-03-20 19:59:56 UTC
rust-bors Avatar
rust-bors on 2026-03-20 19:59:56 UTC
View on GitHub

☀️ Try build successful (CI)
Build commit: 4907eac (4907eac94165faff6c5e5e015670b1c584275f7b, parent: bfc05d6b072585dfd0c792ec1b8728c08a3511fe)

petrochenkov Avatar
petrochenkov on 2026-03-20 20:12:39 UTC
petrochenkov Avatar
petrochenkov on 2026-03-20 20:12:39 UTC
View on GitHub

@craterbot check

craterbot Avatar
craterbot on 2026-03-20 20:13:15 UTC
craterbot Avatar
craterbot on 2026-03-20 20:13:15 UTC
View on GitHub

👌 Experiment pr-154149 created and queued.
🤖 Automatically detected try build 4907eac
🔍 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 Avatar
craterbot on 2026-03-28 10:24:52 UTC
craterbot Avatar
craterbot on 2026-03-28 10:24:52 UTC
View on GitHub

🚧 Experiment pr-154149 is now running

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

craterbot Avatar
craterbot on 2026-03-30 08:16:36 UTC
craterbot Avatar
craterbot on 2026-03-30 08:16:36 UTC
View on GitHub

🎉 Experiment pr-154149 is completed!
📊 136 regressed and 4 fixed (858234 total)
📊 5129 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-154149/retry-regressed-list.txt

rustbot Avatar
rustbot on 2026-04-08 16:48:27 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-04-08 16:48:27 UTC · hidden as outdated
View on GitHub

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.

rust-log-analyzer Avatar
rust-log-analyzer on 2026-04-08 17:25:05 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-04-08 17:25:05 UTC · hidden as outdated
View on GitHub

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

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set2.sh"
+ /scripts/stage_2_test_set2.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-03-05/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---

test result: FAILED. 70 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.08s

all doctests ran in 3.08s; merged doctests compilation took 1.97s
error: doctest failed, to rerun pass `-p rustc_lint_defs --doc`
Bootstrap failed while executing `--stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:31:25
  local time: Wed Apr  8 17:24:53 UTC 2026
  network time: Wed, 08 Apr 2026 17:24:53 GMT
##[error]Process completed with exit code 1.
rustbot Avatar
rustbot on 2026-04-09 16:59:59 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-04-09 16:59:59 UTC · hidden as outdated
View on GitHub

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.

rust-log-analyzer Avatar
rust-log-analyzer on 2026-04-09 17:43:00 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-04-09 17:43:00 UTC · hidden as outdated
View on GitHub

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

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set2.sh"
+ /scripts/stage_2_test_set2.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-03-05/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---

test result: FAILED. 70 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.05s

all doctests ran in 2.94s; merged doctests compilation took 1.86s
error: doctest failed, to rerun pass `-p rustc_lint_defs --doc`
Bootstrap failed while executing `--stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:30:01
  local time: Thu Apr  9 17:33:47 UTC 2026
  network time: Thu, 09 Apr 2026 17:33:48 GMT
##[error]Process completed with exit code 1.
rustbot Avatar
rustbot on 2026-04-10 16:21:32 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-04-10 16:21:32 UTC · hidden as outdated
View on GitHub

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.

petrochenkov Avatar
petrochenkov on 2026-04-10 16:22:05 UTC
petrochenkov Avatar
petrochenkov on 2026-04-10 16:22:05 UTC
View on GitHub

@bors try

rust-bors Avatar
rust-bors on 2026-04-10 16:22:12 UTC · hidden as outdated
rust-bors Avatar
rust-bors on 2026-04-10 16:22:12 UTC · hidden as outdated
View on GitHub

⌛ Trying commit 3b24e32 with merge fe84aa3

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/24252835068

petrochenkov Avatar
petrochenkov on 2026-04-10 16:24:01 UTC
petrochenkov Avatar
petrochenkov on 2026-04-10 16:24:01 UTC
View on GitHub

TODO: @craterbot run mode=check-only p=1 crates=https://crater-reports.s3.amazonaws.com/pr-154149/retry-regressed-list.txt

rust-log-analyzer Avatar
rust-log-analyzer on 2026-04-10 16:56:26 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-04-10 16:56:26 UTC · hidden as outdated
View on GitHub

The job aarch64-gnu-llvm-21-2 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_set2.sh"
+ /scripts/stage_2_test_set2.sh
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---

test result: FAILED. 70 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.10s

all doctests ran in 3.09s; merged doctests compilation took 1.96s
error: doctest failed, to rerun pass `-p rustc_lint_defs --doc`
Bootstrap failed while executing `--stage 2 test --skip tidy --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:30:41
  local time: Fri Apr 10 16:56:14 UTC 2026
  network time: Fri, 10 Apr 2026 16:56:15 GMT
##[error]Process completed with exit code 1.
rust-bors Avatar
rust-bors on 2026-04-10 18:30:30 UTC
rust-bors Avatar
rust-bors on 2026-04-10 18:30:30 UTC
View on GitHub

☀️ Try build successful (CI)
Build commit: fe84aa3 (fe84aa3583bb2681b5d0580316bde6d58ccfd6b5, parent: 8317fef20409adedaa7c385fa6e954867bf626fc)

petrochenkov Avatar
petrochenkov on 2026-04-10 18:37:50 UTC
petrochenkov Avatar
petrochenkov on 2026-04-10 18:37:50 UTC
View on GitHub
craterbot Avatar
craterbot on 2026-04-10 18:37:58 UTC
craterbot Avatar
craterbot on 2026-04-10 18:37:58 UTC
View on GitHub

👌 Experiment pr-154149-1 created and queued.
🤖 Automatically detected try build fe84aa3
🔍 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

petrochenkov Avatar
petrochenkov on 2026-04-10 18:41:57 UTC
petrochenkov Avatar
petrochenkov on 2026-04-10 18:41:57 UTC
View on GitHub

@craterbot p=11
This is a tiny run, and beta-1.95-5 is a full run.

craterbot Avatar
craterbot on 2026-04-10 18:42:01 UTC
craterbot Avatar
craterbot on 2026-04-10 18:42:01 UTC
View on GitHub

📝 Configuration of the pr-154149-1 experiment changed.

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

craterbot Avatar
craterbot on 2026-04-12 06:21:58 UTC
craterbot Avatar
craterbot on 2026-04-12 06:21:58 UTC
View on GitHub

🚧 Experiment pr-154149-1 is now running

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

craterbot Avatar
craterbot on 2026-04-12 13:39:02 UTC
craterbot Avatar
craterbot on 2026-04-12 13:39:02 UTC
View on GitHub

🎉 Experiment pr-154149-1 is completed!
📊 22 regressed and 0 fixed (5063 total)
📊 906 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-154149-1/retry-regressed-list.txt

rustbot Avatar
rustbot on 2026-04-12 20:06:13 UTC
rustbot Avatar
rustbot on 2026-04-12 20:06:13 UTC
View on GitHub

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.

petrochenkov Avatar
petrochenkov on 2026-04-12 20:57:52 UTC
petrochenkov Avatar
petrochenkov on 2026-04-12 20:57:52 UTC
View on GitHub

Blocked on #155213.
@rustbot blocked

rust-bors Avatar
rust-bors on 2026-04-13 22:14:25 UTC
rust-bors Avatar
rust-bors on 2026-04-13 22:14:25 UTC
View on GitHub

☔ The latest upstream changes (presumably #155253) made this pull request unmergeable. Please resolve the merge conflicts.