Borrow checker incorrectly accepts code when calling function with complex lifetime bounds through a fn pointer #57170
Labels
A-NLL
Area: Non-lexical lifetimes (NLL)
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
NLL-sound
Working towards the "invalid code does not compile" goal
P-high
High priority
regression-from-stable-to-stable
Performance or correctness regression from one stable version to another.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following code compiles and prints a bogus value:
Output (release mode):
(playground: https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=048d856b4689599b1e35f0a44ebe629f)
Expected result: a borrow checker error, the same as the one obtained when calling
shorten_lifetime
directly.I accidentally ran into this issue when trying to spell the fn pointer type of
fnptr
(I'm not sure how to add constraints to the lifetimes of a higher-ranked fn type likefor<'a, 'b> fn(...) -> T
)The text was updated successfully, but these errors were encountered: