Skip to content

Commit b8763fe

Browse files
committed
Auto merge of #12902 - Veykril:item-scope, r=Veykril
fix: Order ItemScope::entries results
2 parents 32e640e + f867ddc commit b8763fe

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

crates/hir-def/src/item_scope.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::collections::hash_map::Entry;
55

66
use base_db::CrateId;
77
use hir_expand::{name::Name, AstId, MacroCallId};
8+
use itertools::Itertools;
89
use once_cell::sync::Lazy;
910
use profile::Count;
1011
use rustc_hash::{FxHashMap, FxHashSet};
@@ -97,15 +98,14 @@ pub(crate) enum BuiltinShadowMode {
9798
impl ItemScope {
9899
pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, PerNs)> + 'a {
99100
// FIXME: shadowing
100-
let keys: FxHashSet<_> = self
101-
.types
101+
self.types
102102
.keys()
103103
.chain(self.values.keys())
104104
.chain(self.macros.keys())
105105
.chain(self.unresolved.iter())
106-
.collect();
107-
108-
keys.into_iter().map(move |name| (name, self.get(name)))
106+
.sorted()
107+
.unique()
108+
.map(move |name| (name, self.get(name)))
109109
}
110110

111111
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {

crates/ide-assists/src/handlers/expand_glob_import.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::{
3636
// pub struct Baz;
3737
// }
3838
//
39-
// use foo::{Baz, Bar};
39+
// use foo::{Bar, Baz};
4040
//
4141
// fn qux(bar: Bar, baz: Baz) {}
4242
// ```
@@ -281,7 +281,7 @@ mod foo {
281281
pub fn f() {}
282282
}
283283
284-
use foo::{Baz, Bar, f};
284+
use foo::{Bar, Baz, f};
285285
286286
fn qux(bar: Bar, baz: Baz) {
287287
f();
@@ -351,7 +351,7 @@ mod foo {
351351
pub fn f() {}
352352
}
353353
354-
use foo::{Baz, Bar, f};
354+
use foo::{Bar, Baz, f};
355355
356356
fn qux(bar: Bar, baz: Baz) {
357357
f();
@@ -440,7 +440,7 @@ mod foo {
440440
}
441441
}
442442
443-
use foo::{bar::{Baz, Bar, f}, baz::*};
443+
use foo::{bar::{Bar, Baz, f}, baz::*};
444444
445445
fn qux(bar: Bar, baz: Baz) {
446446
f();
@@ -561,7 +561,7 @@ mod foo {
561561
562562
use foo::{
563563
bar::{*, f},
564-
baz::{g, qux::{q, h}}
564+
baz::{g, qux::{h, q}}
565565
};
566566
567567
fn qux(bar: Bar, baz: Baz) {

crates/ide-assists/src/tests/generated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ mod foo {
535535
pub struct Baz;
536536
}
537537
538-
use foo::{Baz, Bar};
538+
use foo::{Bar, Baz};
539539
540540
fn qux(bar: Bar, baz: Baz) {}
541541
"#####,

crates/ide-completion/src/render.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,8 @@ fn main() {
12711271
st S []
12721272
st &mut S [type]
12731273
st S []
1274-
fn main() []
12751274
fn foo(…) []
1275+
fn main() []
12761276
"#]],
12771277
);
12781278
check_relevance(
@@ -1288,8 +1288,8 @@ fn main() {
12881288
lc s [type+name+local]
12891289
st S [type]
12901290
st S []
1291-
fn main() []
12921291
fn foo(…) []
1292+
fn main() []
12931293
"#]],
12941294
);
12951295
check_relevance(
@@ -1305,8 +1305,8 @@ fn main() {
13051305
lc ssss [type+local]
13061306
st S [type]
13071307
st S []
1308-
fn main() []
13091308
fn foo(…) []
1309+
fn main() []
13101310
"#]],
13111311
);
13121312
}
@@ -1342,10 +1342,10 @@ fn main() {
13421342
lc &t [type+local]
13431343
st S []
13441344
st &S [type]
1345-
st T []
13461345
st S []
1347-
fn main() []
1346+
st T []
13481347
fn foo(…) []
1348+
fn main() []
13491349
md core []
13501350
"#]],
13511351
)
@@ -1388,10 +1388,10 @@ fn main() {
13881388
lc &mut t [type+local]
13891389
st S []
13901390
st &mut S [type]
1391-
st T []
13921391
st S []
1393-
fn main() []
1392+
st T []
13941393
fn foo(…) []
1394+
fn main() []
13951395
md core []
13961396
"#]],
13971397
)
@@ -1483,12 +1483,12 @@ fn main() {
14831483
expect![[r#"
14841484
st S []
14851485
st &S [type]
1486-
st T []
14871486
st S []
1488-
fn main() []
1487+
st T []
14891488
fn bar() []
14901489
fn &bar() [type]
14911490
fn foo(…) []
1491+
fn main() []
14921492
md core []
14931493
"#]],
14941494
)
@@ -1633,8 +1633,8 @@ fn foo() {
16331633
ev Foo::B [type_could_unify]
16341634
fn foo() []
16351635
en Foo []
1636-
fn baz() []
16371636
fn bar() []
1637+
fn baz() []
16381638
"#]],
16391639
);
16401640
}
@@ -1724,9 +1724,9 @@ fn f() {
17241724
}
17251725
"#,
17261726
expect![[r#"
1727-
md std []
17281727
st Buffer []
17291728
fn f() []
1729+
md std []
17301730
tt BufRead (use std::io::BufRead) [requires_import]
17311731
st BufReader (use std::io::BufReader) [requires_import]
17321732
st BufWriter (use std::io::BufWriter) [requires_import]

0 commit comments

Comments
 (0)