Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use log::debug;
use std::cell::{Cell, RefCell};
use std::{cmp, fmt, iter, ptr};
use std::collections::BTreeSet;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::ptr_key::PtrKey;
use rustc_data_structures::sync::Lrc;

Expand Down Expand Up @@ -431,7 +432,7 @@ impl ModuleKind {
}
}

type Resolutions<'a> = RefCell<FxHashMap<(Ident, Namespace), &'a RefCell<NameResolution<'a>>>>;
type Resolutions<'a> = RefCell<FxIndexMap<(Ident, Namespace), &'a RefCell<NameResolution<'a>>>>;

/// One node in the tree of modules.
pub struct ModuleData<'a> {
Expand Down Expand Up @@ -496,15 +497,10 @@ impl<'a> ModuleData<'a> {
}
}

fn for_each_child_stable<R, F>(&'a self, resolver: &mut R, mut f: F)
fn for_each_child_stable<R, F>(&'a self, resolver: &mut R, f: F)
where R: AsMut<Resolver<'a>>, F: FnMut(&mut R, Ident, Namespace, &'a NameBinding<'a>)
{
let resolutions = resolver.as_mut().resolutions(self).borrow();
let mut resolutions = resolutions.iter().collect::<Vec<_>>();
resolutions.sort_by_cached_key(|&(&(ident, ns), _)| (ident.as_str(), ns));
for &(&(ident, ns), &resolution) in resolutions.iter() {
resolution.borrow().binding.map(|binding| f(resolver, ident, ns, binding));
}
self.for_each_child(resolver, f)
}

fn res(&self) -> Option<Res> {
Expand Down
26 changes: 13 additions & 13 deletions src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ LL | let x = Option(1);
| ^^^^^^
help: try using one of the enum's variants
|
LL | let x = std::prelude::v1::Option::None(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | let x = std::prelude::v1::Option::Some(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | let x = std::option::Option::None(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | let x = std::option::Option::Some(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^

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

error[E0532]: expected tuple struct/variant, found enum `Example`
--> $DIR/issue-43871-enum-instead-of-variant.rs:27:12
Expand All @@ -47,14 +47,14 @@ LL | let z = ManyVariants();
| ^^^^^^^^^^^^
help: try using one of the enum's variants
|
LL | let z = ManyVariants::Eight();
LL | let z = ManyVariants::One();
| ^^^^^^^^^^^^^^^^^
LL | let z = ManyVariants::Two();
| ^^^^^^^^^^^^^^^^^
LL | let z = ManyVariants::Three();
| ^^^^^^^^^^^^^^^^^^^
LL | let z = ManyVariants::Five();
| ^^^^^^^^^^^^^^^^^^
LL | let z = ManyVariants::Four();
| ^^^^^^^^^^^^^^^^^^
LL | let z = ManyVariants::Nine();
| ^^^^^^^^^^^^^^^^^^
and 6 other candidates

error: aborting due to 5 previous errors
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-35675.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ LL | fn qux() -> Some {
| ^^^^
| |
| not a type
| help: try using the variant's enum: `Option`
| help: try using the variant's enum: `std::option::Option`

error: aborting due to 7 previous errors

Expand Down