Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMIR borrowck: print lvalues in error messages in the same way that the AST borrowck #44985
Conversation
rust-highfive
assigned
pnkfelix
Oct 2, 2017
This comment has been minimized.
This comment has been minimized.
|
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
I'd like some feedback on this PR. I can't think of any example that trigger the messages marked |
This comment has been minimized.
This comment has been minimized.
|
@zilbuz I'm about to hit the sack, but if you use the following input code, I think you should see some examples of some of the cases you are wondering about: #![feature(slice_patterns)]
fn main() {
#[derive(Debug)]
enum E<X> { A(X), B { x: X } }
#[derive(Debug)]
struct S<'a, X: 'a, Y>{ x: &'a [X], y: (Y, Y), };
let e = E::A(3);
match e {
E::A(ref ax) => println!("e.ax: {:?}", ax),
E::B { x: ref bx } => println!("e.bx: {:?}", bx),
}
let s = S { x: &[1, 2, 3,], y: (999, 998) };
match s {
S {
x: &[ref x0, ref xn..],
y: (ref y0, ref y1)
} => {
println!("s.x0: {:?} s.xn: {:?}", x0, xn);
println!("s.y0: {:?}, s.y1: {:?}", y0, y1);
}
_ => panic!("other case"),
}
} |
aidanhs
added
the
S-waiting-on-review
label
Oct 5, 2017
zilbuz
added some commits
Oct 2, 2017
zilbuz
force-pushed the
zilbuz:issue-44974
branch
from
148856c
to
e32e81c
Oct 6, 2017
zilbuz
changed the title
[WIP] MIR borrowck: print lvalues in error messages in the same way that the AST borrowck
MIR borrowck: print lvalues in error messages in the same way that the AST borrowck
Oct 6, 2017
This comment has been minimized.
This comment has been minimized.
pnkfelix
reviewed
Oct 9, 2017
| // Static and field from struct | ||
| unsafe { | ||
| let _x = sfoo.x(); | ||
| sfoo.x; //[mir]~ ERROR cannot use `sfoo.x` because it was mutably borrowed (Mir) |
This comment has been minimized.
This comment has been minimized.
pnkfelix
Oct 9, 2017
Member
oh interesting...
(I think this represents a bug in MIR-borrowck. But fixing that is orthogonal to this PR in any case.)
This comment has been minimized.
This comment has been minimized.
pnkfelix
Oct 9, 2017
Member
(likewise for all the other cases below that are paths based off of static variables)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
pnkfelix
referenced this pull request
Oct 9, 2017
Closed
MIR-borrowck: paths off of statics should not be borrow-checked #45129
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 10, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 12, 2017
This comment has been minimized.
This comment has been minimized.
|
|
zilbuz commentedOct 2, 2017
•
edited
Fix #44974
.namerather than.<num>[..]when borrowing inside a slice