diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2017-08-07 15:06:10 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2017-08-11 12:11:38 +0200 |
| commit | e777189b4accdd7a92adf8554a368d399ff7f3ee (patch) | |
| tree | 1715374707f5b8186437caa223f104c60a930131 /src/librustc_const_eval | |
| parent | 7f2423eede51cc622420356988777db2473a0be2 (diff) | |
Use ItemLocalId as key for TypeckTables::pat_binding_modes.
Diffstat (limited to 'src/librustc_const_eval')
| -rw-r--r-- | src/librustc_const_eval/check_match.rs | 20 | ||||
| -rw-r--r-- | src/librustc_const_eval/pattern.rs | 2 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 0d92bff02b1..a990670f08b 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -269,7 +269,12 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { fn check_for_bindings_named_the_same_as_variants(cx: &MatchVisitor, pat: &Pat) { pat.walk(|p| { if let PatKind::Binding(_, _, name, None) = p.node { - let bm = *cx.tables.pat_binding_modes.get(&p.id).expect("missing binding mode"); + cx.tables.validate_hir_id(p.hir_id); + let bm = *cx.tables + .pat_binding_modes + .get(&p.hir_id.local_id) + .expect("missing binding mode"); + if bm != ty::BindByValue(hir::MutImmutable) { // Nothing to check. return true; @@ -458,7 +463,12 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor, let mut by_ref_span = None; for pat in pats { pat.each_binding(|_, id, span, _path| { - let bm = *cx.tables.pat_binding_modes.get(&id).expect("missing binding mode"); + let hir_id = cx.tcx.hir.node_to_hir_id(id); + cx.tables.validate_hir_id(hir_id); + let bm = *cx.tables + .pat_binding_modes + .get(&hir_id.local_id) + .expect("missing binding mode"); if let ty::BindByReference(..) = bm { by_ref_span = Some(span); } @@ -491,7 +501,11 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor, for pat in pats { pat.walk(|p| { if let PatKind::Binding(_, _, _, ref sub) = p.node { - let bm = *cx.tables.pat_binding_modes.get(&p.id).expect("missing binding mode"); + cx.tables.validate_hir_id(p.hir_id); + let bm = *cx.tables + .pat_binding_modes + .get(&p.hir_id.local_id) + .expect("missing binding mode"); match bm { ty::BindByValue(..) => { let pat_ty = cx.tables.node_id_to_type(p.hir_id); diff --git a/src/librustc_const_eval/pattern.rs b/src/librustc_const_eval/pattern.rs index bad9895420a..924193786c1 100644 --- a/src/librustc_const_eval/pattern.rs +++ b/src/librustc_const_eval/pattern.rs @@ -381,7 +381,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ty::TyRef(r, _) => Some(r), _ => None, }; - let bm = *self.tables.pat_binding_modes.get(&pat.id) + let bm = *self.tables.pat_binding_modes.get(&pat.hir_id.local_id) .expect("missing binding mode"); let (mutability, mode) = match bm { ty::BindByValue(hir::MutMutable) => |
