You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Destructuring boxes into multiple mutable references seems broken #30104
More keywords: match, if let.
(no, they don't work either)
Two workarounds are to either a) use *&mut *x or b) bring std::ops::DerefMut in and use *x.deref_mut():
use std::ops::DerefMut;
fn main() {
let mut x = Box::new((1, 2));
{ let (ref mut a, ref mut b) = *&mut *x; }
{ let (ref mut a, ref mut b) = *x.deref_mut(); }
}
I don't fully understand it, but that RFC sounds like it was intended to make Boxmore like other types. This issue is pointing out a discrepancy between Box and other types.
e.g., compare the code from the original issue with
Activity
jethrogb commentedon Feb 16, 2016
#![feature(box_patterns)]
box pattern
There. Now other people can find this bug.
aidanhs commentedon Jun 2, 2016
More keywords: match, if let.
(no, they don't work either)
Two workarounds are to either a) use
*&mut *xor b) bringstd::ops::DerefMutin and use*x.deref_mut():jonhoo commentedon Oct 31, 2017
Is this a dupe of #16223?
Mark-Simulacrum commentedon Oct 31, 2017
I don't think so, but am uncertain. Might have the same underlying cause, though -- hard to tell.
arielb1 commentedon Oct 31, 2017
This is as defined by RFC rust-lang/rfcs#130
jethrogb commentedon Oct 31, 2017
I don't fully understand it, but that RFC sounds like it was intended to make
Boxmore like other types. This issue is pointing out a discrepancy betweenBoxand other types.e.g., compare the code from the original issue with
(compiles)
This sounds to me like
Boxis still getting special treatment and the RFC has not been fully implemented yet, therefore this issue should remain open.arielb1 commentedon Nov 1, 2017
@jethrogb
So the RFC was just poorly-defined. I think the solution to mutating in
matchshould be able to be extended to handle this.shepmaster commentedon May 8, 2018
3 of these 4 cases fail with Rust 1.25.0. The good news is that with NLL, all 4 work! 🎉
Add regression test for issue rust-lang#30104
Rollup merge of rust-lang#53349 - memoryruins:nll-tests, r=nikomatsakis
Auto merge of #53449 - frewsxcv:rollup, r=frewsxcv
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=<try>
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix