diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-06-18 02:49:44 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-06-18 03:15:07 +0300 |
| commit | 8c0fef80d712fccb890aebf62c4054cda9a796cb (patch) | |
| tree | 43028360214599a134b4879e8949905af9cbd798 /src | |
| parent | 1f9423a87aadacf1dc8f52e3df56f61a7415d4d7 (diff) | |
| download | rust-8c0fef80d712fccb890aebf62c4054cda9a796cb.tar.gz rust-8c0fef80d712fccb890aebf62c4054cda9a796cb.zip | |
Fix ICE in memory categorization of tuple patterns
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/mem_categorization.rs | 8 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-34334.rs | 15 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index d513af10b36..a345e94ebda 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -1145,8 +1145,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } } Some(Def::Struct(..)) => { - let expected_len = match self.pat_ty(&pat) { - Ok(&ty::TyS{sty: ty::TyStruct(adt_def, _), ..}) => { + let expected_len = match self.pat_ty(&pat)?.sty { + ty::TyStruct(adt_def, _) => { adt_def.struct_variant().fields.len() } ref ty => { @@ -1196,8 +1196,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { PatKind::Tuple(ref subpats, ddpos) => { // (p1, ..., pN) - let expected_len = match self.pat_ty(&pat) { - Ok(&ty::TyS{sty: ty::TyTuple(ref tys), ..}) => tys.len(), + let expected_len = match self.pat_ty(&pat)?.sty { + ty::TyTuple(ref tys) => tys.len(), ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty), }; for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) { diff --git a/src/test/compile-fail/issue-34334.rs b/src/test/compile-fail/issue-34334.rs new file mode 100644 index 00000000000..ffcd052369d --- /dev/null +++ b/src/test/compile-fail/issue-34334.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main () { + let sr: Vec<(u32, _, _) = vec![]; //~ ERROR expected one of `+`, `,`, or `>`, found `=` + let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); + //~^ ERROR unresolved name `sr` +} |
