Skip to content

Commit e442262

Browse files
jroeschJared Roesch
authored andcommitted
---
yaml --- r: 235831 b: refs/heads/stable c: bbdca2c h: refs/heads/master i: 235829: 8681bc6 235827: a860abe 235823: f32498a v: v3
1 parent 3bee68e commit e442262

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 91de8e6c281fafd257e52def26551b2b722aaddb
32+
refs/heads/stable: bbdca2c8aded0497c289536ee5ead694ca2d8fc0
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/librustc_typeck/astconv.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub trait AstConv<'tcx> {
111111
}
112112

113113
/// What type should we use when a type is omitted?
114-
fn ty_infer(&self, span: Span) -> Ty<'tcx>;
114+
fn ty_infer(&self, default: Option<Ty<'tcx>>, span: Span) -> Ty<'tcx>;
115115

116116
/// Projecting an associated type from a (potentially)
117117
/// higher-ranked trait reference is more complicated, because of
@@ -403,7 +403,7 @@ fn create_substs_for_ast_path<'tcx>(
403403
// they were optional (e.g. paths inside expressions).
404404
let mut type_substs = if param_mode == PathParamMode::Optional &&
405405
types_provided.is_empty() {
406-
(0..formal_ty_param_count).map(|_| this.ty_infer(span)).collect()
406+
ty_param_defs.iter().map(|p| this.ty_infer(p.default, span)).collect()
407407
} else {
408408
types_provided
409409
};
@@ -1661,7 +1661,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
16611661
// values in a ExprClosure, or as
16621662
// the type of local variables. Both of these cases are
16631663
// handled specially and will not descend into this routine.
1664-
this.ty_infer(ast_ty.span)
1664+
this.ty_infer(None, ast_ty.span)
16651665
}
16661666
};
16671667

@@ -1677,7 +1677,7 @@ pub fn ty_of_arg<'tcx>(this: &AstConv<'tcx>,
16771677
{
16781678
match a.ty.node {
16791679
ast::TyInfer if expected_ty.is_some() => expected_ty.unwrap(),
1680-
ast::TyInfer => this.ty_infer(a.ty.span),
1680+
ast::TyInfer => this.ty_infer(None, a.ty.span),
16811681
_ => ast_ty_to_ty(this, rscope, &*a.ty),
16821682
}
16831683
}
@@ -1796,7 +1796,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
17961796

17971797
let output_ty = match decl.output {
17981798
ast::Return(ref output) if output.node == ast::TyInfer =>
1799-
ty::FnConverging(this.ty_infer(output.span)),
1799+
ty::FnConverging(this.ty_infer(None, output.span)),
18001800
ast::Return(ref output) =>
18011801
ty::FnConverging(convert_ty_with_lifetime_elision(this,
18021802
implied_output_region,
@@ -1936,7 +1936,7 @@ pub fn ty_of_closure<'tcx>(
19361936
_ if is_infer && expected_ret_ty.is_some() =>
19371937
expected_ret_ty.unwrap(),
19381938
_ if is_infer =>
1939-
ty::FnConverging(this.ty_infer(decl.output.span())),
1939+
ty::FnConverging(this.ty_infer(None, decl.output.span())),
19401940
ast::Return(ref output) =>
19411941
ty::FnConverging(ast_ty_to_ty(this, &rb, &**output)),
19421942
ast::DefaultReturn(..) => unreachable!(),

branches/stable/src/librustc_typeck/check/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,8 +1138,13 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
11381138
trait_def.associated_type_names.contains(&assoc_name)
11391139
}
11401140

1141-
fn ty_infer(&self, _span: Span) -> Ty<'tcx> {
1142-
self.infcx().next_ty_var()
1141+
fn ty_infer(&self, default: Option<Ty<'tcx>>, _span: Span) -> Ty<'tcx> {
1142+
let ty_var = self.infcx().next_ty_var();
1143+
match default {
1144+
Some(default) => { self.infcx().defaults.borrow_mut().insert(ty_var, default); }
1145+
None => {}
1146+
}
1147+
ty_var
11431148
}
11441149

11451150
fn projected_ty_from_poly_trait_ref(&self,

branches/stable/src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl<'a, 'tcx> AstConv<'tcx> for ItemCtxt<'a, 'tcx> {
404404
}
405405
}
406406

407-
fn ty_infer(&self, span: Span) -> Ty<'tcx> {
407+
fn ty_infer(&self, _default: Option<Ty<'tcx>>, span: Span) -> Ty<'tcx> {
408408
span_err!(self.tcx().sess, span, E0121,
409409
"the type placeholder `_` is not allowed within types on item signatures");
410410
self.tcx().types.err

0 commit comments

Comments
 (0)