Skip to content

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

Open
petrochenkov wants to merge 2 commits intorust-lang:mainfrom
petrochenkov:globvisglob
Open

resolve: Extend ambiguous_import_visibilities deprecation lint to glob-vs-glob ambiguities#154149
petrochenkov wants to merge 2 commits intorust-lang:mainfrom
petrochenkov:globvisglob

Conversation

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Mar 20, 2026

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

@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 20, 2026
&& let ItemKind::Use(_, UseKind::Glob) = item.kind
{
// Glob import visibilities can be increasee by other
// more public glob imports in cases of ambiguity.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a fix for #151124.

tcx,
);
if let Some(max_vis_decl) = decl.ambiguity_vis_max.get() {
// Avoid the most visible import in an ambiguous glob set being reported as unused.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a fix for #152004.


if let Some(binding) = resolution.binding()
&& old_decl != Some(binding)
&& (old_decl != Some(binding) || old_vis != Some(binding.vis()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

@rustbot
Copy link
Collaborator

rustbot commented Mar 20, 2026

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

@bors try

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 20, 2026
resolve: Extend `ambiguous_import_visibilities` deprecation lint to glob-vs-glob ambiguities
@petrochenkov petrochenkov added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2026
@rust-log-analyzer
Copy link
Collaborator

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

rust-bors bot commented Mar 20, 2026

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

@petrochenkov
Copy link
Contributor Author

@craterbot check

@craterbot
Copy link
Collaborator

👌 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

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

Labels

S-waiting-on-crater Status: Waiting on a crater run to be completed. 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.

5 participants