1
Fork 0

rustc: work around issue with default-method-simple, fix some rebase

errors
This commit is contained in:
Niko Matsakis 2013-04-30 14:09:14 -04:00
parent 545d51c160
commit 70b9ad1748
4 changed files with 29 additions and 7 deletions

View file

@ -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_self(ty: t) -> bool {
match get(ty).sty {
ty_self(*) => true,
_ => false
}
}
pub fn type_is_structural(ty: t) -> bool {
match get(ty).sty {
ty_struct(*) | ty_tup(_) | ty_enum(*) | ty_closure(_) | ty_trait(*) |

View file

@ -658,6 +658,12 @@ pub impl<'self> LookupContext<'self> {
let tcx = self.tcx();
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) => {
let region = self.infcx().next_region_var_nb(self.expr.span);
(ty::mk_rptr(tcx, region, self_mt),
@ -679,6 +685,16 @@ pub impl<'self> LookupContext<'self> {
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(

View file

@ -2966,7 +2966,8 @@ pub fn check_block(fcx0: @mut FnCtxt, blk: &ast::blk) {
pub fn check_block_with_expected(fcx: @mut FnCtxt,
blk: &ast::blk,
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) {
let mut warned = false;

View file

@ -457,20 +457,18 @@ fn constrain_call(rcx: @mut Rcx,
let callee_scope = call_expr.id;
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
// valid for at least the lifetime of the function:
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
// references, and we need to propagate constraints as a
// result. modes are going away and the "DerefArgs" code
// should be ported to use adjustments
ty::set_default_mode(tcx, input.mode, ast::by_copy);
let is_by_ref = ty::resolved_mode(tcx, input.mode) == ast::by_ref;
if implicitly_ref_args || is_by_ref {
guarantor::for_by_ref(rcx, arg_exprs[i], callee_scope);
if implicitly_ref_args {
guarantor::for_by_ref(rcx, arg_expr, callee_scope);
}
}