let def = self.tables.qpath_def(qpath, pat.hir_id);
let adt_def = match ty.sty {
ty::TyAdt(adt_def, _) => adt_def,
- _ => span_bug!(pat.span, "tuple struct pattern not applied to an ADT"),
+ ty::TyError => { // Avoid ICE (#50585)
+ return Pattern {
+ span: pat.span,
+ ty,
+ kind: Box::new(PatternKind::Wild),
+ };
+ }
+ _ => span_bug!(pat.span,
+ "tuple struct pattern not applied to an ADT {:?}",
+ ty.sty),
};
let variant_def = adt_def.variant_of_def(def);
let substs = match ty.sty {
ty::TyAdt(_, substs) |
ty::TyFnDef(_, substs) => substs,
+ ty::TyError => { // Avoid ICE (#50585)
+ return PatternKind::Wild;
+ }
_ => bug!("inappropriate type for def: {:?}", ty.sty),
};
PatternKind::Variant {
--- /dev/null
+// Copyright 2018 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() {
+ |y: Vec<[(); for x in 0..2 {}]>| {};
+ //~^ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/issue-50585.rs:12:18
+ |
+LL | fn main() {
+ | - expected `()` because of default return type
+LL | |y: Vec<[(); for x in 0..2 {}]>| {};
+ | ^^^^^^^^^^^^^^^^ expected usize, found ()
+ |
+ = note: expected type `usize`
+ found type `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.