2019-03-14 03:53:40 -05:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_1() {
|
2020-07-17 07:37:51 -05: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
|
2023-08-21 04:44:09 -05:00
|
|
|
Baz: ti vi
|
2020-07-17 07:37:51 -05:00
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
|
|
|
|
crate::foo::bar
|
|
|
|
Baz: t v
|
|
|
|
"#]],
|
2019-03-14 03:53:40 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_2() {
|
2020-07-17 07:37:51 -05: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 03:53:40 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-12-25 11:05:16 -06:00
|
|
|
#[test]
|
|
|
|
fn glob_privacy_1() {
|
2020-07-17 07:37:51 -05:00
|
|
|
check(
|
2020-03-17 04:46:46 -05:00
|
|
|
r"
|
2020-07-17 07:37:51 -05: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 11:05:16 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_privacy_2() {
|
2020-07-17 07:37:51 -05:00
|
|
|
check(
|
2020-03-17 04:46:46 -05:00
|
|
|
r"
|
2020-07-17 07:37:51 -05:00
|
|
|
//- /lib.rs
|
|
|
|
mod foo;
|
|
|
|
use foo::*;
|
|
|
|
use foo::bar::*;
|
|
|
|
|
|
|
|
//- /foo/mod.rs
|
2022-11-23 09:24:03 -06:00
|
|
|
pub mod bar;
|
2020-07-17 07:37:51 -05:00
|
|
|
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
|
2022-11-23 09:24:03 -06:00
|
|
|
bar: t
|
2020-07-17 07:37:51 -05:00
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
Foo: t v
|
|
|
|
bar: t
|
|
|
|
|
|
|
|
crate::foo::bar
|
|
|
|
PrivateBar: t v
|
|
|
|
PrivateBaz: t v
|
|
|
|
PubCrateStruct: t v
|
|
|
|
"#]],
|
2019-12-25 11:05:16 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-03-14 03:53:40 -05:00
|
|
|
#[test]
|
|
|
|
fn glob_across_crates() {
|
2021-03-08 14:19:44 -06:00
|
|
|
cov_mark::check!(glob_across_crates);
|
2020-07-17 07:37:51 -05:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /main.rs crate:main deps:test_crate
|
|
|
|
use test_crate::*;
|
2019-03-14 03:53:40 -05:00
|
|
|
|
2020-07-17 07:37:51 -05:00
|
|
|
//- /lib.rs crate:test_crate
|
|
|
|
pub struct Baz;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Baz: t v
|
|
|
|
"#]],
|
2019-03-14 03:53:40 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-12-26 09:31:38 -06:00
|
|
|
#[test]
|
|
|
|
fn glob_privacy_across_crates() {
|
2020-07-17 07:37:51 -05:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
//- /main.rs crate:main deps:test_crate
|
|
|
|
use test_crate::*;
|
2019-12-26 09:31:38 -06:00
|
|
|
|
2020-07-17 07:37:51 -05:00
|
|
|
//- /lib.rs crate:test_crate
|
|
|
|
pub struct Baz;
|
|
|
|
struct Foo;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Baz: t v
|
|
|
|
"#]],
|
2019-12-26 09:31:38 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-03-14 03:53:40 -05:00
|
|
|
#[test]
|
|
|
|
fn glob_enum() {
|
2021-03-08 14:19:44 -06:00
|
|
|
cov_mark::check!(glob_enum);
|
2020-07-17 07:37:51 -05:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
enum Foo { Bar, Baz }
|
|
|
|
use self::Foo::*;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Bar: t v
|
|
|
|
Baz: t v
|
|
|
|
Foo: t
|
|
|
|
"#]],
|
2019-03-14 03:53:40 -05:00
|
|
|
);
|
|
|
|
}
|
2019-12-19 09:57:22 -06:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_enum_group() {
|
2021-03-08 14:19:44 -06:00
|
|
|
cov_mark::check!(glob_enum_group);
|
2020-07-17 07:37:51 -05:00
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
enum Foo { Bar, Baz }
|
|
|
|
use self::Foo::{*};
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
|
|
|
Bar: t v
|
|
|
|
Baz: t v
|
|
|
|
Foo: t
|
|
|
|
"#]],
|
2019-12-19 09:57:22 -06:00
|
|
|
);
|
|
|
|
}
|
2020-06-23 21:10:01 -05:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_shadowed_def() {
|
2021-03-08 14:19:44 -06:00
|
|
|
cov_mark::check!(import_shadowed);
|
2020-07-17 07:37:51 -05: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
|
2023-08-21 04:44:09 -05:00
|
|
|
Bar: ti vi
|
2020-07-17 07:37:51 -05:00
|
|
|
bar: t
|
2023-08-21 04:44:09 -05:00
|
|
|
baz: ti
|
2020-07-17 07:37:51 -05:00
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::bar
|
|
|
|
baz: t
|
|
|
|
|
|
|
|
crate::bar::baz
|
|
|
|
Bar: t v
|
|
|
|
|
|
|
|
crate::foo
|
|
|
|
baz: t
|
|
|
|
|
|
|
|
crate::foo::baz
|
|
|
|
Foo: t v
|
|
|
|
"#]],
|
2020-06-23 21:10:01 -05:00
|
|
|
);
|
|
|
|
}
|
2020-06-24 08:30:54 -05:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_shadowed_def_reversed() {
|
2020-07-17 07:37:51 -05: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
|
2023-08-21 04:44:09 -05:00
|
|
|
Bar: ti vi
|
2020-07-17 07:37:51 -05:00
|
|
|
bar: t
|
2023-08-21 04:44:09 -05:00
|
|
|
baz: ti
|
2020-07-17 07:37:51 -05:00
|
|
|
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 08:30:54 -05:00
|
|
|
);
|
|
|
|
}
|
2020-06-24 20:42:44 -05:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_shadowed_def_dependencies() {
|
2020-07-17 07:37:51 -05: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
|
|
|
|
|
2022-07-24 09:04:20 -05:00
|
|
|
crate::a
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::a::foo
|
|
|
|
X: t v
|
|
|
|
|
|
|
|
crate::b
|
2023-08-21 04:44:09 -05:00
|
|
|
foo: ti
|
2020-07-17 07:37:51 -05:00
|
|
|
|
|
|
|
crate::c
|
|
|
|
foo: t
|
|
|
|
|
|
|
|
crate::c::foo
|
|
|
|
Y: t v
|
|
|
|
|
2022-07-24 09:04:20 -05:00
|
|
|
crate::d
|
2023-08-21 04:44:09 -05:00
|
|
|
Y: ti vi
|
|
|
|
foo: ti
|
2020-07-17 07:37:51 -05:00
|
|
|
"#]],
|
2020-06-24 20:42:44 -05:00
|
|
|
);
|
|
|
|
}
|
2022-11-23 09:24:03 -06:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn glob_name_collision_check_visibility() {
|
|
|
|
check(
|
|
|
|
r#"
|
|
|
|
mod event {
|
|
|
|
mod serenity {
|
|
|
|
pub fn Event() {}
|
|
|
|
}
|
|
|
|
use serenity::*;
|
|
|
|
|
|
|
|
pub struct Event {}
|
|
|
|
}
|
|
|
|
|
|
|
|
use event::Event;
|
|
|
|
"#,
|
|
|
|
expect![[r#"
|
|
|
|
crate
|
2023-08-21 04:44:09 -05:00
|
|
|
Event: ti
|
2022-11-23 09:24:03 -06:00
|
|
|
event: t
|
|
|
|
|
|
|
|
crate::event
|
|
|
|
Event: t v
|
|
|
|
serenity: t
|
|
|
|
|
|
|
|
crate::event::serenity
|
|
|
|
Event: v
|
|
|
|
"#]],
|
|
|
|
);
|
|
|
|
}
|