Skip to content

Commit 0b1ed70

Browse files
committed
Auto merge of #12871 - fasterthanlime:sync-from-rust-2, r=Veykril
Sync from `rust-lang/rust` This is the first subtree sync PR from `rust-lang/rust` to `rust-lang/rust-analyzer`, made by following the instructions at: https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html#performing-the-sync-from-rust-langrust-to-clippy It includes all the commits that were made in: * rust-lang/rust#99603 (And that were reviewed ahead of time by `@Veykril` + `@lnicola)`
2 parents ac86b8e + dc94050 commit 0b1ed70

File tree

23 files changed

+357
-309
lines changed

23 files changed

+357
-309
lines changed

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
* text=auto eol=lf
2+
23
# git grep shouldn't match entries in this benchmark data
34
bench_data/** binary
4-
crates/syntax/test_data/** -text eof=LF
5+
56
# Older git versions try to fix line endings on images, this prevents it.
67
*.png binary
78
*.jpg binary

crates/hir-def/src/import_map.rs

+42-38
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ mod tests {
516516
mark
517517
))
518518
})
519+
// HashSet iteration order isn't defined - it's different on
520+
// x86_64 and i686 at the very least
521+
.sorted()
519522
.collect::<String>();
520523
expect.assert_eq(&actual)
521524
}
@@ -588,6 +591,7 @@ mod tests {
588591

589592
Some(format!("{}:\n{:?}\n", name, map))
590593
})
594+
.sorted()
591595
.collect::<String>();
592596

593597
expect.assert_eq(&actual)
@@ -621,15 +625,15 @@ mod tests {
621625
struct Priv;
622626
",
623627
expect![[r#"
628+
lib:
629+
- Pub (t)
630+
- Pub2 (t)
631+
- Pub2 (v)
624632
main:
625633
- publ1 (t)
626634
- real_pu2 (t)
627635
- real_pub (t)
628636
- real_pub::Pub (t)
629-
lib:
630-
- Pub (t)
631-
- Pub2 (t)
632-
- Pub2 (v)
633637
"#]],
634638
);
635639
}
@@ -671,13 +675,13 @@ mod tests {
671675
pub struct S;
672676
",
673677
expect![[r#"
678+
lib:
679+
- S (t)
680+
- S (v)
674681
main:
675682
- m (t)
676683
- m::S (t)
677684
- m::S (v)
678-
lib:
679-
- S (t)
680-
- S (v)
681685
"#]],
682686
);
683687
}
@@ -697,11 +701,11 @@ mod tests {
697701
}
698702
",
699703
expect![[r#"
704+
lib:
705+
- pub_macro (m)
700706
main:
701707
- m (t)
702708
- m::pub_macro (m)
703-
lib:
704-
- pub_macro (m)
705709
"#]],
706710
);
707711
}
@@ -719,14 +723,14 @@ mod tests {
719723
}
720724
",
721725
expect![[r#"
722-
main:
723-
- reexported_module (t)
724-
- reexported_module::S (t)
725-
- reexported_module::S (v)
726726
lib:
727727
- module (t)
728728
- module::S (t)
729729
- module::S (v)
730+
main:
731+
- reexported_module (t)
732+
- reexported_module::S (t)
733+
- reexported_module::S (v)
730734
"#]],
731735
);
732736
}
@@ -831,10 +835,10 @@ mod tests {
831835
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy),
832836
expect![[r#"
833837
dep::fmt (t)
834-
dep::fmt::Display::format_method (a)
835838
dep::fmt::Display (t)
836839
dep::fmt::Display::FMT_CONST (a)
837840
dep::fmt::Display::format_function (a)
841+
dep::fmt::Display::format_method (a)
838842
"#]],
839843
);
840844
}
@@ -860,10 +864,10 @@ mod tests {
860864
"main",
861865
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy).assoc_items_only(),
862866
expect![[r#"
863-
dep::fmt::Display::format_method (a)
864-
dep::fmt::Display::FMT_CONST (a)
865-
dep::fmt::Display::format_function (a)
866-
"#]],
867+
dep::fmt::Display::FMT_CONST (a)
868+
dep::fmt::Display::format_function (a)
869+
dep::fmt::Display::format_method (a)
870+
"#]],
867871
);
868872

869873
check_search(
@@ -920,13 +924,13 @@ mod tests {
920924
"main",
921925
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy),
922926
expect![[r#"
923-
dep::fmt (t)
924-
dep::format (f)
925-
dep::Fmt (v)
926927
dep::Fmt (m)
927928
dep::Fmt (t)
928-
dep::fmt::Display::fmt (a)
929+
dep::Fmt (v)
930+
dep::fmt (t)
929931
dep::fmt::Display (t)
932+
dep::fmt::Display::fmt (a)
933+
dep::format (f)
930934
"#]],
931935
);
932936

@@ -935,10 +939,10 @@ mod tests {
935939
"main",
936940
Query::new("fmt".to_string()).search_mode(SearchMode::Equals),
937941
expect![[r#"
938-
dep::fmt (t)
939-
dep::Fmt (v)
940942
dep::Fmt (m)
941943
dep::Fmt (t)
944+
dep::Fmt (v)
945+
dep::fmt (t)
942946
dep::fmt::Display::fmt (a)
943947
"#]],
944948
);
@@ -948,12 +952,12 @@ mod tests {
948952
"main",
949953
Query::new("fmt".to_string()).search_mode(SearchMode::Contains),
950954
expect![[r#"
951-
dep::fmt (t)
952-
dep::Fmt (v)
953955
dep::Fmt (m)
954956
dep::Fmt (t)
955-
dep::fmt::Display::fmt (a)
957+
dep::Fmt (v)
958+
dep::fmt (t)
956959
dep::fmt::Display (t)
960+
dep::fmt::Display::fmt (a)
957961
"#]],
958962
);
959963
}
@@ -989,12 +993,12 @@ mod tests {
989993
"main",
990994
Query::new("fmt".to_string()),
991995
expect![[r#"
992-
dep::fmt (t)
993-
dep::Fmt (v)
994996
dep::Fmt (m)
995997
dep::Fmt (t)
996-
dep::fmt::Display::fmt (a)
998+
dep::Fmt (v)
999+
dep::fmt (t)
9971000
dep::fmt::Display (t)
1001+
dep::fmt::Display::fmt (a)
9981002
"#]],
9991003
);
10001004

@@ -1003,10 +1007,10 @@ mod tests {
10031007
"main",
10041008
Query::new("fmt".to_string()).name_only(),
10051009
expect![[r#"
1006-
dep::fmt (t)
1007-
dep::Fmt (v)
10081010
dep::Fmt (m)
10091011
dep::Fmt (t)
1012+
dep::Fmt (v)
1013+
dep::fmt (t)
10101014
dep::fmt::Display::fmt (a)
10111015
"#]],
10121016
);
@@ -1027,10 +1031,10 @@ mod tests {
10271031
"main",
10281032
Query::new("FMT".to_string()),
10291033
expect![[r#"
1030-
dep::fmt (t)
1034+
dep::FMT (t)
10311035
dep::FMT (v)
1036+
dep::fmt (t)
10321037
dep::fmt (v)
1033-
dep::FMT (t)
10341038
"#]],
10351039
);
10361040

@@ -1068,10 +1072,10 @@ mod tests {
10681072
"main",
10691073
Query::new("".to_string()).limit(2),
10701074
expect![[r#"
1071-
dep::fmt (t)
1075+
dep::Fmt (m)
10721076
dep::Fmt (t)
10731077
dep::Fmt (v)
1074-
dep::Fmt (m)
1078+
dep::fmt (t)
10751079
"#]],
10761080
);
10771081
}
@@ -1091,10 +1095,10 @@ mod tests {
10911095
"main",
10921096
Query::new("FMT".to_string()),
10931097
expect![[r#"
1094-
dep::fmt (t)
1098+
dep::FMT (t)
10951099
dep::FMT (v)
1100+
dep::fmt (t)
10961101
dep::fmt (v)
1097-
dep::FMT (t)
10981102
"#]],
10991103
);
11001104

crates/hir-def/src/nameres.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,20 @@
4848
//! the result
4949
5050
pub mod attr_resolution;
51-
pub mod diagnostics;
5251
mod collector;
52+
pub mod diagnostics;
5353
mod mod_resolution;
5454
mod path_resolution;
5555
mod proc_macro;
5656

5757
#[cfg(test)]
5858
mod tests;
5959

60-
use std::sync::Arc;
60+
use std::{cmp::Ord, sync::Arc};
6161

6262
use base_db::{CrateId, Edition, FileId};
6363
use hir_expand::{name::Name, InFile, MacroDefId};
64+
use itertools::Itertools;
6465
use la_arena::Arena;
6566
use profile::Count;
6667
use rustc_hash::FxHashMap;
@@ -431,7 +432,9 @@ impl DefMap {
431432

432433
map.modules[module].scope.dump(buf);
433434

434-
for (name, child) in map.modules[module].children.iter() {
435+
for (name, child) in
436+
map.modules[module].children.iter().sorted_by(|a, b| Ord::cmp(&a.0, &b.0))
437+
{
435438
let path = format!("{}::{}", path, name);
436439
buf.push('\n');
437440
go(buf, map, &path, *child);

crates/hir-def/src/nameres/tests.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@ mod b {
648648
a: t
649649
b: t
650650
651-
crate::b
652-
T: v
653-
654651
crate::a
655652
T: t v
653+
654+
crate::b
655+
T: v
656656
"#]],
657657
);
658658
}
@@ -704,13 +704,13 @@ use crate::reex::*;
704704
reex: t
705705
tr: t
706706
707-
crate::tr
708-
PrivTr: t
709-
PubTr: t
710-
711707
crate::reex
712708
_: t
713709
_: t
710+
711+
crate::tr
712+
PrivTr: t
713+
PubTr: t
714714
"#]],
715715
);
716716
}
@@ -920,14 +920,14 @@ use some_module::unknown_func;
920920
some_module: t
921921
unknown_func: v
922922
923-
crate::some_module
924-
unknown_func: v
925-
926923
crate::other_module
927924
some_submodule: t
928925
929926
crate::other_module::some_submodule
930927
unknown_func: v
928+
929+
crate::some_module
930+
unknown_func: v
931931
"#]],
932932
)
933933
}

crates/hir-def/src/nameres/tests/globs.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,13 @@ mod d {
315315
c: t
316316
d: t
317317
318-
crate::d
319-
Y: t v
318+
crate::a
319+
foo: t
320+
321+
crate::a::foo
322+
X: t v
323+
324+
crate::b
320325
foo: t
321326
322327
crate::c
@@ -325,14 +330,9 @@ mod d {
325330
crate::c::foo
326331
Y: t v
327332
328-
crate::b
329-
foo: t
330-
331-
crate::a
333+
crate::d
334+
Y: t v
332335
foo: t
333-
334-
crate::a::foo
335-
X: t v
336336
"#]],
337337
);
338338
}

0 commit comments

Comments
 (0)