Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix by-value self with immediates. #6720

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use core::prelude::*;
use metadata::csearch;
use middle::astencode;
use middle::trans::base::{get_insn_ctxt};
use middle::trans::base::{impl_owned_self, impl_self, no_self};
use middle::trans::base::{impl_self, no_self};
use middle::trans::base::{trans_item, get_item_val, trans_fn};
use middle::trans::common::*;
use middle::ty;
Expand Down Expand Up @@ -109,7 +109,6 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id,
debug!("calling inline trans_fn with self_ty %s",
ty_to_str(ccx.tcx, self_ty));
match mth.explicit_self.node {
ast::sty_value => impl_owned_self(self_ty),
_ => impl_self(self_ty),
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/middle/trans/meth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ pub fn trans_method(ccx: @CrateContext,
base_self_ty.repr(ccx.tcx),
self_ty.repr(ccx.tcx));
match method.explicit_self.node {
ast::sty_value => {
impl_owned_self(self_ty)
}
_ => {
impl_self(self_ty)
}
Expand Down
11 changes: 3 additions & 8 deletions src/librustc/middle/typeck/check/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,9 @@ pub impl<'self> LookupContext<'self> {
let fty = ty::mk_bare_fn(tcx, ty::BareFnTy {sig: fn_sig, ..bare_fn_ty});
debug!("after replacing bound regions, fty=%s", self.ty_to_str(fty));

let self_mode = get_mode_from_explicit_self(candidate.method_ty.explicit_self);
// XXX: We always pass self by-ref since we stuff it in the environment slot.
// Eventually that should not be the case
let self_mode = ty::ByRef;

// before we only checked whether self_ty could be a subtype
// of rcvr_ty; now we actually make it so (this may cause
Expand Down Expand Up @@ -1302,10 +1304,3 @@ pub impl<'self> LookupContext<'self> {
self.tcx().sess.bug(s)
}
}

pub fn get_mode_from_explicit_self(explicit_self: ast::explicit_self_) -> SelfMode {
match explicit_self {
sty_value => ty::ByCopy,
_ => ty::ByRef,
}
}
Binary file removed src/test/run-pass/issue-3559
Binary file not shown.
Binary file removed src/test/run-pass/issue-3702
Binary file not shown.
Binary file removed src/test/run-pass/issue-4016
Binary file not shown.
Binary file removed src/test/run-pass/issue-4092
Binary file not shown.
25 changes: 25 additions & 0 deletions src/test/run-pass/issue-5321-immediates-with-bare-self.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

trait Fooable {
fn yes(self);
}

impl Fooable for uint {
fn yes(self) {
for self.times {
io::println("yes");
}
}
}

fn main() {
2.yes();
}