From 63b7572d0df999ce6d2a9e62878b36e44a81df05 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 20 Feb 2019 01:14:18 +0000 Subject: [PATCH] Stub methods in infer Co-Authored-By: Gabriel Smith --- src/librustc/infer/canonical/mod.rs | 3 +++ src/librustc/infer/canonical/query_response.rs | 15 +++++++++++++++ src/librustc/infer/combine.rs | 2 +- src/librustc/infer/error_reporting/mod.rs | 16 +++++----------- src/librustc/infer/mod.rs | 13 ++++++++----- src/librustc/infer/nll_relate/mod.rs | 4 ++-- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index 613e153ae33d..0d067d1de856 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -443,6 +443,9 @@ impl<'tcx> CanonicalVarValues<'tcx> { UnpackedKind::Lifetime(..) => tcx.mk_region( ty::ReLateBound(ty::INNERMOST, ty::BoundRegion::BrAnon(i)) ).into(), + UnpackedKind::Const(..) => { + unimplemented!() // FIXME(const_generics) + } }) .collect() } diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs index aef0152b6ed7..008882fd5003 100644 --- a/src/librustc/infer/canonical/query_response.rs +++ b/src/librustc/infer/canonical/query_response.rs @@ -315,6 +315,10 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { obligations.extend(ok.into_obligations()); } + (UnpackedKind::Const(..), UnpackedKind::Const(..)) => { + unimplemented!() // FIXME(const_generics) + } + _ => { bug!( "kind mismatch, cannot unify {:?} and {:?}", @@ -473,6 +477,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { opt_values[br.assert_bound_var()] = Some(*original_value); } } + UnpackedKind::Const(..) => { + unimplemented!() // FIXME(const_generics) + } } } @@ -568,6 +575,11 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { ty::OutlivesPredicate(t1, r2) ) ), + UnpackedKind::Const(..) => { + // Consts cannot outlive one another, so we don't expect to + // ecounter this branch. + span_bug!(cause.span, "unexpected const outlives {:?}", constraint); + } } ) }) @@ -602,6 +614,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { obligations .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations()); } + (UnpackedKind::Const(..), UnpackedKind::Const(..)) => { + unimplemented!() // FIXME(const_generics) + } _ => { bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,); } diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index 6ef902a47dc8..885b439ef1ca 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -449,7 +449,7 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' let origin = *variables.var_origin(vid); let new_var_id = variables.new_var(self.for_universe, false, origin); - let u = self.tcx().mk_var(new_var_id); + let u = self.tcx().mk_ty_var(new_var_id); debug!("generalize: replacing original vid={:?} with new={:?}", vid, u); return Ok(u); diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 3dace2f2e89b..c7936534aad2 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -691,17 +691,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ) -> SubstsRef<'tcx> { let generics = self.tcx.generics_of(def_id); let mut num_supplied_defaults = 0; - let mut type_params = generics - .params - .iter() - .rev() - .filter_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime => None, - ty::GenericParamDefKind::Type { has_default, .. } => { - Some((param.def_id, has_default)) - } - }) - .peekable(); + let mut type_params = generics.params.iter().rev().filter_map(|param| match param.kind { + ty::GenericParamDefKind::Lifetime => None, + ty::GenericParamDefKind::Type { has_default, .. } => Some((param.def_id, has_default)), + ty::GenericParamDefKind::Const => None, // FIXME(const_generics:defaults) + }).peekable(); let has_default = { let has_default = type_params.peek().map(|(_, has_default)| has_default); *has_default.unwrap_or(&false) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 84ad742d3c97..cc1c439f3bd9 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -656,7 +656,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { type_variables .unsolved_variables() .into_iter() - .map(|t| self.tcx.mk_var(t)) + .map(|t| self.tcx.mk_ty_var(t)) .chain( (0..int_unification_table.len()) .map(|i| ty::IntVid { index: i as u32 }) @@ -981,7 +981,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } pub fn next_ty_var(&self, origin: TypeVariableOrigin) -> Ty<'tcx> { - self.tcx.mk_var(self.next_ty_var_id(false, origin)) + self.tcx.mk_ty_var(self.next_ty_var_id(false, origin)) } pub fn next_ty_var_in_universe( @@ -992,11 +992,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let vid = self.type_variables .borrow_mut() .new_var(universe, false, origin); - self.tcx.mk_var(vid) + self.tcx.mk_ty_var(vid) } pub fn next_diverging_ty_var(&self, origin: TypeVariableOrigin) -> Ty<'tcx> { - self.tcx.mk_var(self.next_ty_var_id(true, origin)) + self.tcx.mk_ty_var(self.next_ty_var_id(true, origin)) } pub fn next_int_var_id(&self) -> IntVid { @@ -1081,7 +1081,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { TypeVariableOrigin::TypeParameterDefinition(span, param.name), ); - self.tcx.mk_var(ty_var_id).into() + self.tcx.mk_ty_var(ty_var_id).into() + } + GenericParamDefKind::Const { .. } => { + unimplemented!() // FIXME(const_generics) } } } diff --git a/src/librustc/infer/nll_relate/mod.rs b/src/librustc/infer/nll_relate/mod.rs index f37e24b292e0..7140af36acbd 100644 --- a/src/librustc/infer/nll_relate/mod.rs +++ b/src/librustc/infer/nll_relate/mod.rs @@ -310,7 +310,7 @@ where ty::Projection(projection_ty) if D::normalization() == NormalizationStrategy::Lazy => { - return Ok(self.relate_projection_ty(projection_ty, self.infcx.tcx.mk_var(vid))); + return Ok(self.relate_projection_ty(projection_ty, self.infcx.tcx.mk_ty_var(vid))); } _ => (), @@ -764,7 +764,7 @@ where // the universe `_universe`. let new_var_id = variables.new_var(self.universe, false, origin); - let u = self.tcx().mk_var(new_var_id); + let u = self.tcx().mk_ty_var(new_var_id); debug!( "generalize: replacing original vid={:?} with new={:?}", vid,