Rollup merge of #112892 - petrochenkov:cleanres, r=oli-obk
resolve: Minor cleanup to `fn resolve_path_with_ribs` A single-use closure is inlined and one unnecessary enum is removed. Noticed when reviewing https://github.com/rust-lang/rust/pull/112686.
This commit is contained in:
commit
d938be153c
@ -1459,60 +1459,47 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FindBindingResult<'a> {
|
let binding = if let Some(module) = module {
|
||||||
Binding(Result<&'a NameBinding<'a>, Determinacy>),
|
self.resolve_ident_in_module(
|
||||||
Res(Res),
|
module,
|
||||||
}
|
ident,
|
||||||
let find_binding_in_ns = |this: &mut Self, ns| {
|
ns,
|
||||||
let binding = if let Some(module) = module {
|
parent_scope,
|
||||||
this.resolve_ident_in_module(
|
finalize,
|
||||||
module,
|
ignore_binding,
|
||||||
ident,
|
)
|
||||||
ns,
|
} else if let Some(ribs) = ribs && let Some(TypeNS | ValueNS) = opt_ns {
|
||||||
parent_scope,
|
match self.resolve_ident_in_lexical_scope(
|
||||||
finalize,
|
ident,
|
||||||
ignore_binding,
|
ns,
|
||||||
)
|
parent_scope,
|
||||||
} else if let Some(ribs) = ribs
|
finalize,
|
||||||
&& let Some(TypeNS | ValueNS) = opt_ns
|
&ribs[ns],
|
||||||
{
|
ignore_binding,
|
||||||
match this.resolve_ident_in_lexical_scope(
|
) {
|
||||||
ident,
|
// we found a locally-imported or available item/module
|
||||||
ns,
|
Some(LexicalScopeBinding::Item(binding)) => Ok(binding),
|
||||||
parent_scope,
|
// we found a local variable or type param
|
||||||
finalize,
|
Some(LexicalScopeBinding::Res(res)) => {
|
||||||
&ribs[ns],
|
record_segment_res(self, res);
|
||||||
ignore_binding,
|
return PathResult::NonModule(PartialRes::with_unresolved_segments(
|
||||||
) {
|
res,
|
||||||
// we found a locally-imported or available item/module
|
path.len() - 1,
|
||||||
Some(LexicalScopeBinding::Item(binding)) => Ok(binding),
|
));
|
||||||
// we found a local variable or type param
|
|
||||||
Some(LexicalScopeBinding::Res(res)) => return FindBindingResult::Res(res),
|
|
||||||
_ => Err(Determinacy::determined(finalize.is_some())),
|
|
||||||
}
|
}
|
||||||
} else {
|
_ => Err(Determinacy::determined(finalize.is_some())),
|
||||||
let scopes = ScopeSet::All(ns, opt_ns.is_none());
|
|
||||||
this.early_resolve_ident_in_lexical_scope(
|
|
||||||
ident,
|
|
||||||
scopes,
|
|
||||||
parent_scope,
|
|
||||||
finalize,
|
|
||||||
finalize.is_some(),
|
|
||||||
ignore_binding,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
FindBindingResult::Binding(binding)
|
|
||||||
};
|
|
||||||
let binding = match find_binding_in_ns(self, ns) {
|
|
||||||
FindBindingResult::Res(res) => {
|
|
||||||
record_segment_res(self, res);
|
|
||||||
return PathResult::NonModule(PartialRes::with_unresolved_segments(
|
|
||||||
res,
|
|
||||||
path.len() - 1,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
FindBindingResult::Binding(binding) => binding,
|
} else {
|
||||||
|
self.early_resolve_ident_in_lexical_scope(
|
||||||
|
ident,
|
||||||
|
ScopeSet::All(ns, opt_ns.is_none()),
|
||||||
|
parent_scope,
|
||||||
|
finalize,
|
||||||
|
finalize.is_some(),
|
||||||
|
ignore_binding,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
match binding {
|
match binding {
|
||||||
Ok(binding) => {
|
Ok(binding) => {
|
||||||
if segment_idx == 1 {
|
if segment_idx == 1 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user