2019-03-14 08:53:40 +00:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_1() {
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /lib.rs
|
|
|
|
mod foo;
|
|
|
|
use foo::*;
|
|
|
|
|
|
|
|
//- /foo/mod.rs
|
|
|
|
pub mod bar;
|
|
|
|
pub use self::bar::Baz;
|
|
|
|
pub struct Foo;
|
|
|
|
|
|
|
|
//- /foo/bar.rs
|
|
|
|
pub struct Baz;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Baz: t v
|
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
Baz: t v
|
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
|
|
|
|
crate::foo::bar
|
|
|
|
Baz: t v
|
|
|
|
"#]],
|
2019-03-14 08:53:40 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_2() {
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /lib.rs
|
|
|
|
mod foo;
|
|
|
|
use foo::*;
|
|
|
|
|
|
|
|
//- /foo/mod.rs
|
|
|
|
pub mod bar;
|
|
|
|
pub use self::bar::*;
|
|
|
|
pub struct Foo;
|
|
|
|
|
|
|
|
//- /foo/bar.rs
|
|
|
|
pub struct Baz;
|
|
|
|
pub use super::*;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Baz: t v
|
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
Baz: t v
|
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
|
|
|
|
crate::foo::bar
|
|
|
|
Baz: t v
|
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
"#]],
|
2019-03-14 08:53:40 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-12-25 17:05:16 +00:00
|
|
|
#[test]
|
|
|
|
fn glob_privacy_1() {
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
2020-03-17 09:46:46 +00:00
|
|
|
r"
|
2020-07-17 12:37:51 +00:00
|
|
|
//- /lib.rs
|
|
|
|
mod foo;
|
|
|
|
use foo::*;
|
|
|
|
|
|
|
|
//- /foo/mod.rs
|
|
|
|
pub mod bar;
|
|
|
|
pub use self::bar::*;
|
|
|
|
struct PrivateStructFoo;
|
|
|
|
|
|
|
|
//- /foo/bar.rs
|
|
|
|
pub struct Baz;
|
|
|
|
struct PrivateStructBar;
|
|
|
|
pub use super::*;
|
|
|
|
",
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Baz: t v
|
|
|
|
bar: t
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
Baz: t v
|
|
|
|
PrivateStructFoo: t v
|
|
|
|
bar: t
|
|
|
|
|
|
|
|
crate::foo::bar
|
|
|
|
Baz: t v
|
|
|
|
PrivateStructBar: t v
|
|
|
|
PrivateStructFoo: t v
|
|
|
|
bar: t
|
|
|
|
"#]],
|
2019-12-25 17:05:16 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_privacy_2() {
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
2020-03-17 09:46:46 +00:00
|
|
|
r"
|
2020-07-17 12:37:51 +00:00
|
|
|
//- /lib.rs
|
|
|
|
mod foo;
|
|
|
|
use foo::*;
|
|
|
|
use foo::bar::*;
|
|
|
|
|
|
|
|
//- /foo/mod.rs
|
|
|
|
mod bar;
|
|
|
|
fn Foo() {};
|
|
|
|
pub struct Foo {};
|
|
|
|
|
|
|
|
//- /foo/bar.rs
|
|
|
|
pub(super) struct PrivateBaz;
|
|
|
|
struct PrivateBar;
|
|
|
|
pub(crate) struct PubCrateStruct;
|
|
|
|
",
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Foo: t
|
|
|
|
PubCrateStruct: t v
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
|
|
|
|
crate::foo::bar
|
|
|
|
PrivateBar: t v
|
|
|
|
PrivateBaz: t v
|
|
|
|
PubCrateStruct: t v
|
|
|
|
"#]],
|
2019-12-25 17:05:16 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-03-14 08:53:40 +00:00
|
|
|
#[test]
|
|
|
|
fn glob_across_crates() {
|
2020-05-20 10:59:20 +00:00
|
|
|
mark::check!(glob_across_crates);
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /main.rs crate:main deps:test_crate
|
|
|
|
use test_crate::*;
|
2019-03-14 08:53:40 +00:00
|
|
|
|
2020-07-17 12:37:51 +00:00
|
|
|
//- /lib.rs crate:test_crate
|
|
|
|
pub struct Baz;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Baz: t v
|
|
|
|
"#]],
|
2019-03-14 08:53:40 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-12-26 15:31:38 +00:00
|
|
|
#[test]
|
|
|
|
fn glob_privacy_across_crates() {
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /main.rs crate:main deps:test_crate
|
|
|
|
use test_crate::*;
|
2019-12-26 15:31:38 +00:00
|
|
|
|
2020-07-17 12:37:51 +00:00
|
|
|
//- /lib.rs crate:test_crate
|
|
|
|
pub struct Baz;
|
|
|
|
struct Foo;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Baz: t v
|
|
|
|
"#]],
|
2019-12-26 15:31:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-03-14 08:53:40 +00:00
|
|
|
#[test]
|
|
|
|
fn glob_enum() {
|
2020-05-20 10:59:20 +00:00
|
|
|
mark::check!(glob_enum);
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
enum Foo { Bar, Baz }
|
|
|
|
use self::Foo::*;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Bar: t v
|
|
|
|
Baz: t v
|
|
|
|
Foo: t
|
|
|
|
"#]],
|
2019-03-14 08:53:40 +00:00
|
|
|
);
|
|
|
|
}
|
2019-12-19 15:57:22 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_enum_group() {
|
2020-05-20 10:59:20 +00:00
|
|
|
mark::check!(glob_enum_group);
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
enum Foo { Bar, Baz }
|
|
|
|
use self::Foo::{*};
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Bar: t v
|
|
|
|
Baz: t v
|
|
|
|
Foo: t
|
|
|
|
"#]],
|
2019-12-19 15:57:22 +00:00
|
|
|
);
|
|
|
|
}
|
2020-06-24 02:10:01 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_shadowed_def() {
|
2020-06-24 12:20:41 +00:00
|
|
|
mark::check!(import_shadowed);
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /lib.rs
|
|
|
|
mod foo;
|
|
|
|
mod bar;
|
|
|
|
use foo::*;
|
|
|
|
use bar::baz;
|
|
|
|
use baz::Bar;
|
|
|
|
|
|
|
|
//- /foo.rs
|
|
|
|
pub mod baz { pub struct Foo; }
|
|
|
|
|
|
|
|
//- /bar.rs
|
|
|
|
pub mod baz { pub struct Bar; }
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Bar: t v
|
|
|
|
bar: t
|
|
|
|
baz: t
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::bar
|
|
|
|
baz: t
|
|
|
|
|
|
|
|
crate::bar::baz
|
|
|
|
Bar: t v
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
baz: t
|
|
|
|
|
|
|
|
crate::foo::baz
|
|
|
|
Foo: t v
|
|
|
|
"#]],
|
2020-06-24 02:10:01 +00:00
|
|
|
);
|
|
|
|
}
|
2020-06-24 13:30:54 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_shadowed_def_reversed() {
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /lib.rs
|
|
|
|
mod foo;
|
|
|
|
mod bar;
|
|
|
|
use bar::baz;
|
|
|
|
use foo::*;
|
|
|
|
use baz::Bar;
|
|
|
|
|
|
|
|
//- /foo.rs
|
|
|
|
pub mod baz { pub struct Foo; }
|
|
|
|
|
|
|
|
//- /bar.rs
|
|
|
|
pub mod baz { pub struct Bar; }
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Bar: t v
|
|
|
|
bar: t
|
|
|
|
baz: t
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::bar
|
|
|
|
baz: t
|
|
|
|
|
|
|
|
crate::bar::baz
|
|
|
|
Bar: t v
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
baz: t
|
|
|
|
|
|
|
|
crate::foo::baz
|
|
|
|
Foo: t v
|
|
|
|
"#]],
|
2020-06-24 13:30:54 +00:00
|
|
|
);
|
|
|
|
}
|
2020-06-25 01:42:44 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_shadowed_def_dependencies() {
|
2020-07-17 12:37:51 +00:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
mod a { pub mod foo { pub struct X; } }
|
|
|
|
mod b { pub use super::a::foo; }
|
|
|
|
mod c { pub mod foo { pub struct Y; } }
|
|
|
|
mod d {
|
|
|
|
use super::c::foo;
|
|
|
|
use super::b::*;
|
|
|
|
use foo::Y;
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
a: t
|
|
|
|
b: t
|
|
|
|
c: t
|
|
|
|
d: t
|
|
|
|
|
|
|
|
crate::d
|
|
|
|
Y: t v
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::c
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::c::foo
|
|
|
|
Y: t v
|
|
|
|
|
|
|
|
crate::b
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::a
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::a::foo
|
|
|
|
X: t v
|
|
|
|
"#]],
|
2020-06-25 01:42:44 +00:00
|
|
|
);
|
|
|
|
}
|