Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for ambiguous_glob_imports lint #114095

Open
1 of 2 tasks
bvanjoi opened this issue Jul 26, 2023 · 2 comments
Open
1 of 2 tasks

Tracking Issue for ambiguous_glob_imports lint #114095

bvanjoi opened this issue Jul 26, 2023 · 2 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-future-incompatibility Category: Future-incompatibility lints C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bvanjoi
Copy link
Contributor

bvanjoi commented Jul 26, 2023

This is a tracking issue for the "ambiguous_glob_imports", a lint that follows the breaking change policy.

Problem

The name resolution algorithm in rustc does not update bindings recursively when the (Module, Key) already has a binding. This can result in a situation where a glob binding should be marked as ambiguous but it is not, potentially causing code that should fail to compile to pass instead.

For example(#112713):

pub fn foo() -> u32 {
    use sub::*;
    C
}

mod sub {
    mod mod1 { pub const C: u32 = 1; }
    mod mod2 { pub const C: u32 = 2; }

    pub use mod1::*;
    pub use mod2::*;
}

The C in foo function was referred to (Mod(root), Key(C)), where it should have an ambiguous binding but actually not due to the stop the update process early.

Here are additional details regarding the update process:

- importer resolve_glob_import
0 use sub::* nothing was defined
1 use mod1::* 1. (root::sub, C) -> root::sub::mod1::C without ambiguity;
2. (root, C) -> root::sub::mod1::C without ambiguity.
2 use mod2::* 1. (root::sub, C) -> root::sub::mod1::C with ambiguity;
2. It had been stop update the binding of (root, C) due to (root, C) already has a binding.

Solve

We have relaxed the condition for update process and now treat the updated ambiguous error as a warning instead of an error. We use the ambigous_glob_imports lint for back compatibility.

Steps

@bvanjoi bvanjoi added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Jul 26, 2023
@tmiasko
Copy link
Contributor

tmiasko commented Aug 30, 2023

The future incompatibility report is not enabled for dependencies (FutureReleaseError vs FutureReleaseErrorReportNow). Is that intentional?

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Aug 30, 2023

The future incompatibility report is not enabled for dependencies (FutureReleaseError vs FutureReleaseErrorReportNow). Is that intentional?

Yes, it is indeed another matter: #36837

kellerkindt added a commit to kellerkindt/asn1rs that referenced this issue Jan 16, 2024
gnoliyil pushed a commit to gnoliyil/fuchsia that referenced this issue Jan 27, 2024
The uapi module glob use was causing a new rust lint to trigger. The
constants in uapi module were going to cause ambiguous name conflicts
due to the constants of the same names defined in the auth, errno, and
signals modules. The modules as written should not have been able to
compile, but do to a bug in the rust compiler, they did. There are more
details in rust-lang/rust#114095.

Bug: 130265
Test: fx build
Change-Id: I8605a51de353fa6c2089be3ee965737dc55b6f2a
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/898801
Fuchsia-Auto-Submit: Paul Faria <paulfaria@google.com>
Reviewed-by: Theodore Dubois <tbodt@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
@lolbinarycat lolbinarycat added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 18, 2025
@jieyouxu jieyouxu added the C-future-incompatibility Category: Future-incompatibility lints label Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-future-incompatibility Category: Future-incompatibility lints C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants