diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 0d612369cc5c..efb11271af6d 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1976,6 +1976,7 @@ pub trait ImmutableVector<'self, T> { fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool; fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U]; fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U]; + unsafe fn unsafe_ref(&self, index: uint) -> *T; } /// Extension methods for vectors @@ -2097,6 +2098,14 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U] { filter_mapped(*self, f) } + + /// Returns a pointer to the element at the given index, without doing + /// bounds checking. + #[inline(always)] + unsafe fn unsafe_ref(&self, index: uint) -> *T { + let (ptr, _): (*T, uint) = transmute(*self); + ptr.offset(index) + } } pub trait ImmutableEqVector { diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index e62e19f636a4..30c14ab679f3 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -288,11 +288,15 @@ pub impl Reflector { let arg = unsafe { llvm::LLVMGetParam(llfdecl, first_real_arg as c_uint) }; - let fcx = new_fn_ctxt(ccx, ~[], llfdecl, None); + let fcx = new_fn_ctxt(ccx, + ~[], + llfdecl, + ty::mk_uint(ccx.tcx), + None); let bcx = top_scope_block(fcx, None); let arg = BitCast(bcx, arg, llptrty); let ret = adt::trans_get_discr(bcx, repr, arg); - Store(bcx, ret, fcx.llretptr); + Store(bcx, ret, fcx.llretptr.get()); cleanup_and_Br(bcx, bcx, fcx.llreturn); finish_fn(fcx, bcx.llbb); llfdecl diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index b94b53076ec5..2483cacd1a69 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -376,10 +376,10 @@ pub struct ident_interner { pub impl ident_interner { fn intern(&self, val: @~str) -> ast::ident { - ast::ident { repr: self.interner.intern(val), ctxt: 0} + ast::ident { repr: self.interner.intern(val), ctxt: 0 } } fn gensym(&self, val: @~str) -> ast::ident { - ast::ident { repr: self.interner.gensym(val), ctxt: 0} + ast::ident { repr: self.interner.gensym(val), ctxt: 0 } } fn get(&self, idx: ast::ident) -> @~str { self.interner.get(idx.repr) @@ -388,9 +388,9 @@ pub impl ident_interner { self.interner.len() } fn find_equiv>(&self, val: &Q) - -> Option { + -> Option { match self.interner.find_equiv(val) { - Some(v) => Some(ast::ident { repr: v }), + Some(v) => Some(ast::ident { repr: v, ctxt: 0 }), None => None, } }