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

Importing from module with same name as tool module causes ambiguity #111135

Closed
clubby789 opened this issue May 3, 2023 · 3 comments
Closed

Importing from module with same name as tool module causes ambiguity #111135

clubby789 opened this issue May 3, 2023 · 3 comments
Labels
A-resolve Area: Path resolution C-bug Category: This is a bug.

Comments

@clubby789
Copy link
Contributor

I tried this code:

mod rustfmt { pub fn skip() {} }

use rustfmt::skip;
fn main() {
  skip()
}

I expected to see this happen: No error, as the rustfmt tool module cannot be imported from, so the path should resolve to the module.

Instead, this happened:

error[E0659]: `rustfmt` is ambiguous
 --> poc.rs:3:5
  |
3 | use rustfmt::skip;
  |     ^^^^^^^ ambiguous name
  |
  = note: ambiguous because of multiple potential import sources
  = note: `rustfmt` could refer to a tool module
note: `rustfmt` could also refer to the module defined here
 --> poc.rs:1:1
  |
1 | mod rustfmt { pub fn skip() {} }
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: use `crate::rustfmt` to refer to this module unambiguously

This would make adding new tool namespaces (such as the proposed RFC 3368 a breaking change.

Meta

Present on stable, nightly and master.

@rustbot label +A-resolve

@clubby789 clubby789 added the C-bug Category: This is a bug. label May 3, 2023
@rustbot rustbot added the A-resolve Area: Path resolution label May 3, 2023
@petrochenkov
Copy link
Contributor

This is an instance of #56414.

@clubby789
Copy link
Contributor Author

Should this be closed then?

@petrochenkov
Copy link
Contributor

As you want, in any case this can be used as one more motivational case for removing the check from #56414.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Path resolution C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants