// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use check::{FnCtxt, Expectation, Diverges, Needs};
+use check::coercion::CoerceMany;
use rustc::hir::{self, PatKind};
use rustc::hir::def::{Def, CtorKind};
use rustc::hir::pat_util::EnumerateAndAdjustIterator;
use rustc::infer::type_variable::TypeVariableOrigin;
use rustc::traits::ObligationCauseCode;
use rustc::ty::{self, Ty, TypeFoldable};
-use check::{FnCtxt, Expectation, Diverges, Needs};
-use check::coercion::CoerceMany;
-use util::nodemap::FxHashMap;
-
-use std::collections::hash_map::Entry::{Occupied, Vacant};
-use std::cmp;
use syntax::ast;
use syntax::source_map::Spanned;
use syntax::ptr::P;
use syntax::util::lev_distance::find_best_match_for_name;
use syntax_pos::Span;
+use util::nodemap::FxHashMap;
+
+use std::collections::hash_map::Entry::{Occupied, Vacant};
+use std::cmp;
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// The `is_arg` argument indicates whether this pattern is the
// the "discriminant type" (issue #23116).
//
// arielb1 [writes here in this comment thread][c] that there
- // is certainly *some* potential danger, e.g. for an example
+ // is certainly *some* potential danger, e.g., for an example
// like:
//
// [c]: https://github.com/rust-lang/rust/pull/43399#discussion_r130223956
return self.tcx.types.err;
};
- // Type check the path.
+ // Type-check the path.
self.demand_eqtype(pat.span, expected, pat_ty);
- // Type check subpatterns.
+ // Type-check subpatterns.
if self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm) {
pat_ty
} else {
_ => bug!("unexpected pattern definition: {:?}", def)
}
- // Type check the path.
+ // Type-check the path.
let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id).0;
self.demand_suptype(pat.span, expected, pat_ty);
pat_ty
return self.tcx.types.err;
}
- // Type check the path.
+ // Type-check the path.
let (pat_ty, def) = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id);
if !pat_ty.is_fn() {
report_unexpected_def(def);
self.demand_eqtype(pat.span, expected, pat_ty);
- // Type check subpatterns.
+ // Type-check subpatterns.
if subpats.len() == variant.fields.len() ||
subpats.len() < variant.fields.len() && ddpos.is_some() {
let substs = match pat_ty.sty {