Skip to content

Commit fcc3aa1

Browse files
committed
---
yaml --- r: 226167 b: refs/heads/snap-stage3 c: adfdbc4 h: refs/heads/master i: 226165: 6b6cc55 226163: b284e21 226159: 7561bd4 v: v3
1 parent cc56f40 commit fcc3aa1

39 files changed

+166
-1038
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: e5d90d98402475b6e154ce216f9efcb80da1a747
3-
refs/heads/snap-stage3: a5c12f4e39d32af3c951b66bd2839bc0b5a1125b
3+
refs/heads/snap-stage3: adfdbc4bd75f2581e9ad0151b26fb786b64475f8
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/src/doc/reference.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,8 +2368,6 @@ The currently implemented features of the reference compiler are:
23682368
internally without imposing on callers
23692369
(i.e. making them behave like function calls in
23702370
terms of encapsulation).
2371-
* - `default_type_parameter_fallback` - Allows type parameter defaults to
2372-
influence type inference.
23732371

23742372
If a feature is promoted to a language feature, then all existing programs will
23752373
start to receive compilation warnings about `#![feature]` directives which enabled

branches/snap-stage3/src/librustc/ast_map/mod.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ pub enum Node<'ast> {
119119
NodeStructCtor(&'ast StructDef),
120120

121121
NodeLifetime(&'ast Lifetime),
122-
NodeTyParam(&'ast TyParam)
123122
}
124123

125124
/// Represents an entry and its parent NodeID.
@@ -143,7 +142,6 @@ enum MapEntry<'ast> {
143142
EntryBlock(NodeId, &'ast Block),
144143
EntryStructCtor(NodeId, &'ast StructDef),
145144
EntryLifetime(NodeId, &'ast Lifetime),
146-
EntryTyParam(NodeId, &'ast TyParam),
147145

148146
/// Roots for node trees.
149147
RootCrate,
@@ -177,8 +175,7 @@ impl<'ast> MapEntry<'ast> {
177175
NodePat(n) => EntryPat(p, n),
178176
NodeBlock(n) => EntryBlock(p, n),
179177
NodeStructCtor(n) => EntryStructCtor(p, n),
180-
NodeLifetime(n) => EntryLifetime(p, n),
181-
NodeTyParam(n) => EntryTyParam(p, n),
178+
NodeLifetime(n) => EntryLifetime(p, n)
182179
}
183180
}
184181

@@ -197,7 +194,6 @@ impl<'ast> MapEntry<'ast> {
197194
EntryBlock(id, _) => id,
198195
EntryStructCtor(id, _) => id,
199196
EntryLifetime(id, _) => id,
200-
EntryTyParam(id, _) => id,
201197
_ => return None
202198
})
203199
}
@@ -217,7 +213,6 @@ impl<'ast> MapEntry<'ast> {
217213
EntryBlock(_, n) => NodeBlock(n),
218214
EntryStructCtor(_, n) => NodeStructCtor(n),
219215
EntryLifetime(_, n) => NodeLifetime(n),
220-
EntryTyParam(_, n) => NodeTyParam(n),
221216
_ => return None
222217
})
223218
}
@@ -578,7 +573,6 @@ impl<'ast> Map<'ast> {
578573
Some(NodePat(pat)) => pat.span,
579574
Some(NodeBlock(block)) => block.span,
580575
Some(NodeStructCtor(_)) => self.expect_item(self.get_parent(id)).span,
581-
Some(NodeTyParam(ty_param)) => ty_param.span,
582576
_ => return None,
583577
};
584578
Some(sp)
@@ -821,14 +815,6 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
821815
self.parent_node = parent_node;
822816
}
823817

824-
fn visit_generics(&mut self, generics: &'ast Generics) {
825-
for ty_param in generics.ty_params.iter() {
826-
self.insert(ty_param.id, NodeTyParam(ty_param));
827-
}
828-
829-
visit::walk_generics(self, generics);
830-
}
831-
832818
fn visit_trait_item(&mut self, ti: &'ast TraitItem) {
833819
let parent_node = self.parent_node;
834820
self.parent_node = ti.id;
@@ -1029,7 +1015,7 @@ impl<'a> NodePrinter for pprust::State<'a> {
10291015
NodePat(a) => self.print_pat(&*a),
10301016
NodeBlock(a) => self.print_block(&*a),
10311017
NodeLifetime(a) => self.print_lifetime(&*a),
1032-
NodeTyParam(_) => panic!("cannot print TyParam"),
1018+
10331019
// these cases do not carry enough information in the
10341020
// ast_map to reconstruct their full structure for pretty
10351021
// printing.
@@ -1137,9 +1123,6 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
11371123
format!("lifetime {}{}",
11381124
pprust::lifetime_to_string(&**l), id_str)
11391125
}
1140-
Some(NodeTyParam(ref ty_param)) => {
1141-
format!("typaram {:?}{}", ty_param, id_str)
1142-
}
11431126
None => {
11441127
format!("unknown node{}", id_str)
11451128
}

branches/snap-stage3/src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#![feature(slice_splits)]
5757
#![feature(slice_patterns)]
5858
#![feature(slice_position_elem)]
59-
#![feature(slice_concat_ext)]
6059
#![feature(staged_api)]
6160
#![feature(str_char)]
6261
#![feature(str_match_indices)]

branches/snap-stage3/src/librustc/metadata/tydecode.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,6 @@ fn parse_type_param_def_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
833833
assert_eq!(next(st), '|');
834834
let index = parse_u32(st);
835835
assert_eq!(next(st), '|');
836-
let default_def_id = parse_def_(st, NominalType, conv);
837836
let default = parse_opt(st, |st| parse_ty_(st, conv));
838837
let object_lifetime_default = parse_object_lifetime_default(st, conv);
839838

@@ -842,7 +841,6 @@ fn parse_type_param_def_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
842841
def_id: def_id,
843842
space: space,
844843
index: index,
845-
default_def_id: default_def_id,
846844
default: default,
847845
object_lifetime_default: object_lifetime_default,
848846
}

branches/snap-stage3/src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ pub fn enc_region_bounds<'a, 'tcx>(w: &mut Encoder,
409409

410410
pub fn enc_type_param_def<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
411411
v: &ty::TypeParameterDef<'tcx>) {
412-
mywrite!(w, "{}:{}|{}|{}|{}|",
412+
mywrite!(w, "{}:{}|{}|{}|",
413413
token::get_name(v.name), (cx.ds)(v.def_id),
414-
v.space.to_uint(), v.index, (cx.ds)(v.default_def_id));
414+
v.space.to_uint(), v.index);
415415
enc_opt(w, v.default, |w, t| enc_ty(w, cx, t));
416416
enc_object_lifetime_default(w, cx, v.object_lifetime_default);
417417
}

branches/snap-stage3/src/librustc/middle/check_match.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,16 +1016,10 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
10161016
fn check_local(cx: &mut MatchCheckCtxt, loc: &ast::Local) {
10171017
visit::walk_local(cx, loc);
10181018

1019-
let name = match loc.source {
1020-
ast::LocalLet => "local",
1021-
ast::LocalFor => "`for` loop"
1022-
};
1023-
10241019
let mut static_inliner = StaticInliner::new(cx.tcx, None);
10251020
is_refutable(cx, &*static_inliner.fold_pat(loc.pat.clone()), |pat| {
10261021
span_err!(cx.tcx.sess, loc.pat.span, E0005,
1027-
"refutable pattern in {} binding: `{}` not covered",
1028-
name, pat_to_string(pat)
1022+
"refutable pattern in local binding: `{}` not covered", pat_to_string(pat)
10291023
);
10301024
});
10311025

branches/snap-stage3/src/librustc/middle/infer/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
893893
self.report_inference_failure(vo.clone());
894894
}
895895
self.give_suggestion(same_regions);
896-
for &(ref trace, ref terr) in trace_origins {
897-
self.report_and_explain_type_error(trace.clone(), terr);
896+
for &(ref trace, terr) in trace_origins {
897+
self.report_and_explain_type_error(trace.clone(), &terr);
898898
}
899899
}
900900

branches/snap-stage3/src/librustc/middle/infer/mod.rs

Lines changed: 8 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -653,50 +653,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
653653
}
654654
}
655655

656-
/// Returns a type variable's default fallback if any exists. A default
657-
/// must be attached to the variable when created, if it is created
658-
/// without a default, this will return None.
659-
///
660-
/// This code does not apply to integral or floating point variables,
661-
/// only to use declared defaults.
662-
///
663-
/// See `new_ty_var_with_default` to create a type variable with a default.
664-
/// See `type_variable::Default` for details about what a default entails.
665-
pub fn default(&self, ty: Ty<'tcx>) -> Option<type_variable::Default<'tcx>> {
666-
match ty.sty {
667-
ty::TyInfer(ty::TyVar(vid)) => self.type_variables.borrow().default(vid),
668-
_ => None
669-
}
670-
}
671-
672-
pub fn unsolved_variables(&self) -> Vec<ty::Ty<'tcx>> {
673-
let mut variables = Vec::new();
674-
675-
let unbound_ty_vars = self.type_variables
676-
.borrow()
677-
.unsolved_variables()
678-
.into_iter()
679-
.map(|t| self.tcx.mk_var(t));
680-
681-
let unbound_int_vars = self.int_unification_table
682-
.borrow_mut()
683-
.unsolved_variables()
684-
.into_iter()
685-
.map(|v| self.tcx.mk_int_var(v));
686-
687-
let unbound_float_vars = self.float_unification_table
688-
.borrow_mut()
689-
.unsolved_variables()
690-
.into_iter()
691-
.map(|v| self.tcx.mk_float_var(v));
692-
693-
variables.extend(unbound_ty_vars);
694-
variables.extend(unbound_int_vars);
695-
variables.extend(unbound_float_vars);
696-
697-
return variables;
698-
}
699-
700656
fn combine_fields(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>)
701657
-> CombineFields<'a, 'tcx> {
702658
CombineFields {infcx: self,
@@ -1000,22 +956,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1000956
pub fn next_ty_var_id(&self, diverging: bool) -> TyVid {
1001957
self.type_variables
1002958
.borrow_mut()
1003-
.new_var(diverging, None)
959+
.new_var(diverging)
1004960
}
1005961

1006962
pub fn next_ty_var(&self) -> Ty<'tcx> {
1007963
self.tcx.mk_var(self.next_ty_var_id(false))
1008964
}
1009965

1010-
pub fn next_ty_var_with_default(&self,
1011-
default: Option<type_variable::Default<'tcx>>) -> Ty<'tcx> {
1012-
let ty_var_id = self.type_variables
1013-
.borrow_mut()
1014-
.new_var(false, default);
1015-
1016-
self.tcx.mk_var(ty_var_id)
1017-
}
1018-
1019966
pub fn next_diverging_ty_var(&self) -> Ty<'tcx> {
1020967
self.tcx.mk_var(self.next_ty_var_id(true))
1021968
}
@@ -1049,55 +996,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1049996
.collect()
1050997
}
1051998

