Skip to content

Commit f5af471

Browse files
authored
Rollup merge of rust-lang#64043 - matthewjasper:underscore-import-tests, r=alexcrichton
Add some more tests for underscore imports
2 parents 737efa6 + 754a875 commit f5af471

11 files changed

+54
-0
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Check that cyclic glob imports are allowed with underscore imports
2+
3+
// check-pass
4+
5+
mod x {
6+
pub use crate::y::*;
7+
pub use std::ops::Deref as _;
8+
}
9+
10+
mod y {
11+
pub use crate::x::*;
12+
pub use std::ops::Deref as _;
13+
}
14+
15+
pub fn main() {
16+
use x::*;
17+
(&0).deref();
18+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Check that underscore imports don't cause glob imports to be unshadowed
2+
3+
mod a {
4+
pub use std::ops::Deref as Shadow;
5+
}
6+
7+
mod b {
8+
pub use crate::a::*;
9+
macro_rules! m {
10+
($i:ident) => { pub struct $i; }
11+
}
12+
m!(Shadow);
13+
}
14+
15+
mod c {
16+
use crate::b::Shadow as _; // Only imports the struct
17+
18+
fn f(x: &()) {
19+
x.deref(); //~ ERROR no method named `deref` found
20+
}
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0599]: no method named `deref` found for type `&()` in the current scope
2+
--> $DIR/shadow.rs:19:11
3+
|
4+
LL | x.deref();
5+
| ^^^^^
6+
|
7+
= help: items from traits can only be used if the trait is in scope
8+
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
9+
`use std::ops::Deref;`
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)