Self::call constrains lifetime covariance and/or inference unexpectedly under NLL #62185
Labels
A-NLL
Area: Non-lexical lifetimes (NLL)
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Spawned off of #60914, namely the regression of the version-compare crate
Look at this (play):
we get an NLL migration error for it.
Self::compare_iter
is important on line 9; if you replace that withVersion::compare_iter
, then NLL will accept the input.)'a
's in the formal parameters tofn compare_iter
, but that is perhaps less surprising.))Why? I'm not sure; at first I thought it made sense, since I assumed that the call to
Self::compare_iter
would force the two arguments to have the same lifetime'a
that is also attached to theself
parameter.But after reflecting on the matter further, I do not understand why we would not have a reborrow here that would allow the call to
compare_iter
to use a shorter lifetime that both inputs can satisfy.std::slice::Iter<T>
not covariant with respect toT
? I guess I'll need to check that.)Anyway, this is either a soundness fix of AST borrow-check (which would be great news), or it is an NLL-complete bug for MIR borrow-check.
I just didn't want it to get lost in the shuffle of a blog post I am currently working on.
The text was updated successfully, but these errors were encountered: