Contrived type-outlives code does not compile #73808
Labels
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following code (based on #67911 (comment)):
produces the following error message as of
rustc 1.46.0-nightly (ff5b446d2 2020-06-23)
:with
-Z borrowck=mir
:However, this should actually be able to compile. If we infer
y
to the equivalent of&('a + 'b) i32
, then(&('a + 'b) i32, &('a + 'b) i32) <: (&'a i32, &'b i32)
We have that
T: 'a
andT: 'b
from the generic parameterT: 'a + 'b
, so we should be able to determine thatT
lives long enough.However, the current
TypeTest
code (if I understand it correctly) attempts to prove that a type lives long enough by applying each of the lifetime bounds individually (e.g. splittingT: 'a + 'b
intoT: 'a
andT: 'b
). However, neitherT: 'a
norT: 'a
alone is sufficient to prove thatT: 'a + 'b
, so this check fails.I suspect that this will never actually matter in practice, so the additional complexity needed to make this code compile might not be worth it. However, I didn't see an open issue for this, so I opened this issue for future reference.
The text was updated successfully, but these errors were encountered: