Fix a bug with return in anonymous consts
This commit is contained in:
parent
b58b721921
commit
c6bbee802a
@ -257,13 +257,11 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
|
|||||||
fn visit_pat(&mut self, p: &'gcx hir::Pat) {
|
fn visit_pat(&mut self, p: &'gcx hir::Pat) {
|
||||||
match p.node {
|
match p.node {
|
||||||
hir::PatKind::Binding(..) => {
|
hir::PatKind::Binding(..) => {
|
||||||
let bm = *self.fcx
|
if let Some(&bm) = self.fcx.tables.borrow().pat_binding_modes().get(p.hir_id) {
|
||||||
.tables
|
self.tables.pat_binding_modes_mut().insert(p.hir_id, bm);
|
||||||
.borrow()
|
} else {
|
||||||
.pat_binding_modes()
|
self.tcx().sess.delay_span_bug(p.span, "missing binding mode");
|
||||||
.get(p.hir_id)
|
}
|
||||||
.expect("missing binding mode");
|
|
||||||
self.tables.pat_binding_modes_mut().insert(p.hir_id, bm);
|
|
||||||
}
|
}
|
||||||
hir::PatKind::Struct(_, ref fields, _) => {
|
hir::PatKind::Struct(_, ref fields, _) => {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
|
@ -17,3 +17,8 @@ fn foo() {
|
|||||||
[(); return || {}];
|
[(); return || {}];
|
||||||
//~^ ERROR return statement outside of function body
|
//~^ ERROR return statement outside of function body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn bar() {
|
||||||
|
[(); return |ice| {}];
|
||||||
|
//~^ ERROR return statement outside of function body
|
||||||
|
}
|
||||||
|
@ -10,6 +10,12 @@ error[E0572]: return statement outside of function body
|
|||||||
LL | [(); return || {}];
|
LL | [(); return || {}];
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error[E0572]: return statement outside of function body
|
||||||
|
--> $DIR/issue-51714.rs:22:10
|
||||||
|
|
|
||||||
|
LL | [(); return |ice| {}];
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0572`.
|
For more information about this error, try `rustc --explain E0572`.
|
||||||
|
Loading…
Reference in New Issue
Block a user