Note potential but private items in show_candidates
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
parent
9bad8ac498
commit
26cfa6f819
12 changed files with 135 additions and 14 deletions
|
@ -1325,11 +1325,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
// If only some candidates are accessible, take just them
|
||||
if !candidates.iter().all(|v: &ImportSuggestion| !v.accessible) {
|
||||
candidates.retain(|x| x.accessible)
|
||||
}
|
||||
|
||||
candidates
|
||||
}
|
||||
|
||||
|
@ -1794,7 +1789,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
&import_suggestions,
|
||||
Instead::Yes,
|
||||
FoundUse::Yes,
|
||||
DiagMode::Import { append: single_nested },
|
||||
DiagMode::Import { append: single_nested, unresolved_import: false },
|
||||
vec![],
|
||||
"",
|
||||
);
|
||||
|
@ -2751,6 +2746,8 @@ pub(crate) enum DiagMode {
|
|||
Pattern,
|
||||
/// The binding is part of a use statement
|
||||
Import {
|
||||
/// `true` means diagnostics is for unresolved import
|
||||
unresolved_import: bool,
|
||||
/// `true` mean add the tips afterward for case `use a::{b,c}`,
|
||||
/// rather than replacing within.
|
||||
append: bool,
|
||||
|
@ -2801,6 +2798,7 @@ fn show_candidates(
|
|||
return false;
|
||||
}
|
||||
|
||||
let mut showed = false;
|
||||
let mut accessible_path_strings: Vec<PathString<'_>> = Vec::new();
|
||||
let mut inaccessible_path_strings: Vec<PathString<'_>> = Vec::new();
|
||||
|
||||
|
@ -2959,8 +2957,11 @@ fn show_candidates(
|
|||
append_candidates(&mut msg, accessible_path_strings);
|
||||
err.help(msg);
|
||||
}
|
||||
true
|
||||
} else if !(inaccessible_path_strings.is_empty() || matches!(mode, DiagMode::Import { .. })) {
|
||||
showed = true;
|
||||
}
|
||||
if !inaccessible_path_strings.is_empty()
|
||||
&& (!matches!(mode, DiagMode::Import { unresolved_import: false, .. }))
|
||||
{
|
||||
let prefix =
|
||||
if let DiagMode::Pattern = mode { "you might have meant to match on " } else { "" };
|
||||
if let [(name, descr, source_span, note, _)] = &inaccessible_path_strings[..] {
|
||||
|
@ -3023,10 +3024,9 @@ fn show_candidates(
|
|||
|
||||
err.span_note(multi_span, msg);
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
showed = true;
|
||||
}
|
||||
showed
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -734,7 +734,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
&mut diag,
|
||||
Some(err.span),
|
||||
candidates,
|
||||
DiagMode::Import { append: false },
|
||||
DiagMode::Import { append: false, unresolved_import: true },
|
||||
(source != target)
|
||||
.then(|| format!(" as {target}"))
|
||||
.as_deref()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue