resolve: Pass full Finalize
in nearly all cases
This commit is contained in:
parent
900607f49a
commit
ffedcec4e8
3 changed files with 18 additions and 20 deletions
|
@ -279,7 +279,7 @@ impl<'a> Resolver<'a> {
|
||||||
mut ident: Ident,
|
mut ident: Ident,
|
||||||
ns: Namespace,
|
ns: Namespace,
|
||||||
parent_scope: &ParentScope<'a>,
|
parent_scope: &ParentScope<'a>,
|
||||||
finalize_full: Option<Finalize>,
|
finalize: Option<Finalize>,
|
||||||
ribs: &[Rib<'a>],
|
ribs: &[Rib<'a>],
|
||||||
unusable_binding: Option<&'a NameBinding<'a>>,
|
unusable_binding: Option<&'a NameBinding<'a>>,
|
||||||
) -> Option<LexicalScopeBinding<'a>> {
|
) -> Option<LexicalScopeBinding<'a>> {
|
||||||
|
@ -302,7 +302,6 @@ impl<'a> Resolver<'a> {
|
||||||
let normalized_ident = Ident { span: normalized_span, ..ident };
|
let normalized_ident = Ident { span: normalized_span, ..ident };
|
||||||
|
|
||||||
// Walk backwards up the ribs in scope.
|
// Walk backwards up the ribs in scope.
|
||||||
let finalize = finalize_full.map(|finalize| finalize.path_span);
|
|
||||||
let mut module = self.graph_root;
|
let mut module = self.graph_root;
|
||||||
for i in (0..ribs.len()).rev() {
|
for i in (0..ribs.len()).rev() {
|
||||||
debug!("walk rib\n{:?}", ribs[i].bindings);
|
debug!("walk rib\n{:?}", ribs[i].bindings);
|
||||||
|
@ -316,7 +315,7 @@ impl<'a> Resolver<'a> {
|
||||||
i,
|
i,
|
||||||
rib_ident,
|
rib_ident,
|
||||||
*res,
|
*res,
|
||||||
finalize,
|
finalize.map(|finalize| finalize.path_span),
|
||||||
*original_rib_ident_def,
|
*original_rib_ident_def,
|
||||||
ribs,
|
ribs,
|
||||||
)));
|
)));
|
||||||
|
@ -354,7 +353,7 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
self.early_resolve_ident_in_lexical_scope(
|
self.early_resolve_ident_in_lexical_scope(
|
||||||
orig_ident,
|
orig_ident,
|
||||||
ScopeSet::Late(ns, module, finalize_full.map(|finalize| finalize.node_id)),
|
ScopeSet::Late(ns, module, finalize.map(|finalize| finalize.node_id)),
|
||||||
parent_scope,
|
parent_scope,
|
||||||
finalize,
|
finalize,
|
||||||
finalize.is_some(),
|
finalize.is_some(),
|
||||||
|
@ -376,7 +375,7 @@ impl<'a> Resolver<'a> {
|
||||||
orig_ident: Ident,
|
orig_ident: Ident,
|
||||||
scope_set: ScopeSet<'a>,
|
scope_set: ScopeSet<'a>,
|
||||||
parent_scope: &ParentScope<'a>,
|
parent_scope: &ParentScope<'a>,
|
||||||
finalize: Option<Span>,
|
finalize: Option<Finalize>,
|
||||||
force: bool,
|
force: bool,
|
||||||
last_import_segment: bool,
|
last_import_segment: bool,
|
||||||
unusable_binding: Option<&'a NameBinding<'a>>,
|
unusable_binding: Option<&'a NameBinding<'a>>,
|
||||||
|
@ -742,7 +741,7 @@ impl<'a> Resolver<'a> {
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
ns: Namespace,
|
ns: Namespace,
|
||||||
parent_scope: &ParentScope<'a>,
|
parent_scope: &ParentScope<'a>,
|
||||||
finalize: Option<Span>,
|
finalize: Option<Finalize>,
|
||||||
// We are resolving a last import segment during import validation.
|
// We are resolving a last import segment during import validation.
|
||||||
last_import_segment: bool,
|
last_import_segment: bool,
|
||||||
// This binding should be ignored during in-module resolution, so that we don't get
|
// This binding should be ignored during in-module resolution, so that we don't get
|
||||||
|
@ -768,7 +767,7 @@ impl<'a> Resolver<'a> {
|
||||||
mut ident: Ident,
|
mut ident: Ident,
|
||||||
ns: Namespace,
|
ns: Namespace,
|
||||||
parent_scope: &ParentScope<'a>,
|
parent_scope: &ParentScope<'a>,
|
||||||
finalize: Option<Span>,
|
finalize: Option<Finalize>,
|
||||||
last_import_segment: bool,
|
last_import_segment: bool,
|
||||||
unusable_binding: Option<&'a NameBinding<'a>>,
|
unusable_binding: Option<&'a NameBinding<'a>>,
|
||||||
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)> {
|
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)> {
|
||||||
|
@ -808,7 +807,7 @@ impl<'a> Resolver<'a> {
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
ns: Namespace,
|
ns: Namespace,
|
||||||
parent_scope: &ParentScope<'a>,
|
parent_scope: &ParentScope<'a>,
|
||||||
finalize: Option<Span>,
|
finalize: Option<Finalize>,
|
||||||
last_import_segment: bool,
|
last_import_segment: bool,
|
||||||
unusable_binding: Option<&'a NameBinding<'a>>,
|
unusable_binding: Option<&'a NameBinding<'a>>,
|
||||||
) -> Result<&'a NameBinding<'a>, Determinacy> {
|
) -> Result<&'a NameBinding<'a>, Determinacy> {
|
||||||
|
@ -835,7 +834,7 @@ impl<'a> Resolver<'a> {
|
||||||
ns: Namespace,
|
ns: Namespace,
|
||||||
parent_scope: &ParentScope<'a>,
|
parent_scope: &ParentScope<'a>,
|
||||||
restricted_shadowing: bool,
|
restricted_shadowing: bool,
|
||||||
finalize: Option<Span>,
|
finalize: Option<Finalize>,
|
||||||
last_import_segment: bool,
|
last_import_segment: bool,
|
||||||
unusable_binding: Option<&'a NameBinding<'a>>,
|
unusable_binding: Option<&'a NameBinding<'a>>,
|
||||||
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)> {
|
) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)> {
|
||||||
|
@ -901,7 +900,7 @@ impl<'a> Resolver<'a> {
|
||||||
let resolution =
|
let resolution =
|
||||||
self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports.
|
self.resolution(module, key).try_borrow_mut().map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports.
|
||||||
|
|
||||||
if let Some(path_span) = finalize {
|
if let Some(Finalize { path_span, .. }) = finalize {
|
||||||
// If the primary binding is unusable, search further and return the shadowed glob
|
// If the primary binding is unusable, search further and return the shadowed glob
|
||||||
// binding if it exists. What we really want here is having two separate scopes in
|
// binding if it exists. What we really want here is having two separate scopes in
|
||||||
// a module - one for non-globs and one for globs, but until that's done use this
|
// a module - one for non-globs and one for globs, but until that's done use this
|
||||||
|
@ -1391,13 +1390,12 @@ impl<'a> Resolver<'a> {
|
||||||
path: &[Segment],
|
path: &[Segment],
|
||||||
opt_ns: Option<Namespace>, // `None` indicates a module path in import
|
opt_ns: Option<Namespace>, // `None` indicates a module path in import
|
||||||
parent_scope: &ParentScope<'a>,
|
parent_scope: &ParentScope<'a>,
|
||||||
finalize_full: Option<Finalize>,
|
finalize: Option<Finalize>,
|
||||||
ribs: Option<&PerNS<Vec<Rib<'a>>>>,
|
ribs: Option<&PerNS<Vec<Rib<'a>>>>,
|
||||||
unusable_binding: Option<&'a NameBinding<'a>>,
|
unusable_binding: Option<&'a NameBinding<'a>>,
|
||||||
) -> PathResult<'a> {
|
) -> PathResult<'a> {
|
||||||
debug!("resolve_path(path={:?}, opt_ns={:?}, finalize={:?})", path, opt_ns, finalize_full);
|
debug!("resolve_path(path={:?}, opt_ns={:?}, finalize={:?})", path, opt_ns, finalize);
|
||||||
|
|
||||||
let finalize = finalize_full.map(|finalize| finalize.path_span);
|
|
||||||
let mut module = None;
|
let mut module = None;
|
||||||
let mut allow_super = true;
|
let mut allow_super = true;
|
||||||
let mut second_binding = None;
|
let mut second_binding = None;
|
||||||
|
@ -1507,7 +1505,7 @@ impl<'a> Resolver<'a> {
|
||||||
ident,
|
ident,
|
||||||
ns,
|
ns,
|
||||||
parent_scope,
|
parent_scope,
|
||||||
finalize_full,
|
finalize,
|
||||||
&ribs[ns],
|
&ribs[ns],
|
||||||
unusable_binding,
|
unusable_binding,
|
||||||
) {
|
) {
|
||||||
|
@ -1566,7 +1564,7 @@ impl<'a> Resolver<'a> {
|
||||||
} else if res == Res::Err {
|
} else if res == Res::Err {
|
||||||
return PathResult::NonModule(PartialRes::new(Res::Err));
|
return PathResult::NonModule(PartialRes::new(Res::Err));
|
||||||
} else if opt_ns.is_some() && (is_last || maybe_assoc) {
|
} else if opt_ns.is_some() && (is_last || maybe_assoc) {
|
||||||
self.lint_if_path_starts_with_module(finalize_full, path, second_binding);
|
self.lint_if_path_starts_with_module(finalize, path, second_binding);
|
||||||
return PathResult::NonModule(PartialRes::with_unresolved_segments(
|
return PathResult::NonModule(PartialRes::with_unresolved_segments(
|
||||||
res,
|
res,
|
||||||
path.len() - i - 1,
|
path.len() - i - 1,
|
||||||
|
@ -1609,7 +1607,7 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.lint_if_path_starts_with_module(finalize_full, path, second_binding);
|
self.lint_if_path_starts_with_module(finalize, path, second_binding);
|
||||||
|
|
||||||
PathResult::Module(match module {
|
PathResult::Module(match module {
|
||||||
Some(module) => module,
|
Some(module) => module,
|
||||||
|
|
|
@ -717,7 +717,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
||||||
ident,
|
ident,
|
||||||
ns,
|
ns,
|
||||||
&import.parent_scope,
|
&import.parent_scope,
|
||||||
Some(import.span),
|
finalize,
|
||||||
true,
|
true,
|
||||||
target_bindings[ns].get(),
|
target_bindings[ns].get(),
|
||||||
);
|
);
|
||||||
|
@ -778,7 +778,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
||||||
ident,
|
ident,
|
||||||
ns,
|
ns,
|
||||||
&import.parent_scope,
|
&import.parent_scope,
|
||||||
Some(import.span),
|
finalize,
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
|
@ -708,7 +708,7 @@ impl<'a> Resolver<'a> {
|
||||||
ident,
|
ident,
|
||||||
ScopeSet::Macro(kind),
|
ScopeSet::Macro(kind),
|
||||||
&parent_scope,
|
&parent_scope,
|
||||||
Some(ident.span),
|
Some(Finalize::new(ast::CRATE_NODE_ID, ident.span)),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
|
@ -751,7 +751,7 @@ impl<'a> Resolver<'a> {
|
||||||
ident,
|
ident,
|
||||||
ScopeSet::Macro(MacroKind::Attr),
|
ScopeSet::Macro(MacroKind::Attr),
|
||||||
&parent_scope,
|
&parent_scope,
|
||||||
Some(ident.span),
|
Some(Finalize::new(ast::CRATE_NODE_ID, ident.span)),
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue