You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A bounded Drop impl on a std generic (impl[K: Ord + Clone, V] Drop for BTreeMap[K, V]) is not taken as drop glue: locals are not dropped at scope end, an explicit drop() works #2571
impl[K: Ord + Clone, V] Drop for BTreeMap[K, V]:
move fn drop(): ...
A BTreeMap[i32, Tag] local (Tag counts its drops) at scope end ran no destructor (total 0); an explicit drop(map) ran it (total 10). Changing the impl to impl[K, V] Drop for BTreeMap[K, V] made the implicit drop run (1, 11).
A user-tier generic with a bounded Drop impl (impl[T: Clone] Drop for Holder[T]) runs its destructor at scope end (probe printed 1111 with four drops), so the miss is specific to the std tier or to a std generic: Sema.type_has_drop_impl resolves the owner through type_sym_is_shadowed/select_trait_impl_tiered or impl_lookup, and one of those paths does not see a bounded impl.
Expected
A bounded Drop impl is the type's destructor exactly as an unbounded one is; a type whose Drop impl is skipped silently leaks (§ leaks are defects). The workaround in std (an unbounded impl) stands until this is fixed; a check that refuses a bounded Drop impl that drop glue cannot see would at least be loud.
Closed by #2580 (c7fa606), D154: a Drop impl's bounds are the type's own. An impl demanding a bound the type's declaration does not is refused ("a destructor runs for every instantiation", §2.4), which closes the silent-leak class; an impl restating the type's bounds is its destructor and drop glue already runs it (behav_2571). std's BTreeMap impl stays unbounded because the type declares no bounds. err_2571 pins the refusal.
Activity
Phase 4: BTreeMap and BTreeSet over the M*LIB B+tree (D151); D152; D1…
Seven compiler fixes: literals at distinct demands (D153), element-pl…
ehartford commentedon Oct 23, 2026
Closed by #2580 (c7fa606), D154: a Drop impl's bounds are the type's own. An impl demanding a bound the type's declaration does not is refused ("a destructor runs for every instantiation", §2.4), which closes the silent-leak class; an impl restating the type's bounds is its destructor and drop glue already runs it (behav_2571). std's BTreeMap impl stays unbounded because the type declares no bounds. err_2571 pins the refusal.