about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2022-03-23 22:47:19 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2022-03-25 02:03:54 +0300
commit0749ec67bc927eba90f4be5544055d3cd9040e58 (patch)
treedf280b79a257a516ddc13f4ea4c5af98a1816766
parent63b8f01bb5ca277e7df8d7efe094ed4244c1790c (diff)
downloadrust-0749ec67bc927eba90f4be5544055d3cd9040e58.tar.gz
rust-0749ec67bc927eba90f4be5544055d3cd9040e58.zip
resolve: Do not build expensive suggestions if they are not actually used
Also remove a redundant parameter from `fn resolve_path(_with_ribs)`, `crate_lint: CrateLint` is a more detailed version of `record_used: bool` with `CrateLint::No` meaning `false` and anything else meaning `true`.
-rw-r--r--compiler/rustc_resolve/src/build_reduced_graph.rs3
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs8
-rw-r--r--compiler/rustc_resolve/src/imports.rs16
-rw-r--r--compiler/rustc_resolve/src/late.rs30
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs6
-rw-r--r--compiler/rustc_resolve/src/lib.rs401
-rw-r--r--compiler/rustc_resolve/src/macros.rs6
-rw-r--r--src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed10
-rw-r--r--src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs10
-rw-r--r--src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr55
-rw-r--r--src/test/ui/rust-2018/edition-lint-nested-paths.fixed6
-rw-r--r--src/test/ui/rust-2018/edition-lint-nested-paths.rs6
-rw-r--r--src/test/ui/rust-2018/edition-lint-nested-paths.stderr33
-rw-r--r--src/test/ui/rust-2018/edition-lint-paths.fixed6
-rw-r--r--src/test/ui/rust-2018/edition-lint-paths.rs6
-rw-r--r--src/test/ui/rust-2018/edition-lint-paths.stderr45
-rw-r--r--src/test/ui/rust-2018/extern-crate-rename.fixed2
-rw-r--r--src/test/ui/rust-2018/extern-crate-rename.rs2
-rw-r--r--src/test/ui/rust-2018/extern-crate-rename.stderr11
-rw-r--r--src/test/ui/rust-2018/extern-crate-submod.fixed3
-rw-r--r--src/test/ui/rust-2018/extern-crate-submod.rs3
-rw-r--r--src/test/ui/rust-2018/extern-crate-submod.stderr11
22 files changed, 234 insertions, 445 deletions
diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs
index 2c3ddae9cb4..924e2d43785 100644
--- a/compiler/rustc_resolve/src/build_reduced_graph.rs
+++ b/compiler/rustc_resolve/src/build_reduced_graph.rs
@@ -296,9 +296,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
                     &segments,
                     Some(TypeNS),
                     parent_scope,
-                    !speculative,
                     path.span,
-                    CrateLint::SimplePath(id),
+                    if speculative { CrateLint::No } else { CrateLint::SimplePath(id) },
                 ) {
                     PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
                         let res = module.res().expect("visibility resolved to unnamed block");
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index e88b6a57376..e678ac9d518 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -1426,7 +1426,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
     ) -> Option<(Vec<Segment>, Vec<String>)> {
         // Replace first ident with `self` and check if that is valid.
         path[0].ident.name = kw::SelfLower;
-        let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
+        let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
         debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
         if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
     }
