Skip to content

Commit 5c69168

Browse files
committed
kill custom type inference defaults (these don't really work anyway)
1 parent c5eb255 commit 5c69168

File tree

6 files changed

+17
-32
lines changed

6 files changed

+17
-32
lines changed

src/librustc/infer/mod.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use middle::free_region::{FreeRegionMap, RegionRelations};
2323
use middle::region;
2424
use middle::lang_items;
2525
use mir::tcx::LvalueTy;
26-
use ty::subst::{Kind, Subst, Substs};
26+
use ty::subst::{Substs};
2727
use ty::{TyVid, IntVid, FloatVid};
2828
use ty::{self, Ty, TyCtxt};
2929
use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
@@ -1003,26 +1003,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10031003
/// as the substitutions for the default, `(T, U)`.
10041004
pub fn type_var_for_def(&self,
10051005
span: Span,
1006-
def: &ty::TypeParameterDef,
1007-
substs: &[Kind<'tcx>])
1006+
def: &ty::TypeParameterDef)
10081007
-> Ty<'tcx> {
1009-
let default = if def.has_default {
1010-
let default = self.tcx.type_of(def.def_id);
1011-
Some(type_variable::Default {
1012-
ty: default.subst_spanned(self.tcx, substs, Some(span)),
1013-
origin_span: span,
1014-
def_id: def.def_id
1015-
})
1016-
} else {
1017-
None
1018-
};
1019-
1020-
10211008
let ty_var_id = self.type_variables
10221009
.borrow_mut()
10231010
.new_var(false,
10241011
TypeVariableOrigin::TypeParameterDefinition(span, def.name),
1025-
default);
1012+
None);
10261013

10271014
self.tcx.mk_var(ty_var_id)
10281015
}
@@ -1035,8 +1022,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10351022
-> &'tcx Substs<'tcx> {
10361023
Substs::for_item(self.tcx, def_id, |def, _| {
10371024
self.region_var_for_def(span, def)
1038-
}, |def, substs| {
1039-
self.type_var_for_def(span, def, substs)
1025+
}, |def, _| {
1026+
self.type_var_for_def(span, def)
10401027
})
10411028
}
10421029

src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use hir::def::Def;
1919
use hir::def_id::DefId;
2020
use middle::resolve_lifetime as rl;
2121
use namespace::Namespace;
22-
use rustc::ty::subst::{Kind, Subst, Substs};
22+
use rustc::ty::subst::{Subst, Substs};
2323
use rustc::traits;
2424
use rustc::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable};
2525
use rustc::ty::wf::object_region_bounds;
@@ -51,7 +51,6 @@ pub trait AstConv<'gcx, 'tcx> {
5151
/// Same as ty_infer, but with a known type parameter definition.
5252
fn ty_infer_for_def(&self,
5353
_def: &ty::TypeParameterDef,
54-
_substs: &[Kind<'tcx>],
5554
span: Span) -> Ty<'tcx> {
5655
self.ty_infer(span)
5756
}
@@ -250,7 +249,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
250249
} else if infer_types {
251250
// No type parameters were provided, we can infer all.
252251
let ty_var = if !default_needs_object_self(def) {
253-
self.ty_infer_for_def(def, substs, span)
252+
self.ty_infer_for_def(def, span)
254253
} else {
255254
self.ty_infer(span)
256255
};

src/librustc_typeck/check/method/confirm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
305305
} else {
306306
self.region_var_for_def(self.span, def)
307307
}
308-
}, |def, cur_substs| {
308+
}, |def, _cur_substs| {
309309
let i = def.index as usize;
310310
if i < parent_substs.len() {
311311
parent_substs.type_at(i)
@@ -316,7 +316,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
316316
{
317317
self.to_ty(ast_ty)
318318
} else {
319-
self.type_var_for_def(self.span, def, cur_substs)
319+
self.type_var_for_def(self.span, def)
320320
}
321321
})
322322
}

src/librustc_typeck/check/method/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
249249
let substs = Substs::for_item(self.tcx,
250250
trait_def_id,
251251
|def, _| self.region_var_for_def(span, def),
252-
|def, substs| {
252+
|def, _substs| {
253253
if def.index == 0 {
254254
self_ty
255255
} else if let Some(ref input_types) = opt_input_types {
256256
input_types[def.index as usize - 1]
257257
} else {
258-
self.type_var_for_def(span, def, substs)
258+
self.type_var_for_def(span, def)
259259
}
260260
});
261261

src/librustc_typeck/check/method/probe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,12 +1265,12 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
12651265
// `impl_self_ty()` for an explanation.
12661266
self.tcx.types.re_erased
12671267
}
1268-
}, |def, cur_substs| {
1268+
}, |def, _cur_substs| {
12691269
let i = def.index as usize;
12701270
if i < substs.len() {
12711271
substs.type_at(i)
12721272
} else {
1273-
self.type_var_for_def(self.span, def, cur_substs)
1273+
self.type_var_for_def(self.span, def)
12741274
}
12751275
});
12761276
xform_fn_sig.subst(self.tcx, substs)

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use namespace::Namespace;
9292
use rustc::infer::{self, InferCtxt, InferOk, RegionVariableOrigin};
9393
use rustc::infer::type_variable::{TypeVariableOrigin};
9494
use rustc::middle::region;
95-
use rustc::ty::subst::{Kind, Subst, Substs};
95+
use rustc::ty::subst::{Subst, Substs};
9696
use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode};
9797
use rustc::ty::{ParamTy, LvaluePreference, NoPreference, PreferMutLvalue};
9898
use rustc::ty::{self, Ty, TyCtxt, Visibility};
@@ -1652,9 +1652,8 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> {
16521652

16531653
fn ty_infer_for_def(&self,
16541654
ty_param_def: &ty::TypeParameterDef,
1655-
substs: &[Kind<'tcx>],
16561655
span: Span) -> Ty<'tcx> {
1657-
self.type_var_for_def(span, ty_param_def, substs)
1656+
self.type_var_for_def(span, ty_param_def)
16581657
}
16591658

16601659
fn projected_ty_from_poly_trait_ref(&self,
@@ -4747,7 +4746,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47474746
// Handle Self first, so we can adjust the index to match the AST.
47484747
if has_self && i == 0 {
47494748
return opt_self_ty.unwrap_or_else(|| {
4750-
self.type_var_for_def(span, def, substs)
4749+
self.type_var_for_def(span, def)
47514750
});
47524751
}
47534752
i -= has_self as usize;
@@ -4780,7 +4779,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47804779
// This can also be reached in some error cases:
47814780
// We prefer to use inference variables instead of
47824781
// TyError to let type inference recover somewhat.
4783-
self.type_var_for_def(span, def, substs)
4782+
self.type_var_for_def(span, def)
47844783
}
47854784
});
47864785

0 commit comments

Comments
 (0)