Skip to content

Commit 037e930

Browse files
committed
Review fixes
1 parent 404df1c commit 037e930

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/librustc_resolve/diagnostics.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ impl<'a> Resolver<'a> {
659659
return;
660660
}
661661

662-
let via_import = name_binding.is_import() && !name_binding.is_extern_crate();
663-
664662
let child_accessible =
665663
accessible && this.is_accessible_from(name_binding.vis, parent_scope.module);
666664

@@ -669,6 +667,13 @@ impl<'a> Resolver<'a> {
669667
return;
670668
}
671669

670+
let via_import = name_binding.is_import() && !name_binding.is_extern_crate();
671+
672+
// There is an assumption elsewhere that paths of variants are in the enum's
673+
// declaration and not imported. With this assumption, the variant component is
674+
// chopped and the rest of the path is assumed to be the enum's own path. For
675+
// errors where a variant is used as the type instead of the enum, this causes
676+
// funny looking invalid suggestions, i.e `foo` instead of `foo::MyEnum`.
672677
if via_import && name_binding.is_possibly_imported_variant() {
673678
return;
674679
}

0 commit comments

Comments
 (0)