store the segment name when resolution fails

This commit is contained in:
bohan 2024-01-13 21:05:41 +08:00
parent 284cb714d2
commit c288cb1f74
10 changed files with 58 additions and 51 deletions

View file

@ -213,7 +213,7 @@ enum ResolutionError<'a> {
SelfImportOnlyInImportListWithNonEmptyPrefix,
/// Error E0433: failed to resolve.
FailedToResolve {
last_segment: Option<Symbol>,
segment: Option<Symbol>,
label: String,
suggestion: Option<Suggestion>,
module: Option<ModuleOrUniformRoot<'a>>,
@ -396,12 +396,14 @@ enum PathResult<'a> {
suggestion: Option<Suggestion>,
is_error_from_last_segment: bool,
module: Option<ModuleOrUniformRoot<'a>>,
/// The segment name of target
segment_name: Symbol,
},
}
impl<'a> PathResult<'a> {
fn failed(
span: Span,
ident: Ident,
is_error_from_last_segment: bool,
finalize: bool,
module: Option<ModuleOrUniformRoot<'a>>,
@ -409,7 +411,14 @@ impl<'a> PathResult<'a> {
) -> PathResult<'a> {
let (label, suggestion) =
if finalize { label_and_suggestion() } else { (String::new(), None) };
PathResult::Failed { span, label, suggestion, is_error_from_last_segment, module }
PathResult::Failed {
span: ident.span,
segment_name: ident.name,
label,
suggestion,
is_error_from_last_segment,
module,
}
}
}