fix: Order ItemScope::entries results

This commit is contained in:
Lukas Wirth 2022-07-28 18:49:31 +02:00
parent ce7541260d
commit f867ddc621
4 changed files with 22 additions and 22 deletions

View File

@ -5,6 +5,7 @@
use base_db::CrateId;
use hir_expand::{name::Name, AstId, MacroCallId};
use itertools::Itertools;
use once_cell::sync::Lazy;
use profile::Count;
use rustc_hash::{FxHashMap, FxHashSet};
@ -97,15 +98,14 @@ pub(crate) enum BuiltinShadowMode {
impl ItemScope {
pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, PerNs)> + 'a {
// FIXME: shadowing
let keys: FxHashSet<_> = self
.types
self.types
.keys()
.chain(self.values.keys())
.chain(self.macros.keys())
.chain(self.unresolved.iter())
.collect();
keys.into_iter().map(move |name| (name, self.get(name)))
.sorted()
.unique()
.map(move |name| (name, self.get(name)))
}
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {

View File

@ -36,7 +36,7 @@
// pub struct Baz;
// }
//
// use foo::{Baz, Bar};
// use foo::{Bar, Baz};
//
// fn qux(bar: Bar, baz: Baz) {}
// ```
@ -281,7 +281,7 @@ mod foo {
pub fn f() {}
}
use foo::{Baz, Bar, f};
use foo::{Bar, Baz, f};
fn qux(bar: Bar, baz: Baz) {
f();
@ -351,7 +351,7 @@ mod foo {
pub fn f() {}
}
use foo::{Baz, Bar, f};
use foo::{Bar, Baz, f};
fn qux(bar: Bar, baz: Baz) {
f();
@ -440,7 +440,7 @@ pub fn g() {}
}
}
use foo::{bar::{Baz, Bar, f}, baz::*};
use foo::{bar::{Bar, Baz, f}, baz::*};
fn qux(bar: Bar, baz: Baz) {
f();
@ -561,7 +561,7 @@ pub fn j() {}
use foo::{
bar::{*, f},
baz::{g, qux::{q, h}}
baz::{g, qux::{h, q}}
};
fn qux(bar: Bar, baz: Baz) {

View File

@ -535,7 +535,7 @@ mod foo {
pub struct Baz;
}
use foo::{Baz, Bar};
use foo::{Bar, Baz};
fn qux(bar: Bar, baz: Baz) {}
"#####,

View File

@ -1271,8 +1271,8 @@ fn main() {
st S []
st &mut S [type]
st S []
fn main() []
fn foo() []
fn main() []
"#]],
);
check_relevance(
@ -1288,8 +1288,8 @@ fn main() {
lc s [type+name+local]
st S [type]
st S []
fn main() []
fn foo() []
fn main() []
"#]],
);
check_relevance(
@ -1305,8 +1305,8 @@ fn main() {
lc ssss [type+local]
st S [type]
st S []
fn main() []
fn foo() []
fn main() []
"#]],
);
}
@ -1342,10 +1342,10 @@ fn main() {
lc &t [type+local]
st S []
st &S [type]
st T []
st S []
fn main() []
st T []
fn foo() []
fn main() []
md core []
"#]],
)
@ -1388,10 +1388,10 @@ fn main() {
lc &mut t [type+local]
st S []
st &mut S [type]
st T []
st S []
fn main() []
st T []
fn foo() []
fn main() []
md core []
"#]],
)
@ -1483,12 +1483,12 @@ fn main() {
expect![[r#"
st S []
st &S [type]
st T []
st S []
fn main() []
st T []
fn bar() []
fn &bar() [type]
fn foo() []
fn main() []
md core []
"#]],
)
@ -1633,8 +1633,8 @@ fn foo() {
ev Foo::B [type_could_unify]
fn foo() []
en Foo []
fn baz() []
fn bar() []
fn baz() []
"#]],
);
}
@ -1724,9 +1724,9 @@ fn f() {
}
"#,
expect![[r#"
md std []
st Buffer []
fn f() []
md std []
tt BufRead (use std::io::BufRead) [requires_import]
st BufReader (use std::io::BufReader) [requires_import]
st BufWriter (use std::io::BufWriter) [requires_import]