*a == *b
moves when dereferencing &Rc<RefCell<dyn Trait>>
#75231
Labels
C-bug
Category: This is a bug.
*a == *b
moves when dereferencing &Rc<RefCell<dyn Trait>>
#75231
This bug report comes from a question in the users forum:
https://users.rust-lang.org/t/attempting-to-contain-an-rc-refcell-sometrait-in-an-enum-field-with-clone/46913
They had a problem with
#[derive(PartialEq)]
on an enum where one variant containsRc<RefCell<dyn Trait>>
, and there is a manualPartialEq
for thatdyn Trait
. I looked at the macro expansion to see that it matchesref
patterns and then uses(*__self_0) == (*__arg_1_0)
, so I reduced the error to this code:I expected to see this happen: successful compilation
Instead, this happened: (playground)
Meta
The error is the same with all compilers currently on the playground,
1.45.2
,1.46.0-beta.2
, and1.47.0-nightly (2020-08-05 22ee68dc586440f96b76)
.Reduction
Changing to
a == b
works, but that's not helpful when we want the derived code to work.Reducing the parameters to
&RefCell<dyn Trait>
does build successfully.Reducing the parameters to
&dyn Trait
changes to a lifetime error:This one is solved by changing to
'static
as suggested, or by changing thePartialEq
to:... but that change does nothing for the original issue.
The text was updated successfully, but these errors were encountered: