Uh oh!
There was an error while loading. Please reload this page.
MIR borrowck: print lvalues in error messages in the same way that the AST borrowck - #44985
Conversation
rust-highfive
commented
Oct 2, 2017
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
zilbuz
commented
Oct 2, 2017
I'd like some feedback on this PR. I can't think of any example that trigger the messages marked |
pnkfelix
commented
Oct 2, 2017
@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)]fnmain(){#[derive(Debug)]enumE<X>{A(X),B{x:X}}#[derive(Debug)]structS<'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"),}} |
… AST borrowck - Print fields with `.name` rather than `.<num>` - Autoderef values if followed by a field or an index
…type that is neither Adt nor tuple
…reported lvalue for constant index Previously the constant index was reported as `[x of y]` or `[-x of y]` where `x` was the offset and `y` the minimum length of the slice. The minus sign wasn't in the right case since for `&[_, x, .., _, _]`, the error reported was `[-1 of 4]`, and for `&[_, _, .., x, _]`, the error reported was `[2 of 4]`. This commit fixes the sign so that the indexes 1 and -2 are reported, and remove the ` of y` part of the message to make it more succinct.
….]` to match the AST borrowck output
…variable hasn't a name
zilbuz
commented
Oct 6, 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) |
There was a problem hiding this comment.
oh interesting...
(I think this represents a bug in MIR-borrowck. But fixing that is orthogonal to this PR in any case.)
There was a problem hiding this comment.
(likewise for all the other cases below that are paths based off of static variables)
pnkfelix
commented
Oct 9, 2017
bors
commented
Oct 9, 2017
📌 Commit e32e81c has been approved by |
bors
commented
Oct 10, 2017
⌛ Testing commit e32e81c with merge fd85391dbaf891fda53943b00e97cd609d3186c2... |
bors
commented
Oct 10, 2017
💔 Test failed - status-travis |
kennytm
commented
Oct 11, 2017
@bors retry
|
bors
commented
Oct 12, 2017
MIR borrowck: print lvalues in error messages in the same way that the AST borrowck Fix#44974 - Print fields with `.name` rather than `.<num>` - Autoderef values if followed by a field or an index - Output `[..]` when borrowing inside a slice
bors
commented
Oct 12, 2017
☀️ Test successful - status-appveyor, status-travis |
Fix#44974
.namerather than.<num>[..]when borrowing inside a slice