Rollup merge of #121226 - chenyukang:yukang-fix-import-alias, r=davidtwco
Fix issues in suggesting importing extern crate paths Fixes #121168 r? ``@petrochenkov``
This commit is contained in:
commit
c5dafe66ba
6 changed files with 72 additions and 1 deletions
|
@ -1294,10 +1294,20 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let mut path_segments = path_segments.clone();
|
||||
path_segments.push(ast::PathSegment::from_ident(ident));
|
||||
|
||||
let alias_import = if let NameBindingKind::Import { import, .. } =
|
||||
name_binding.kind
|
||||
&& let ImportKind::ExternCrate { source: Some(_), .. } = import.kind
|
||||
&& import.parent_scope.expansion == parent_scope.expansion
|
||||
{
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
let is_extern_crate_that_also_appears_in_prelude =
|
||||
name_binding.is_extern_crate() && lookup_ident.span.at_least_rust_2018();
|
||||
|
||||
if !is_extern_crate_that_also_appears_in_prelude {
|
||||
if !is_extern_crate_that_also_appears_in_prelude || alias_import {
|
||||
// add the module to the lookup
|
||||
if seen_modules.insert(module.def_id()) {
|
||||
if via_import { &mut worklist_via_import } else { &mut worklist }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue