|
11 | 11 | //! This pass type-checks the MIR to ensure it is not broken.
|
12 | 12 | #![allow(unreachable_code)]
|
13 | 13 |
|
14 |
| -use rustc::hir::def_id::DefId; |
15 |
| -use rustc::hir::map::DefPathData; |
16 | 14 | use rustc::infer::{InferCtxt, InferOk, InferResult, LateBoundRegionConversionTime, UnitResult};
|
17 | 15 | use rustc::infer::region_constraints::RegionConstraintData;
|
18 | 16 | use rustc::traits::{self, FulfillmentContext};
|
@@ -43,9 +41,8 @@ pub fn type_check<'a, 'gcx, 'tcx>(
|
43 | 41 | body_id: ast::NodeId,
|
44 | 42 | param_env: ty::ParamEnv<'gcx>,
|
45 | 43 | mir: &Mir<'tcx>,
|
46 |
| - mir_def_id: DefId, |
47 | 44 | ) -> MirTypeckRegionConstraints<'tcx> {
|
48 |
| - let mut checker = TypeChecker::new(infcx, body_id, param_env, mir_def_id); |
| 45 | + let mut checker = TypeChecker::new(infcx, body_id, param_env); |
49 | 46 | let errors_reported = {
|
50 | 47 | let mut verifier = TypeVerifier::new(&mut checker, mir);
|
51 | 48 | verifier.visit_mir(mir);
|
@@ -411,11 +408,6 @@ pub struct TypeChecker<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
|
411 | 408 | body_id: ast::NodeId,
|
412 | 409 | reported_errors: FxHashSet<(Ty<'tcx>, Span)>,
|
413 | 410 | constraints: MirTypeckRegionConstraints<'tcx>,
|
414 |
| - |
415 |
| - // FIXME(#45940) - True if this is a MIR shim or ADT constructor |
416 |
| - // (e.g., for a tuple struct.) In that case, the internal types of |
417 |
| - // operands and things require normalization. |
418 |
| - is_adt_constructor: bool, |
419 | 411 | }
|
420 | 412 |
|
421 | 413 | /// A collection of region constraints that must be satisfied for the
|
@@ -467,22 +459,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
467 | 459 | infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
468 | 460 | body_id: ast::NodeId,
|
469 | 461 | param_env: ty::ParamEnv<'gcx>,
|
470 |
| - mir_def_id: DefId, |
471 | 462 | ) -> Self {
|
472 |
| - let def_key = infcx.tcx.def_key(mir_def_id); |
473 |
| - let is_adt_constructor = match def_key.disambiguated_data.data { |
474 |
| - DefPathData::StructCtor => true, |
475 |
| - _ => false, |
476 |
| - }; |
477 |
| - |
478 | 463 | TypeChecker {
|
479 | 464 | infcx,
|
480 | 465 | last_span: DUMMY_SP,
|
481 | 466 | body_id,
|
482 | 467 | param_env,
|
483 | 468 | reported_errors: FxHashSet(),
|
484 | 469 | constraints: MirTypeckRegionConstraints::default(),
|
485 |
| - is_adt_constructor, |
486 | 470 | }
|
487 | 471 | }
|
488 | 472 |
|
@@ -1099,17 +1083,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
1099 | 1083 | continue;
|
1100 | 1084 | }
|
1101 | 1085 | };
|
1102 |
| - let op_ty = match op { |
1103 |
| - Operand::Consume(lv) => { |
1104 |
| - let lv_ty = lv.ty(mir, tcx).to_ty(tcx); |
1105 |
| - if self.is_adt_constructor { |
1106 |
| - self.normalize(&lv_ty, location) |
1107 |
| - } else { |
1108 |
| - lv_ty |
1109 |
| - } |
1110 |
| - } |
1111 |
| - Operand::Constant(c) => c.ty, |
1112 |
| - }; |
| 1086 | + let op_ty = op.ty(mir, tcx); |
1113 | 1087 | if let Err(terr) = self.sub_types(
|
1114 | 1088 | op_ty,
|
1115 | 1089 | field_ty,
|
@@ -1198,7 +1172,7 @@ impl MirPass for TypeckMir {
|
1198 | 1172 | }
|
1199 | 1173 | let param_env = tcx.param_env(def_id);
|
1200 | 1174 | tcx.infer_ctxt().enter(|infcx| {
|
1201 |
| - let _region_constraint_sets = type_check(&infcx, id, param_env, mir, def_id); |
| 1175 | + let _region_constraint_sets = type_check(&infcx, id, param_env, mir); |
1202 | 1176 |
|
1203 | 1177 | // For verification purposes, we just ignore the resulting
|
1204 | 1178 | // region constraint sets. Not our problem. =)
|
|
0 commit comments