@@ -1446,7 +1446,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
     ) -> Option<(Vec<Segment>, Vec<String>)> {
         // Replace first ident with `crate` and check if that is valid.
         path[0].ident.name = kw::Crate;
-        let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
+        let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
         debug!("make_missing_crate_suggestion:  path={:?} result={:?}", path, result);
         if let PathResult::Module(..) = result {
             Some((
@@ -1478,7 +1478,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
     ) -> Option<(Vec<Segment>, Vec<String>)> {
         // Replace first ident with `crate` and check if that is valid.
         path[0].ident.name = kw::Super;
-        let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
+        let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
         debug!("make_missing_super_suggestion:  path={:?} result={:?}", path, result);
         if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
     }
@@ -1513,7 +1513,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
         for name in extern_crate_names.into_iter() {
             // Replace first ident with a crate name and check if that is valid.
             path[0].ident.name = name;
-            let result = self.r.resolve_path(&path, None, parent_scope, false, span, CrateLint::No);
+            let result = self.r.resolve_path(&path, None, parent_scope, span, CrateLint::No);
             debug!(
                 "make_external_crate_suggestion: name={:?} path={:?} result={:?}",
                 name, path, result
diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs
index 70ade7a5600..87c06559cca 100644
--- a/compiler/rustc_resolve/src/imports.rs
+++ b/compiler/rustc_resolve/src/imports.rs
@@ -123,10 +123,6 @@ impl<'a> Import<'a> {
             _ => false,
         }
     }
-
-    crate fn crate_lint(&self) -> CrateLint {
-        CrateLint::UsePath { root_id: self.root_id, root_span: self.root_span }
-    }
 }
 
 #[derive(Clone, Default, Debug)]
@@ -791,9 +787,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 &import.module_path,
                 None,
                 &import.parent_scope,
-                false,
                 import.span,
-                import.crate_lint(),
+                CrateLint::No,
             );
             import.vis.set(orig_vis);
 
@@ -887,13 +882,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             _ => None,
         };
         let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
+        let crate_lint =
+            CrateLint::UsePath { root_id: import.root_id, root_span: import.root_span };
         let path_res = self.r.resolve_path(
             &import.module_path,
             None,
             &import.parent_scope,
-            true,
             import.span,
-            import.crate_lint(),
+            crate_lint,
         );
         let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
         if let Some(orig_unusable_binding) = orig_unusable_binding {
@@ -982,7 +978,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                     let mut full_path = import.module_path.clone();
                     full_path.push(Segment::from_ident(Ident::empty()));
                     self.r.lint_if_path_starts_with_module(
-                        import.crate_lint(),
+                        crate_lint,
                         &full_path,
                         import.span,
                         None,
@@ -1254,7 +1250,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             self.r.per_ns(|this, ns| {
                 if let Ok(binding) = source_bindings[ns].get() {
                     this.lint_if_path_starts_with_module(
-                        import.crate_lint(),
+                        crate_lint,
                         &full_path,
                         import.span,
                         Some(binding),
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index d5b1aa00e52..511dc285cb4 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -768,7 +768,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
         &mut self,
         path: &[Segment],
         opt_ns: Option<Namespace>, // `None` indicates a module path in import
-        record_used: bool,
         path_span: Span,
         crate_lint: CrateLint,
     ) -> PathResult<'a> {
@@ -776,7 +775,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
             path,
             opt_ns,
             &self.parent_scope,
-            record_used,
             path_span,
             crate_lint,
             Some(&self.ribs),
@@ -1253,18 +1251,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
                 PathSource::Trait(AliasPossibility::No),
                 CrateLint::SimplePath(trait_ref.ref_id),
             );
-            let res = res.base_res();
-            if res != Res::Err {
-                if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.resolve_path(
-                    &path,
-                    Some(TypeNS),
-                    true,
-                    trait_ref.path.span,
-                    CrateLint::SimplePath(trait_ref.ref_id),
-                ) {
-                    new_id = Some(res.def_id());
-                    new_val = Some((module, trait_ref.clone()));
-                }
+            if let Some(def_id) = res.base_res().opt_def_id() {
+                new_id = Some(def_id);
+                new_val = Some((self.r.expect_module(def_id), trait_ref.clone()));
             }
         }
         let original_trait_ref = replace(&mut self.current_trait_ref, new_val);
@@ -2026,6 +2015,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
             None
         };
 
+        assert_ne!(crate_lint, CrateLint::No);
         let partial_res = match self.resolve_qpath_anywhere(
             id,
             qself,
@@ -2060,7 +2050,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
                     std_path.push(Segment::from_ident(Ident::with_dummy_span(sym::std)));
                     std_path.extend(path);
                     if let PathResult::Module(_) | PathResult::NonModule(_) =
-                        self.resolve_path(&std_path, Some(ns), false, span, CrateLint::No)
+                        self.resolve_path(&std_path, Some(ns), span, CrateLint::No)
                     {
                         // Check if we wrote `str::from_utf8` instead of `std::str::from_utf8`
                         let item_span =
@@ -2228,7 +2218,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
             )));
         }
 
-        let result = match self.resolve_path(&path, Some(ns), true, span, crate_lint) {
+        let result = match self.resolve_path(&path, Some(ns), span, crate_lint) {
             PathResult::NonModule(path_res) => path_res,
             PathResult::Module(ModuleOrUniformRoot::Module(module)) if !module.is_normal() => {
                 PartialRes::new(module.res().unwrap())
@@ -2268,13 +2258,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
             && path[0].ident.name != kw::DollarCrate
         {
             let unqualified_result = {
-                match self.resolve_path(
-                    &[*path.last().unwrap()],
-                    Some(ns),
-                    false,
-                    span,
-                    CrateLint::No,
-                ) {
+                match self.resolve_path(&[*path.last().unwrap()], Some(ns), span, CrateLint::No) {
                     PathResult::NonModule(path_res) => path_res.base_res(),
                     PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
                         module.res().unwrap()
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index 1394f4083d0..3c6caa79537 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -188,7 +188,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
             } else {
                 let mod_path = &path[..path.len() - 1];
                 let mod_prefix =
-                    match self.resolve_path(mod_path, Some(TypeNS), false, span, CrateLint::No) {
+                    match self.resolve_path(mod_path, Some(TypeNS), span, CrateLint::No) {
                         PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.res(),
                         _ => None,
                     }
@@ -648,7 +648,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
         if let crate::PathSource::TraitItem(_) = source {
             let mod_path = &path[..path.len() - 1];
             if let PathResult::Module(ModuleOrUniformRoot::Module(module)) =
-                self.resolve_path(mod_path, None, false, span, CrateLint::No)
+                self.resolve_path(mod_path, None, span, CrateLint::No)
             {
                 let resolutions = self.r.resolutions(module).borrow();
                 let targets: Vec<_> =
@@ -1384,7 +1384,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
             // Search in module.
             let mod_path = &path[..path.len() - 1];
             if let PathResult::Module(ModuleOrUniformRoot::Module(module)) =
-                self.resolve_path(mod_path, Some(TypeNS), false, span, CrateLint::No)
+                self.resolve_path(mod_path, Some(TypeNS), span, CrateLint::No)
             {
                 self.r.add_module_candidates(module, &mut names, &filter_fn);
             }
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs
index 77fd7115938..5a87dede54e 100644
--- a/compiler/rustc_resolve/src/lib.rs
+++ b/compiler/rustc_resolve/src/lib.rs
@@ -449,6 +449,19 @@ enum PathResult<'a> {
     },
 }
 
+impl<'a> PathResult<'a> {
+    fn failed(
+        span: Span,
+        is_error_from_last_segment: bool,
+        record_used: bool,
+        label_and_suggestion: impl FnOnce() -> (String, Option<Suggestion>),
+    ) -> PathResult<'a> {
+        let (label, suggestion) =
+            if record_used { label_and_suggestion() } else { (String::new(), None) };
+        PathResult::Failed { span, label, suggestion, is_error_from_last_segment }
+    }
+}
+
 #[derive(Debug)]
 enum ModuleKind {
     /// An anonymous module; e.g., just a block.
@@ -2206,19 +2219,10 @@ impl<'a> Resolver<'a> {
         path: &[Segment],
         opt_ns: Option<Namespace>, // `None` indicates a module path in import
         parent_scope: &ParentScope<'a>,
-        record_used: bool,
         path_span: Span,
         crate_lint: CrateLint,
     ) -> PathResult<'a> {
-        self.resolve_path_with_ribs(
-            path,
-            opt_ns,
-            parent_scope,
-            record_used,
-            path_span,
-            crate_lint,
-            None,
-        )
+        self.resolve_path_with_ribs(path, opt_ns, parent_scope, path_span, crate_lint, None)
     }
 
     fn resolve_path_with_ribs(
@@ -2226,19 +2230,18 @@ impl<'a> Resolver<'a> {
         path: &[Segment],
         opt_ns: Option<Namespace>, // `None` indicates a module path in import
         parent_scope: &ParentScope<'a>,
-        record_used: bool,
         path_span: Span,
         crate_lint: CrateLint,
         ribs: Option<&PerNS<Vec<Rib<'a>>>>,
     ) -> PathResult<'a> {
+        let record_used = crate_lint != CrateLint::No;
         let mut module = None;
         let mut allow_super = true;
         let mut second_binding = None;
 
         debug!(
-            "resolve_path(path={:?}, opt_ns={:?}, record_used={:?}, \
-             path_span={:?}, crate_lint={:?})",
-            path, opt_ns, record_used, path_span, crate_lint,
+            "resolve_path(path={:?}, opt_ns={:?}, path_span={:?}, crate_lint={:?})",
+            path, opt_ns, path_span, crate_lint,
         );
 
         for (i, &Segment { ident, id, has_generic_args: _ }) in path.iter().enumerate() {
@@ -2278,13 +2281,9 @@ impl<'a> Resolver<'a> {
                             continue;
                         }
                     }
-                    let msg = "there are too many leading `super` keywords".to_string();
-                    return PathResult::Failed {
-                        span: ident.span,
-                        label: msg,
-                        suggestion: None,
-                        is_error_from_last_segment: false,
-                    };
+                    return PathResult::failed(ident.span, false, record_used, || {
+                        ("there are too many leading `super` keywords".to_string(), None)
+                    });
                 }
                 if i == 0 {
                     if name == kw::SelfLower {
@@ -2313,22 +2312,19 @@ impl<'a> Resolver<'a> {
 
             // Report special messages for path segment keywords in wrong positions.
             if ident.is_path_segment_keyword() && i != 0 {
-                let name_str = if name == kw::PathRoot {
-                    "crate root".to_string()
-                } else {
-                    format!("`{}`", name)
-                };
-                let label = if i == 1 && path[0].ident.name == kw::PathRoot {
-                    format!("global paths cannot start with {}", name_str)
-                } else {
-                    format!("{} in paths can only be used in start position", name_str)
-                };
-                return PathResult::Failed {
-                    span: ident.span,
-                    label,
-                    suggestion: None,
-                    is_error_from_last_segment: false,
-                };
+                return PathResult::failed(ident.span, false, record_used, || {
+                    let name_str = if name == kw::PathRoot {
+                        "crate root".to_string()
+                    } else {
+                        format!("`{}`", name)
+                    };
+                    let label = if i == 1 && path[0].ident.name == kw::PathRoot {
+                        format!("global paths cannot start with {}", name_str)
+                    } else {
+                        format!("{} in paths can only be used in start position", name_str)
+                    };
+                    (label, None)
+                });
             }
 
             enum FindBindingResult<'a> {
@@ -2356,16 +2352,11 @@ impl<'a> Resolver<'a> {
                         path_span,
                     )
                 } else {
-                    let record_used_id = if record_used {
-                        crate_lint.node_id().or(Some(CRATE_NODE_ID))
-                    } else {
-                        None
-                    };
                     match this.resolve_ident_in_lexical_scope(
                         ident,
                         ns,
                         parent_scope,
-                        record_used_id,
+                        crate_lint.node_id(),
                         path_span,
                         &ribs.unwrap()[ns],
                     ) {
@@ -2425,19 +2416,14 @@ impl<'a> Resolver<'a> {
                             path.len() - i - 1,
                         ));
                     } else {
-                        let label = format!(
-                            "`{}` is {} {}, not a module",
-                            ident,
-                            res.article(),
-                            res.descr(),
-                        );
-
-                        return PathResult::Failed {
-                            span: ident.span,
-                            label,
-                            suggestion: None,
-                            is_error_from_last_segment: is_last,
-                        };
+                        return PathResult::failed(ident.span, is_last, record_used, || {
+                            let label = format!(
+                                "`{ident}` is {} {}, not a module",
+                                res.article(),
+                                res.descr()
+                            );
+                            (label, None)
+                        });
                     }
                 }
                 Err(Undetermined) => return PathResult::Indeterminate,
@@ -2450,171 +2436,169 @@ impl<'a> Resolver<'a> {
                             ));
                         }
                     }
-                    let module_res = match module {
-                        Some(ModuleOrUniformRoot::Module(module)) => module.res(),
-                        _ => None,
-                    };
-                    let (label, suggestion) = if module_res == self.graph_root.res() {
-                        let is_mod = |res| matches!(res, Res::Def(DefKind::Mod, _));
-                        // Don't look up import candidates if this is a speculative resolve
-                        let mut candidates = if record_used {
-                            self.lookup_import_candidates(ident, TypeNS, parent_scope, is_mod)
-                        } else {
-                            Vec::new()
-                        };
-                        candidates.sort_by_cached_key(|c| {
-                            (c.path.segments.len(), pprust::path_to_string(&c.path))
-                        });
-                        if let Some(candidate) = candidates.get(0) {
-                            (
-                                String::from("unresolved import"),
-                                Some((
-                                    vec![(ident.span, pprust::path_to_string(&candidate.path))],
-                                    String::from("a similar path exists"),
-                                    Applicability::MaybeIncorrect,
-                                )),
-                            )
-                        } else if self.session.edition() == Edition::Edition2015 {
-                            (format!("maybe a missing crate `{}`?", ident), None)
-                        } else {
-                            (format!("could not find `{}` in the crate root", ident), None)
-                        }
-                    } else if i == 0 {
-                        if ident
-                            .name
-                            .as_str()
-                            .chars()
-                            .next()
-                            .map_or(false, |c| c.is_ascii_uppercase())
-                        {
-                            // Check whether the name refers to an item in the value namespace.
-                            let suggestion = if ribs.is_some() {
-                                let match_span = match self.resolve_ident_in_lexical_scope(
-                                    ident,
-                                    ValueNS,
-                                    parent_scope,
-                                    None,
-                                    path_span,
-                                    &ribs.unwrap()[ValueNS],
-                                ) {
-                                    // Name matches a local variable. For example:
-                                    // ```
-                                    // fn f() {
-                                    //     let Foo: &str = "";
-                                    //     println!("{}", Foo::Bar); // Name refers to local
-                                    //                               // variable `Foo`.
-                                    // }
-                                    // ```
-                                    Some(LexicalScopeBinding::Res(Res::Local(id))) => {
-                                        Some(*self.pat_span_map.get(&id).unwrap())
-                                    }
 
-                                    // Name matches item from a local name binding
-                                    // created by `use` declaration. For example:
-                                    // ```
-                                    // pub Foo: &str = "";
-                                    //
-                                    // mod submod {
-                                    //     use super::Foo;
-                                    //     println!("{}", Foo::Bar); // Name refers to local
-                                    //                               // binding `Foo`.
-                                    // }
-                                    // ```
-                                    Some(LexicalScopeBinding::Item(name_binding)) => {
-                                        Some(name_binding.span)
-                                    }
-                                    _ => None,
-                                };
-
-                                if let Some(span) = match_span {
+                    return PathResult::failed(ident.span, is_last, record_used, || {
+                        let module_res = match module {
+                            Some(ModuleOrUniformRoot::Module(module)) => module.res(),
+                            _ => None,
+                        };
+                        if module_res == self.graph_root.res() {
+                            let is_mod = |res| matches!(res, Res::Def(DefKind::Mod, _));
+                            let mut candidates =
+                                self.lookup_import_candidates(ident, TypeNS, parent_scope, is_mod);
+                            candidates.sort_by_cached_key(|c| {
+                                (c.path.segments.len(), pprust::path_to_string(&c.path))
+                            });
+                            if let Some(candidate) = candidates.get(0) {
+                                (
+                                    String::from("unresolved import"),
                                     Some((
-                                        vec![(span, String::from(""))],
-                                        format!("`{}` is defined here, but is not a type", ident),
+                                        vec![(ident.span, pprust::path_to_string(&candidate.path))],
+                                        String::from("a similar path exists"),
                                         Applicability::MaybeIncorrect,
-                                    ))
-                                } else {
-                                    None
-                                }
+                                    )),
+                                )
+                            } else if self.session.edition() == Edition::Edition2015 {
+                                (format!("maybe a missing crate `{}`?", ident), None)
                             } else {
-                                None
-                            };
+                                (format!("could not find `{}` in the crate root", ident), None)
+                            }
+                        } else if i == 0 {
+                            if ident
+                                .name
+                                .as_str()
+                                .chars()
+                                .next()
+                                .map_or(false, |c| c.is_ascii_uppercase())
+                            {
+                                // Check whether the name refers to an item in the value namespace.
+                                let suggestion = if ribs.is_some() {
+                                    let match_span = match self.resolve_ident_in_lexical_scope(
+                                        ident,
+                                        ValueNS,
+                                        parent_scope,
+                                        None,
+                                        path_span,
+                                        &ribs.unwrap()[ValueNS],
+                                    ) {
+                                        // Name matches a local variable. For example:
+                                        // ```
+                                        // fn f() {
+                                        //     let Foo: &str = "";
+                                        //     println!("{}", Foo::Bar); // Name refers to local
+                                        //                               // variable `Foo`.
+                                        // }
+                                        // ```
+                                        Some(LexicalScopeBinding::Res(Res::Local(id))) => {
+                                            Some(*self.pat_span_map.get(&id).unwrap())
+                                        }
+
+                                        // Name matches item from a local name binding
+                                        // created by `use` declaration. For example:
+                                        // ```
+                                        // pub Foo: &str = "";
+                                        //
+                                        // mod submod {
+                                        //     use super::Foo;
+                                        //     println!("{}", Foo::Bar); // Name refers to local
+                                        //                               // binding `Foo`.
+                                        // }
+                                        // ```
+                                        Some(LexicalScopeBinding::Item(name_binding)) => {
+                                            Some(name_binding.span)
+                                        }
+                                        _ => None,
+                                    };
 
-                            (format!("use of undeclared type `{}`", ident), suggestion)
-                        } else {
-                            (
-                                format!("use of undeclared crate or module `{}`", ident),
-                                if ident.name == sym::alloc {
-                                    Some((
-                                        vec![],
-                                        String::from(
-                                            "add `extern crate alloc` to use the `alloc` crate",
-                                        ),
-                                        Applicability::MaybeIncorrect,
-                                    ))
+                                    if let Some(span) = match_span {
+                                        Some((
+                                            vec![(span, String::from(""))],
+                                            format!(
+                                                "`{}` is defined here, but is not a type",
+                                                ident
+                                            ),
+                                            Applicability::MaybeIncorrect,
+                                        ))
+                                    } else {
+                                        None
+                                    }
                                 } else {
-                                    self.find_similarly_named_module_or_crate(
-                                        ident.name,
-                                        &parent_scope.module,
-                                    )
-                                    .map(|sugg| {
-                                        (
-                                            vec![(ident.span, sugg.to_string())],
+                                    None
+                                };
+
+                                (format!("use of undeclared type `{}`", ident), suggestion)
+                            } else {
+                                (
+                                    format!("use of undeclared crate or module `{}`", ident),
+                                    if ident.name == sym::alloc {
+                                        Some((
+                                            vec![],
                                             String::from(
-                                                "there is a crate or module with a similar name",
+                                                "add `extern crate alloc` to use the `alloc` crate",
                                             ),
                                             Applicability::MaybeIncorrect,
+                                        ))
+                                    } else {
+                                        self.find_similarly_named_module_or_crate(
+                                            ident.name,
+                                            &parent_scope.module,
                                         )
-                                    })
-                                },
-                            )
-                        }
-                    } else {
-                        let parent = path[i - 1].ident.name;
-                        let parent = match parent {
-                            // ::foo is mounted at the crate root for 2015, and is the extern
-                            // prelude for 2018+
-                            kw::PathRoot if self.session.edition() > Edition::Edition2015 => {
-                                "the list of imported crates".to_owned()
-                            }
-                            kw::PathRoot | kw::Crate => "the crate root".to_owned(),
-                            _ => {
-                                format!("`{}`", parent)
+                                        .map(|sugg| {
+                                            (
+                                                vec![(ident.span, sugg.to_string())],
+                                                String::from(
+                                                    "there is a crate or module with a similar name",
+                                                ),
+                                                Applicability::MaybeIncorrect,
+                                            )
+                                        })
+                                    },
+                                )
                             }
-                        };
-
-                        let mut msg = format!("could not find `{}` in {}", ident, parent);
-                        if ns == TypeNS || ns == ValueNS {
-                            let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
-                            if let FindBindingResult::Binding(Ok(binding)) =
-                                find_binding_in_ns(self, ns_to_try)
-                            {
-                                let mut found = |what| {
-                                    msg = format!(
-                                        "expected {}, found {} `{}` in {}",
-                                        ns.descr(),
-                                        what,
-                                        ident,
-                                        parent
-                                    )
-                                };
-                                if binding.module().is_some() {
-                                    found("module")
-                                } else {
-                                    match binding.res() {
-                                        def::Res::<NodeId>::Def(kind, id) => found(kind.descr(id)),
-                                        _ => found(ns_to_try.descr()),
-                                    }
+                        } else {
+                            let parent = path[i - 1].ident.name;
+                            let parent = match parent {
+                                // ::foo is mounted at the crate root for 2015, and is the extern
+                                // prelude for 2018+
+                                kw::PathRoot if self.session.edition() > Edition::Edition2015 => {
+                                    "the list of imported crates".to_owned()
+                                }
+                                kw::PathRoot | kw::Crate => "the crate root".to_owned(),
+                                _ => {
+                                    format!("`{}`", parent)
                                 }
                             };
+
+                            let mut msg = format!("could not find `{}` in {}", ident, parent);
+                            if ns == TypeNS || ns == ValueNS {
+                                let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS };
+                                if let FindBindingResult::Binding(Ok(binding)) =
+                                    find_binding_in_ns(self, ns_to_try)
+                                {
+                                    let mut found = |what| {
+                                        msg = format!(
+                                            "expected {}, found {} `{}` in {}",
+                                            ns.descr(),
+                                            what,
+                                            ident,
+                                            parent
+                                        )
+                                    };
+                                    if binding.module().is_some() {
+                                        found("module")
+                                    } else {
+                                        match binding.res() {
+                                            def::Res::<NodeId>::Def(kind, id) => {
+                                                found(kind.descr(id))
+                                            }
+                                            _ => found(ns_to_try.descr()),
+                                        }
+                                    }
+                                };
+                            }
+                            (msg, None)
                         }
-                        (msg, None)
-                    };
-                    return PathResult::Failed {
-                        span: ident.span,
-                        label,
-                        suggestion,
-                        is_error_from_last_segment: is_last,
-                    };
+                    });
                 }
             }
         }
@@ -3374,7 +3358,6 @@ impl<'a> Resolver<'a> {
             &Segment::from_path(path),
             Some(ns),
             parent_scope,
-            false,
             path.span,
             CrateLint::No,
         ) {
@@ -3543,7 +3526,7 @@ fn module_to_string(module: Module<'_>) -> Option<String> {
     Some(names_to_string(&names))
 }
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, PartialEq, Debug)]
 enum CrateLint {
     /// Do not issue the lint.
     No,
diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs
index e34d3e605ec..d30aed71e23 100644
--- a/compiler/rustc_resolve/src/macros.rs
+++ b/compiler/rustc_resolve/src/macros.rs
@@ -415,7 +415,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
 
         let mut indeterminate = false;
         for ns in [TypeNS, ValueNS, MacroNS].iter().copied() {
-            match self.resolve_path(path, Some(ns), &parent_scope, false, span, CrateLint::No) {
+            match self.resolve_path(path, Some(ns), &parent_scope, span, CrateLint::No) {
                 PathResult::Module(ModuleOrUniformRoot::Module(_)) => return Ok(true),
                 PathResult::NonModule(partial_res) if partial_res.unresolved_segments() == 0 => {
                     return Ok(true);
@@ -579,7 +579,6 @@ impl<'a> Resolver<'a> {
                 &path,
                 Some(MacroNS),
                 parent_scope,
-                false,
                 path_span,
                 CrateLint::No,
             ) {
@@ -1033,9 +1032,8 @@ impl<'a> Resolver<'a> {
                 &path,
                 Some(MacroNS),
                 &parent_scope,
-                true,
                 path_span,
-                CrateLint::No,
+                CrateLint::SimplePath(ast::CRATE_NODE_ID),
             ) {
                 PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => {
                     let res = path_res.base_res();
diff --git a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed
index acb0aa420ab..5786ed7b1d5 100644
--- a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed
+++ b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed
@@ -17,28 +17,18 @@ crate mod foo {
 use crate::foo::{bar::{baz::{}}};
 //~^ ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
 
 use crate::foo::{bar::{XX, baz::{}}};
 //~^ ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
 //~| ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
 
 use crate::foo::{bar::{baz::{}, baz1::{}}};
 //~^ ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
 //~| ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
 
 fn main() {
 }
diff --git a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs
index 4825528e97f..b7c86088c75 100644
--- a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs
+++ b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs
@@ -17,28 +17,18 @@ crate mod foo {
 use foo::{bar::{baz::{}}};
 //~^ ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
 
 use foo::{bar::{XX, baz::{}}};
 //~^ ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
 //~| ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
 
 use foo::{bar::{baz::{}, baz1::{}}};
 //~^ ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
 //~| ERROR absolute paths must start with
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| WARN this is accepted in the current edition
 
 fn main() {
 }
diff --git a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr
index 8a3113729b4..e47c320f78f 100644
--- a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr
+++ b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr
@@ -13,16 +13,7 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:17:5
-   |
-LL | use foo::{bar::{baz::{}}};
-   |     ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:23:5
+  --> $DIR/edition-lint-nested-empty-paths.rs:21:5
    |
 LL | use foo::{bar::{XX, baz::{}}};
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@@ -31,7 +22,7 @@ LL | use foo::{bar::{XX, baz::{}}};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:23:5
+  --> $DIR/edition-lint-nested-empty-paths.rs:21:5
    |
 LL | use foo::{bar::{XX, baz::{}}};
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@@ -40,43 +31,7 @@ LL | use foo::{bar::{XX, baz::{}}};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:23:5
-   |
-LL | use foo::{bar::{XX, baz::{}}};
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:23:5
-   |
-LL | use foo::{bar::{XX, baz::{}}};
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:33:5
-   |
-LL | use foo::{bar::{baz::{}, baz1::{}}};
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:33:5
-   |
-LL | use foo::{bar::{baz::{}, baz1::{}}};
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:33:5
+  --> $DIR/edition-lint-nested-empty-paths.rs:27:5
    |
 LL | use foo::{bar::{baz::{}, baz1::{}}};
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
@@ -85,7 +40,7 @@ LL | use foo::{bar::{baz::{}, baz1::{}}};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-empty-paths.rs:33:5
+  --> $DIR/edition-lint-nested-empty-paths.rs:27:5
    |
 LL | use foo::{bar::{baz::{}, baz1::{}}};
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
@@ -93,5 +48,5 @@ LL | use foo::{bar::{baz::{}, baz1::{}}};
    = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
-error: aborting due to 10 previous errors
+error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/rust-2018/edition-lint-nested-paths.fixed b/src/test/ui/rust-2018/edition-lint-nested-paths.fixed
index 4eb1184cb6d..c4546f8c821 100644
--- a/src/test/ui/rust-2018/edition-lint-nested-paths.fixed
+++ b/src/test/ui/rust-2018/edition-lint-nested-paths.fixed
@@ -8,10 +8,6 @@ use crate::foo::{a, b};
 //~| this is accepted in the current edition
 //~| ERROR absolute paths must start with
 //~| this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| this is accepted in the current edition
 
 mod foo {
     crate fn a() {}
@@ -29,8 +25,6 @@ fn main() {
         //~| this is accepted in the current edition
         //~| ERROR absolute paths must start with
         //~| this is accepted in the current edition
-        //~| ERROR absolute paths must start with
-        //~| this is accepted in the current edition
         x::a();
         c();
     }
diff --git a/src/test/ui/rust-2018/edition-lint-nested-paths.rs b/src/test/ui/rust-2018/edition-lint-nested-paths.rs
index 2a358224d9b..a7e34e407a3 100644
--- a/src/test/ui/rust-2018/edition-lint-nested-paths.rs
+++ b/src/test/ui/rust-2018/edition-lint-nested-paths.rs
@@ -8,10 +8,6 @@ use foo::{a, b};
 //~| this is accepted in the current edition
 //~| ERROR absolute paths must start with
 //~| this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| this is accepted in the current edition
-//~| ERROR absolute paths must start with
-//~| this is accepted in the current edition
 
 mod foo {
     crate fn a() {}
@@ -29,8 +25,6 @@ fn main() {
         //~| this is accepted in the current edition
         //~| ERROR absolute paths must start with
         //~| this is accepted in the current edition
-        //~| ERROR absolute paths must start with
-        //~| this is accepted in the current edition
         x::a();
         c();
     }
diff --git a/src/test/ui/rust-2018/edition-lint-nested-paths.stderr b/src/test/ui/rust-2018/edition-lint-nested-paths.stderr
index 3d596022b0a..24b17f212eb 100644
--- a/src/test/ui/rust-2018/edition-lint-nested-paths.stderr
+++ b/src/test/ui/rust-2018/edition-lint-nested-paths.stderr
@@ -22,34 +22,7 @@ LL | use foo::{a, b};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-paths.rs:6:5
-   |
-LL | use foo::{a, b};
-   |     ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-paths.rs:6:5
-   |
-LL | use foo::{a, b};
-   |     ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-paths.rs:27:13
-   |
-LL |         use foo::{self as x, c};
-   |             ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-paths.rs:27:13
+  --> $DIR/edition-lint-nested-paths.rs:23:13
    |
 LL |         use foo::{self as x, c};
    |             ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
@@ -58,7 +31,7 @@ LL |         use foo::{self as x, c};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-nested-paths.rs:27:13
+  --> $DIR/edition-lint-nested-paths.rs:23:13
    |
 LL |         use foo::{self as x, c};
    |             ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
@@ -66,5 +39,5 @@ LL |         use foo::{self as x, c};
    = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
-error: aborting due to 7 previous errors
+error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/rust-2018/edition-lint-paths.fixed b/src/test/ui/rust-2018/edition-lint-paths.fixed
index 46adf02a391..47f82c51dae 100644
--- a/src/test/ui/rust-2018/edition-lint-paths.fixed
+++ b/src/test/ui/rust-2018/edition-lint-paths.fixed
@@ -12,8 +12,6 @@ pub mod foo {
     use crate::bar::Bar;
     //~^ ERROR absolute
     //~| WARN this is accepted in the current edition
-    //~| ERROR absolute
-    //~| WARN this is accepted in the current edition
 
     use super::bar::Bar2;
     use crate::bar::Bar3;
@@ -42,8 +40,6 @@ pub mod foo {
 use crate::bar::Bar;
 //~^ ERROR absolute
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute
-//~| WARN this is accepted in the current edition
 
 pub mod bar {
     use edition_lint_paths as foo;
@@ -61,8 +57,6 @@ mod baz {
 impl crate::foo::SomeTrait for u32 {}
 //~^ ERROR absolute
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute
-//~| WARN this is accepted in the current edition
 
 fn main() {
     let x = crate::bar::Bar;
diff --git a/src/test/ui/rust-2018/edition-lint-paths.rs b/src/test/ui/rust-2018/edition-lint-paths.rs
index f70bf90d681..e278983da4a 100644
--- a/src/test/ui/rust-2018/edition-lint-paths.rs
+++ b/src/test/ui/rust-2018/edition-lint-paths.rs
@@ -12,8 +12,6 @@ pub mod foo {
     use bar::Bar;
     //~^ ERROR absolute
     //~| WARN this is accepted in the current edition
-    //~| ERROR absolute
-    //~| WARN this is accepted in the current edition
 
     use super::bar::Bar2;
     use crate::bar::Bar3;
@@ -42,8 +40,6 @@ pub mod foo {
 use bar::Bar;
 //~^ ERROR absolute
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute
-//~| WARN this is accepted in the current edition
 
 pub mod bar {
     use edition_lint_paths as foo;
@@ -61,8 +57,6 @@ mod baz {
 impl ::foo::SomeTrait for u32 {}
 //~^ ERROR absolute
 //~| WARN this is accepted in the current edition
-//~| ERROR absolute
-//~| WARN this is accepted in the current edition
 
 fn main() {
     let x = ::bar::Bar;
diff --git a/src/test/ui/rust-2018/edition-lint-paths.stderr b/src/test/ui/rust-2018/edition-lint-paths.stderr
index 481c68e1033..1ded8cd3694 100644
--- a/src/test/ui/rust-2018/edition-lint-paths.stderr
+++ b/src/test/ui/rust-2018/edition-lint-paths.stderr
@@ -13,16 +13,7 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:12:9
-   |
-LL |     use bar::Bar;
-   |         ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:21:9
+  --> $DIR/edition-lint-paths.rs:19:9
    |
 LL |     use bar;
    |         ^^^ help: use `crate`: `crate::bar`
@@ -31,7 +22,7 @@ LL |     use bar;
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:27:9
+  --> $DIR/edition-lint-paths.rs:25:9
    |
 LL |     use {main, Bar as SomethingElse};
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -40,7 +31,7 @@ LL |     use {main, Bar as SomethingElse};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:27:9
+  --> $DIR/edition-lint-paths.rs:25:9
    |
 LL |     use {main, Bar as SomethingElse};
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -49,7 +40,7 @@ LL |     use {main, Bar as SomethingElse};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:27:9
+  --> $DIR/edition-lint-paths.rs:25:9
    |
 LL |     use {main, Bar as SomethingElse};
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -58,7 +49,7 @@ LL |     use {main, Bar as SomethingElse};
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:42:5
+  --> $DIR/edition-lint-paths.rs:40:5
    |
 LL | use bar::Bar;
    |     ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@@ -67,16 +58,7 @@ LL | use bar::Bar;
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:42:5
-   |
-LL | use bar::Bar;
-   |     ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:56:9
+  --> $DIR/edition-lint-paths.rs:52:9
    |
 LL |     use *;
    |         ^ help: use `crate`: `crate::*`
@@ -85,16 +67,7 @@ LL |     use *;
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:61:6
-   |
-LL | impl ::foo::SomeTrait for u32 {}
-   |      ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:61:6
+  --> $DIR/edition-lint-paths.rs:57:6
    |
 LL | impl ::foo::SomeTrait for u32 {}
    |      ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
@@ -103,7 +76,7 @@ LL | impl ::foo::SomeTrait for u32 {}
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/edition-lint-paths.rs:68:13
+  --> $DIR/edition-lint-paths.rs:62:13
    |
 LL |     let x = ::bar::Bar;
    |             ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@@ -111,5 +84,5 @@ LL |     let x = ::bar::Bar;
    = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
-error: aborting due to 12 previous errors
+error: aborting due to 9 previous errors
 
diff --git a/src/test/ui/rust-2018/extern-crate-rename.fixed b/src/test/ui/rust-2018/extern-crate-rename.fixed
index 05b881a9b08..ea832ef3e7d 100644
--- a/src/test/ui/rust-2018/extern-crate-rename.fixed
+++ b/src/test/ui/rust-2018/extern-crate-rename.fixed
@@ -12,8 +12,6 @@ extern crate edition_lint_paths as my_crate;
 use crate::my_crate::foo;
 //~^ ERROR absolute paths must start
 //~| WARNING this is accepted in the current edition
-//~| ERROR absolute paths must start
-//~| WARNING this is accepted in the current edition
 
 fn main() {
     foo();
diff --git a/src/test/ui/rust-2018/extern-crate-rename.rs b/src/test/ui/rust-2018/extern-crate-rename.rs
index 6e327be193b..b1f617dd884 100644
--- a/src/test/ui/rust-2018/extern-crate-rename.rs
+++ b/src/test/ui/rust-2018/extern-crate-rename.rs
@@ -12,8 +12,6 @@ extern crate edition_lint_paths as my_crate;
 use my_crate::foo;
 //~^ ERROR absolute paths must start
 //~| WARNING this is accepted in the current edition
-//~| ERROR absolute paths must start
-//~| WARNING this is accepted in the current edition
 
 fn main() {
     foo();
diff --git a/src/test/ui/rust-2018/extern-crate-rename.stderr b/src/test/ui/rust-2018/extern-crate-rename.stderr
index f2f379ca396..4bccbc51223 100644
--- a/src/test/ui/rust-2018/extern-crate-rename.stderr
+++ b/src/test/ui/rust-2018/extern-crate-rename.stderr
@@ -12,14 +12,5 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
    = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/extern-crate-rename.rs:12:5
-   |
-LL | use my_crate::foo;
-   |     ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/rust-2018/extern-crate-submod.fixed b/src/test/ui/rust-2018/extern-crate-submod.fixed
index fdbd893abed..9b0b0dd8ee1 100644
--- a/src/test/ui/rust-2018/extern-crate-submod.fixed
+++ b/src/test/ui/rust-2018/extern-crate-submod.fixed
@@ -19,9 +19,6 @@ mod m {
 use crate::m::edition_lint_paths::foo;
 //~^ ERROR absolute paths must start
 //~| WARNING this is accepted in the current edition
-//~| ERROR absolute paths must start
-//~| WARNING this is accepted in the current edition
-
 
 fn main() {
     foo();
diff --git a/src/test/ui/rust-2018/extern-crate-submod.rs b/src/test/ui/rust-2018/extern-crate-submod.rs
index c2b915849f0..dfce9128c51 100644
--- a/src/test/ui/rust-2018/extern-crate-submod.rs
+++ b/src/test/ui/rust-2018/extern-crate-submod.rs
@@ -19,9 +19,6 @@ mod m {
 use m::edition_lint_paths::foo;
 //~^ ERROR absolute paths must start
 //~| WARNING this is accepted in the current edition
-//~| ERROR absolute paths must start
-//~| WARNING this is accepted in the current edition
-
 
 fn main() {
     foo();
diff --git a/src/test/ui/rust-2018/extern-crate-submod.stderr b/src/test/ui/rust-2018/extern-crate-submod.stderr
index c4c3168bc97..3c75319aeda 100644
--- a/src/test/ui/rust-2018/extern-crate-submod.stderr
+++ b/src/test/ui/rust-2018/extern-crate-submod.stderr
@@ -12,14 +12,5 @@ LL | #![deny(absolute_paths_not_starting_with_crate)]
    = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
    = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
 
-error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
-  --> $DIR/extern-crate-submod.rs:19:5
-   |
-LL | use m::edition_lint_paths::foo;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo`
-   |
-   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
-   = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error