Skip to content

Commit e186acc

Browse files
committed
Fix rebase conflicts
1 parent 919975d commit e186acc

File tree

5 files changed

+48
-102
lines changed

5 files changed

+48
-102
lines changed

src/librustc_typeck/check/closure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
4848
match expected_sig_and_kind {
4949
None => { // doesn't look like an unboxed closure
5050
let region = astconv::opt_ast_region_to_region(fcx,
51-
fcx.infcx(),
51+
fcx,
5252
expr.span,
5353
&None);
5454

@@ -117,7 +117,7 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
117117
abi::RustCall,
118118
expected_sig);
119119

120-
let region = match fcx.infcx().anon_regions(expr.span, 1) {
120+
let region = match fcx.anon_regions(expr.span, 1) {
121121
Err(_) => {
122122
fcx.ccx.tcx.sess.span_bug(expr.span,
123123
"can't make anon regions here?!")

src/librustc_typeck/check/mod.rs

Lines changed: 36 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19331933
}
19341934

19351935
pub fn to_ty(&self, ast_t: &ast::Ty) -> Ty<'tcx> {
1936-
let t = ast_ty_to_ty(self, self.infcx(), ast_t);
1936+
let t = ast_ty_to_ty(self, self, ast_t);
19371937

19381938
let mut bounds_checker = wf::BoundsChecker::new(self,
19391939
ast_t.span,
@@ -2123,18 +2123,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21232123
}
21242124
}
21252125

2126-
//impl<'a, 'tcx> RegionScope for infer::InferCtxt<'a, 'tcx> {
2127-
// fn default_region_bound(&self, span: Span) -> Option<ty::Region> {
2128-
// Some(self.next_region_var(infer::MiscVariable(span)))
2129-
// }
2130-
//
2131-
// fn anon_regions(&self, span: Span, count: uint)
2132-
// -> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> {
2133-
// Ok(Vec::from_fn(count, |_| {
2134-
// self.next_region_var(infer::MiscVariable(span))
2135-
// }))
2136-
// }
2137-
//}
2126+
impl<'a, 'tcx> RegionScope for FnCtxt<'a, 'tcx> {
2127+
fn default_region_bound(&self, span: Span) -> Option<ty::Region> {
2128+
Some(self.infcx().next_region_var(infer::MiscVariable(span)))
2129+
}
2130+
2131+
fn anon_regions(&self, span: Span, count: uint)
2132+
-> Result<Vec<ty::Region>, Option<Vec<(String, uint)>>> {
2133+
Ok(Vec::from_fn(count, |_| {
2134+
self.infcx().next_region_var(infer::MiscVariable(span))
2135+
}))
2136+
}
2137+
}
21382138

21392139
#[deriving(Copy, Show, PartialEq, Eq)]
21402140
pub enum LvaluePreference {
@@ -2347,58 +2347,6 @@ fn autoderef_for_index<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
23472347
}
23482348
}
23492349

2350-
/// Autoderefs `base_expr`, looking for a `Slice` impl. If it finds one, installs the relevant
2351-
/// method info and returns the result type (else None).
2352-
fn try_overloaded_slice<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2353-
method_call: MethodCall,
2354-
expr: &ast::Expr,
2355-
base_expr: &ast::Expr,
2356-
base_ty: Ty<'tcx>,
2357-
start_expr: &Option<P<ast::Expr>>,
2358-
end_expr: &Option<P<ast::Expr>>,
2359-
mutbl: ast::Mutability)
2360-
-> Option<Ty<'tcx>> // return type is result of slice
2361-
{
2362-
let lvalue_pref = match mutbl {
2363-
ast::MutMutable => PreferMutLvalue,
2364-
ast::MutImmutable => NoPreference
2365-
};
2366-
2367-
let opt_method_ty =
2368-
autoderef_for_index(fcx, base_expr, base_ty, lvalue_pref, |adjusted_ty, autoderefref| {
2369-
try_overloaded_slice_step(fcx, method_call, expr, base_expr,
2370-
adjusted_ty, autoderefref, mutbl,
2371-
start_expr, end_expr)
2372-
});
2373-
2374-
// Regardless of whether the lookup succeeds, check the method arguments
2375-
// so that we have *some* type for each argument.
2376-
let method_ty_or_err = opt_method_ty.unwrap_or(fcx.tcx().types.err);
2377-
2378-
let mut args = vec![];
2379-
start_expr.as_ref().map(|x| args.push(x));
2380-
end_expr.as_ref().map(|x| args.push(x));
2381-
2382-
check_method_argument_types(fcx,
2383-
expr.span,
2384-
method_ty_or_err,
2385-
expr,
2386-
args.as_slice(),
2387-
AutorefArgs::Yes,
2388-
DontTupleArguments);
2389-
2390-
opt_method_ty.map(|method_ty| {
2391-
let result_ty = ty::ty_fn_ret(method_ty);
2392-
match result_ty {
2393-
ty::FnConverging(result_ty) => result_ty,
2394-
ty::FnDiverging => {
2395-
fcx.tcx().sess.span_bug(expr.span,
2396-
"slice trait does not define a `!` return")
2397-
}
2398-
}
2399-
})
2400-
}
2401-
24022350
/// Checks for a `Slice` (or `SliceMut`) impl at the relevant level of autoderef. If it finds one,
24032351
/// installs method info and returns type of method (else None).
24042352
fn try_overloaded_slice_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
@@ -4327,7 +4275,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
43274275
let actual_structure_type = fcx.expr_ty(&*expr);
43284276
if !ty::type_is_error(actual_structure_type) {
43294277
let type_and_substs = astconv::ast_path_to_ty_relaxed(fcx,
4330-
fcx.infcx(),
4278+
fcx,
43314279
struct_id,
43324280
path);
43334281
match fcx.mk_subty(false,
@@ -4410,8 +4358,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
44104358
},
44114359
base_t,
44124360
None);
4413-
fcx.write_ty(idx.id, ty::mk_err());
4414-
fcx.write_ty(id, ty::mk_err())
4361+
fcx.write_ty(idx.id, fcx.tcx().types.err);
4362+
fcx.write_ty(id, fcx.tcx().types.err);
44154363
}
44164364
}
44174365
}
@@ -4440,7 +4388,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
44404388
fcx.write_ty(id, element_ty);
44414389
}
44424390
_ => {
4443-
check_expr_has_type(fcx, &**idx, ty::mk_err());
4391+
check_expr_has_type(fcx, &**idx, fcx.tcx().types.err);
44444392
fcx.type_error_message(
44454393
expr.span,
44464394
|actual| {
@@ -4449,7 +4397,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
44494397
},
44504398
base_t,
44514399
None);
4452-
fcx.write_ty(id, ty::mk_err())
4400+
fcx.write_ty(id, fcx.tcx().types.err);
44534401
}
44544402
}
44554403
}
@@ -4468,19 +4416,21 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
44684416
});
44694417

