about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-28 20:11:34 +0000
committerbors <bors@rust-lang.org>2014-06-28 20:11:34 +0000
commitfe8bc178014dc2c5badd8443329c179478a40cc4 (patch)
treeb5bfc8f15cc996fe751306924595f81bcc558a27 /src/doc
parentde337f3ddfbef800a8cf731e0b593e341af1e3e5 (diff)
parent0dfc90ab15475aa64bea393671463a8e9784ae3f (diff)
downloadrust-fe8bc178014dc2c5badd8443329c179478a40cc4.tar.gz
rust-fe8bc178014dc2c5badd8443329c179478a40cc4.zip
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`.
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/guide-ffi.md22
-rw-r--r--src/doc/guide-runtime.md6
-rw-r--r--src/doc/guide-unsafe.md32
-rw-r--r--src/doc/rust.md2
4 files changed, 32 insertions, 30 deletions
diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md
index 13e44765d59..bba9594afeb 100644
--- a/src/doc/guide-ffi.md
+++ b/src/doc/guide-ffi.md
@@ -50,19 +50,19 @@ use libc::{c_int, size_t};
 
 #[link(name = "snappy")]
 extern {
-    fn snappy_compress(input: *u8,
+    fn snappy_compress(input: *const u8,
                        input_length: size_t,
                        compressed: *mut u8,
                        compressed_length: *mut size_t) -> c_int;
-    fn snappy_uncompress(compressed: *u8,
+    fn snappy_uncompress(compressed: *const u8,
                          compressed_length: size_t,
                          uncompressed: *mut u8,
                          uncompressed_length: *mut size_t) -> c_int;
     fn snappy_max_compressed_length(source_length: size_t) -> size_t;
-    fn snappy_uncompressed_length(compressed: *u8,
+    fn snappy_uncompressed_length(compressed: *const u8,
                                   compressed_length: size_t,
                                   result: *mut size_t) -> c_int;
-    fn snappy_validate_compressed_buffer(compressed: *u8,
+    fn snappy_validate_compressed_buffer(compressed: *const u8,
                                          compressed_length: size_t) -> c_int;
 }
 # fn main() {}
@@ -82,7 +82,7 @@ the allocated memory. The length is less than or equal to the capacity.
 ~~~~
 # extern crate libc;
 # use libc::{c_int, size_t};
-# unsafe fn snappy_validate_compressed_buffer(_: *u8, _: size_t) -> c_int { 0 }
+# unsafe fn snappy_validate_compressed_buffer(_: *const u8, _: size_t) -> c_int { 0 }
 # fn main() {}
 pub fn validate_compressed_buffer(src: &[u8]) -> bool {
     unsafe {
@@ -106,7 +106,7 @@ the true length after compression for setting the length.
 ~~~~
 # extern crate libc;
 # use libc::{size_t, c_int};
-# unsafe fn snappy_compress(a: *u8, b: size_t, c: *mut u8,
+# unsafe fn snappy_compress(a: *const u8, b: size_t, c: *mut u8,
 #                           d: *mut size_t) -> c_int { 0 }
 # unsafe fn snappy_max_compressed_length(a: size_t) -> size_t { a }
 # fn main() {}
@@ -132,11 +132,11 @@ format and `snappy_uncompressed_length` will retrieve the exact buffer size requ
 ~~~~
 # extern crate libc;
 # use libc::{size_t, c_int};
-# unsafe fn snappy_uncompress(compressed: *u8,
+# unsafe fn snappy_uncompress(compressed: *const u8,
 #                             compressed_length: size_t,
 #                             uncompressed: *mut u8,
 #                             uncompressed_length: *mut size_t) -> c_int { 0 }
-# unsafe fn snappy_uncompressed_length(compressed: *u8,
+# unsafe fn snappy_uncompressed_length(compressed: *const u8,
 #                                      compressed_length: size_t,
 #                                      result: *mut size_t) -> c_int { 0 }
 # fn main() {}
@@ -418,7 +418,7 @@ Unsafe functions, on the other hand, advertise it to the world. An unsafe functi
 this:
 
 ~~~~
-unsafe fn kaboom(ptr: *int) -> int { *ptr }
+unsafe fn kaboom(ptr: *const int) -> int { *ptr }
 ~~~~
 
 This function can only be called from an `unsafe` block or another `unsafe` function.
@@ -453,7 +453,7 @@ use std::ptr;
 
 #[link(name = "readline")]
 extern {
-    static mut rl_prompt: *libc::c_char;
+    static mut rl_prompt: *const libc::c_char;
 }
 
 fn main() {
@@ -478,7 +478,7 @@ extern crate libc;
 #[link(name = "kernel32")]
 #[allow(non_snake_case_functions)]
 extern "stdcall" {
-    fn SetEnvironmentVariableA(n: *u8, v: *u8) -> libc::c_int;
+    fn SetEnvironmentVariableA(n: *const u8, v: *const u8) -> libc::c_int;
 }
 # fn main() { }
 ~~~~
diff --git a/src/doc/guide-runtime.md b/src/doc/guide-runtime.md
index 0050bd2d77f..1367bdc0755 100644
--- a/src/doc/guide-runtime.md
+++ b/src/doc/guide-runtime.md
@@ -245,7 +245,7 @@ extern crate green;
 extern crate rustuv;
 
 #[start]
-fn start(argc: int, argv: **u8) -> int {
+fn start(argc: int, argv: *const *const u8) -> int {
     green::start(argc, argv, rustuv::event_loop, main)
 }
 
@@ -261,7 +261,9 @@ inside of an OS thread.
 extern crate native;
 
 #[start]
-fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) }
+fn start(argc: int, argv: *const *const u8) -> int {
+    native::start(argc, argv, main)
+}
 
 fn main() {}
 ~~~
diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md
index 609d8937c80..ffaabbb04ab 100644
--- a/src/doc/guide-unsafe.md
+++ b/src/doc/guide-unsafe.md
@@ -79,7 +79,7 @@ let ref_2: &mut u8 = unsafe { mem::transmute(&mut *ref_1) };
 ## Raw pointers
 
 Rust offers two additional pointer types "raw pointers", written as
-`*T` and `*mut T`. They're an approximation of C's `const T*` and `T*`
+`*const T` and `*mut T`. They're an approximation of C's `const T*` and `T*`
 respectively; indeed, one of their most common uses is for FFI,
 interfacing with external C libraries.
 
@@ -100,7 +100,7 @@ offered by the Rust language and libraries. For example, they
 - lack any form of lifetimes, unlike `&`, and so the compiler cannot
   reason about dangling pointers; and
 - have no guarantees about aliasing or mutability other than mutation
-  not being allowed directly through a `*T`.
+  not being allowed directly through a `*const T`.
 
 Fortunately, they come with a redeeming feature: the weaker guarantees
 mean weaker restrictions. The missing restrictions make raw pointers
@@ -131,13 +131,13 @@ unsafe, and neither is converting to an integer.
 
 At runtime, a raw pointer `*` and a reference pointing to the same
 piece of data have an identical representation. In fact, an `&T`
-reference will implicitly coerce to an `*T` raw pointer in safe code
+reference will implicitly coerce to an `*const T` raw pointer in safe code
 and similarly for the `mut` variants (both coercions can be performed
-explicitly with, respectively, `value as *T` and `value as *mut T`).
+explicitly with, respectively, `value as *const T` and `value as *mut T`).
 
-Going the opposite direction, from `*` to a reference `&`, is not
+Going the opposite direction, from `*const` to a reference `&`, is not
 safe. A `&T` is always valid, and so, at a minimum, the raw pointer
-`*T` has to be a valid to a valid instance of type `T`. Furthermore,
+`*const T` has to be a valid to a valid instance of type `T`. Furthermore,
 the resulting pointer must satisfy the aliasing and mutability laws of
 references. The compiler assumes these properties are true for any
 references, no matter how they are created, and so any conversion from
@@ -149,7 +149,7 @@ The recommended method for the conversion is
 ```
 let i: u32 = 1;
 // explicit cast
