resolve: Turn enum Finalize
into an optional struct
This commit is contained in:
parent
637b3f6807
commit
900607f49a
8 changed files with 59 additions and 92 deletions
|
@ -417,15 +417,12 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
crate fn lint_if_path_starts_with_module(
|
||||
&mut self,
|
||||
finalize: Finalize,
|
||||
finalize: Option<Finalize>,
|
||||
path: &[Segment],
|
||||
second_binding: Option<&NameBinding<'_>>,
|
||||
) {
|
||||
let (diag_id, diag_span) = match finalize {
|
||||
Finalize::No => return,
|
||||
Finalize::SimplePath(id, path_span) => (id, path_span),
|
||||
Finalize::UsePath { root_id, root_span, .. } => (root_id, root_span),
|
||||
Finalize::QPathTrait { qpath_id, qpath_span, .. } => (qpath_id, qpath_span),
|
||||
let Some(Finalize { node_id, root_span, .. }) = finalize else {
|
||||
return;
|
||||
};
|
||||
|
||||
let first_name = match path.get(0) {
|
||||
|
@ -463,11 +460,11 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let diag = BuiltinLintDiagnostics::AbsPathWithModule(diag_span);
|
||||
let diag = BuiltinLintDiagnostics::AbsPathWithModule(root_span);
|
||||
self.lint_buffer.buffer_lint_with_diagnostic(
|
||||
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
|
||||
diag_id,
|
||||
diag_span,
|
||||
node_id,
|
||||
root_span,
|
||||
"absolute paths must start with `self`, `super`, \
|
||||
`crate`, or an external crate name in the 2018 edition",
|
||||
diag,
|
||||
|
@ -1873,7 +1870,7 @@ impl<'a> Resolver<'a> {
|
|||
ident,
|
||||
ns_to_try,
|
||||
parent_scope,
|
||||
Finalize::No,
|
||||
None,
|
||||
&ribs[ns_to_try],
|
||||
unusable_binding,
|
||||
) {
|
||||
|
@ -1921,7 +1918,7 @@ impl<'a> Resolver<'a> {
|
|||
ident,
|
||||
ValueNS,
|
||||
parent_scope,
|
||||
Finalize::No,
|
||||
None,
|
||||
&ribs[ValueNS],
|
||||
unusable_binding,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue