-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
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-completeWorking towards the "valid code works" goalWorking towards the "valid code works" 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
The following should pass borrowck:
trait Trait {
type Item<'a>: 'a;
}
fn assert_static<T: 'static>(_: T) {}
fn test_args<I: Trait>() {
let closure = |a, _b| assert_static(a);
//~^ ERROR the associated type may not live long enough
closure(None::<I::Item::<'_>>, &None::<I::Item::<'_>>);
}
fn test_upvars<I: Trait>() {
let upvars = (None::<I::Item::<'_>>, &None::<I::Item::<'_>>);
let _closure = || {
let (a, _b) = upvars;
assert_static(a);
//~^ ERROR the associated type may not live long enough
};
}
When promoting the type-test I::Item::<'_>: 'static
from the closure to the parent function, we fail to do so because we can't express '_
in terms of universal regions because the corresponding free region doesn't have an external_name
?:
self.definitions[upper_bound].external_name.unwrap_or(r) |
@rustbot label C-bug T-types A-NLL NLL-complete 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-completeWorking towards the "valid code works" goalWorking towards the "valid code works" 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.