-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix End-user description not implemented for field access on `TyClosure #45938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
vramana
commented
Nov 11, 2017
•
edited
Loading
edited
- Add Tests
I think we are not quite ready for a PR here. I think we will want to edit the caller of |
What is the issue number again? |
ah #45698 |
src/librustc_mir/borrow_check.rs
Outdated
@@ -1235,6 +1237,18 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> | |||
("", format!(""), None), // (dont emit downcast info) | |||
ProjectionElem::Field(field, _ty) => { | |||
autoderef = true; | |||
match proj.base { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use self.mir.lvalue_ty(proj.base).to_ty(tcx)
src/librustc_mir/borrow_check.rs
Outdated
} | ||
}, | ||
_ => () | ||
}; | ||
("", format!(".{}", self.describe_field(&proj.base, field.index())), None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like it would print .local
. I think it's probably a better idea to ditch the prefix/middle/suffix scheme and just push things from the match arms.
badbd1e
to
c9533cb
Compare
So r=me with one of the tests (e.g. src/compile-fail/borrowck/borrowck-multiple-captures.rs) adjusted to also test MIR borrowck (see e.g. src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast-trait.rs to how this is done). |
@arielb1 Sure |
☔ The latest upstream changes (presumably #45436) made this pull request unmergeable. Please resolve the merge conflicts. |
3b92d6b
to
e2825ac
Compare
c831fbb
to
a0cd79f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a nested test and convert to use the helper I suggested?
src/librustc_mir/borrow_check.rs
Outdated
let local_def = self.tcx.with_freevars(node_id, |fv| fv[field_index].def); | ||
|
||
match local_def { | ||
Def::Local(local_node_id) => self.tcx.hir.name(local_node_id).to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that the code in ppaux
does self.tcx.hir.name(local_def.var_id())
-- maybe we should do that. I think in particular this could be a Def::Upvar
for nested closures. Maybe try this example:
// Field from upvar
{
let mut x = 0;
|| { || {
let y = &mut x;
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
//[mir]~^ ERROR cannot borrow `**x` as mutable more than once at a time (Ast)
//[mir]~| ERROR cannot borrow `(**x)` as mutable more than once at a time (Mir)
*y = 1;
} };
}
a0cd79f
to
f0f016b
Compare
f0f016b
to
5144d32
Compare
I just realized that the
This might be a nicer thing to use than |
📌 Commit 5144d32 has been approved by |
@bors p=1 I'll like to land this today so I can have some sense of scale of the MIR borrowck situation |
Fix End-user description not implemented for field access on `TyClosure - [x] Add Tests
☀️ Test successful - status-appveyor, status-travis |