Skip to content

Commit cde0f94

Browse files
committed
librustc_resolve: make sure pattern def gets recorded if resolve_path returns Err(true)
In 1a374b8, (pr #33046) fixed the error reporting of a specific case, but the change that was introduced did not make sure that `record_def` was called in all cases, which lead to an ICE in [1]. This change restores the original `else` case, but keeps the changes that were committed in 1a374b8. This commit fixes issue #33293. [1] `rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_`
1 parent 8f3e8c7 commit cde0f94

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/librustc_resolve/lib.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -2422,13 +2422,16 @@ impl<'a> Resolver<'a> {
24222422
}
24232423
}
24242424
}
2425-
} else if let Err(false) = self.resolve_path(pat_id, &path, 0, ValueNS) {
2426-
resolve_error(
2427-
self,
2428-
path.span,
2429-
ResolutionError::UnresolvedEnumVariantStructOrConst(
2430-
&path.segments.last().unwrap().identifier.name.as_str())
2431-
);
2425+
} else {
2426+
if let Err(false) = self.resolve_path(pat_id, &path, 0, ValueNS) {
2427+
// No error has been reported, so we need to do this ourselves.
2428+
resolve_error(
2429+
self,
2430+
path.span,
2431+
ResolutionError::UnresolvedEnumVariantStructOrConst(
2432+
&path.segments.last().unwrap().identifier.name.as_str())
2433+
);
2434+
}
24322435
self.record_def(pattern.id, err_path_resolution());
24332436
}
24342437
visit::walk_path(self, path);

0 commit comments

Comments
 (0)