Skip to content

Commit 047a8d0

Browse files
nikomatsakissgrif
authored andcommitted
kill custom type inference defaults (these don't really work anyway)
1 parent 7112d65 commit 047a8d0

File tree

6 files changed

+16
-31
lines changed

6 files changed

+16
-31
lines changed

src/librustc/infer/mod.rs

+5-18
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use middle::free_region::RegionRelations;
2222
use middle::region;
2323
use middle::lang_items;
2424
use mir::tcx::PlaceTy;
25-
use ty::subst::{Kind, Subst, Substs};
25+
use ty::subst::Substs;
2626
use ty::{TyVid, IntVid, FloatVid};
2727
use ty::{self, Ty, TyCtxt};
2828
use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
@@ -1093,26 +1093,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10931093
/// as the substitutions for the default, `(T, U)`.
10941094
pub fn type_var_for_def(&self,
10951095
span: Span,
1096-
def: &ty::TypeParameterDef,
1097-
substs: &[Kind<'tcx>])
1096+
def: &ty::TypeParameterDef)
10981097
-> Ty<'tcx> {
1099-
let default = if def.has_default {
1100-
let default = self.tcx.type_of(def.def_id);
1101-
Some(type_variable::Default {
1102-
ty: default.subst_spanned(self.tcx, substs, Some(span)),
1103-
origin_span: span,
1104-
def_id: def.def_id
1105-
})
1106-
} else {
1107-
None
1108-
};
1109-
1110-
11111098
let ty_var_id = self.type_variables
11121099
.borrow_mut()
11131100
.new_var(false,
11141101
TypeVariableOrigin::TypeParameterDefinition(span, def.name),
1115-
default);
1102+
None);
11161103

11171104
self.tcx.mk_var(ty_var_id)
11181105
}
@@ -1125,8 +1112,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11251112
-> &'tcx Substs<'tcx> {
11261113
Substs::for_item(self.tcx, def_id, |def, _| {
11271114
self.region_var_for_def(span, def)
1128-
}, |def, substs| {
1129-
self.type_var_for_def(span, def, substs)
1115+
}, |def, _| {
1116+
self.type_var_for_def(span, def)
11301117
})
11311118
}
11321119

src/librustc_typeck/astconv.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -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
}
@@ -261,7 +260,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
261260
} else if infer_types {
262261
// No type parameters were provided, we can infer all.
263262
let ty_var = if !default_needs_object_self(def) {
264-
self.ty_infer_for_def(def, substs, span)
263+
self.ty_infer_for_def(def, span)
265264
} else {
266265
self.ty_infer(span)
267266
};

src/librustc_typeck/check/method/confirm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
325325
} else {
326326
self.region_var_for_def(self.span, def)
327327
}
328-
}, |def, cur_substs| {
328+
}, |def, _cur_substs| {
329329
let i = def.index as usize;
330330
if i < parent_substs.len() {
331331
parent_substs.type_at(i)
@@ -336,7 +336,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
336336
{
337337
self.to_ty(ast_ty)
338338
} else {
339-
self.type_var_for_def(self.span, def, cur_substs)
339+
self.type_var_for_def(self.span, def)
340340
}
341341
})
342342
}

src/librustc_typeck/check/method/mod.rs

+2-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1304,12 +1304,12 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
13041304
// `impl_self_ty()` for an explanation.
13051305
self.tcx.types.re_erased
13061306
}
1307-
}, |def, cur_substs| {
1307+
}, |def, _cur_substs| {
13081308
let i = def.index as usize;
13091309
if i < substs.len() {
13101310
substs.type_at(i)
13111311
} else {
1312-
self.type_var_for_def(self.span, def, cur_substs)
1312+
self.type_var_for_def(self.span, def)
13131313
}
13141314
});
13151315
xform_fn_sig.subst(self.tcx, substs)

src/librustc_typeck/check/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ use rustc::infer::{self, InferCtxt, InferOk, RegionVariableOrigin};
9393
use rustc::infer::anon_types::AnonTypeDecl;
9494
use rustc::infer::type_variable::{TypeVariableOrigin};
9595
use rustc::middle::region;
96-
use rustc::ty::subst::{Kind, Subst, Substs};
96+
use rustc::ty::subst::{Subst, Substs};
9797
use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode};
9898
use rustc::ty::{self, Ty, TyCtxt, Visibility, ToPredicate};
9999
use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
@@ -1692,9 +1692,8 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> {
16921692

16931693
fn ty_infer_for_def(&self,
16941694
ty_param_def: &ty::TypeParameterDef,
1695-
substs: &[Kind<'tcx>],
16961695
span: Span) -> Ty<'tcx> {
1697-
self.type_var_for_def(span, ty_param_def, substs)
1696+
self.type_var_for_def(span, ty_param_def)
16981697
}
16991698

17001699
fn projected_ty_from_poly_trait_ref(&self,
@@ -4793,7 +4792,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47934792
// Handle Self first, so we can adjust the index to match the AST.
47944793
if has_self && i == 0 {
47954794
return opt_self_ty.unwrap_or_else(|| {
4796-
self.type_var_for_def(span, def, substs)
4795+
self.type_var_for_def(span, def)
47974796
});
47984797
}
47994798
i -= has_self as usize;
@@ -4826,7 +4825,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
48264825
// This can also be reached in some error cases:
48274826
// We prefer to use inference variables instead of
48284827
// TyError to let type inference recover somewhat.
4829-
self.type_var_for_def(span, def, substs)
4828+
self.type_var_for_def(span, def)
48304829
}
48314830
});
48324831

0 commit comments

Comments
 (0)