mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Rewrite def map tests from insta to expect
Those indentation markers are annoying...
This commit is contained in:
parent
2c268b9a5f
commit
fcdac03033
5 changed files with 1728 additions and 1845 deletions
|
@ -6,26 +6,29 @@ 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;
|
||||||
|
@ -39,102 +42,94 @@ fn crate_def_map_smoke_test() {
|
||||||
//- /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,
|
|
||||||
not_to_be: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum E { V }
|
enum E { V }
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
static EXT: u8;
|
static EXT: u8;
|
||||||
fn ext();
|
fn ext();
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[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
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
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 {
|
mod b {
|
||||||
const B: usize = 0;
|
const B: usize = 0;
|
||||||
|
|
||||||
mod c {
|
mod c {
|
||||||
use super::super::*;
|
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;
|
||||||
|
@ -143,51 +138,45 @@ fn bogus_paths() {
|
||||||
//- /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
|
//- /foo/mod.rs
|
||||||
pub struct Baz;
|
pub struct Baz;
|
||||||
",
|
"#,
|
||||||
);
|
expect![[r#"
|
||||||
assert_snapshot!(map,
|
crate
|
||||||
@r###"
|
Foo: t v
|
||||||
⋮crate
|
foo: t
|
||||||
⋮Foo: t v
|
|
||||||
⋮foo: t
|
crate::foo
|
||||||
⋮
|
Baz: t v
|
||||||
⋮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
|
//- /foo/mod.rs
|
||||||
|
@ -196,60 +185,58 @@ fn use_trees() {
|
||||||
//- /foo/bar.rs
|
//- /foo/bar.rs
|
||||||
pub struct Baz;
|
pub struct Baz;
|
||||||
pub enum Quux {};
|
pub enum Quux {};
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Baz: t v
|
||||||
|
Quux: t
|
||||||
|
foo: t
|
||||||
|
|
||||||
|
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]
|
#[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
|
//- /foo/mod.rs
|
||||||
pub mod bar;
|
pub mod bar;
|
||||||
|
|
||||||
pub use self::bar::Baz;
|
pub use self::bar::Baz;
|
||||||
|
|
||||||
//- /foo/bar.rs
|
//- /foo/bar.rs
|
||||||
pub struct Baz;
|
pub struct Baz;
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Baz: t v
|
||||||
|
foo: t
|
||||||
|
|
||||||
|
crate::foo
|
||||||
|
Baz: t v
|
||||||
|
bar: t
|
||||||
|
|
||||||
|
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]
|
#[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::*;
|
||||||
|
|
||||||
|
@ -260,37 +247,35 @@ fn std_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#"
|
||||||
assert_snapshot!(map, @r###"
|
crate
|
||||||
⋮crate
|
E: t
|
||||||
⋮E: t
|
V: t v
|
||||||
⋮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;
|
||||||
|
@ -304,74 +289,73 @@ fn edition_2015_imports() {
|
||||||
|
|
||||||
//- /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
|
||||||
|
|
||||||
assert_snapshot!(map, @r###"
|
crate::bar
|
||||||
⋮crate
|
Bar: t v
|
||||||
⋮bar: t
|
|
||||||
⋮foo: t
|
crate::foo
|
||||||
⋮
|
Bar: t v
|
||||||
⋮crate::bar
|
FromLib: t v
|
||||||
⋮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
|
//- /foo/mod.rs
|
||||||
pub mod bar;
|
pub mod bar;
|
||||||
|
|
||||||
//- /foo/bar.rs
|
//- /foo/bar.rs
|
||||||
pub struct Baz;
|
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 alloc;
|
||||||
mod sync;
|
mod sync;
|
||||||
|
|
||||||
|
@ -380,26 +364,24 @@ fn extern_crate_rename() {
|
||||||
|
|
||||||
//- /lib.rs crate:alloc
|
//- /lib.rs crate:alloc
|
||||||
struct Arc;
|
struct Arc;
|
||||||
",
|
"#,
|
||||||
);
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
alloc_crate: t
|
||||||
|
sync: t
|
||||||
|
|
||||||
assert_snapshot!(map, @r###"
|
crate::sync
|
||||||
⋮crate
|
Arc: t v
|
||||||
⋮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 alloc;
|
||||||
mod sync;
|
mod sync;
|
||||||
|
|
||||||
|
@ -408,67 +390,61 @@ fn extern_crate_rename_2015_edition() {
|
||||||
|
|
||||||
//- /lib.rs crate:alloc
|
//- /lib.rs crate:alloc
|
||||||
struct Arc;
|
struct Arc;
|
||||||
",
|
"#,
|
||||||
);
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
alloc_crate: t
|
||||||
|
sync: t
|
||||||
|
|
||||||
assert_snapshot!(map,
|
crate::sync
|
||||||
@r###"
|
Arc: t v
|
||||||
⋮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
|
//- /foo.rs
|
||||||
pub struct Baz;
|
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};
|
||||||
|
@ -488,18 +464,17 @@ fn std_prelude_takes_precedence_above_core_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};
|
||||||
|
@ -516,19 +491,18 @@ fn cfg_not_test() {
|
||||||
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};
|
||||||
|
@ -545,19 +519,18 @@ fn cfg_test() {
|
||||||
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
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ 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::*;
|
||||||
|
@ -15,30 +15,29 @@ fn glob_1() {
|
||||||
|
|
||||||
//- /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::*;
|
||||||
|
@ -51,31 +50,30 @@ fn glob_2() {
|
||||||
//- /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;
|
||||||
|
@ -91,30 +89,29 @@ fn glob_privacy_1() {
|
||||||
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;
|
||||||
|
@ -131,203 +128,177 @@ fn glob_privacy_2() {
|
||||||
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 {
|
|
||||||
Bar, Baz
|
|
||||||
}
|
|
||||||
use self::Foo::*;
|
use self::Foo::*;
|
||||||
",
|
"#,
|
||||||
);
|
expect![[r#"
|
||||||
assert_snapshot!(map, @r###"
|
crate
|
||||||
⋮crate
|
Bar: t v
|
||||||
⋮Bar: t v
|
Baz: t v
|
||||||
⋮Baz: t v
|
Foo: t
|
||||||
⋮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 {
|
|
||||||
Bar, Baz
|
|
||||||
}
|
|
||||||
use self::Foo::{*};
|
use self::Foo::{*};
|
||||||
",
|
"#,
|
||||||
);
|
expect![[r#"
|
||||||
assert_snapshot!(map, @r###"
|
crate
|
||||||
⋮crate
|
Bar: t v
|
||||||
⋮Bar: t v
|
Baz: t v
|
||||||
⋮Baz: t v
|
Foo: t
|
||||||
⋮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 foo::*;
|
||||||
use bar::baz;
|
use bar::baz;
|
||||||
|
|
||||||
use baz::Bar;
|
use baz::Bar;
|
||||||
|
|
||||||
//- /foo.rs
|
//- /foo.rs
|
||||||
pub mod baz {
|
pub mod baz { pub struct Foo; }
|
||||||
pub struct Foo;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- /bar.rs
|
//- /bar.rs
|
||||||
pub mod baz {
|
pub mod baz { pub struct Bar; }
|
||||||
pub struct Bar;
|
"#,
|
||||||
}
|
expect![[r#"
|
||||||
"###,
|
crate
|
||||||
);
|
Bar: t v
|
||||||
assert_snapshot!(map, @r###"
|
bar: t
|
||||||
⋮crate
|
baz: t
|
||||||
⋮Bar: t v
|
foo: t
|
||||||
⋮bar: t
|
|
||||||
⋮baz: t
|
crate::bar
|
||||||
⋮foo: t
|
baz: t
|
||||||
⋮
|
|
||||||
⋮crate::bar
|
crate::bar::baz
|
||||||
⋮baz: t
|
Bar: t v
|
||||||
⋮
|
|
||||||
⋮crate::bar::baz
|
crate::foo
|
||||||
⋮Bar: t v
|
baz: t
|
||||||
⋮
|
|
||||||
⋮crate::foo
|
crate::foo::baz
|
||||||
⋮baz: t
|
Foo: t v
|
||||||
⋮
|
"#]],
|
||||||
⋮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 bar::baz;
|
||||||
use foo::*;
|
use foo::*;
|
||||||
|
|
||||||
use baz::Bar;
|
use baz::Bar;
|
||||||
|
|
||||||
//- /foo.rs
|
//- /foo.rs
|
||||||
pub mod baz {
|
pub mod baz { pub struct Foo; }
|
||||||
pub struct Foo;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- /bar.rs
|
//- /bar.rs
|
||||||
pub mod baz {
|
pub mod baz { pub struct Bar; }
|
||||||
pub struct Bar;
|
"#,
|
||||||
}
|
expect![[r#"
|
||||||
"###,
|
crate
|
||||||
);
|
Bar: t v
|
||||||
assert_snapshot!(map, @r###"
|
bar: t
|
||||||
⋮crate
|
baz: t
|
||||||
⋮Bar: t v
|
foo: t
|
||||||
⋮bar: t
|
|
||||||
⋮baz: t
|
crate::bar
|
||||||
⋮foo: t
|
baz: t
|
||||||
⋮
|
|
||||||
⋮crate::bar
|
crate::bar::baz
|
||||||
⋮baz: t
|
Bar: t v
|
||||||
⋮
|
|
||||||
⋮crate::bar::baz
|
crate::foo
|
||||||
⋮Bar: t v
|
baz: t
|
||||||
⋮
|
|
||||||
⋮crate::foo
|
crate::foo::baz
|
||||||
⋮baz: t
|
Foo: t v
|
||||||
⋮
|
"#]],
|
||||||
⋮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; } }
|
||||||
|
@ -336,33 +307,32 @@ fn glob_shadowed_def_dependencies() {
|
||||||
use super::b::*;
|
use super::b::*;
|
||||||
use foo::Y;
|
use foo::Y;
|
||||||
}
|
}
|
||||||
"###,
|
"#,
|
||||||
);
|
expect![[r#"
|
||||||
assert_snapshot!(map, @r###"
|
crate
|
||||||
⋮crate
|
a: t
|
||||||
⋮a: t
|
b: t
|
||||||
⋮b: t
|
c: t
|
||||||
⋮c: t
|
d: t
|
||||||
⋮d: t
|
|
||||||
⋮
|
crate::d
|
||||||
⋮crate::d
|
Y: t v
|
||||||
⋮Y: t v
|
foo: t
|
||||||
⋮foo: t
|
|
||||||
⋮
|
crate::c
|
||||||
⋮crate::c
|
foo: t
|
||||||
⋮foo: t
|
|
||||||
⋮
|
crate::c::foo
|
||||||
⋮crate::c::foo
|
Y: t v
|
||||||
⋮Y: t v
|
|
||||||
⋮
|
crate::b
|
||||||
⋮crate::b
|
foo: t
|
||||||
⋮foo: t
|
|
||||||
⋮
|
crate::a
|
||||||
⋮crate::a
|
foo: t
|
||||||
⋮foo: t
|
|
||||||
⋮
|
crate::a::foo
|
||||||
⋮crate::a::foo
|
X: t v
|
||||||
⋮X: t v
|
"#]],
|
||||||
"###
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_rules_are_globally_visible() {
|
fn macro_rules_are_globally_visible() {
|
||||||
let map = def_map(
|
check(
|
||||||
r"
|
r#"
|
||||||
//- /lib.rs
|
//- /lib.rs
|
||||||
macro_rules! structs {
|
macro_rules! structs {
|
||||||
($($i:ident),*) => {
|
($($i:ident),*) => {
|
||||||
|
@ -15,32 +15,29 @@ fn macro_rules_are_globally_visible() {
|
||||||
|
|
||||||
//- /nested.rs
|
//- /nested.rs
|
||||||
structs!(Bar, Baz);
|
structs!(Bar, Baz);
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Foo: t
|
||||||
|
nested: t
|
||||||
|
|
||||||
|
crate::nested
|
||||||
|
Bar: t
|
||||||
|
Baz: t
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Foo: t
|
|
||||||
⋮nested: t
|
|
||||||
⋮
|
|
||||||
⋮crate::nested
|
|
||||||
⋮Bar: t
|
|
||||||
⋮Baz: t
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_rules_can_define_modules() {
|
fn macro_rules_can_define_modules() {
|
||||||
let map = def_map(
|
check(
|
||||||
r"
|
r#"
|
||||||
//- /lib.rs
|
//- /lib.rs
|
||||||
macro_rules! m {
|
macro_rules! m {
|
||||||
($name:ident) => { mod $name; }
|
($name:ident) => { mod $name; }
|
||||||
}
|
}
|
||||||
m!(n1);
|
m!(n1);
|
||||||
|
mod m { m!(n3) }
|
||||||
mod m {
|
|
||||||
m!(n3)
|
|
||||||
}
|
|
||||||
|
|
||||||
//- /n1.rs
|
//- /n1.rs
|
||||||
m!(n2)
|
m!(n2)
|
||||||
|
@ -48,31 +45,31 @@ fn macro_rules_can_define_modules() {
|
||||||
struct X;
|
struct X;
|
||||||
//- /m/n3.rs
|
//- /m/n3.rs
|
||||||
struct Y;
|
struct Y;
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
m: t
|
||||||
|
n1: t
|
||||||
|
|
||||||
|
crate::m
|
||||||
|
n3: t
|
||||||
|
|
||||||
|
crate::m::n3
|
||||||
|
Y: t v
|
||||||
|
|
||||||
|
crate::n1
|
||||||
|
n2: t
|
||||||
|
|
||||||
|
crate::n1::n2
|
||||||
|
X: t v
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮m: t
|
|
||||||
⋮n1: t
|
|
||||||
⋮
|
|
||||||
⋮crate::m
|
|
||||||
⋮n3: t
|
|
||||||
⋮
|
|
||||||
⋮crate::m::n3
|
|
||||||
⋮Y: t v
|
|
||||||
⋮
|
|
||||||
⋮crate::n1
|
|
||||||
⋮n2: t
|
|
||||||
⋮
|
|
||||||
⋮crate::n1::n2
|
|
||||||
⋮X: t v
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_rules_from_other_crates_are_visible() {
|
fn macro_rules_from_other_crates_are_visible() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
foo::structs!(Foo, Bar)
|
foo::structs!(Foo, Bar)
|
||||||
mod bar;
|
mod bar;
|
||||||
|
@ -87,25 +84,25 @@ fn macro_rules_from_other_crates_are_visible() {
|
||||||
$(struct $i { field: u32 } )*
|
$(struct $i { field: u32 } )*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Bar: t
|
||||||
|
Foo: t
|
||||||
|
bar: t
|
||||||
|
|
||||||
|
crate::bar
|
||||||
|
Bar: t
|
||||||
|
Foo: t
|
||||||
|
bar: t
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Bar: t
|
|
||||||
⋮Foo: t
|
|
||||||
⋮bar: t
|
|
||||||
⋮
|
|
||||||
⋮crate::bar
|
|
||||||
⋮Bar: t
|
|
||||||
⋮Foo: t
|
|
||||||
⋮bar: t
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_rules_export_with_local_inner_macros_are_visible() {
|
fn macro_rules_export_with_local_inner_macros_are_visible() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
foo::structs!(Foo, Bar)
|
foo::structs!(Foo, Bar)
|
||||||
mod bar;
|
mod bar;
|
||||||
|
@ -120,30 +117,32 @@ fn macro_rules_export_with_local_inner_macros_are_visible() {
|
||||||
$(struct $i { field: u32 } )*
|
$(struct $i { field: u32 } )*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Bar: t
|
||||||
|
Foo: t
|
||||||
|
bar: t
|
||||||
|
|
||||||
|
crate::bar
|
||||||
|
Bar: t
|
||||||
|
Foo: t
|
||||||
|
bar: t
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Bar: t
|
|
||||||
⋮Foo: t
|
|
||||||
⋮bar: t
|
|
||||||
⋮
|
|
||||||
⋮crate::bar
|
|
||||||
⋮Bar: t
|
|
||||||
⋮Foo: t
|
|
||||||
⋮bar: t
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn local_inner_macros_makes_local_macros_usable() {
|
fn local_inner_macros_makes_local_macros_usable() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
foo::structs!(Foo, Bar);
|
foo::structs!(Foo, Bar);
|
||||||
mod bar;
|
mod bar;
|
||||||
|
|
||||||
//- /bar.rs
|
//- /bar.rs
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
//- /lib.rs crate:foo
|
//- /lib.rs crate:foo
|
||||||
#[macro_export(local_inner_macros)]
|
#[macro_export(local_inner_macros)]
|
||||||
macro_rules! structs {
|
macro_rules! structs {
|
||||||
|
@ -157,32 +156,31 @@ fn local_inner_macros_makes_local_macros_usable() {
|
||||||
$(struct $i { field: u32 } )*
|
$(struct $i { field: u32 } )*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Bar: t
|
||||||
|
Foo: t
|
||||||
|
bar: t
|
||||||
|
|
||||||
|
crate::bar
|
||||||
|
Bar: t
|
||||||
|
Foo: t
|
||||||
|
bar: t
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Bar: t
|
|
||||||
⋮Foo: t
|
|
||||||
⋮bar: t
|
|
||||||
⋮
|
|
||||||
⋮crate::bar
|
|
||||||
⋮Bar: t
|
|
||||||
⋮Foo: t
|
|
||||||
⋮bar: t
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
|
fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
macro_rules! baz {
|
macro_rules! baz {
|
||||||
() => {
|
() => {
|
||||||
use foo::bar;
|
use foo::bar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foo!();
|
foo!();
|
||||||
bar!();
|
bar!();
|
||||||
baz!();
|
baz!();
|
||||||
|
@ -200,21 +198,21 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
|
||||||
use foo::foo;
|
use foo::foo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Foo: t
|
||||||
|
bar: m
|
||||||
|
foo: m
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Foo: t
|
|
||||||
⋮bar: m
|
|
||||||
⋮foo: m
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_rules_from_other_crates_are_visible_with_macro_use() {
|
fn macro_rules_from_other_crates_are_visible_with_macro_use() {
|
||||||
mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use);
|
mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use);
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
structs!(Foo);
|
structs!(Foo);
|
||||||
structs_priv!(Bar);
|
structs_priv!(Bar);
|
||||||
|
@ -246,25 +244,25 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() {
|
||||||
($i:ident) => { struct $i; }
|
($i:ident) => { struct $i; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Bar: t v
|
||||||
|
Foo: t v
|
||||||
|
bar: t
|
||||||
|
foo: t
|
||||||
|
|
||||||
|
crate::bar
|
||||||
|
Baz: t v
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Bar: t v
|
|
||||||
⋮Foo: t v
|
|
||||||
⋮bar: t
|
|
||||||
⋮foo: t
|
|
||||||
⋮
|
|
||||||
⋮crate::bar
|
|
||||||
⋮Baz: t v
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prelude_is_macro_use() {
|
fn prelude_is_macro_use() {
|
||||||
mark::check!(prelude_is_macro_use);
|
mark::check!(prelude_is_macro_use);
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
structs!(Foo);
|
structs!(Foo);
|
||||||
structs_priv!(Bar);
|
structs_priv!(Bar);
|
||||||
|
@ -299,25 +297,24 @@ fn prelude_is_macro_use() {
|
||||||
macro_rules! structs_outside {
|
macro_rules! structs_outside {
|
||||||
($i:ident) => { struct $i; }
|
($i:ident) => { struct $i; }
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Bar: t v
|
||||||
|
Foo: t v
|
||||||
|
Out: t v
|
||||||
|
bar: t
|
||||||
|
|
||||||
|
crate::bar
|
||||||
|
Baz: t v
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Bar: t v
|
|
||||||
⋮Foo: t v
|
|
||||||
⋮Out: t v
|
|
||||||
⋮bar: t
|
|
||||||
⋮
|
|
||||||
⋮crate::bar
|
|
||||||
⋮Baz: t v
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prelude_cycle() {
|
fn prelude_cycle() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /lib.rs
|
|
||||||
#[prelude_import]
|
#[prelude_import]
|
||||||
use self::prelude::*;
|
use self::prelude::*;
|
||||||
|
|
||||||
|
@ -328,27 +325,25 @@ fn prelude_cycle() {
|
||||||
() => (mod foo {})
|
() => (mod foo {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
prelude: t
|
||||||
|
|
||||||
|
crate::prelude
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮prelude: t
|
|
||||||
⋮
|
|
||||||
⋮crate::prelude
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn plain_macros_are_legacy_textual_scoped() {
|
fn plain_macros_are_legacy_textual_scoped() {
|
||||||
let map = def_map(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs
|
//- /main.rs
|
||||||
mod m1;
|
mod m1;
|
||||||
bar!(NotFoundNotMacroUse);
|
bar!(NotFoundNotMacroUse);
|
||||||
|
|
||||||
mod m2 {
|
mod m2 { foo!(NotFoundBeforeInside2); }
|
||||||
foo!(NotFoundBeforeInside2);
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
($x:ident) => { struct $x; }
|
($x:ident) => { struct $x; }
|
||||||
|
@ -402,46 +397,45 @@ fn plain_macros_are_legacy_textual_scoped() {
|
||||||
($x:ident) => { struct $x; }
|
($x:ident) => { struct $x; }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Ok: t v
|
||||||
|
OkAfter: t v
|
||||||
|
OkShadowStop: t v
|
||||||
|
m1: t
|
||||||
|
m2: t
|
||||||
|
m3: t
|
||||||
|
m5: t
|
||||||
|
m7: t
|
||||||
|
ok_double_macro_use_shadow: v
|
||||||
|
|
||||||
|
crate::m7
|
||||||
|
|
||||||
|
crate::m1
|
||||||
|
|
||||||
|
crate::m5
|
||||||
|
m6: t
|
||||||
|
|
||||||
|
crate::m5::m6
|
||||||
|
|
||||||
|
crate::m2
|
||||||
|
|
||||||
|
crate::m3
|
||||||
|
OkAfterInside: t v
|
||||||
|
OkMacroUse: t v
|
||||||
|
m4: t
|
||||||
|
ok_shadow: v
|
||||||
|
|
||||||
|
crate::m3::m4
|
||||||
|
ok_shadow_deep: v
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Ok: t v
|
|
||||||
⋮OkAfter: t v
|
|
||||||
⋮OkShadowStop: t v
|
|
||||||
⋮m1: t
|
|
||||||
⋮m2: t
|
|
||||||
⋮m3: t
|
|
||||||
⋮m5: t
|
|
||||||
⋮m7: t
|
|
||||||
⋮ok_double_macro_use_shadow: v
|
|
||||||
⋮
|
|
||||||
⋮crate::m7
|
|
||||||
⋮
|
|
||||||
⋮crate::m1
|
|
||||||
⋮
|
|
||||||
⋮crate::m5
|
|
||||||
⋮m6: t
|
|
||||||
⋮
|
|
||||||
⋮crate::m5::m6
|
|
||||||
⋮
|
|
||||||
⋮crate::m2
|
|
||||||
⋮
|
|
||||||
⋮crate::m3
|
|
||||||
⋮OkAfterInside: t v
|
|
||||||
⋮OkMacroUse: t v
|
|
||||||
⋮m4: t
|
|
||||||
⋮ok_shadow: v
|
|
||||||
⋮
|
|
||||||
⋮crate::m3::m4
|
|
||||||
⋮ok_shadow_deep: v
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn type_value_macro_live_in_different_scopes() {
|
fn type_value_macro_live_in_different_scopes() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
($x:ident) => { type $x = (); }
|
($x:ident) => { type $x = (); }
|
||||||
|
@ -452,20 +446,20 @@ fn type_value_macro_live_in_different_scopes() {
|
||||||
|
|
||||||
use self::foo as baz;
|
use self::foo as baz;
|
||||||
fn baz() {}
|
fn baz() {}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
bar: t m
|
||||||
|
baz: t v m
|
||||||
|
foo: t m
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮bar: t m
|
|
||||||
⋮baz: t v m
|
|
||||||
⋮foo: t m
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_use_can_be_aliased() {
|
fn macro_use_can_be_aliased() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate foo;
|
extern crate foo;
|
||||||
|
@ -482,21 +476,20 @@ fn macro_use_can_be_aliased() {
|
||||||
($x:ident) => { struct $x; }
|
($x:ident) => { struct $x; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Alias: t v
|
||||||
|
Direct: t v
|
||||||
|
foo: t
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Alias: t v
|
|
||||||
⋮Direct: t v
|
|
||||||
⋮foo: t
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn path_qualified_macros() {
|
fn path_qualified_macros() {
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs
|
|
||||||
macro_rules! foo {
|
macro_rules! foo {
|
||||||
($x:ident) => { struct $x; }
|
($x:ident) => { struct $x; }
|
||||||
}
|
}
|
||||||
|
@ -516,37 +509,36 @@ fn path_qualified_macros() {
|
||||||
macro_rules! bar {
|
macro_rules! bar {
|
||||||
($x:ident) => { struct $x; }
|
($x:ident) => { struct $x; }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub use bar as alias1;
|
pub use bar as alias1;
|
||||||
pub use super::bar as alias2;
|
pub use super::bar as alias2;
|
||||||
pub use crate::bar as alias3;
|
pub use crate::bar as alias3;
|
||||||
pub use self::bar as not_found;
|
pub use self::bar as not_found;
|
||||||
}
|
}
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
OkAliasCrate: t v
|
||||||
|
OkAliasPlain: t v
|
||||||
|
OkAliasSuper: t v
|
||||||
|
OkCrate: t v
|
||||||
|
OkPlain: t v
|
||||||
|
bar: m
|
||||||
|
m: t
|
||||||
|
|
||||||
|
crate::m
|
||||||
|
alias1: m
|
||||||
|
alias2: m
|
||||||
|
alias3: m
|
||||||
|
not_found: _
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮OkAliasCrate: t v
|
|
||||||
⋮OkAliasPlain: t v
|
|
||||||
⋮OkAliasSuper: t v
|
|
||||||
⋮OkCrate: t v
|
|
||||||
⋮OkPlain: t v
|
|
||||||
⋮bar: m
|
|
||||||
⋮m: t
|
|
||||||
⋮
|
|
||||||
⋮crate::m
|
|
||||||
⋮alias1: m
|
|
||||||
⋮alias2: m
|
|
||||||
⋮alias3: m
|
|
||||||
⋮not_found: _
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_dollar_crate_is_correct_in_item() {
|
fn macro_dollar_crate_is_correct_in_item() {
|
||||||
mark::check!(macro_dollar_crate_self);
|
mark::check!(macro_dollar_crate_self);
|
||||||
let map = def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
//- /main.rs crate:main deps:foo
|
//- /main.rs crate:main deps:foo
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate foo;
|
extern crate foo;
|
||||||
|
@ -585,26 +577,26 @@ fn macro_dollar_crate_is_correct_in_item() {
|
||||||
|
|
||||||
struct Bar;
|
struct Bar;
|
||||||
struct Baz;
|
struct Baz;
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Bar: t v
|
||||||
|
Baz: t v
|
||||||
|
Foo: t v
|
||||||
|
FooSelf: t v
|
||||||
|
foo: t
|
||||||
|
m: t
|
||||||
|
|
||||||
|
crate::m
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮Bar: t v
|
|
||||||
⋮Baz: t v
|
|
||||||
⋮Foo: t v
|
|
||||||
⋮FooSelf: t v
|
|
||||||
⋮foo: t
|
|
||||||
⋮m: t
|
|
||||||
⋮
|
|
||||||
⋮crate::m
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_dollar_crate_is_correct_in_indirect_deps() {
|
fn macro_dollar_crate_is_correct_in_indirect_deps() {
|
||||||
mark::check!(macro_dollar_crate_other);
|
mark::check!(macro_dollar_crate_other);
|
||||||
// From std
|
// From std
|
||||||
let map = def_map(
|
check(
|
||||||
r#"
|
r#"
|
||||||
//- /main.rs crate:main deps:std
|
//- /main.rs crate:main deps:std
|
||||||
foo!();
|
foo!();
|
||||||
|
@ -630,27 +622,15 @@ fn macro_dollar_crate_is_correct_in_indirect_deps() {
|
||||||
|
|
||||||
pub struct bar;
|
pub struct bar;
|
||||||
"#,
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
bar: t v
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮bar: t v
|
|
||||||
"###);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn expand_derive() {
|
fn expand_derive() {
|
||||||
let map = compute_crate_def_map(
|
|
||||||
"
|
|
||||||
//- /main.rs
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct Foo;
|
|
||||||
",
|
|
||||||
);
|
|
||||||
assert_eq!(map.modules[map.root].scope.impls().len(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn expand_multiple_derive() {
|
|
||||||
let map = compute_crate_def_map(
|
let map = compute_crate_def_map(
|
||||||
"
|
"
|
||||||
//- /main.rs
|
//- /main.rs
|
||||||
|
@ -664,8 +644,8 @@ fn expand_multiple_derive() {
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_expansion_overflow() {
|
fn macro_expansion_overflow() {
|
||||||
mark::check!(macro_expansion_overflow);
|
mark::check!(macro_expansion_overflow);
|
||||||
compute_crate_def_map(
|
check(
|
||||||
"
|
r#"
|
||||||
macro_rules! a {
|
macro_rules! a {
|
||||||
($e:expr; $($t:tt)*) => {
|
($e:expr; $($t:tt)*) => {
|
||||||
b!($($t)*);
|
b!($($t)*);
|
||||||
|
@ -681,6 +661,9 @@ macro_rules! b {
|
||||||
}
|
}
|
||||||
|
|
||||||
b! { static = #[] (); }
|
b! { static = #[] (); }
|
||||||
",
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
"#]],
|
||||||
"###
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue