Do not resolve labels across function boundary

Fix #19331.
nit: What about using `if-let` or just checking if `is_some` to reduce LOC?