-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(resolve): update the ambiguity glob binding recursively #112743
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// edition: 2021 | ||
// check-pass | ||
|
||
mod abc { | ||
pub struct Beeblebrox; | ||
pub struct Zaphod; | ||
} | ||
|
||
mod foo { | ||
pub mod bar { | ||
use crate::abc::*; | ||
|
||
#[derive(Debug)] | ||
pub enum Zaphod { | ||
Whale, | ||
President, | ||
} | ||
} | ||
pub use bar::*; | ||
} | ||
|
||
mod baz { | ||
pub fn do_something() { | ||
println!("{:?}", crate::foo::Zaphod::Whale); | ||
} | ||
} | ||
|
||
fn main() { | ||
baz::do_something(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// edition: 2021 | ||
|
||
pub fn foo() -> u32 { | ||
use sub::*; | ||
C //~ERROR `C` is ambiguous | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change. It will throw an ambiguous error after this PR, but it currently compiles without error. |
||
} | ||
|
||
mod sub { | ||
mod mod1 { pub const C: u32 = 1; } | ||
mod mod2 { pub const C: u32 = 2; } | ||
|
||
pub use mod1::*; | ||
pub use mod2::*; | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0659]: `C` is ambiguous | ||
--> $DIR/issue-112713.rs:5:5 | ||
| | ||
LL | C | ||
| ^ ambiguous name | ||
| | ||
= note: ambiguous because of multiple glob imports of a name in the same module | ||
note: `C` could refer to the constant imported here | ||
--> $DIR/issue-112713.rs:12:13 | ||
| | ||
LL | pub use mod1::*; | ||
| ^^^^^^^ | ||
= help: consider adding an explicit import of `C` to disambiguate | ||
note: `C` could also refer to the constant imported here | ||
--> $DIR/issue-112713.rs:13:13 | ||
| | ||
LL | pub use mod2::*; | ||
| ^^^^^^^ | ||
= help: consider adding an explicit import of `C` to disambiguate | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0659`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 | ||
|
||
macro_rules! m { | ||
() => { | ||
pub fn EVP_PKEY_id() {} | ||
}; | ||
} | ||
|
||
mod openssl { | ||
pub use self::evp::*; | ||
pub use self::handwritten::*; | ||
|
||
mod evp { | ||
m!(); | ||
} | ||
|
||
mod handwritten { | ||
m!(); | ||
} | ||
} | ||
use openssl::*; | ||
|
||
fn main() { | ||
EVP_PKEY_id(); //~ ERROR `EVP_PKEY_id` is ambiguous | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0659]: `EVP_PKEY_id` is ambiguous | ||
--> $DIR/issue-112743.rs:24:5 | ||
| | ||
LL | EVP_PKEY_id(); | ||
| ^^^^^^^^^^^ ambiguous name | ||
| | ||
= note: ambiguous because of multiple glob imports of a name in the same module | ||
note: `EVP_PKEY_id` could refer to the function imported here | ||
--> $DIR/issue-112743.rs:10:13 | ||
| | ||
LL | pub use self::evp::*; | ||
| ^^^^^^^^^^^^ | ||
= help: consider adding an explicit import of `EVP_PKEY_id` to disambiguate | ||
note: `EVP_PKEY_id` could also refer to the function imported here | ||
--> $DIR/issue-112743.rs:11:13 | ||
| | ||
LL | pub use self::handwritten::*; | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
= help: consider adding an explicit import of `EVP_PKEY_id` to disambiguate | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0659`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// check-pass | ||
|
||
mod a { | ||
pub trait P {} | ||
} | ||
pub use a::*; | ||
|
||
mod b { | ||
#[derive(Clone)] | ||
pub enum P { | ||
A | ||
} | ||
} | ||
pub use b::P; | ||
|
||
mod c { | ||
use crate::*; | ||
pub struct S(Vec<P>); | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// check-pass | ||
|
||
struct Foo; | ||
|
||
mod foo { | ||
use super::*; | ||
|
||
#[derive(Debug)] | ||
pub struct Foo; | ||
} | ||
|
||
mod bar { | ||
use super::foo::*; | ||
|
||
fn bar(_: Foo) {} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// check-pass | ||
|
||
use thing::*; | ||
|
||
#[derive(Debug)] | ||
pub enum Thing { | ||
Foo, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_thing() { | ||
let thing = Thing::Foo; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change too: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment has a typo, but I assume you mean Crater will finish soon and show what actually breaks after these changes. |
||
} | ||
} | ||
|
||
mod thing { | ||
pub enum Thing { | ||
Bar, | ||
} | ||
} | ||
|
||
fn main() {} |
Uh oh!
There was an error while loading. Please reload this page.