borrowck treatment of struct-tuple more liberal than struct with fields #10902
Labels
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Forked off of #10766
A question in #rust regarding a borrow checker error led me on the following exploration.
The four variants are labelled
one
,tup
,two_tuple
, andtwo_fields
one
is just repeating the test case from the description (of Should&'a Value as &'a Trait
work? #10766). Its a sanity check that the old error message and behavior still persists.two_fields
is closest to what achin described in his bug report. The problem that the borrow checker reports for that code is interesting, and it is replicated by the more minimal test case at the end of this comment.two_fields
that I made while trying to make as minimal a test case as possible.The interesting thing is that
two_tuple
(and likewisetup
) do not exhibit that error, even though they are completely analogous code. This is probably representative of a bug somewhere in the borrow checker since it really should be treating a struct-tuple here the same as a struct with named fields. (Plus, you know, these borrows look okay to me... but I have not yet dived in and tried to understand what the problem is that they are trying to flag.)The code:
This is a slightly reduced test from the original one above (that was originally a comment on #10766).
And here are the results:
The text was updated successfully, but these errors were encountered: