rustc: work around issue with default-method-simple, fix some rebase
errors
This commit is contained in:
parent
545d51c160
commit
70b9ad1748
4 changed files with 29 additions and 7 deletions
|
@ -1553,6 +1553,13 @@ pub fn type_is_ty_var(ty: t) -> bool {
|
||||||
|
|
||||||
pub fn type_is_bool(ty: t) -> bool { get(ty).sty == ty_bool }
|
pub fn type_is_bool(ty: t) -> bool { get(ty).sty == ty_bool }
|
||||||
|
|
||||||
|
pub fn type_is_self(ty: t) -> bool {
|
||||||
|
match get(ty).sty {
|
||||||
|
ty_self(*) => true,
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn type_is_structural(ty: t) -> bool {
|
pub fn type_is_structural(ty: t) -> bool {
|
||||||
match get(ty).sty {
|
match get(ty).sty {
|
||||||
ty_struct(*) | ty_tup(_) | ty_enum(*) | ty_closure(_) | ty_trait(*) |
|
ty_struct(*) | ty_tup(_) | ty_enum(*) | ty_closure(_) | ty_trait(*) |
|
||||||
|
|
|
@ -658,6 +658,12 @@ pub impl<'self> LookupContext<'self> {
|
||||||
|
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
return match ty::get(self_ty).sty {
|
return match ty::get(self_ty).sty {
|
||||||
|
ty::ty_rptr(_, self_mt) if default_method_hack(self_mt) => {
|
||||||
|
(self_ty,
|
||||||
|
ty::AutoDerefRef(ty::AutoDerefRef {
|
||||||
|
autoderefs: autoderefs,
|
||||||
|
autoref: None}))
|
||||||
|
}
|
||||||
ty::ty_rptr(_, self_mt) => {
|
ty::ty_rptr(_, self_mt) => {
|
||||||
let region = self.infcx().next_region_var_nb(self.expr.span);
|
let region = self.infcx().next_region_var_nb(self.expr.span);
|
||||||
(ty::mk_rptr(tcx, region, self_mt),
|
(ty::mk_rptr(tcx, region, self_mt),
|
||||||
|
@ -679,6 +685,16 @@ pub impl<'self> LookupContext<'self> {
|
||||||
autoref: None}))
|
autoref: None}))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn default_method_hack(self_mt: ty::mt) -> bool {
|
||||||
|
// FIXME(#6129). Default methods can't deal with autoref.
|
||||||
|
//
|
||||||
|
// I am a horrible monster and I pray for death. Currently
|
||||||
|
// the default method code fails when you try to reborrow
|
||||||
|
// because it is not handling types correctly. In lieu of
|
||||||
|
// fixing that, I am introducing this horrible hack. - ndm
|
||||||
|
self_mt.mutbl == m_imm && ty::type_is_self(self_mt.ty)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search_for_autosliced_method(
|
fn search_for_autosliced_method(
|
||||||
|
|
|
@ -2966,7 +2966,8 @@ pub fn check_block(fcx0: @mut FnCtxt, blk: &ast::blk) {
|
||||||
pub fn check_block_with_expected(fcx: @mut FnCtxt,
|
pub fn check_block_with_expected(fcx: @mut FnCtxt,
|
||||||
blk: &ast::blk,
|
blk: &ast::blk,
|
||||||
expected: Option<ty::t>) {
|
expected: Option<ty::t>) {
|
||||||
let prev = replace(&mut fcx.ps, fcx.ps.recurse(blk));
|
let purity_state = fcx.ps.recurse(blk);
|
||||||
|
let prev = replace(&mut fcx.ps, purity_state);
|
||||||
|
|
||||||
do fcx.with_region_lb(blk.node.id) {
|
do fcx.with_region_lb(blk.node.id) {
|
||||||
let mut warned = false;
|
let mut warned = false;
|
||||||
|
|
|
@ -457,20 +457,18 @@ fn constrain_call(rcx: @mut Rcx,
|
||||||
let callee_scope = call_expr.id;
|
let callee_scope = call_expr.id;
|
||||||
let callee_region = ty::re_scope(callee_scope);
|
let callee_region = ty::re_scope(callee_scope);
|
||||||
|
|
||||||
for fn_sig.inputs.eachi |i, input| {
|
for arg_exprs.each |&arg_expr| {
|
||||||
// ensure that any regions appearing in the argument type are
|
// ensure that any regions appearing in the argument type are
|
||||||
// valid for at least the lifetime of the function:
|
// valid for at least the lifetime of the function:
|
||||||
constrain_regions_in_type_of_node(
|
constrain_regions_in_type_of_node(
|
||||||
rcx, arg_exprs[i].id, callee_region, arg_exprs[i].span);
|
rcx, arg_expr.id, callee_region, arg_expr.span);
|
||||||
|
|
||||||
// unfortunately, there are two means of taking implicit
|
// unfortunately, there are two means of taking implicit
|
||||||
// references, and we need to propagate constraints as a
|
// references, and we need to propagate constraints as a
|
||||||
// result. modes are going away and the "DerefArgs" code
|
// result. modes are going away and the "DerefArgs" code
|
||||||
// should be ported to use adjustments
|
// should be ported to use adjustments
|
||||||
ty::set_default_mode(tcx, input.mode, ast::by_copy);
|
if implicitly_ref_args {
|
||||||
let is_by_ref = ty::resolved_mode(tcx, input.mode) == ast::by_ref;
|
guarantor::for_by_ref(rcx, arg_expr, callee_scope);
|
||||||
if implicitly_ref_args || is_by_ref {
|
|
||||||
guarantor::for_by_ref(rcx, arg_exprs[i], callee_scope);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue