1
Fork 0

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`.
This commit is contained in:
Vadim Petrochenkov 2022-03-23 22:47:19 +03:00
parent 63b8f01bb5
commit 0749ec67bc
22 changed files with 237 additions and 448 deletions

View file

@ -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