forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#64043 - matthewjasper:underscore-import-tes…
…ts, r=alexcrichton Add some more tests for underscore imports
- Loading branch information
Showing
11 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Check that cyclic glob imports are allowed with underscore imports | ||
|
||
// check-pass | ||
|
||
mod x { | ||
pub use crate::y::*; | ||
pub use std::ops::Deref as _; | ||
} | ||
|
||
mod y { | ||
pub use crate::x::*; | ||
pub use std::ops::Deref as _; | ||
} | ||
|
||
pub fn main() { | ||
use x::*; | ||
(&0).deref(); | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Check that underscore imports don't cause glob imports to be unshadowed | ||
|
||
mod a { | ||
pub use std::ops::Deref as Shadow; | ||
} | ||
|
||
mod b { | ||
pub use crate::a::*; | ||
macro_rules! m { | ||
($i:ident) => { pub struct $i; } | ||
} | ||
m!(Shadow); | ||
} | ||
|
||
mod c { | ||
use crate::b::Shadow as _; // Only imports the struct | ||
|
||
fn f(x: &()) { | ||
x.deref(); //~ ERROR no method named `deref` found | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0599]: no method named `deref` found for type `&()` in the current scope | ||
--> $DIR/shadow.rs:19:11 | ||
| | ||
LL | x.deref(); | ||
| ^^^^^ | ||
| | ||
= help: items from traits can only be used if the trait is in scope | ||
= note: the following trait is implemented but not in scope, perhaps add a `use` for it: | ||
`use std::ops::Deref;` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |
File renamed without changes.
File renamed without changes.