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

Removing '&const' usage and cleaning up the ast #7342

Merged
merged 2 commits into from
Jun 29, 2013
Merged
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
4 changes: 2 additions & 2 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ impl<T:Freeze + Send> RWARC<T> {
// lock it. This wraps the unsafety, with the justification that the 'lock'
// field is never overwritten; only 'failed' and 'data'.
#[doc(hidden)]
fn borrow_rwlock<T:Freeze + Send>(state: *const RWARCInner<T>) -> *RWlock {
unsafe { cast::transmute(&const (*state).lock) }
fn borrow_rwlock<T:Freeze + Send>(state: *mut RWARCInner<T>) -> *RWlock {
unsafe { cast::transmute(&(*state).lock) }
}

/// The "write permission" token used for RWARC.write_downgrade().
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ impl cmp::Eq for BitvSet {
}

impl Container for BitvSet {
fn len(&const self) -> uint { self.size }
fn is_empty(&const self) -> bool { self.size == 0 }
fn len(&self) -> uint { self.size }
fn is_empty(&self) -> bool { self.size == 0 }
}

impl Mutable for BitvSet {
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ pub struct Deque<T> {

impl<T> Container for Deque<T> {
/// Return the number of elements in the deque
fn len(&const self) -> uint { self.nelts }
fn len(&self) -> uint { self.nelts }

/// Return true if the deque contains no elements
fn is_empty(&const self) -> bool { self.len() == 0 }
fn is_empty(&self) -> bool { self.len() == 0 }
}

impl<T> Mutable for Deque<T> {
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/flate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static lz_fast : c_int = 0x1; // LZ with only one probe
static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"

pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
do vec::as_const_buf(bytes) |b, len| {
pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
do vec::as_imm_buf(bytes) |b, len| {
unsafe {
let mut outsz : size_t = 0;
let res =
Expand All @@ -62,8 +62,8 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
}
}

pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
do vec::as_const_buf(bytes) |b, len| {
pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] {
do vec::as_imm_buf(bytes) |b, len| {
unsafe {
let mut outsz : size_t = 0;
let res =
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {

impl<K: TotalOrd, V> Container for TreeMap<K, V> {
/// Return the number of elements in the map
fn len(&const self) -> uint { self.length }
fn len(&self) -> uint { self.length }

/// Return true if the map contains no elements
fn is_empty(&const self) -> bool { self.root.is_none() }
fn is_empty(&self) -> bool { self.root.is_none() }
}

impl<K: TotalOrd, V> Mutable for TreeMap<K, V> {
Expand Down Expand Up @@ -265,11 +265,11 @@ impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
impl<T: TotalOrd> Container for TreeSet<T> {
/// Return the number of elements in the set
#[inline]
fn len(&const self) -> uint { self.map.len() }
fn len(&self) -> uint { self.map.len() }

/// Return true if the set contains no elements
#[inline]
fn is_empty(&const self) -> bool { self.map.is_empty() }
fn is_empty(&self) -> bool { self.map.is_empty() }
}

impl<T: TotalOrd> Mutable for TreeSet<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
's' => { return ast::sty_static; }
'v' => { return ast::sty_value; }
'@' => { return ast::sty_box(get_mutability(string[1])); }
'~' => { return ast::sty_uniq(get_mutability(string[1])); }
'~' => { return ast::sty_uniq; }
'&' => {
// FIXME(#4846) expl. region
return ast::sty_region(None, get_mutability(string[1]));
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,8 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explic
ebml_w.writer.write(&[ '@' as u8 ]);
encode_mutability(ebml_w, m);
}
sty_uniq(m) => {
sty_uniq => {
ebml_w.writer.write(&[ '~' as u8 ]);
encode_mutability(ebml_w, m);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn check_expr(sess: Session,
if is_const {
match e.node {
expr_unary(_, deref, _) => { }
expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) => {
expr_unary(_, box(_), _) | expr_unary(_, uniq, _) => {
sess.span_err(e.span,
"disallowed operator in constant expression");
return;
Expand Down
76 changes: 38 additions & 38 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,122 +152,122 @@ impl LanguageItems {

// FIXME #4621: Method macros sure would be nice here.

pub fn freeze_trait(&const self) -> def_id {
pub fn freeze_trait(&self) -> def_id {
self.items[FreezeTraitLangItem as uint].get()
}
pub fn copy_trait(&const self) -> def_id {
pub fn copy_trait(&self) -> def_id {
self.items[CopyTraitLangItem as uint].get()
}
pub fn send_trait(&const self) -> def_id {
pub fn send_trait(&self) -> def_id {
self.items[SendTraitLangItem as uint].get()
}
pub fn sized_trait(&const self) -> def_id {
pub fn sized_trait(&self) -> def_id {
self.items[SizedTraitLangItem as uint].get()
}

pub fn drop_trait(&const self) -> def_id {
pub fn drop_trait(&self) -> def_id {
self.items[DropTraitLangItem as uint].get()
}

pub fn add_trait(&const self) -> def_id {
pub fn add_trait(&self) -> def_id {
self.items[AddTraitLangItem as uint].get()
}
pub fn sub_trait(&const self) -> def_id {
pub fn sub_trait(&self) -> def_id {
self.items[SubTraitLangItem as uint].get()
}
pub fn mul_trait(&const self) -> def_id {
pub fn mul_trait(&self) -> def_id {
self.items[MulTraitLangItem as uint].get()
}
pub fn div_trait(&const self) -> def_id {
pub fn div_trait(&self) -> def_id {
self.items[DivTraitLangItem as uint].get()
}
pub fn rem_trait(&const self) -> def_id {
pub fn rem_trait(&self) -> def_id {
self.items[RemTraitLangItem as uint].get()
}
pub fn neg_trait(&const self) -> def_id {
pub fn neg_trait(&self) -> def_id {
self.items[NegTraitLangItem as uint].get()
}
pub fn not_trait(&const self) -> def_id {
pub fn not_trait(&self) -> def_id {
self.items[NotTraitLangItem as uint].get()
}
pub fn bitxor_trait(&const self) -> def_id {
pub fn bitxor_trait(&self) -> def_id {
self.items[BitXorTraitLangItem as uint].get()
}
pub fn bitand_trait(&const self) -> def_id {
pub fn bitand_trait(&self) -> def_id {
self.items[BitAndTraitLangItem as uint].get()
}
pub fn bitor_trait(&const self) -> def_id {
pub fn bitor_trait(&self) -> def_id {
self.items[BitOrTraitLangItem as uint].get()
}
pub fn shl_trait(&const self) -> def_id {
pub fn shl_trait(&self) -> def_id {
self.items[ShlTraitLangItem as uint].get()
}
pub fn shr_trait(&const self) -> def_id {
pub fn shr_trait(&self) -> def_id {
self.items[ShrTraitLangItem as uint].get()
}
pub fn index_trait(&const self) -> def_id {
pub fn index_trait(&self) -> def_id {
self.items[IndexTraitLangItem as uint].get()
}

pub fn eq_trait(&const self) -> def_id {
pub fn eq_trait(&self) -> def_id {
self.items[EqTraitLangItem as uint].get()
}
pub fn ord_trait(&const self) -> def_id {
pub fn ord_trait(&self) -> def_id {
self.items[OrdTraitLangItem as uint].get()
}

pub fn str_eq_fn(&const self) -> def_id {
pub fn str_eq_fn(&self) -> def_id {
self.items[StrEqFnLangItem as uint].get()
}
pub fn uniq_str_eq_fn(&const self) -> def_id {
pub fn uniq_str_eq_fn(&self) -> def_id {
self.items[UniqStrEqFnLangItem as uint].get()
}
pub fn annihilate_fn(&const self) -> def_id {
pub fn annihilate_fn(&self) -> def_id {
self.items[AnnihilateFnLangItem as uint].get()
}
pub fn log_type_fn(&const self) -> def_id {
pub fn log_type_fn(&self) -> def_id {
self.items[LogTypeFnLangItem as uint].get()
}
pub fn fail_fn(&const self) -> def_id {
pub fn fail_fn(&self) -> def_id {
self.items[FailFnLangItem as uint].get()
}
pub fn fail_bounds_check_fn(&const self) -> def_id {
pub fn fail_bounds_check_fn(&self) -> def_id {
self.items[FailBoundsCheckFnLangItem as uint].get()
}
pub fn exchange_malloc_fn(&const self) -> def_id {
pub fn exchange_malloc_fn(&self) -> def_id {
self.items[ExchangeMallocFnLangItem as uint].get()
}
pub fn exchange_free_fn(&const self) -> def_id {
pub fn exchange_free_fn(&self) -> def_id {
self.items[ExchangeFreeFnLangItem as uint].get()
}
pub fn malloc_fn(&const self) -> def_id {
pub fn malloc_fn(&self) -> def_id {
self.items[MallocFnLangItem as uint].get()
}
pub fn free_fn(&const self) -> def_id {
pub fn free_fn(&self) -> def_id {
self.items[FreeFnLangItem as uint].get()
}
pub fn borrow_as_imm_fn(&const self) -> def_id {
pub fn borrow_as_imm_fn(&self) -> def_id {
self.items[BorrowAsImmFnLangItem as uint].get()
}
pub fn borrow_as_mut_fn(&const self) -> def_id {
pub fn borrow_as_mut_fn(&self) -> def_id {
self.items[BorrowAsMutFnLangItem as uint].get()
}
pub fn return_to_mut_fn(&const self) -> def_id {
pub fn return_to_mut_fn(&self) -> def_id {
self.items[ReturnToMutFnLangItem as uint].get()
}
pub fn check_not_borrowed_fn(&const self) -> def_id {
pub fn check_not_borrowed_fn(&self) -> def_id {
self.items[CheckNotBorrowedFnLangItem as uint].get()
}
pub fn strdup_uniq_fn(&const self) -> def_id {
pub fn strdup_uniq_fn(&self) -> def_id {
self.items[StrDupUniqFnLangItem as uint].get()
}
pub fn record_borrow_fn(&const self) -> def_id {
pub fn record_borrow_fn(&self) -> def_id {
self.items[RecordBorrowFnLangItem as uint].get()
}
pub fn unrecord_borrow_fn(&const self) -> def_id {
pub fn unrecord_borrow_fn(&self) -> def_id {
self.items[UnrecordBorrowFnLangItem as uint].get()
}
pub fn start_fn(&const self) -> def_id {
pub fn start_fn(&self) -> def_id {
self.items[StartFnLangItem as uint].get()
}
pub fn ty_desc(&const self) -> def_id {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ fn visit_fn(fk: &visit::fn_kind,
match *fk {
fk_method(_, _, method) => {
match method.explicit_self.node {
sty_value | sty_region(*) | sty_box(_) | sty_uniq(_) => {
sty_value | sty_region(*) | sty_box(_) | sty_uniq => {
fn_maps.add_variable(Arg(method.self_id,
special_idents::self_));
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
let is_float = ty::type_is_fp(ty);
return match u {
ast::box(_) |
ast::uniq(_) |
ast::uniq |
ast::deref => {
let (dv, _dt) = const_deref(cx, te, ty, true);
dv
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ fn trans_unary_datum(bcx: block,
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty,
heap_managed)
}
ast::uniq(_) => {
ast::uniq => {
let heap = heap_for_unique(bcx, un_ty);
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/meth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ pub fn trans_trait_callee(bcx: block,
let llpair = match explicit_self {
ast::sty_region(*) => Load(bcx, llpair),
ast::sty_static | ast::sty_value |
ast::sty_box(_) | ast::sty_uniq(_) => llpair
ast::sty_box(_) | ast::sty_uniq => llpair
};

let callee_ty = node_id_type(bcx, callee_id);
Expand Down Expand Up @@ -622,7 +622,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,

self_mode = ty::ByRef;
}
ast::sty_uniq(_) => {
ast::sty_uniq => {
// Pass the unique pointer.
match store {
ty::UniqTraitStore => llself = llbox,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/type_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ pub fn mark_for_method_call(cx: &Context, e_id: node_id, callee_id: node_id) {
pub fn mark_for_expr(cx: &Context, e: &expr) {
match e.node {
expr_vstore(_, _) | expr_vec(_, _) | expr_struct(*) | expr_tup(_) |
expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) |
expr_unary(_, box(_), _) | expr_unary(_, uniq, _) |
expr_binary(_, add, _, _) | expr_copy(_) | expr_repeat(*) => {
node_type_needs(cx, use_repr, e.id);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3696,14 +3696,14 @@ pub enum DtorKind {
}

impl DtorKind {
pub fn is_not_present(&const self) -> bool {
pub fn is_not_present(&self) -> bool {
match *self {
NoDtor => true,
_ => false
}
}

pub fn is_present(&const self) -> bool {
pub fn is_present(&self) -> bool {
!self.is_not_present()
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,10 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
ty::mt {ty: self_info.untransformed_self_ty,
mutbl: mutability}))
}
ast::sty_uniq(mutability) => {
ast::sty_uniq => {
Some(ty::mk_uniq(this.tcx(),
ty::mt {ty: self_info.untransformed_self_ty,
mutbl: mutability}))
mutbl: ast::m_imm}))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/check/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,11 +1123,11 @@ impl<'self> LookupContext<'self> {
}
}

sty_uniq(m) => {
sty_uniq => {
debug!("(is relevant?) explicit self is a unique pointer");
match ty::get(rcvr_ty).sty {
ty::ty_uniq(mt) => {
mutability_matches(mt.mutbl, m) &&
mutability_matches(mt.mutbl, ast::m_imm) &&
self.fcx.can_mk_subty(mt.ty, candidate.rcvr_ty).is_ok()
}

Expand Down
7 changes: 4 additions & 3 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
ast::expr_unary(callee_id, unop, oprnd) => {
let exp_inner = do unpack_expected(fcx, expected) |sty| {
match unop {
ast::box(_) | ast::uniq(_) => match *sty {
ast::box(_) | ast::uniq => match *sty {
ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => Some(mt.ty),
_ => None
},
Expand All @@ -2318,9 +2318,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
oprnd_t = ty::mk_box(tcx,
ty::mt {ty: oprnd_t, mutbl: mutbl});
}
ast::uniq(mutbl) => {
ast::uniq => {
oprnd_t = ty::mk_uniq(tcx,
ty::mt {ty: oprnd_t, mutbl: mutbl});
ty::mt {ty: oprnd_t,
mutbl: ast::m_imm});
}
ast::deref => {
let sty = structure_of(fcx, expr.span, oprnd_t);
Expand Down
Loading