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

View file

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