44704418
let idx_type = match (t_start, t_end) {
4471-
(Some(ty), None) | (None, Some(ty)) => Some(ty),
4472-
(Some(t_start), Some(t_end))
4473-
if ty::type_is_error(t_start) || ty::type_is_error(t_end) => {
4474-
Some(ty::mk_err())
4475-
}
4476-
(Some(t_start), Some(t_end)) => {
4477-
Some(infer::common_supertype(fcx.infcx(),
4478-
infer::RangeExpression(expr.span),
4479-
true,
4480-
t_start,
4481-
t_end))
4482-
}
4483-
_ => None
4419+
(Some(ty), None) | (None, Some(ty)) => {
4420+
Some(ty)
4421+
}
4422+
(Some(t_start), Some(t_end)) if (ty::type_is_error(t_start) ||
4423+
ty::type_is_error(t_end)) => {
4424+
Some(fcx.tcx().types.err)
4425+
}
4426+
(Some(t_start), Some(t_end)) => {
4427+
Some(infer::common_supertype(fcx.infcx(),
4428+
infer::RangeExpression(expr.span),
4429+
true,
4430+
t_start,
4431+
t_end))
4432+
}
4433+
_ => None
44844434
};
44854435

44864436
// Note that we don't check the type of start/end satisfy any
@@ -4489,7 +4439,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
44894439

44904440
let range_type = match idx_type {
44914441
Some(idx_type) if ty::type_is_error(idx_type) => {
4492-
ty::mk_err()
4442+
fcx.tcx().types.err
44934443
}
44944444
Some(idx_type) => {
44954445
// Find the did from the appropriate lang item.
@@ -4515,7 +4465,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
45154465
ty::mk_struct(tcx, did, tcx.mk_substs(substs))
45164466
} else {
45174467
tcx.sess.span_err(expr.span, "No lang item for range syntax");
4518-
ty::mk_err()
4468+
fcx.tcx().types.err
45194469
}
45204470
}
45214471
None => {
@@ -4525,7 +4475,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
45254475
ty::mk_struct(tcx, did, tcx.mk_substs(substs))
45264476
} else {
45274477
tcx.sess.span_err(expr.span, "No lang item for range syntax");
4528-
ty::mk_err()
4478+
fcx.tcx().types.err
45294479
}
45304480
}
45314481
};

src/librustc_typeck/collect.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,6 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
10981098
let bounds = compute_bounds(ccx,
10991099
assoc_ty,
11001100
assoc_type_def.bounds.as_slice(),
1101-
&assoc_type_def.unbound,
11021101
assoc_type_def.span);
11031102

11041103
ty::predicates(ccx.tcx, assoc_ty, &bounds).into_iter()

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
14741474

14751475
ty::ty_projection(ref data) => {
14761476
let trait_ref = match data.trait_ref.clean(cx) {
1477-
TyParamBound::TraitBound(t) => t.trait_,
1477+
TyParamBound::TraitBound(t, _) => t.trait_,
14781478
TyParamBound::RegionBound(_) => panic!("cleaning a trait got a region??"),
14791479
};
14801480
Type::QPath {

src/test/run-pass/trait-static-method-generic-inference.rs renamed to src/test/compile-fail/trait-static-method-generic-inference.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Issue #3902. We are (at least currently) unable to infer `Self`
12+
// based on `T`, even though there is only a single impl, because of
13+
// the possibility of associated types and other things (basically: no
14+
// constraints on `Self` here at all).
15+
1116
mod base {
1217
pub trait HasNew<T> {
1318
fn new() -> T;
@@ -22,19 +27,11 @@ mod base {
2227
Foo { dummy: () }
2328
}
2429
}
25-
26-
pub struct Bar {
27-
dummy: (),
28-
}
29-
30-
impl HasNew<Bar> for Bar {
31-
fn new() -> Bar {
32-
Bar { dummy: () }
33-
}
34-
}
3530
}
3631

37-
pub fn main() {
32+
pub fn foo() {
3833
let _f: base::Foo = base::HasNew::new();
39-
let _b: base::Bar = base::HasNew::new();
34+
//~^ ERROR type annotations required
4035
}
36+
37+
fn main() { }

0 commit comments

Comments
 (0)