Skip to content

Commit add0a42

Browse files
committed
Remove for_each_child_stable
Now that `Resolutions` has a deterministic iteration order, it's no longer necessary to sort its entries before iterating over them
1 parent dd403e4 commit add0a42

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

src/librustc_resolve/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl<'a> Resolver<'a> {
527527
in_module_is_extern)) = worklist.pop() {
528528
// We have to visit module children in deterministic order to avoid
529529
// instabilities in reported imports (#43552).
530-
in_module.for_each_child_stable(self, |this, ident, ns, name_binding| {
530+
in_module.for_each_child(self, |this, ident, ns, name_binding| {
531531
// avoid imports entirely
532532
if name_binding.is_import() && !name_binding.is_extern_crate() { return; }
533533
// avoid non-importable candidates as well

src/librustc_resolve/late/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<'a> LateResolutionVisitor<'a, '_> {
728728
// abort if the module is already found
729729
if result.is_some() { break; }
730730

731-
in_module.for_each_child_stable(self.r, |_, ident, _, name_binding| {
731+
in_module.for_each_child(self.r, |_, ident, _, name_binding| {
732732
// abort if the module is already found or if name_binding is private external
733733
if result.is_some() || !name_binding.vis.is_visible_locally() {
734734
return
@@ -760,7 +760,7 @@ impl<'a> LateResolutionVisitor<'a, '_> {
760760
fn collect_enum_variants(&mut self, def_id: DefId) -> Option<Vec<Path>> {
761761
self.find_module(def_id).map(|(enum_module, enum_import_suggestion)| {
762762
let mut variants = Vec::new();
763-
enum_module.for_each_child_stable(self.r, |_, ident, _, name_binding| {
763+
enum_module.for_each_child(self.r, |_, ident, _, name_binding| {
764764
if let Res::Def(DefKind::Variant, _) = name_binding.res() {
765765
let mut segms = enum_import_suggestion.path.segments.clone();
766766
segms.push(ast::PathSegment::from_ident(ident));

src/librustc_resolve/lib.rs

-11
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,6 @@ impl<'a> ModuleData<'a> {
497497
}
498498
}
499499

500-
fn for_each_child_stable<R, F>(&'a self, resolver: &mut R, mut f: F)
501-
where R: AsMut<Resolver<'a>>, F: FnMut(&mut R, Ident, Namespace, &'a NameBinding<'a>)
502-
{
503-
let resolutions = resolver.as_mut().resolutions(self).borrow();
504-
let mut resolutions = resolutions.iter().collect::<Vec<_>>();
505-
resolutions.sort_by_cached_key(|&(&(ident, ns), _)| (ident.as_str(), ns));
506-
for &(&(ident, ns), &resolution) in resolutions.iter() {
507-
resolution.borrow().binding.map(|binding| f(resolver, ident, ns, binding));
508-
}
509-
}
510-
511500
fn res(&self) -> Option<Res> {
512501
match self.kind {
513502
ModuleKind::Def(kind, def_id, _) => Some(Res::Def(kind, def_id)),

src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | let x = Option(1);
55
| ^^^^^^
66
help: try using one of the enum's variants
77
|
8-
LL | let x = std::prelude::v1::Option::None(1);
9-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10-
LL | let x = std::prelude::v1::Option::Some(1);
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
LL | let x = std::option::Option::None(1);
9+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | let x = std::option::Option::Some(1);
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0532]: expected tuple struct/variant, found enum `Option`
1414
--> $DIR/issue-43871-enum-instead-of-variant.rs:21:12
@@ -17,10 +17,10 @@ LL | if let Option(_) = x {
1717
| ^^^^^^
1818
help: try using one of the enum's variants
1919
|
20-
LL | if let std::prelude::v1::Option::None(_) = x {
21-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22-
LL | if let std::prelude::v1::Option::Some(_) = x {
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
LL | if let std::option::Option::None(_) = x {
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
22+
LL | if let std::option::Option::Some(_) = x {
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error[E0532]: expected tuple struct/variant, found enum `Example`
2626
--> $DIR/issue-43871-enum-instead-of-variant.rs:27:12
@@ -47,14 +47,14 @@ LL | let z = ManyVariants();
4747
| ^^^^^^^^^^^^
4848
help: try using one of the enum's variants
4949
|
50-
LL | let z = ManyVariants::Eight();
50+
LL | let z = ManyVariants::One();
51+
| ^^^^^^^^^^^^^^^^^
52+
LL | let z = ManyVariants::Two();
53+
| ^^^^^^^^^^^^^^^^^
54+
LL | let z = ManyVariants::Three();
5155
| ^^^^^^^^^^^^^^^^^^^
52-
LL | let z = ManyVariants::Five();
53-
| ^^^^^^^^^^^^^^^^^^
5456
LL | let z = ManyVariants::Four();
5557
| ^^^^^^^^^^^^^^^^^^
56-
LL | let z = ManyVariants::Nine();
57-
| ^^^^^^^^^^^^^^^^^^
5858
and 6 other candidates
5959

6060
error: aborting due to 5 previous errors

src/test/ui/issues/issue-35675.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ LL | fn qux() -> Some {
6363
| ^^^^
6464
| |
6565
| not a type
66-
| help: try using the variant's enum: `Option`
66+
| help: try using the variant's enum: `std::option::Option`
6767

6868
error: aborting due to 7 previous errors
6969

0 commit comments

Comments
 (0)