Open
Description
Both of these closures should fail borrowck: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e9855ecda2f9427454cebce7738e598d
struct MyTy<T: Trait>(T);
trait Trait {}
impl Trait for &'static str {}
fn wf<T>(_: T) {}
fn test() {
let _: for<'x> fn(MyTy<&'x str>) = |_| {}; // PASS!
// but it should fail for the same reason this fails:
let _: for<'x> fn(MyTy<&'x str>) = |x| wf(x); // FAIL
}
I think we should simply do WF-checking of closure input/output types in the closure environment, but doing so would cause accidental breakages due to #104477. So #104477 should be resolved first.
@rustbot label A-NLL NLL-sound C-bug T-types A-borrow-checker