Fix performance issue in liveness checking

This commit is contained in:
yukang 2026-01-20 01:07:54 +08:00
parent d940e56841
commit d2aa64fa2d

View file

@ -1086,11 +1086,6 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
let Some((name, decl_span)) = self.checked_places.names[index] else { continue };
// By convention, underscore-prefixed bindings are explicitly allowed to be unused.
if name.as_str().starts_with('_') {
continue;
}
let is_maybe_drop_guard = maybe_drop_guard(
tcx,
self.typing_env,
@ -1118,6 +1113,11 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
continue;
};
// By convention, underscore-prefixed bindings are allowed to be unused explicitly
if name.as_str().starts_with('_') {
break;
}
match kind {
AccessKind::Assign => {
let suggestion = annotate_mut_binding_to_immutable_binding(