mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
refactor path construction
Co-Authored-By: mu001999 <mu001999@outlook.com>
This commit is contained in:
@@ -2406,7 +2406,6 @@ fn report_privacy_error(&mut self, privacy_error: &PrivacyError<'ra>) {
|
||||
let first_binding = decl;
|
||||
let mut next_binding = Some(decl);
|
||||
let mut next_ident = ident;
|
||||
let mut path = vec![];
|
||||
while let Some(binding) = next_binding {
|
||||
let name = next_ident;
|
||||
next_binding = match binding.kind {
|
||||
@@ -2427,18 +2426,17 @@ fn report_privacy_error(&mut self, privacy_error: &PrivacyError<'ra>) {
|
||||
|
||||
match binding.kind {
|
||||
DeclKind::Import { source_decl, import, .. } => {
|
||||
for segment in &import.module_path {
|
||||
// Don't include `{{root}}` in suggestions - it's an internal symbol
|
||||
// that should never be shown to users.
|
||||
if segment.ident.name != kw::PathRoot {
|
||||
path.push(segment.ident);
|
||||
}
|
||||
}
|
||||
// Don't include `{{root}}` in suggestions - it's an internal symbol
|
||||
// that should never be shown to users.
|
||||
let path = import
|
||||
.module_path
|
||||
.iter()
|
||||
.filter(|seg| seg.ident.name != kw::PathRoot)
|
||||
.map(|seg| seg.ident.clone())
|
||||
.chain(std::iter::once(ident))
|
||||
.collect::<Vec<_>>();
|
||||
let through_reexport = !matches!(source_decl.kind, DeclKind::Def(_));
|
||||
sugg_paths.push((
|
||||
path.iter().cloned().chain(std::iter::once(ident)).collect::<Vec<_>>(),
|
||||
through_reexport,
|
||||
));
|
||||
sugg_paths.push((path, through_reexport));
|
||||
}
|
||||
DeclKind::Def(_) => {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user