sort hash maps for tests
This commit is contained in:
parent
8b6f02d0d6
commit
0efb5364c3
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -257,7 +257,7 @@ dependencies = [
|
||||
"encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -551,7 +551,7 @@ dependencies = [
|
||||
"console 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -1242,7 +1242,7 @@ dependencies = [
|
||||
"ra_parser 0.1.0",
|
||||
"ra_text_edit 0.1.0",
|
||||
"rowan 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"test_utils 0.1.0",
|
||||
"text_unit 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1262,7 +1262,7 @@ dependencies = [
|
||||
name = "ra_tt"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1467,7 +1467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"colosseum 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"text_unit 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -1625,7 +1625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "smol_str"
|
||||
version = "0.1.10"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2181,7 +2181,7 @@ dependencies = [
|
||||
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||
"checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373"
|
||||
"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be"
|
||||
"checksum smol_str 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d077b3367211e9c6e2e012fb804c444e0d80ab5a51ae4137739b58e6446dcaef"
|
||||
"checksum smol_str 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e6507d018aa8dfcaa08aaab587605591cd2109df66a921486a2220e2daf9fa29"
|
||||
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
||||
"checksum stacker 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb79482f57cf598af52094ec4cc3b3c42499d3ce5bd426f2ac41515b7e57404b"
|
||||
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
@ -5,7 +5,7 @@
|
||||
/// `Name` is a wrapper around string, which is used in hir for both references
|
||||
/// and declarations. In theory, names should also carry hygiene info, but we are
|
||||
/// not there yet!
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct Name {
|
||||
text: SmolStr,
|
||||
}
|
||||
|
@ -8,7 +8,11 @@
|
||||
use test_utils::covers;
|
||||
use insta::assert_snapshot_matches;
|
||||
|
||||
use crate::{Crate, mock::{MockDatabase, CrateGraphFixture}, nameres::Resolution};
|
||||
use crate::{
|
||||
Crate,
|
||||
mock::{MockDatabase, CrateGraphFixture},
|
||||
nameres::Resolution,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
@ -25,12 +29,15 @@ fn compute_crate_def_map(fixture: &str, graph: Option<CrateGraphFixture>) -> Arc
|
||||
fn render_crate_def_map(map: &CrateDefMap) -> String {
|
||||
let mut buf = String::new();
|
||||
go(&mut buf, map, "\ncrate", map.root);
|
||||
return buf;
|
||||
return buf.trim().to_string();
|
||||
|
||||
fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: CrateModuleId) {
|
||||
*buf += path;
|
||||
*buf += "\n";
|
||||
for (name, res) in map.modules[module].scope.items.iter() {
|
||||
|
||||
let mut entries = map.modules[module].scope.items.iter().collect::<Vec<_>>();
|
||||
entries.sort_by_key(|(name, _)| *name);
|
||||
for (name, res) in entries {
|
||||
*buf += &format!("{}: {}\n", name, dump_resolution(res))
|
||||
}
|
||||
for (name, child) in map.modules[module].children.iter() {
|
||||
@ -79,21 +86,20 @@ enum E { V }
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
V: t v
|
||||
E: t
|
||||
foo: t
|
||||
S: t v
|
||||
|
||||
crate::foo
|
||||
bar: t
|
||||
f: v
|
||||
|
||||
crate::foo::bar
|
||||
Baz: t v
|
||||
E: t
|
||||
"###
|
||||
)
|
||||
⋮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
|
||||
"###)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -113,12 +119,12 @@ fn bogus_paths() {
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
foo: t
|
||||
S: t v
|
||||
|
||||
crate::foo
|
||||
"###
|
||||
⋮crate
|
||||
⋮S: t v
|
||||
⋮foo: t
|
||||
⋮
|
||||
⋮crate::foo
|
||||
"###
|
||||
)
|
||||
}
|
||||
|
||||
@ -137,13 +143,13 @@ fn use_as() {
|
||||
);
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Foo: t v
|
||||
foo: t
|
||||
|
||||
crate::foo
|
||||
Baz: t v
|
||||
"###
|
||||
⋮crate
|
||||
⋮Foo: t v
|
||||
⋮foo: t
|
||||
⋮
|
||||
⋮crate::foo
|
||||
⋮Baz: t v
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
@ -164,21 +170,19 @@ fn use_trees() {
|
||||
pub enum Quux {};
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Quux: t
|
||||
Baz: t v
|
||||
foo: t
|
||||
|
||||
crate::foo
|
||||
bar: t
|
||||
|
||||
crate::foo::bar
|
||||
Quux: t
|
||||
Baz: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Baz: t v
|
||||
⋮Quux: t
|
||||
⋮foo: t
|
||||
⋮
|
||||
⋮crate::foo
|
||||
⋮bar: t
|
||||
⋮
|
||||
⋮crate::foo::bar
|
||||
⋮Baz: t v
|
||||
⋮Quux: t
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -199,20 +203,18 @@ fn re_exports() {
|
||||
pub struct Baz;
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Baz: t v
|
||||
foo: t
|
||||
|
||||
crate::foo
|
||||
bar: t
|
||||
Baz: t v
|
||||
|
||||
crate::foo::bar
|
||||
Baz: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Baz: t v
|
||||
⋮foo: t
|
||||
⋮
|
||||
⋮crate::foo
|
||||
⋮Baz: t v
|
||||
⋮bar: t
|
||||
⋮
|
||||
⋮crate::foo::bar
|
||||
⋮Baz: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -237,10 +239,10 @@ fn std_prelude() {
|
||||
},
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
Bar: t v
|
||||
Baz: t v
|
||||
"###);
|
||||
⋮crate
|
||||
⋮Bar: t v
|
||||
⋮Baz: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -254,10 +256,10 @@ enum E { V }
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
V: t v
|
||||
E: t
|
||||
"###
|
||||
⋮crate
|
||||
⋮E: t
|
||||
⋮V: t v
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
@ -285,20 +287,18 @@ fn edition_2015_imports() {
|
||||
},
|
||||
);
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
bar: t
|
||||
foo: t
|
||||
|
||||
crate::bar
|
||||
Bar: t v
|
||||
|
||||
crate::foo
|
||||
FromLib: t v
|
||||
Bar: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮bar: t
|
||||
⋮foo: t
|
||||
⋮
|
||||
⋮crate::bar
|
||||
⋮Bar: t v
|
||||
⋮
|
||||
⋮crate::foo
|
||||
⋮Bar: t v
|
||||
⋮FromLib: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -317,16 +317,14 @@ fn module_resolution_works_for_non_standard_filenames() {
|
||||
},
|
||||
);
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Bar: t v
|
||||
foo: t
|
||||
|
||||
crate::foo
|
||||
Bar: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Bar: t v
|
||||
⋮foo: t
|
||||
⋮
|
||||
⋮crate::foo
|
||||
⋮Bar: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -348,12 +346,10 @@ fn name_res_works_for_broken_modules() {
|
||||
pub struct Baz;
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Baz: _
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Baz: _
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -369,19 +365,17 @@ fn item_map_using_self() {
|
||||
pub struct Baz;
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Baz: t v
|
||||
foo: t
|
||||
|
||||
crate::foo
|
||||
bar: t
|
||||
|
||||
crate::foo::bar
|
||||
Baz: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Baz: t v
|
||||
⋮foo: t
|
||||
⋮
|
||||
⋮crate::foo
|
||||
⋮bar: t
|
||||
⋮
|
||||
⋮crate::foo::bar
|
||||
⋮Baz: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -400,12 +394,10 @@ fn item_map_across_crates() {
|
||||
},
|
||||
);
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Baz: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Baz: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -430,12 +422,10 @@ fn extern_crate_rename() {
|
||||
},
|
||||
);
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Arc: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Arc: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -462,9 +452,9 @@ fn extern_crate_rename_2015_edition() {
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Arc: t v
|
||||
"###
|
||||
⋮crate
|
||||
⋮Arc: t v
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
@ -490,12 +480,10 @@ pub mod b {
|
||||
},
|
||||
);
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
C: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮C: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -519,12 +507,10 @@ fn reexport_across_crates() {
|
||||
},
|
||||
);
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Baz: t v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Baz: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -544,13 +530,11 @@ fn foo() {}
|
||||
},
|
||||
);
|
||||
|
||||
assert_snapshot_matches!(map,
|
||||
@r###"
|
||||
crate
|
||||
Bar: t v
|
||||
foo: v
|
||||
"###
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
⋮crate
|
||||
⋮Bar: t v
|
||||
⋮foo: v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -18,20 +18,20 @@ fn glob_1() {
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
bar: t
|
||||
Foo: t v
|
||||
Baz: t v
|
||||
foo: t
|
||||
|
||||
crate::foo
|
||||
bar: t
|
||||
Foo: t v
|
||||
Baz: t v
|
||||
|
||||
crate::foo::bar
|
||||
Baz: t v
|
||||
"###
|
||||
⋮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
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
@ -54,22 +54,22 @@ fn glob_2() {
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
bar: t
|
||||
Foo: t v
|
||||
Baz: t v
|
||||
foo: t
|
||||
|
||||
crate::foo
|
||||
bar: t
|
||||
Foo: t v
|
||||
Baz: t v
|
||||
|
||||
crate::foo::bar
|
||||
bar: t
|
||||
Foo: t v
|
||||
Baz: t v
|
||||
"###
|
||||
⋮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
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
@ -90,9 +90,9 @@ fn glob_across_crates() {
|
||||
},
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
Baz: t v
|
||||
"###
|
||||
⋮crate
|
||||
⋮Baz: t v
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
@ -109,10 +109,10 @@ enum Foo {
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
Foo: t
|
||||
Bar: t v
|
||||
Baz: t v
|
||||
"###
|
||||
⋮crate
|
||||
⋮Bar: t v
|
||||
⋮Baz: t v
|
||||
⋮Foo: t
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
@ -18,14 +18,14 @@ macro_rules! structs {
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
nested: t
|
||||
Foo: t v
|
||||
|
||||
crate::nested
|
||||
Bar: t v
|
||||
Baz: t v
|
||||
"###);
|
||||
⋮crate
|
||||
⋮Foo: t v
|
||||
⋮nested: t
|
||||
⋮
|
||||
⋮crate::nested
|
||||
⋮Bar: t v
|
||||
⋮Baz: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -45,15 +45,15 @@ macro_rules! m {
|
||||
",
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
n1: t
|
||||
|
||||
crate::n1
|
||||
n2: t
|
||||
|
||||
crate::n1::n2
|
||||
X: t v
|
||||
"###);
|
||||
⋮crate
|
||||
⋮n1: t
|
||||
⋮
|
||||
⋮crate::n1
|
||||
⋮n2: t
|
||||
⋮
|
||||
⋮crate::n1::n2
|
||||
⋮X: t v
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -81,14 +81,14 @@ macro_rules! structs {
|
||||
},
|
||||
);
|
||||
assert_snapshot_matches!(map, @r###"
|
||||
crate
|
||||
bar: t
|
||||
Foo: t v
|
||||
Bar: t v
|
||||
|
||||
crate::bar
|
||||
bar: t
|
||||
Foo: t v
|
||||
Bar: t v
|
||||
"###);
|
||||
⋮crate
|
||||
⋮Bar: t v
|
||||
⋮Foo: t v
|
||||
⋮bar: t
|
||||
⋮
|
||||
⋮crate::bar
|
||||
⋮Bar: t v
|
||||
⋮Foo: t v
|
||||
⋮bar: t
|
||||
"###);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ rowan = "0.5.0"
|
||||
# ideally, `serde` should be enabled by `ra_lsp_server`, but we enable it here
|
||||
# to reduce number of compilations
|
||||
text_unit = { version = "0.1.8", features = ["serde"] }
|
||||
smol_str = { version = "0.1.9", features = ["serde"] }
|
||||
smol_str = { version = "0.1.11", features = ["serde"] }
|
||||
|
||||
ra_text_edit = { path = "../ra_text_edit" }
|
||||
ra_parser = { path = "../ra_parser" }
|
||||
|
Loading…
Reference in New Issue
Block a user