mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-31 23:38:45 +00:00
Auto merge of #12902 - Veykril:item-scope, r=Veykril
fix: Order ItemScope::entries results
This commit is contained in:
commit
b8763fe224
4 changed files with 22 additions and 22 deletions
|
@ -5,6 +5,7 @@ use std::collections::hash_map::Entry;
|
||||||
|
|
||||||
use base_db::CrateId;
|
use base_db::CrateId;
|
||||||
use hir_expand::{name::Name, AstId, MacroCallId};
|
use hir_expand::{name::Name, AstId, MacroCallId};
|
||||||
|
use itertools::Itertools;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use profile::Count;
|
use profile::Count;
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
@ -97,15 +98,14 @@ pub(crate) enum BuiltinShadowMode {
|
||||||
impl ItemScope {
|
impl ItemScope {
|
||||||
pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, PerNs)> + 'a {
|
pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, PerNs)> + 'a {
|
||||||
// FIXME: shadowing
|
// FIXME: shadowing
|
||||||
let keys: FxHashSet<_> = self
|
self.types
|
||||||
.types
|
|
||||||
.keys()
|
.keys()
|
||||||
.chain(self.values.keys())
|
.chain(self.values.keys())
|
||||||
.chain(self.macros.keys())
|
.chain(self.macros.keys())
|
||||||
.chain(self.unresolved.iter())
|
.chain(self.unresolved.iter())
|
||||||
.collect();
|
.sorted()
|
||||||
|
.unique()
|
||||||
keys.into_iter().map(move |name| (name, self.get(name)))
|
.map(move |name| (name, self.get(name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
|
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
|
||||||
|
|
|
@ -36,7 +36,7 @@ use crate::{
|
||||||
// pub struct Baz;
|
// pub struct Baz;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// use foo::{Baz, Bar};
|
// use foo::{Bar, Baz};
|
||||||
//
|
//
|
||||||
// fn qux(bar: Bar, baz: Baz) {}
|
// fn qux(bar: Bar, baz: Baz) {}
|
||||||
// ```
|
// ```
|
||||||
|
@ -281,7 +281,7 @@ mod foo {
|
||||||
pub fn f() {}
|
pub fn f() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
use foo::{Baz, Bar, f};
|
use foo::{Bar, Baz, f};
|
||||||
|
|
||||||
fn qux(bar: Bar, baz: Baz) {
|
fn qux(bar: Bar, baz: Baz) {
|
||||||
f();
|
f();
|
||||||
|
@ -351,7 +351,7 @@ mod foo {
|
||||||
pub fn f() {}
|
pub fn f() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
use foo::{Baz, Bar, f};
|
use foo::{Bar, Baz, f};
|
||||||
|
|
||||||
fn qux(bar: Bar, baz: Baz) {
|
fn qux(bar: Bar, baz: Baz) {
|
||||||
f();
|
f();
|
||||||
|
@ -440,7 +440,7 @@ mod foo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use foo::{bar::{Baz, Bar, f}, baz::*};
|
use foo::{bar::{Bar, Baz, f}, baz::*};
|
||||||
|
|
||||||
fn qux(bar: Bar, baz: Baz) {
|
fn qux(bar: Bar, baz: Baz) {
|
||||||
f();
|
f();
|
||||||
|
@ -561,7 +561,7 @@ mod foo {
|
||||||
|
|
||||||
use foo::{
|
use foo::{
|
||||||
bar::{*, f},
|
bar::{*, f},
|
||||||
baz::{g, qux::{q, h}}
|
baz::{g, qux::{h, q}}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn qux(bar: Bar, baz: Baz) {
|
fn qux(bar: Bar, baz: Baz) {
|
||||||
|
|
|
@ -535,7 +535,7 @@ mod foo {
|
||||||
pub struct Baz;
|
pub struct Baz;
|
||||||
}
|
}
|
||||||
|
|
||||||
use foo::{Baz, Bar};
|
use foo::{Bar, Baz};
|
||||||
|
|
||||||
fn qux(bar: Bar, baz: Baz) {}
|
fn qux(bar: Bar, baz: Baz) {}
|
||||||
"#####,
|
"#####,
|
||||||
|
|
|
@ -1271,8 +1271,8 @@ fn main() {
|
||||||
st S []
|
st S []
|
||||||
st &mut S [type]
|
st &mut S [type]
|
||||||
st S []
|
st S []
|
||||||
fn main() []
|
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
|
fn main() []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_relevance(
|
check_relevance(
|
||||||
|
@ -1288,8 +1288,8 @@ fn main() {
|
||||||
lc s [type+name+local]
|
lc s [type+name+local]
|
||||||
st S [type]
|
st S [type]
|
||||||
st S []
|
st S []
|
||||||
fn main() []
|
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
|
fn main() []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
check_relevance(
|
check_relevance(
|
||||||
|
@ -1305,8 +1305,8 @@ fn main() {
|
||||||
lc ssss [type+local]
|
lc ssss [type+local]
|
||||||
st S [type]
|
st S [type]
|
||||||
st S []
|
st S []
|
||||||
fn main() []
|
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
|
fn main() []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1342,10 +1342,10 @@ fn main() {
|
||||||
lc &t [type+local]
|
lc &t [type+local]
|
||||||
st S []
|
st S []
|
||||||
st &S [type]
|
st &S [type]
|
||||||
st T []
|
|
||||||
st S []
|
st S []
|
||||||
fn main() []
|
st T []
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
|
fn main() []
|
||||||
md core []
|
md core []
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
|
@ -1388,10 +1388,10 @@ fn main() {
|
||||||
lc &mut t [type+local]
|
lc &mut t [type+local]
|
||||||
st S []
|
st S []
|
||||||
st &mut S [type]
|
st &mut S [type]
|
||||||
st T []
|
|
||||||
st S []
|
st S []
|
||||||
fn main() []
|
st T []
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
|
fn main() []
|
||||||
md core []
|
md core []
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
|
@ -1483,12 +1483,12 @@ fn main() {
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
st S []
|
st S []
|
||||||
st &S [type]
|
st &S [type]
|
||||||
st T []
|
|
||||||
st S []
|
st S []
|
||||||
fn main() []
|
st T []
|
||||||
fn bar() []
|
fn bar() []
|
||||||
fn &bar() [type]
|
fn &bar() [type]
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
|
fn main() []
|
||||||
md core []
|
md core []
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
|
@ -1633,8 +1633,8 @@ fn foo() {
|
||||||
ev Foo::B [type_could_unify]
|
ev Foo::B [type_could_unify]
|
||||||
fn foo() []
|
fn foo() []
|
||||||
en Foo []
|
en Foo []
|
||||||
fn baz() []
|
|
||||||
fn bar() []
|
fn bar() []
|
||||||
|
fn baz() []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1724,9 +1724,9 @@ fn f() {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
md std []
|
|
||||||
st Buffer []
|
st Buffer []
|
||||||
fn f() []
|
fn f() []
|
||||||
|
md std []
|
||||||
tt BufRead (use std::io::BufRead) [requires_import]
|
tt BufRead (use std::io::BufRead) [requires_import]
|
||||||
st BufReader (use std::io::BufReader) [requires_import]
|
st BufReader (use std::io::BufReader) [requires_import]
|
||||||
st BufWriter (use std::io::BufWriter) [requires_import]
|
st BufWriter (use std::io::BufWriter) [requires_import]
|
||||||
|
|
Loading…
Reference in a new issue