1052-
// We have to take `&mut Substs` in order to provide the correct substitutions for defaults
1053-
// along the way, for this reason we don't return them.
1054-
pub fn type_vars_for_defs(&self,
1055-
span: Span,
1056-
space: subst::ParamSpace,
1057-
substs: &mut Substs<'tcx>,
1058-
defs: &[ty::TypeParameterDef<'tcx>]) {
1059-
1060-
let mut vars = Vec::with_capacity(defs.len());
1061-
1062-
for def in defs.iter() {
1063-
let default = def.default.map(|default| {
1064-
type_variable::Default {
1065-
ty: default.subst_spanned(self.tcx, substs, Some(span)),
1066-
origin_span: span,
1067-
def_id: def.default_def_id
1068-
}
1069-
});
1070-
1071-
let ty_var = self.next_ty_var_with_default(default);
1072-
substs.types.push(space, ty_var);
1073-
vars.push(ty_var)
1074-
}
1075-
}
1076-
1077999
/// Given a set of generics defined on a type or impl, returns a substitution mapping each
10781000
/// type/region parameter to a fresh inference variable.
10791001
pub fn fresh_substs_for_generics(&self,
10801002
span: Span,
10811003
generics: &ty::Generics<'tcx>)
10821004
-> subst::Substs<'tcx>
10831005
{
1084-
let type_params = subst::VecPerParamSpace::empty();
1085-
1006+
let type_params =
1007+
generics.types.map(
1008+
|_| self.next_ty_var());
10861009
let region_params =
10871010
generics.regions.map(
10881011
|d| self.next_region_var(EarlyBoundRegion(span, d.name)));
1089-
1090-
let mut substs = subst::Substs::new(type_params, region_params);
1091-
1092-
for space in subst::ParamSpace::all().iter() {
1093-
self.type_vars_for_defs(
1094-
span,
1095-
*space,
1096-
&mut substs,
1097-
generics.types.get_slice(*space));
1098-
}
1099-
1100-
return substs;
1012+
subst::Substs::new(type_params, region_params)
11011013
}
11021014

11031015
/// Given a set of generics defined on a trait, returns a substitution mapping each output
@@ -1115,17 +1027,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11151027
assert!(generics.regions.len(subst::SelfSpace) == 0);
11161028
assert!(generics.regions.len(subst::FnSpace) == 0);
11171029

1118-
let type_params = Vec::new();
1030+
let type_parameter_count = generics.types.len(subst::TypeSpace);
1031+
let type_parameters = self.next_ty_vars(type_parameter_count);
11191032

11201033
let region_param_defs = generics.regions.get_slice(subst::TypeSpace);
11211034
let regions = self.region_vars_for_defs(span, region_param_defs);
11221035

1123-
let mut substs = subst::Substs::new_trait(type_params, regions, self_ty);
1124-
1125-
let type_parameter_defs = generics.types.get_slice(subst::TypeSpace);
1126-
self.type_vars_for_defs(span, subst::TypeSpace, &mut substs, type_parameter_defs);
1127-
1128-
return substs;
1036+
subst::Substs::new_trait(type_parameters, regions, self_ty)
11291037
}
11301038

11311039
pub fn fresh_bound_region(&self, debruijn: ty::DebruijnIndex) -> ty::Region {
@@ -1360,25 +1268,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13601268
self.report_and_explain_type_error(trace, err);
13611269
}
13621270

1363-
pub fn report_conflicting_default_types(&self,
1364-
span: Span,
1365-
expected: type_variable::Default<'tcx>,
1366-
actual: type_variable::Default<'tcx>) {
1367-
let trace = TypeTrace {
1368-
origin: Misc(span),
1369-
values: Types(ty::ExpectedFound {
1370-
expected: expected.ty,
1371-
found: actual.ty
1372-
})
1373-
};
1374-
1375-
self.report_and_explain_type_error(trace,
1376-
&TypeError::TyParamDefaultMismatch(ty::ExpectedFound {
1377-
expected: expected,
1378-
found: actual
1379-
}));
1380-
}
1381-
13821271
pub fn replace_late_bound_regions_with_fresh_var<T>(
13831272
&self,
13841273
span: Span,

0 commit comments

Comments
 (0)