-let p_imm: *u32 = &i as *u32;
+let p_imm: *const u32 = &i as *const u32;
 let mut m: u32 = 2;
 // implicit coercion
 let p_mut: *mut u32 = &mut m;
@@ -256,7 +256,7 @@ impl<T: Send> Drop for Unique<T> {
             // Copy the object out from the pointer onto the stack,
             // where it is covered by normal Rust destructor semantics
             // and cleans itself up, if necessary
-            ptr::read(self.ptr as *T);
+            ptr::read(self.ptr as *const T);
 
             // clean-up our allocation
             free(self.ptr as *mut c_void)
@@ -457,7 +457,7 @@ extern crate libc;
 
 // Entry point for this program
 #[start]
-fn start(_argc: int, _argv: **u8) -> int {
+fn start(_argc: int, _argv: *const *const u8) -> int {
     0
 }
 
@@ -482,7 +482,7 @@ compiler's name mangling too:
 extern crate libc;
 
 #[no_mangle] // ensure that this symbol is called `main` in the output
-pub extern fn main(argc: int, argv: **u8) -> int {
+pub extern fn main(argc: int, argv: *const *const u8) -> int {
     0
 }
 
@@ -540,8 +540,8 @@ use core::mem;
 use core::raw::Slice;
 
 #[no_mangle]
-pub extern fn dot_product(a: *u32, a_len: u32,
-                          b: *u32, b_len: u32) -> u32 {
+pub extern fn dot_product(a: *const u32, a_len: u32,
+                          b: *const u32, b_len: u32) -> u32 {
     // Convert the provided arrays into Rust slices.
     // The core::raw module guarantees that the Slice
     // structure has the same memory layout as a &[T]
@@ -573,7 +573,7 @@ extern fn begin_unwind(args: &core::fmt::Arguments,
 
 #[lang = "stack_exhausted"] extern fn stack_exhausted() {}
 #[lang = "eh_personality"] extern fn eh_personality() {}
-# #[start] fn start(argc: int, argv: **u8) -> int { 0 }
+# #[start] fn start(argc: int, argv: *const *const u8) -> int { 0 }
 # fn main() {}
 ```
 
@@ -595,7 +595,7 @@ standard library itself.
 > parts of the language may never be full specified and so details may
 > differ wildly between implementations (and even versions of `rustc`
 > itself).
-> 
+>
 > Furthermore, this is just an overview; the best form of
 > documentation for specific instances of these features are their
 > definitions and uses in `std`.
@@ -627,7 +627,7 @@ via a declaration like
 extern "rust-intrinsic" {
     fn transmute<T, U>(x: T) -> U;
 
-    fn offset<T>(dst: *T, offset: int) -> *T;
+    fn offset<T>(dst: *const T, offset: int) -> *const T;
 }
 ```
 
@@ -677,7 +677,7 @@ unsafe fn deallocate(ptr: *mut u8, _size: uint, _align: uint) {
 }
 
 #[start]
-fn main(argc: int, argv: **u8) -> int {
+fn main(argc: int, argv: *const *const u8) -> int {
     let x = box 1;
 
     0
diff --git a/src/doc/rust.md b/src/doc/rust.md
index 9dc5c66a08d..c5a6a01f483 100644
--- a/src/doc/rust.md
+++ b/src/doc/rust.md
@@ -1614,7 +1614,7 @@ extern crate libc;
 use libc::{c_char, FILE};
 
 extern {
-    fn fopen(filename: *c_char, mode: *c_char) -> *FILE;
+    fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE;
 }
 # fn main() {}
 ~~~~