-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.NLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.NLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.