Rollup merge of #151376 - chenyukang:yukang-fix-perf, r=lqd

Fix performance issue in liveness checking

r? @ghost

from https://github.com/rust-lang/rust/pull/150955#issuecomment-3769274223
This commit is contained in:
Jonathan Brouwer 2026-01-30 13:20:23 +01:00 committed by GitHub
commit a4b553804b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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(