Rewrite def map tests from insta to expect

Those indentation markers are annoying...
This commit is contained in:
Aleksey Kladov 2020-07-17 14:37:51 +02:00
parent 2c268b9a5f
commit fcdac03033
5 changed files with 1728 additions and 1845 deletions

View file

@ -6,558 +6,531 @@ mod primitives;
use std::sync::Arc;
use insta::assert_snapshot;
use expect::{expect, Expect};
use ra_db::{fixture::WithFixture, SourceDatabase};
use test_utils::mark;
use crate::{db::DefDatabase, nameres::*, test_db::TestDB};
fn def_map(ra_fixture: &str) -> String {
compute_crate_def_map(ra_fixture).dump()
}
fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
let db = TestDB::with_files(fixture);
let krate = db.crate_graph().iter().next().unwrap();
db.crate_def_map(krate)
}
fn check(ra_fixture: &str, expect: Expect) {
let db = TestDB::with_files(ra_fixture);
let krate = db.crate_graph().iter().next().unwrap();
let actual = db.crate_def_map(krate).dump() + "\n";
expect.assert_eq(&actual);
}
#[test]
fn crate_def_map_smoke_test() {
let map = def_map(
r"
//- /lib.rs
mod foo;
struct S;
use crate::foo::bar::E;
use self::E::V;
check(
r#"
//- /lib.rs
mod foo;
struct S;
use crate::foo::bar::E;
use self::E::V;
//- /foo/mod.rs
pub mod bar;
fn f() {}
//- /foo/mod.rs
pub mod bar;
fn f() {}
//- /foo/bar.rs
pub struct Baz;
//- /foo/bar.rs
pub struct Baz;
union U {
to_be: bool,
not_to_be: u8,
}
union U { to_be: bool, not_to_be: u8 }
enum E { V }
enum E { V }
extern {
static EXT: u8;
fn ext();
}
"#,
expect![[r#"
crate
E: t
S: t v
V: t v
foo: t
extern {
static EXT: u8;
fn ext();
}
",
crate::foo
bar: t
f: v
crate::foo::bar
Baz: t v
E: t
EXT: v
U: t
ext: v
"#]],
);
assert_snapshot!(map, @r###"
crate
E: t
S: t v
V: t v
foo: t
crate::foo
bar: t
f: v
crate::foo::bar
Baz: t v
E: t
EXT: v
U: t
ext: v
"###)
}
#[test]
fn crate_def_map_super_super() {
let map = def_map(
"
//- /lib.rs
mod a {
const A: usize = 0;
mod b {
const B: usize = 0;
mod c {
use super::super::*;
}
}
check(
r#"
mod a {
const A: usize = 0;
mod b {
const B: usize = 0;
mod c {
use super::super::*;
}
",
}
}
"#,
expect![[r#"
crate
a: t
crate::a
A: v
b: t
crate::a::b
B: v
c: t
crate::a::b::c
A: v
b: t
"#]],
);
assert_snapshot!(map, @r###"
crate
a: t
crate::a
A: v
b: t
crate::a::b
B: v
c: t
crate::a::b::c
A: v
b: t
"###)
}
#[test]
fn crate_def_map_fn_mod_same_name() {
let map = def_map(
"
//- /lib.rs
mod m {
pub mod z {}
pub fn z() {}
}
",
check(
r#"
mod m {
pub mod z {}
pub fn z() {}
}
"#,
expect![[r#"
crate
m: t
crate::m
z: t v
crate::m::z
"#]],
);
assert_snapshot!(map, @r###"
crate
m: t
crate::m
z: t v
crate::m::z
"###)
}
#[test]
fn bogus_paths() {
mark::check!(bogus_paths);
let map = def_map(
"
//- /lib.rs
mod foo;
struct S;
use self;
check(
r#"
//- /lib.rs
mod foo;
struct S;
use self;
//- /foo/mod.rs
use super;
use crate;
//- /foo/mod.rs
use super;
use crate;
"#,
expect![[r#"
crate
S: t v
foo: t
",
crate::foo
"#]],
);
assert_snapshot!(map, @r###"
crate
S: t v
foo: t
crate::foo
"###
)
}
#[test]
fn use_as() {
let map = def_map(
"
//- /lib.rs
mod foo;
check(
r#"
//- /lib.rs
mod foo;
use crate::foo::Baz as Foo;
use crate::foo::Baz as Foo;
//- /foo/mod.rs
pub struct Baz;
"#,
expect![[r#"
crate
Foo: t v
foo: t
//- /foo/mod.rs
pub struct Baz;
",
);
assert_snapshot!(map,
@r###"
crate
Foo: t v
foo: t
crate::foo
Baz: t v
"###
crate::foo
Baz: t v
"#]],
);
}
#[test]
fn use_trees() {
let map = def_map(
"
//- /lib.rs
mod foo;
check(
r#"
//- /lib.rs
mod foo;
use crate::foo::bar::{Baz, Quux};
use crate::foo::bar::{Baz, Quux};
//- /foo/mod.rs
pub mod bar;
//- /foo/mod.rs
pub mod bar;
//- /foo/bar.rs
pub struct Baz;
pub enum Quux {};
"#,
expect![[r#"
crate
Baz: t v
Quux: t
foo: t
//- /foo/bar.rs
pub struct Baz;
pub enum Quux {};
",
crate::foo
bar: t
crate::foo::bar
Baz: t v
Quux: t
"#]],
);
assert_snapshot!(map, @r###"
crate
Baz: t v
Quux: t
foo: t
crate::foo
bar: t
crate::foo::bar
Baz: t v
Quux: t
"###);
}
#[test]
fn re_exports() {
let map = def_map(
"
//- /lib.rs
mod foo;
check(
r#"
//- /lib.rs
mod foo;
use self::foo::Baz;
use self::foo::Baz;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::Baz;
//- /foo/mod.rs
pub mod bar;
//- /foo/bar.rs
pub struct Baz;
"#,
expect![[r#"
crate
Baz: t v
foo: t
pub use self::bar::Baz;
crate::foo
Baz: t v
bar: t
//- /foo/bar.rs
pub struct Baz;
",
crate::foo::bar
Baz: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
Baz: t v
foo: t
crate::foo
Baz: t v
bar: t
crate::foo::bar
Baz: t v
"###);
}
#[test]
fn std_prelude() {
mark::check!(std_prelude);
let map = def_map(
"
//- /main.rs crate:main deps:test_crate
use Foo::*;
check(
r#"
//- /main.rs crate:main deps:test_crate
use Foo::*;
//- /lib.rs crate:test_crate
mod prelude;
#[prelude_import]
use prelude::*;
//- /lib.rs crate:test_crate
mod prelude;
#[prelude_import]
use prelude::*;
//- /prelude.rs
pub enum Foo { Bar, Baz };
",
//- /prelude.rs
pub enum Foo { Bar, Baz };
"#,
expect![[r#"
crate
Bar: t v
Baz: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
Bar: t v
Baz: t v
"###);
}
#[test]
fn can_import_enum_variant() {
mark::check!(can_import_enum_variant);
let map = def_map(
"
//- /lib.rs
enum E { V }
use self::E::V;
",
);
assert_snapshot!(map, @r###"
crate
E: t
V: t v
"###
check(
r#"
enum E { V }
use self::E::V;
"#,
expect![[r#"
crate
E: t
V: t v
"#]],
);
}
#[test]
fn edition_2015_imports() {
let map = def_map(
"
//- /main.rs crate:main deps:other_crate edition:2015
mod foo;
mod bar;
check(
r#"
//- /main.rs crate:main deps:other_crate edition:2015
mod foo;
mod bar;
//- /bar.rs
struct Bar;
//- /bar.rs
struct Bar;
//- /foo.rs
use bar::Bar;
use other_crate::FromLib;
//- /foo.rs
use bar::Bar;
use other_crate::FromLib;
//- /lib.rs crate:other_crate edition:2018
struct FromLib;
",
//- /lib.rs crate:other_crate edition:2018
struct FromLib;
"#,
expect![[r#"
crate
bar: t
foo: t
crate::bar
Bar: t v
crate::foo
Bar: t v
FromLib: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
bar: t
foo: t
crate::bar
Bar: t v
crate::foo
Bar: t v
FromLib: t v
"###);
}
#[test]
fn item_map_using_self() {
let map = def_map(
"
//- /lib.rs
mod foo;
use crate::foo::bar::Baz::{self};
//- /foo/mod.rs
pub mod bar;
//- /foo/bar.rs
pub struct Baz;
",
check(
r#"
//- /lib.rs
mod foo;
use crate::foo::bar::Baz::{self};
//- /foo/mod.rs
pub mod bar;
//- /foo/bar.rs
pub struct Baz;
"#,
expect![[r#"
crate
Baz: t v
foo: t
crate::foo
bar: t
crate::foo::bar
Baz: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
Baz: t v
foo: t
crate::foo
bar: t
crate::foo::bar
Baz: t v
"###);
}
#[test]
fn item_map_across_crates() {
let map = def_map(
"
//- /main.rs crate:main deps:test_crate
use test_crate::Baz;
check(
r#"
//- /main.rs crate:main deps:test_crate
use test_crate::Baz;
//- /lib.rs crate:test_crate
pub struct Baz;
",
//- /lib.rs crate:test_crate
pub struct Baz;
"#,
expect![[r#"
crate
Baz: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
Baz: t v
"###);
}
#[test]
fn extern_crate_rename() {
let map = def_map(
"
//- /main.rs crate:main deps:alloc
extern crate alloc as alloc_crate;
check(
r#"
//- /main.rs crate:main deps:alloc
extern crate alloc as alloc_crate;
mod alloc;
mod sync;
mod alloc;
mod sync;
//- /sync.rs
use alloc_crate::Arc;
//- /sync.rs
use alloc_crate::Arc;
//- /lib.rs crate:alloc
struct Arc;
"#,
expect![[r#"
crate
alloc_crate: t
sync: t
//- /lib.rs crate:alloc
struct Arc;
",
crate::sync
Arc: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
alloc_crate: t
sync: t
crate::sync
Arc: t v
"###);
}
#[test]
fn extern_crate_rename_2015_edition() {
let map = def_map(
"
//- /main.rs crate:main deps:alloc edition:2015
extern crate alloc as alloc_crate;
check(
r#"
//- /main.rs crate:main deps:alloc edition:2015
extern crate alloc as alloc_crate;
mod alloc;
mod sync;
mod alloc;
mod sync;
//- /sync.rs
use alloc_crate::Arc;
//- /sync.rs
use alloc_crate::Arc;
//- /lib.rs crate:alloc
struct Arc;
"#,
expect![[r#"
crate
alloc_crate: t
sync: t
//- /lib.rs crate:alloc
struct Arc;
",
);
assert_snapshot!(map,
@r###"
crate
alloc_crate: t
sync: t
crate::sync
Arc: t v
"###
crate::sync
Arc: t v
"#]],
);
}
#[test]
fn reexport_across_crates() {
let map = def_map(
"
//- /main.rs crate:main deps:test_crate
use test_crate::Baz;
check(
r#"
//- /main.rs crate:main deps:test_crate
use test_crate::Baz;
//- /lib.rs crate:test_crate
pub use foo::Baz;
//- /lib.rs crate:test_crate
pub use foo::Baz;
mod foo;
mod foo;
//- /foo.rs
pub struct Baz;
",
//- /foo.rs
pub struct Baz;
"#,
expect![[r#"
crate
Baz: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
Baz: t v
"###);
}
#[test]
fn values_dont_shadow_extern_crates() {
let map = def_map(
"
//- /main.rs crate:main deps:foo
fn foo() {}
use foo::Bar;
check(
r#"
//- /main.rs crate:main deps:foo
fn foo() {}
use foo::Bar;
//- /foo/lib.rs crate:foo
pub struct Bar;
",
//- /foo/lib.rs crate:foo
pub struct Bar;
"#,
expect![[r#"
crate
Bar: t v
foo: v
"#]],
);
assert_snapshot!(map, @r###"
crate
Bar: t v
foo: v
"###);
}
#[test]
fn std_prelude_takes_precedence_above_core_prelude() {
let map = def_map(
check(
r#"
//- /main.rs crate:main deps:core,std
use {Foo, Bar};
//- /main.rs crate:main deps:core,std
use {Foo, Bar};
//- /std.rs crate:std deps:core
#[prelude_import]
pub use self::prelude::*;
mod prelude {
pub struct Foo;
pub use core::prelude::Bar;
}
//- /std.rs crate:std deps:core
#[prelude_import]
pub use self::prelude::*;
mod prelude {
pub struct Foo;
pub use core::prelude::Bar;
}
//- /core.rs crate:core
#[prelude_import]
pub use self::prelude::*;
mod prelude {
pub struct Bar;
}
"#,
//- /core.rs crate:core
#[prelude_import]
pub use self::prelude::*;
mod prelude {
pub struct Bar;
}
"#,
expect![[r#"
crate
Bar: t v
Foo: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
Bar: t v
Foo: t v
"###);
}
#[test]
fn cfg_not_test() {
let map = def_map(
check(
r#"
//- /main.rs crate:main deps:std
use {Foo, Bar, Baz};
//- /main.rs crate:main deps:std
use {Foo, Bar, Baz};
//- /lib.rs crate:std
#[prelude_import]
pub use self::prelude::*;
mod prelude {
#[cfg(test)]
pub struct Foo;
#[cfg(not(test))]
pub struct Bar;
#[cfg(all(not(any()), feature = "foo", feature = "bar", opt = "42"))]
pub struct Baz;
}
"#,
//- /lib.rs crate:std
#[prelude_import]
pub use self::prelude::*;
mod prelude {
#[cfg(test)]
pub struct Foo;
#[cfg(not(test))]
pub struct Bar;
#[cfg(all(not(any()), feature = "foo", feature = "bar", opt = "42"))]
pub struct Baz;
}
"#,
expect![[r#"
crate
Bar: t v
Baz: _
Foo: _
"#]],
);
assert_snapshot!(map, @r###"
crate
Bar: t v
Baz: _
Foo: _
"###);
}
#[test]
fn cfg_test() {
let map = def_map(
check(
r#"
//- /main.rs crate:main deps:std
use {Foo, Bar, Baz};
//- /main.rs crate:main deps:std
use {Foo, Bar, Baz};
//- /lib.rs crate:std cfg:test,feature=foo,feature=bar,opt=42
#[prelude_import]
pub use self::prelude::*;
mod prelude {
#[cfg(test)]
pub struct Foo;
#[cfg(not(test))]
pub struct Bar;
#[cfg(all(not(any()), feature = "foo", feature = "bar", opt = "42"))]
pub struct Baz;
}
"#,
//- /lib.rs crate:std cfg:test,feature=foo,feature=bar,opt=42
#[prelude_import]
pub use self::prelude::*;
mod prelude {
#[cfg(test)]
pub struct Foo;
#[cfg(not(test))]
pub struct Bar;
#[cfg(all(not(any()), feature = "foo", feature = "bar", opt = "42"))]
pub struct Baz;
}
"#,
expect![[r#"
crate
Bar: _
Baz: t v
Foo: t v
"#]],
);
assert_snapshot!(map, @r###"
crate
Bar: _
Baz: t v
Foo: t v
"###);
}
#[test]
fn infer_multiple_namespace() {
let map = def_map(
check(
r#"
//- /main.rs
mod a {
@ -571,18 +544,17 @@ mod b {
pub const T: () = ();
}
"#,
);
expect![[r#"
crate
T: t v
a: t
b: t
assert_snapshot!(map, @r###"
crate
T: t v
a: t
b: t
crate::b
T: v
crate::a
T: t v
"###);
crate::b
T: v
crate::a
T: t v
"#]],
);
}

View file

@ -2,367 +2,337 @@ use super::*;
#[test]
fn glob_1() {
let map = def_map(
r"
//- /lib.rs
mod foo;
use foo::*;
check(
r#"
//- /lib.rs
mod foo;
use foo::*;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::Baz;
pub struct Foo;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::Baz;
pub struct Foo;
//- /foo/bar.rs
pub struct Baz;
",
);
assert_snapshot!(map, @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/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
"#]],
);
}
#[test]
fn glob_2() {
let map = def_map(
"
//- /lib.rs
mod foo;
use foo::*;
check(
r#"
//- /lib.rs
mod foo;
use foo::*;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::*;
pub struct Foo;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::*;
pub struct Foo;
//- /foo/bar.rs
pub struct Baz;
pub use super::*;
",
);
assert_snapshot!(map, @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
"###
//- /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
"#]],
);
}
#[test]
fn glob_privacy_1() {
let map = def_map(
check(
r"
//- /lib.rs
mod foo;
use foo::*;
//- /lib.rs
mod foo;
use foo::*;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::*;
struct PrivateStructFoo;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::*;
struct PrivateStructFoo;
//- /foo/bar.rs
pub struct Baz;
struct PrivateStructBar;
pub use super::*;
",
);
assert_snapshot!(map, @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
"###
//- /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
"#]],
);
}
#[test]
fn glob_privacy_2() {
let map = def_map(
check(
r"
//- /lib.rs
mod foo;
use foo::*;
use foo::bar::*;
//- /lib.rs
mod foo;
use foo::*;
use foo::bar::*;
//- /foo/mod.rs
mod bar;
fn Foo() {};
pub struct Foo {};
//- /foo/mod.rs
mod bar;
fn Foo() {};
pub struct Foo {};
//- /foo/bar.rs
pub(super) struct PrivateBaz;
struct PrivateBar;
pub(crate) struct PubCrateStruct;
",
);
assert_snapshot!(map, @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
"###
//- /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
"#]],
);
}
#[test]
fn glob_across_crates() {
mark::check!(glob_across_crates);
let map = def_map(
r"
//- /main.rs crate:main deps:test_crate
use test_crate::*;
check(
r#"
//- /main.rs crate:main deps:test_crate
use test_crate::*;
//- /lib.rs crate:test_crate
pub struct Baz;
",
);
assert_snapshot!(map, @r###"
crate
Baz: t v
"###
//- /lib.rs crate:test_crate
pub struct Baz;
"#,
expect![[r#"
crate
Baz: t v
"#]],
);
}
#[test]
fn glob_privacy_across_crates() {
let map = def_map(
r"
//- /main.rs crate:main deps:test_crate
use test_crate::*;
check(
r#"
//- /main.rs crate:main deps:test_crate
use test_crate::*;
//- /lib.rs crate:test_crate
pub struct Baz;
struct Foo;
",
);
assert_snapshot!(map, @r###"
crate
Baz: t v
"###
//- /lib.rs crate:test_crate
pub struct Baz;
struct Foo;
"#,
expect![[r#"
crate
Baz: t v
"#]],
);
}
#[test]
fn glob_enum() {
mark::check!(glob_enum);
let map = def_map(
"
//- /lib.rs
enum Foo {
Bar, Baz
}
use self::Foo::*;
",
);
assert_snapshot!(map, @r###"
crate
Bar: t v
Baz: t v
Foo: t
"###
check(
r#"
enum Foo { Bar, Baz }
use self::Foo::*;
"#,
expect![[r#"
crate
Bar: t v
Baz: t v
Foo: t
"#]],
);
}
#[test]
fn glob_enum_group() {
mark::check!(glob_enum_group);
let map = def_map(
r"
//- /lib.rs
enum Foo {
Bar, Baz
}
use self::Foo::{*};
",
);
assert_snapshot!(map, @r###"
crate
Bar: t v
Baz: t v
Foo: t
"###
check(
r#"
enum Foo { Bar, Baz }
use self::Foo::{*};
"#,
expect![[r#"
crate
Bar: t v
Baz: t v
Foo: t
"#]],
);
}
#[test]
fn glob_shadowed_def() {
mark::check!(import_shadowed);
let map = def_map(
r###"
//- /lib.rs
mod foo;
mod bar;
check(
r#"
//- /lib.rs
mod foo;
mod bar;
use foo::*;
use bar::baz;
use baz::Bar;
use foo::*;
use bar::baz;
//- /foo.rs
pub mod baz { pub struct Foo; }
use baz::Bar;
//- /bar.rs
pub mod baz { pub struct Bar; }
"#,
expect![[r#"
crate
Bar: t v
bar: t
baz: t
foo: t
//- /foo.rs
pub mod baz {
pub struct Foo;
}
crate::bar
baz: t
//- /bar.rs
pub mod baz {
pub struct Bar;
}
"###,
);
assert_snapshot!(map, @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
"###
crate::bar::baz
Bar: t v
crate::foo
baz: t
crate::foo::baz
Foo: t v
"#]],
);
}
#[test]
fn glob_shadowed_def_reversed() {
let map = def_map(
r###"
//- /lib.rs
mod foo;
mod bar;
check(
r#"
//- /lib.rs
mod foo;
mod bar;
use bar::baz;
use foo::*;
use baz::Bar;
use bar::baz;
use foo::*;
//- /foo.rs
pub mod baz { pub struct Foo; }
use baz::Bar;
//- /bar.rs
pub mod baz { pub struct Bar; }
"#,
expect![[r#"
crate
Bar: t v
bar: t
baz: t
foo: t
//- /foo.rs
pub mod baz {
pub struct Foo;
}
crate::bar
baz: t
//- /bar.rs
pub mod baz {
pub struct Bar;
}
"###,
);
assert_snapshot!(map, @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
"###
crate::bar::baz
Bar: t v
crate::foo
baz: t
crate::foo::baz
Foo: t v
"#]],
);
}
#[test]
fn glob_shadowed_def_dependencies() {
let map = def_map(
r###"
//- /lib.rs
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;
}
"###,
);
assert_snapshot!(map, @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
"###
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
"#]],
);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,23 +2,22 @@ use super::*;
#[test]
fn primitive_reexport() {
let map = def_map(
"
//- /lib.rs
mod foo;
use foo::int;
check(
r#"
//- /lib.rs
mod foo;
use foo::int;
//- /foo.rs
pub use i32 as int;
",
);
assert_snapshot!(map, @r###"
crate
foo: t
int: t
crate::foo
int: t
"###
//- /foo.rs
pub use i32 as int;
"#,
expect![[r#"
crate
foo: t
int: t
crate::foo
int: t
"#]],
);
}