auto merge of #15208 : alexcrichton/rust/snapshots, r=pcwalton

This change registers new snapshots, allowing `*T` to be removed from the language. This is a large breaking change, and it is recommended that if compiler errors are seen that any FFI calls are audited to determine whether they should be actually taking `*mut T`.
This commit is contained in:
bors 2014-06-28 20:11:34 +00:00
commit fe8bc17801
228 changed files with 1813 additions and 1685 deletions

View file

@ -82,7 +82,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
(),
|()| unsafe {
if !llvm::LLVMRustLinkInExternalBitcode(llmod,
ptr as *libc::c_char,
ptr as *const libc::c_char,
bc.len() as libc::size_t) {
link::llvm_err(sess,
format!("failed to load bc of `{}`",
@ -94,10 +94,11 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
// Internalize everything but the reachable symbols of the current module
let cstrs: Vec<::std::c_str::CString> =
reachable.iter().map(|s| s.as_slice().to_c_str()).collect();
let arr: Vec<*i8> = cstrs.iter().map(|c| c.with_ref(|p| p)).collect();
let arr: Vec<*const i8> = cstrs.iter().map(|c| c.with_ref(|p| p)).collect();
let ptr = arr.as_ptr();
unsafe {
llvm::LLVMRustRunRestrictionPass(llmod, ptr as **libc::c_char,
llvm::LLVMRustRunRestrictionPass(llmod,
ptr as *const *const libc::c_char,
arr.len() as libc::size_t);
}

File diff suppressed because it is too large Load diff

View file

@ -176,7 +176,7 @@ pub struct LintId {
impl PartialEq for LintId {
fn eq(&self, other: &LintId) -> bool {
(self.lint as *Lint) == (other.lint as *Lint)
(self.lint as *const Lint) == (other.lint as *const Lint)
}
}
@ -184,7 +184,7 @@ impl Eq for LintId { }
impl<S: hash::Writer> hash::Hash<S> for LintId {
fn hash(&self, state: &mut S) {
let ptr = self.lint as *Lint;
let ptr = self.lint as *const Lint;
ptr.hash(state);
}
}

View file

@ -1308,7 +1308,7 @@ fn my_visit_expr(_e: &Expr) { }
fn my_visit_item(i: &Item,
ebml_w: &mut Encoder,
ecx_ptr: *int,
ecx_ptr: *const int,
index: &mut Vec<entry<i64>>) {
let mut ebml_w = unsafe { ebml_w.unsafe_clone() };
// See above
@ -1320,7 +1320,7 @@ fn my_visit_item(i: &Item,
fn my_visit_foreign_item(ni: &ForeignItem,
ebml_w: &mut Encoder,
ecx_ptr:*int,
ecx_ptr:*const int,
index: &mut Vec<entry<i64>>) {
// See above
let ecx: &EncodeContext = unsafe { mem::transmute(ecx_ptr) };
@ -1341,7 +1341,7 @@ fn my_visit_foreign_item(ni: &ForeignItem,
struct EncodeVisitor<'a,'b> {
ebml_w_for_visit_item: &'a mut Encoder<'b>,
ecx_ptr:*int,
ecx_ptr:*const int,
index: &'a mut Vec<entry<i64>>,
}
@ -1386,7 +1386,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
Public);
// See comment in `encode_side_tables_for_ii` in astencode
let ecx_ptr: *int = unsafe { mem::transmute(ecx) };
let ecx_ptr: *const int = unsafe { mem::transmute(ecx) };
visit::walk_crate(&mut EncodeVisitor {
index: &mut index,
ecx_ptr: ecx_ptr,

View file

@ -545,14 +545,15 @@ fn get_metadata_section_imp(os: abi::Os, filename: &Path) -> Result<MetadataBlob
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
let mut name_buf = ptr::null();
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
let name = str::raw::from_buf_len(name_buf as *u8, name_len as uint);
let name = str::raw::from_buf_len(name_buf as *const u8,
name_len as uint);
debug!("get_metadata_section: name {}", name);
if read_meta_section_name(os).as_slice() == name.as_slice() {
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
let mut found =
Err(format!("metadata not found: '{}'", filename.display()));
let cvbuf: *u8 = mem::transmute(cbuf);
let cvbuf: *const u8 = mem::transmute(cbuf);
let vlen = encoder::metadata_encoding_version.len();
debug!("checking {} bytes of metadata-version stamp",
vlen);

View file

@ -943,7 +943,7 @@ impl<'a> write_tag_and_id for Encoder<'a> {
}
struct SideTableEncodingIdVisitor<'a,'b> {
ecx_ptr: *libc::c_void,
ecx_ptr: *const libc::c_void,
new_ebml_w: &'a mut Encoder<'b>,
}

View file

@ -360,7 +360,8 @@ fn visit_fn(ir: &mut IrMaps,
let mut fn_maps = IrMaps::new(ir.tcx);
unsafe {
debug!("creating fn_maps: {}", transmute::<&IrMaps, *IrMaps>(&fn_maps));
debug!("creating fn_maps: {}",
transmute::<&IrMaps, *const IrMaps>(&fn_maps));
}
for arg in decl.inputs.iter() {

View file

@ -44,7 +44,7 @@ impl<T> HomogeneousTuple3<T> for (T, T, T) {
fn as_slice<'a>(&'a self) -> &'a [T] {
unsafe {
let ptr: *T = mem::transmute(self);
let ptr: *const T = mem::transmute(self);
let slice = raw::Slice { data: ptr, len: 3 };
mem::transmute(slice)
}
@ -52,7 +52,7 @@ impl<T> HomogeneousTuple3<T> for (T, T, T) {
fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
unsafe {
let ptr: *T = mem::transmute(self);
let ptr: *const T = mem::transmute(self);
let slice = raw::Slice { data: ptr, len: 3 };
mem::transmute(slice)
}

View file

@ -453,7 +453,7 @@ pub fn StructGEP(cx: &Block, pointer: ValueRef, idx: uint) -> ValueRef {
}
}
pub fn GlobalString(cx: &Block, _str: *c_char) -> ValueRef {
pub fn GlobalString(cx: &Block, _str: *const c_char) -> ValueRef {
unsafe {
if cx.unreachable.get() {
return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref());
@ -462,7 +462,7 @@ pub fn GlobalString(cx: &Block, _str: *c_char) -> ValueRef {
}
}
pub fn GlobalStringPtr(cx: &Block, _str: *c_char) -> ValueRef {
pub fn GlobalStringPtr(cx: &Block, _str: *const c_char) -> ValueRef {
unsafe {
if cx.unreachable.get() {
return llvm::LLVMGetUndef(Type::i8p(cx.ccx()).to_ref());
@ -577,7 +577,8 @@ pub fn TruncOrBitCast(cx: &Block, val: ValueRef, dest_ty: Type) -> ValueRef {
}
}
pub fn Cast(cx: &Block, op: Opcode, val: ValueRef, dest_ty: Type, _: *u8)
pub fn Cast(cx: &Block, op: Opcode, val: ValueRef, dest_ty: Type,
_: *const u8)
-> ValueRef {
unsafe {
if cx.unreachable.get() { return llvm::LLVMGetUndef(dest_ty.to_ref()); }
@ -636,7 +637,8 @@ pub fn EmptyPhi(cx: &Block, ty: Type) -> ValueRef {
}
}
pub fn Phi(cx: &Block, ty: Type, vals: &[ValueRef], bbs: &[BasicBlockRef]) -> ValueRef {
pub fn Phi(cx: &Block, ty: Type, vals: &[ValueRef],
bbs: &[BasicBlockRef]) -> ValueRef {
unsafe {
if cx.unreachable.get() { return llvm::LLVMGetUndef(ty.to_ref()); }
B(cx).phi(ty, vals, bbs)
@ -672,7 +674,7 @@ pub fn add_comment(cx: &Block, text: &str) {
B(cx).add_comment(text)
}
pub fn InlineAsmCall(cx: &Block, asm: *c_char, cons: *c_char,
pub fn InlineAsmCall(cx: &Block, asm: *const c_char, cons: *const c_char,
inputs: &[ValueRef], output: Type,
volatile: bool, alignstack: bool,
dia: AsmDialect) -> ValueRef {

View file

@ -31,9 +31,9 @@ pub struct Builder<'a> {
// This is a really awful way to get a zero-length c-string, but better (and a
// lot more efficient) than doing str::as_c_str("", ...) every time.
pub fn noname() -> *c_char {
pub fn noname() -> *const c_char {
static cnull: c_char = 0;
&cnull as *c_char
&cnull as *const c_char
}
impl<'a> Builder<'a> {
@ -564,14 +564,14 @@ impl<'a> Builder<'a> {
}
}
pub fn global_string(&self, _str: *c_char) -> ValueRef {
pub fn global_string(&self, _str: *const c_char) -> ValueRef {
self.count_insn("globalstring");
unsafe {
llvm::LLVMBuildGlobalString(self.llbuilder, _str, noname())
}
}
pub fn global_string_ptr(&self, _str: *c_char) -> ValueRef {
pub fn global_string_ptr(&self, _str: *const c_char) -> ValueRef {
self.count_insn("globalstringptr");
unsafe {
llvm::LLVMBuildGlobalStringPtr(self.llbuilder, _str, noname())
@ -774,7 +774,7 @@ impl<'a> Builder<'a> {
}
}
pub fn inline_asm_call(&self, asm: *c_char, cons: *c_char,
pub fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
inputs: &[ValueRef], output: Type,
volatile: bool, alignstack: bool,
dia: AsmDialect) -> ValueRef {

View file

@ -471,7 +471,7 @@ impl<'a> Block<'a> {
}
pub fn to_str(&self) -> String {
let blk: *Block = self;
let blk: *const Block = self;
format!("[block {}]", blk)
}
}
@ -568,7 +568,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
}
let sc = llvm::LLVMConstStringInContext(cx.llcx,
s.get().as_ptr() as *c_char,
s.get().as_ptr() as *const c_char,
s.get().len() as c_uint,
!null_terminated as Bool);
@ -636,7 +636,7 @@ pub fn C_array(ty: Type, elts: &[ValueRef]) -> ValueRef {
pub fn C_bytes(ccx: &CrateContext, bytes: &[u8]) -> ValueRef {
unsafe {
let ptr = bytes.as_ptr() as *c_char;
let ptr = bytes.as_ptr() as *const c_char;
return llvm::LLVMConstStringInContext(ccx.llcx, ptr, bytes.len() as c_uint, True);
}
}

View file

@ -221,8 +221,8 @@ impl CrateContext {
llvm_insns: RefCell::new(HashMap::new()),
fn_stats: RefCell::new(Vec::new()),
},
int_type: Type::from_ref(ptr::null()),
opaque_vec_type: Type::from_ref(ptr::null()),
int_type: Type::from_ref(ptr::mut_null()),
opaque_vec_type: Type::from_ref(ptr::mut_null()),
builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)),
uses_gc: false,
dbg_cx: dbg_cx,

View file

@ -805,7 +805,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
type_metadata,
is_local_to_unit,
global,
ptr::null());
ptr::mut_null());
}
})
});
@ -980,7 +980,7 @@ pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) {
}
};
if unsafe { llvm::LLVMIsAAllocaInst(llarg.val) } == ptr::null() {
if unsafe { llvm::LLVMIsAAllocaInst(llarg.val) } == ptr::mut_null() {
cx.sess().span_bug(span, "debuginfo::create_argument_metadata() - \
Referenced variable location is not an alloca!");
}
@ -1221,7 +1221,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
cx.sess().opts.optimize != config::No,
llfn,
template_parameters,
ptr::null())
ptr::mut_null())
}
})
});
@ -1257,7 +1257,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
// Return type -- llvm::DIBuilder wants this at index 0
match fn_decl.output.node {
ast::TyNil => {
signature.push(ptr::null());
signature.push(ptr::mut_null());
}
_ => {
assert_type_for_node_id(cx, fn_ast_id, error_span);
@ -1328,7 +1328,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
file_metadata,
name,
actual_self_type_metadata,
ptr::null(),
ptr::mut_null(),
0,
0)
}
@ -1361,7 +1361,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
file_metadata,
name,
actual_type_metadata,
ptr::null(),
ptr::mut_null(),
0,
0)
}
@ -2374,7 +2374,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
bytes_to_bits(enum_type_size),
bytes_to_bits(enum_type_align),
0, // Flags
ptr::null(),
ptr::mut_null(),
0, // RuntimeLang
unique_type_id_str)
}
@ -2554,10 +2554,10 @@ fn create_struct_stub(cx: &CrateContext,
bytes_to_bits(struct_size),
bytes_to_bits(struct_align),
0,
ptr::null(),
ptr::mut_null(),
empty_array,
0,
ptr::null(),
ptr::mut_null(),
unique_type_id)
})
})
@ -2855,7 +2855,7 @@ fn subroutine_type_metadata(cx: &CrateContext,
// return type
signature_metadata.push(match ty::get(signature.output).sty {
ty::ty_nil => ptr::null(),
ty::ty_nil => ptr::mut_null(),
_ => type_metadata(cx, signature.output, span)
});
@ -3153,7 +3153,8 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) {
KnownLocation { scope, line, .. } => {
let col = 0u; // Always set the column to zero like Clang and GCC
debug!("setting debug location to {} {}", line, col);
let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32), scope, ptr::null()];
let elements = [C_i32(cx, line as i32), C_i32(cx, col as i32),
scope, ptr::mut_null()];
unsafe {
metadata_node = llvm::LLVMMDNodeInContext(debug_context(cx).llcontext,
elements.as_ptr(),
@ -3162,7 +3163,7 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) {
}
UnknownLocation => {
debug!("clearing debug location ");
metadata_node = ptr::null();
metadata_node = ptr::mut_null();
}
};
@ -3771,7 +3772,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
// create and insert
let parent_scope = match parent_node {
Some(ref node) => node.scope,
None => ptr::null()
None => ptr::mut_null()
};
let namespace_name = token::get_name(name);
let scope = namespace_name.get().with_c_str(|namespace_name| {
@ -3781,7 +3782,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
parent_scope,
namespace_name,
// cannot reconstruct file ...
ptr::null(),
ptr::mut_null(),
// ... or line information, but that's not so important.
0)
}

View file

@ -158,7 +158,7 @@ pub struct creader_cache_key {
pub type creader_cache = RefCell<HashMap<creader_cache_key, t>>;
pub struct intern_key {
sty: *sty,
sty: *const sty,
}
// NB: Do not replace this with #[deriving(PartialEq)]. The automatically-derived
@ -409,7 +409,7 @@ enum t_opaque {}
#[allow(raw_pointer_deriving)]
#[deriving(Clone, PartialEq, Eq, Hash)]
pub struct t { inner: *t_opaque }
pub struct t { inner: *const t_opaque }
impl fmt::Show for t {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -1216,7 +1216,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
flags: flags,
};
let sty_ptr = &t.sty as *sty;
let sty_ptr = &t.sty as *const sty;
let key = intern_key {
sty: sty_ptr,
@ -1227,7 +1227,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
cx.next_id.set(cx.next_id.get() + 1);
unsafe {
mem::transmute::<*sty, t>(sty_ptr)
mem::transmute::<*const sty, t>(sty_ptr)
}
}

View file

@ -1262,7 +1262,7 @@ impl<'a> RegionScope for infer::InferCtxt<'a> {
impl<'a> FnCtxt<'a> {
pub fn tag(&self) -> String {
format!("{}", self as *FnCtxt)
format!("{}", self as *const FnCtxt)
}
pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {

View file

@ -129,7 +129,7 @@ impl<'a> PluginLoader<'a> {
let registrar =
match lib.symbol(symbol.as_slice()) {
Ok(registrar) => {
mem::transmute::<*u8,PluginRegistrarFun>(registrar)
mem::transmute::<*mut u8,PluginRegistrarFun>(registrar)
}
// again fatal if we can't register macros
Err(err) => self.sess.span_fatal(vi.span, err.as_slice())

View file

@ -355,7 +355,12 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String {
ty_float(t) => ast_util::float_ty_to_str(t).to_string(),
ty_box(typ) => format!("Gc<{}>", ty_to_str(cx, typ)),
ty_uniq(typ) => format!("Box<{}>", ty_to_str(cx, typ)),
ty_ptr(ref tm) => format!("*{}", mt_to_str(cx, tm)),
ty_ptr(ref tm) => {
format!("*{} {}", match tm.mutbl {
ast::MutMutable => "mut",
ast::MutImmutable => "const",
}, ty_to_str(cx, tm.ty))
}
ty_rptr(r, ref tm) => {
let mut buf = region_ptr_to_str(cx, r);
buf.push_str(mt_to_str(cx, tm).as_slice());

View file

@ -34,7 +34,7 @@ fn read_u32v_be(dst: &mut[u32], input: &[u8]) {
assert!(dst.len() * 4 == input.len());
unsafe {
let mut x = dst.unsafe_mut_ref(0) as *mut _ as *mut u32;
let mut y = input.unsafe_ref(0) as *_ as *u32;
let mut y = input.unsafe_ref(0) as *const _ as *const u32;
for _ in range(0, dst.len()) {
*x = to_be32(*y);
x = x.offset(1);