From 779ee2a2dd06235470cf5b6bea90b78619dc0654 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 27 Jun 2013 03:32:21 -0400 Subject: [PATCH 01/10] util: make NonCopyable 0 size (instead of 1 byte) this also adds a derived Eq, TotalEq, Ord and TotalOrd along with removing the useless constructor --- src/libstd/option.rs | 2 +- src/libstd/util.rs | 51 +++++++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/libstd/option.rs b/src/libstd/option.rs index f3ea81f1ae560..12ae2abd4a1f0 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -447,7 +447,7 @@ fn test_option_dance() { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_option_too_much_dance() { - let mut y = Some(util::NonCopyable::new()); + let mut y = Some(util::NonCopyable); let _y2 = y.swap_unwrap(); let _y3 = y.swap_unwrap(); } diff --git a/src/libstd/util.rs b/src/libstd/util.rs index 6eddae17ce6f0..e66271df47849 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -75,18 +75,14 @@ pub fn replace(dest: &mut T, mut src: T) -> T { } /// A non-copyable dummy type. +#[deriving(Eq, TotalEq, Ord, TotalOrd)] +#[no_drop_flag] pub struct NonCopyable; -impl NonCopyable { - /// Creates a dummy non-copyable structure and returns it for use. - pub fn new() -> NonCopyable { NonCopyable } -} - impl Drop for NonCopyable { fn drop(&self) { } } - /// A type with no inhabitants pub enum Void { } @@ -130,39 +126,70 @@ pub fn unreachable() -> ! { #[cfg(test)] mod tests { + use super::*; use option::{None, Some}; - use util::{Void, NonCopyable, id, replace, swap}; use either::{Either, Left, Right}; + use sys::size_of; + use kinds::Drop; #[test] - pub fn identity_crisis() { + fn identity_crisis() { // Writing a test for the identity function. How did it come to this? let x = ~[(5, false)]; //FIXME #3387 assert!(x.eq(id(copy x))); let y = copy x; assert!(x.eq(&id(y))); } + #[test] - pub fn test_swap() { + fn test_swap() { let mut x = 31337; let mut y = 42; swap(&mut x, &mut y); assert_eq!(x, 42); assert_eq!(y, 31337); } + #[test] - pub fn test_replace() { - let mut x = Some(NonCopyable::new()); + fn test_replace() { + let mut x = Some(NonCopyable); let y = replace(&mut x, None); assert!(x.is_none()); assert!(y.is_some()); } + #[test] - pub fn test_uninhabited() { + fn test_uninhabited() { let could_only_be_coin : Either = Right (()); match could_only_be_coin { Right (coin) => coin, Left (is_void) => is_void.uninhabited () } } + + #[test] + fn test_noncopyable() { + assert_eq!(size_of::(), 0); + + // verify that `#[no_drop_flag]` works as intended on a zero-size struct + + static mut did_run: bool = false; + + struct Foo { five: int } + + impl Drop for Foo { + fn drop(&self) { + assert_eq!(self.five, 5); + unsafe { + did_run = true; + } + } + } + + { + let _a = (NonCopyable, Foo { five: 5 }, NonCopyable); + } + + unsafe { assert_eq!(did_run, true); } + } } From dcf1dc060a895d2b4de04b6d13291989c2f3dbec Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Thu, 27 Jun 2013 20:47:45 +0300 Subject: [PATCH 02/10] Rename #[no_drop_flag] to #[unsafe_no_drop_flag] --- src/librustc/middle/ty.rs | 2 +- src/libstd/unstable/atomics.rs | 2 +- src/libstd/util.rs | 4 ++-- src/test/run-pass/attr-no-drop-flag-size.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index b53359abed4bb..29d81f37da7d4 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3904,7 +3904,7 @@ impl DtorKind { pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind { match cx.destructor_for_type.find(&struct_id) { Some(&method_def_id) => { - let flag = !has_attr(cx, struct_id, "no_drop_flag"); + let flag = !has_attr(cx, struct_id, "unsafe_no_drop_flag"); TraitDtor(method_def_id, flag) } diff --git a/src/libstd/unstable/atomics.rs b/src/libstd/unstable/atomics.rs index 45eced9846cea..1e5ac305df37e 100644 --- a/src/libstd/unstable/atomics.rs +++ b/src/libstd/unstable/atomics.rs @@ -62,7 +62,7 @@ pub struct AtomicPtr { /** * An owned atomic pointer. Ensures that only a single reference to the data is held at any time. */ -#[no_drop_flag] +#[unsafe_no_drop_flag] pub struct AtomicOption { priv p: *mut c_void } diff --git a/src/libstd/util.rs b/src/libstd/util.rs index e66271df47849..fe1087a04389a 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -76,7 +76,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// A non-copyable dummy type. #[deriving(Eq, TotalEq, Ord, TotalOrd)] -#[no_drop_flag] +#[unsafe_no_drop_flag] pub struct NonCopyable; impl Drop for NonCopyable { @@ -171,7 +171,7 @@ mod tests { fn test_noncopyable() { assert_eq!(size_of::(), 0); - // verify that `#[no_drop_flag]` works as intended on a zero-size struct + // verify that `#[unsafe_no_drop_flag]` works as intended on a zero-size struct static mut did_run: bool = false; diff --git a/src/test/run-pass/attr-no-drop-flag-size.rs b/src/test/run-pass/attr-no-drop-flag-size.rs index 00a7955d834cb..87c476d781e7e 100644 --- a/src/test/run-pass/attr-no-drop-flag-size.rs +++ b/src/test/run-pass/attr-no-drop-flag-size.rs @@ -10,7 +10,7 @@ use std::sys::size_of; -#[no_drop_flag] +#[unsafe_no_drop_flag] struct Test { a: T } From b854d6ea1caf9051fcd3da822e0f65c437d1ed84 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 27 Jun 2013 12:00:00 -0700 Subject: [PATCH 03/10] docs: Mention rustpkg in release notes --- RELEASES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASES.txt b/RELEASES.txt index dbee53f8e3058..9ac4d650b43f1 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -101,6 +101,7 @@ Version 0.7 (July 2013) dynamic borrowcheck failures for debugging. * rustdoc has a nicer stylesheet. * Various improvements to rustdoc. + * Improvements to rustpkg (see the detailed release notes) * Other * More and improved library documentation. From d805859ff5bf90f7513550453a7fd797eb2e778d Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 27 Jun 2013 12:13:55 -0700 Subject: [PATCH 04/10] rustpkg: Update manual --- doc/rustpkg.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/rustpkg.md b/doc/rustpkg.md index b12bce5a0afdf..506fc2ad15a8c 100644 --- a/doc/rustpkg.md +++ b/doc/rustpkg.md @@ -95,12 +95,22 @@ When building a package that is in a `git` repository, When building a package that is not under version control, or that has no tags, `rustpkg` assumes the intended version is 0.1. +# Dependencies + +rustpkg infers dependencies from `extern mod` directives. +Thus, there should be no need to pass a `-L` flag to rustpkg to tell it where to find a library. +(In the future, it will also be possible to write an `extern mod` directive referring to a remote package.) + # Custom build scripts A file called `pkg.rs` at the root level in a workspace is called a *package script*. If a package script exists, rustpkg executes it to build the package rather than inferring crates as described previously. +Inside `pkg.rs`, it's possible to call back into rustpkg to finish up the build. +`rustpkg::api` contains functions to build, install, or clean libraries and executables +in the way rustpkg normally would without custom build logic. + # Command reference ## build From aabeba3d63221651d965b7aa39bbf28781f9d16f Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Thu, 27 Jun 2013 14:48:53 +0900 Subject: [PATCH 05/10] extra: unused import fix for android --- src/libextra/ebml.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libextra/ebml.rs b/src/libextra/ebml.rs index 92a027100daf4..dd3ba639c054c 100644 --- a/src/libextra/ebml.rs +++ b/src/libextra/ebml.rs @@ -82,8 +82,14 @@ pub mod reader { use core::cast::transmute; use core::int; use core::io; - use core::ptr::offset; use core::str; + + #[cfg(target_arch = "x86")] + #[cfg(target_arch = "x86_64")] + use core::ptr::offset; + + #[cfg(target_arch = "x86")] + #[cfg(target_arch = "x86_64")] use core::unstable::intrinsics::bswap32; // ebml reading From 6b2297d118bdbc3b1487dc48ae56f9e1755b41f5 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Thu, 27 Jun 2013 14:49:12 +0900 Subject: [PATCH 06/10] std: unused import fix for android --- src/libstd/libc.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs index 3c2ae93b65637..41b78afded1a8 100644 --- a/src/libstd/libc.rs +++ b/src/libstd/libc.rs @@ -349,7 +349,6 @@ pub mod types { use libc::types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t}; use libc::types::os::arch::c99::{c_longlong, c_ulonglong}; use libc::types::os::arch::posix88::{uid_t, gid_t, ino_t}; - use libc::types::os::arch::posix88::{uid_t}; pub type nlink_t = u16; pub type blksize_t = u32; From 5fccce4051f452f68ad725d2e7520d3971f3178d Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 27 Jun 2013 16:45:09 -0400 Subject: [PATCH 07/10] rc: add missing `#[unsafe_no_drop_flag]` The destructors were updated in d9f6dd263c16a21108c27dbf15a3d59a43a5b490 but this was accidentally left out. --- src/libextra/rc.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 8ef58a188d930..5b1451387e7ad 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -36,6 +36,7 @@ struct RcBox { /// Immutable reference counted pointer type #[non_owned] +#[unsafe_no_drop_flag] pub struct Rc { priv ptr: *mut RcBox, } @@ -168,6 +169,7 @@ struct RcMutBox { /// Mutable reference counted pointer type #[non_owned] #[mutable] +#[unsafe_no_drop_flag] pub struct RcMut { priv ptr: *mut RcMutBox, } From c45af013517148b8fe6e6234ecad729baf135c23 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 28 Jun 2013 00:23:38 -0400 Subject: [PATCH 08/10] fix stage0 build --- src/libstd/util.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libstd/util.rs b/src/libstd/util.rs index fe1087a04389a..fd29d7dc14bd7 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -173,16 +173,18 @@ mod tests { // verify that `#[unsafe_no_drop_flag]` works as intended on a zero-size struct - static mut did_run: bool = false; + // NOTE: uncomment after snapshot, will not parse yet + //static mut did_run: bool = false; struct Foo { five: int } impl Drop for Foo { fn drop(&self) { assert_eq!(self.five, 5); - unsafe { - did_run = true; - } + // NOTE: uncomment after snapshot, will not parse yet + //unsafe { + //did_run = true; + //} } } @@ -190,6 +192,7 @@ mod tests { let _a = (NonCopyable, Foo { five: 5 }, NonCopyable); } - unsafe { assert_eq!(did_run, true); } + // NOTE: uncomment after snapshot, will not parse yet + //unsafe { assert_eq!(did_run, true); } } } From 659cd55e758094cd473033c28587d8429496c860 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 27 Jun 2013 18:48:12 -0400 Subject: [PATCH 09/10] add a tutorial on containers and iterators --- doc/tutorial-container.md | 207 ++++++++++++++++++++++++++++++++++++++ doc/tutorial.md | 127 +---------------------- mk/docs.mk | 10 ++ 3 files changed, 218 insertions(+), 126 deletions(-) create mode 100644 doc/tutorial-container.md diff --git a/doc/tutorial-container.md b/doc/tutorial-container.md new file mode 100644 index 0000000000000..66bd0b9c1319f --- /dev/null +++ b/doc/tutorial-container.md @@ -0,0 +1,207 @@ +% Containers and iterators + +# Containers + +The container traits are defined in the `std::container` module. + +## Unique and managed vectors + +Vectors have `O(1)` indexing and removal from the end, along with `O(1)` +amortized insertion. Vectors are the most common container in Rust, and are +flexible enough to fit many use cases. + +Vectors can also be sorted and used as efficient lookup tables with the +`std::vec::bsearch` function, if all the elements are inserted at one time and +deletions are unnecessary. + +## Maps and sets + +Maps are collections of unique keys with corresponding values, and sets are +just unique keys without a corresponding value. The `Map` and `Set` traits in +`std::container` define the basic interface. + +The standard library provides three owned map/set types: + +* `std::hashmap::HashMap` and `std::hashmap::HashSet`, requiring the keys to + implement `Eq` and `Hash` +* `std::trie::TrieMap` and `std::trie::TrieSet`, requiring the keys to be `uint` +* `extra::treemap::TreeMap` and `extra::treemap::TreeSet`, requiring the keys + to implement `TotalOrd` + +These maps do not use managed pointers so they can be sent between tasks as +long as the key and value types are sendable. Neither the key or value type has +to be copyable. + +The `TrieMap` and `TreeMap` maps are ordered, while `HashMap` uses an arbitrary +order. + +Each `HashMap` instance has a random 128-bit key to use with a keyed hash, +making the order of a set of keys in a given hash table randomized. Rust +provides a [SipHash](https://131002.net/siphash/) implementation for any type +implementing the `IterBytes` trait. + +## Double-ended queues + +The `extra::deque` module implements a double-ended queue with `O(1)` amortized +inserts and removals from both ends of the container. It also has `O(1)` +indexing like a vector. The contained elements are not required to be copyable, +and the queue will be sendable if the contained type is sendable. + +## Priority queues + +The `extra::priority_queue` module implements a queue ordered by a key. The +contained elements are not required to be copyable, and the queue will be +sendable if the contained type is sendable. + +Insertions have `O(log n)` time complexity and checking or popping the largest +element is `O(1)`. Converting a vector to a priority queue can be done +in-place, and has `O(n)` complexity. A priority queue can also be converted to +a sorted vector in-place, allowing it to be used for an `O(n log n)` in-place +heapsort. + +# Iterators + +## Iteration protocol + +The iteration protocol is defined by the `Iterator` trait in the +`std::iterator` module. The minimal implementation of the trait is a `next` +method, yielding the next element from an iterator object: + +~~~ +/// An infinite stream of zeroes +struct ZeroStream; + +impl Iterator for ZeroStream { + fn next(&mut self) -> Option { + Some(0) + } +} +~~~~ + +Reaching the end of the iterator is signalled by returning `None` instead of +`Some(item)`: + +~~~ +/// A stream of N zeroes +struct ZeroStream { + priv remaining: uint +} + +impl ZeroStream { + fn new(n: uint) -> ZeroStream { + ZeroStream { remaining: n } + } +} + +impl Iterator for ZeroStream { + fn next(&mut self) -> Option { + if self.remaining == 0 { + None + } else { + self.remaining -= 1; + Some(0) + } + } +} +~~~ + +## Container iterators + +Containers implement iteration over the contained elements by returning an +iterator object. For example, vectors have four iterators available: + +* `vector.iter()`, for immutable references to the elements +* `vector.mut_iter()`, for mutable references to the elements +* `vector.rev_iter()`, for immutable references to the elements in reverse order +* `vector.mut_rev_iter()`, for mutable references to the elements in reverse order + +### Freezing + +Unlike most other languages with external iterators, Rust has no *iterator +invalidation*. As long an iterator is still in scope, the compiler will prevent +modification of the container through another handle. + +~~~ +let mut xs = [1, 2, 3]; +{ + let _it = xs.iter(); + + // the vector is frozen for this scope, the compiler will statically + // prevent modification +} +// the vector becomes unfrozen again at the end of the scope +~~~ + +These semantics are due to most container iterators being implemented with `&` +and `&mut`. + +## Iterator adaptors + +The `IteratorUtil` trait implements common algorithms as methods extending +every `Iterator` implementation. For example, the `fold` method will accumulate +the items yielded by an `Iterator` into a single value: + +~~~ +let xs = [1, 9, 2, 3, 14, 12]; +let result = xs.iter().fold(0, |accumulator, item| accumulator - *item); +assert_eq!(result, -41); +~~~ + +Some adaptors return an adaptor object implementing the `Iterator` trait itself: + +~~~ +let xs = [1, 9, 2, 3, 14, 12]; +let ys = [5, 2, 1, 8]; +let sum = xs.iter().chain_(ys.iter()).fold(0, |a, b| a + *b); +assert_eq!(sum, 57); +~~~ + +Note that some adaptors like the `chain_` method above use a trailing +underscore to work around an issue with method resolve. The underscores will be +dropped when they become unnecessary. + +## For loops + +The `for` loop syntax is currently in transition, and will switch from the old +closure-based iteration protocol to iterator objects. For now, the `advance` +adaptor is required as a compatibility shim to use iterators with for loops. + +~~~ +let xs = [2, 3, 5, 7, 11, 13, 17]; + +// print out all the elements in the vector +for xs.iter().advance |x| { + println(x.to_str()) +} + +// print out all but the first 3 elements in the vector +for xs.iter().skip(3).advance |x| { + println(x.to_str()) +} +~~~ + +For loops are *often* used with a temporary iterator object, as above. They can +also advance the state of an iterator in a mutable location: + +~~~ +let xs = [1, 2, 3, 4, 5]; +let ys = ["foo", "bar", "baz", "foobar"]; + +// create an iterator yielding tuples of elements from both vectors +let mut it = xs.iter().zip(ys.iter()); + +// print out the pairs of elements up to (&3, &"baz") +for it.advance |(x, y)| { + println(fmt!("%d %s", *x, *y)); + + if *x == 3 { + break; + } +} + +// yield and print the last pair from the iterator +println(fmt!("last: %?", it.next())); + +// the iterator is now fully consumed +assert!(it.next().is_none()); +~~~ diff --git a/doc/tutorial.md b/doc/tutorial.md index 0701d61351cea..fc0f7b74a7af8 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1607,132 +1607,6 @@ do spawn { If you want to see the output of `debug!` statements, you will need to turn on `debug!` logging. To enable `debug!` logging, set the RUST_LOG environment variable to the name of your crate, which, for a file named `foo.rs`, will be `foo` (e.g., with bash, `export RUST_LOG=foo`). -## For loops - -> ***Note:*** The closure-based protocol used `for` loop is on the way out. The `for` loop will -> use iterator objects in the future instead. - -The most common way to express iteration in Rust is with a `for` -loop. Like `do`, `for` is a nice syntax for describing control flow -with closures. Additionally, within a `for` loop, `break`, `loop`, -and `return` work just as they do with `while` and `loop`. - -Consider again our `each` function, this time improved to return -immediately when the iteratee returns `false`: - -~~~~ -fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool { - let mut n = 0; - while n < v.len() { - if !op(&v[n]) { - return false; - } - n += 1; - } - return true; -} -~~~~ - -And using this function to iterate over a vector: - -~~~~ -# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool { -# let mut n = 0; -# while n < v.len() { -# if !op(&v[n]) { -# return false; -# } -# n += 1; -# } -# return true; -# } -each([2, 4, 8, 5, 16], |n| { - if *n % 2 != 0 { - println("found odd number!"); - false - } else { true } -}); -~~~~ - -With `for`, functions like `each` can be treated more -like built-in looping structures. When calling `each` -in a `for` loop, instead of returning `false` to break -out of the loop, you just write `break`. To skip ahead -to the next iteration, write `loop`. - -~~~~ -# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool { -# let mut n = 0; -# while n < v.len() { -# if !op(&v[n]) { -# return false; -# } -# n += 1; -# } -# return true; -# } -for each([2, 4, 8, 5, 16]) |n| { - if *n % 2 != 0 { - println("found odd number!"); - break; - } -} -~~~~ - -As an added bonus, you can use the `return` keyword, which is not -normally allowed in closures, in a block that appears as the body of a -`for` loop: the meaning of `return` in such a block is to return from -the enclosing function, not just the loop body. - -~~~~ -# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool { -# let mut n = 0; -# while n < v.len() { -# if !op(&v[n]) { -# return false; -# } -# n += 1; -# } -# return true; -# } -fn contains(v: &[int], elt: int) -> bool { - for each(v) |x| { - if (*x == elt) { return true; } - } - false -} -~~~~ - -Notice that, because `each` passes each value by borrowed pointer, -the iteratee needs to dereference it before using it. -In these situations it can be convenient to lean on Rust's -argument patterns to bind `x` to the actual value, not the pointer. - -~~~~ -# fn each(v: &[int], op: &fn(v: &int) -> bool) -> bool { -# let mut n = 0; -# while n < v.len() { -# if !op(&v[n]) { -# return false; -# } -# n += 1; -# } -# return true; -# } -# fn contains(v: &[int], elt: int) -> bool { - for each(v) |&x| { - if (x == elt) { return true; } - } -# false -# } -~~~~ - -`for` syntax only works with stack closures. - -> ***Note:*** This is, essentially, a special loop protocol: -> the keywords `break`, `loop`, and `return` work, in varying degree, -> with `while`, `loop`, `do`, and `for` constructs. - # Methods Methods are like functions except that they always begin with a special argument, @@ -2653,6 +2527,7 @@ tutorials on individual topics. * [Tasks and communication][tasks] * [Macros][macros] * [The foreign function interface][ffi] +* [Containers and iterators](tutorial-container.html) There is further documentation on the [wiki]. diff --git a/mk/docs.mk b/mk/docs.mk index 8470da7c07b2c..f11a3d24b8d25 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -99,6 +99,16 @@ doc/tutorial-macros.html: tutorial-macros.md doc/version_info.html \ --include-before-body=doc/version_info.html \ --output=$@ +DOCS += doc/tutorial-container.html +doc/tutorial-container.html: tutorial-container.md doc/version_info.html doc/rust.css + @$(call E, pandoc: $@) + $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \ + $(CFG_PANDOC) --standalone --toc \ + --section-divs --number-sections \ + --from=markdown --to=html --css=rust.css \ + --include-before-body=doc/version_info.html \ + --output=$@ + DOCS += doc/tutorial-ffi.html doc/tutorial-ffi.html: tutorial-ffi.md doc/version_info.html doc/rust.css @$(call E, pandoc: $@) From 3fbea161075aa21a217bd794e3f5cac7085e94ec Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 27 Jun 2013 16:39:06 -0700 Subject: [PATCH 10/10] Update man page --- man/rustc.1 | 69 ++++++++++++++--------------------------------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/man/rustc.1 b/man/rustc.1 index 9ed98c142943b..4e76749f707ee 100644 --- a/man/rustc.1 +++ b/man/rustc.1 @@ -1,4 +1,4 @@ -.TH RUSTC "1" "February 2013" "rustc 0.6" "User Commands" +.TH RUSTC "1" "July 2013" "rustc 0.7" "User Commands" .SH NAME rustc \- rust compiler .SH SYNOPSIS @@ -33,6 +33,12 @@ Add a directory to the library search path \fB\-\-lib\fR Compile a library crate .TP +\fB\-\-linker\fR LINKER +Program to use for linking instead of the default +.TP +\fB\-\-link-args\fR FLAGS +A space-separated list of flags passed to the linker +.TP \fB\-\-ls\fR List the symbols defined by a library crate .TP @@ -48,6 +54,11 @@ Write output to \fB\-\-opt\-level\fR LEVEL Optimize with possible levels 0-3 .TP +\fB\-\-passes\fR NAMES +Comma- or space-separated list of optimization passes. Overrides +the default passes for the optimization level. A value of 'list' +will list the available passes. +.TP \fB\-\-out\-dir\fR DIR Write output to compiler-chosen filename in .TP @@ -77,6 +88,12 @@ Target triple cpu-manufacturer-kernel[-os] to compile for (see http://sources.redhat.com/autobook/autobook/autobook_17.html for detail) .TP +\fB\-\-target-feature\fR TRIPLE +Target-specific attributes (see llc -mattr=help for detail) +.TP +\fB\-\-android-cross-path\fR PATH +The path to the Android NDK +.TP \fB\-W\fR help Print 'lint' options and default settings .TP @@ -94,56 +111,6 @@ Set lint forbidden .TP \fB\-Z\fR FLAG Set internal debugging options. Use "-Z help" to print available options. - -Available debug flags are: -.RS -.IP \[bu] -\fBverbose\fR - in general, enable more debug printouts -.IP \[bu] -\fBtime\-passes\fR - measure time of each rustc pass -.IP \[bu] -\fBcount\-llvm\-insns\fR - count where LLVM instrs originate -.IP \[bu] -\fBtime\-llvm\-passes\fR - measure time of each LLVM pass -.IP \[bu] -\fBtrans\-stats\fR - gather trans statistics -.IP \[bu] -\fBno\-asm\-comments\fR - omit comments when using \fI\-S\fR -.IP \[bu] -\fBno\-verify\fR - skip LLVM verification -.IP \[bu] -\fBtrace\fR - emit trace logs -.IP \[bu] -\fBcoherence\fR - perform coherence checking -.IP \[bu] -\fBborrowck\-stats\fR - gather borrowck statistics -.IP \[bu] -\fBborrowck\-note\-pure\fR - note where purity is req'd -.IP \[bu] -\fBborrowck\-note\-loan\fR - note where loans are req'd -.IP \[bu] -\fBno\-landing\-pads\fR - omit landing pads for unwinding -.IP \[bu] -\fBdebug\-llvm\fR - enable debug output from LLVM -.IP \[bu] -\fBcount\-type\-sizes\fR - count the sizes of aggregate types -.IP \[bu] -\fBmeta\-stats\fR - gather metadata statistics -.IP \[bu] -\fBno\-opt\fR - do not optimize, even if \fI\-O\fR is passed -.IP \[bu] -\fBno\-monomorphic\-collapse\fR - do not collapse template instantiations -.IP \[bu] -\fBgc\fR - Garbage collect shared data (experimental) -.IP \[bu] -\fBjit\fR - Execute using JIT (experimental) -.IP \[bu] -\fBextra\-debug\-info\fR - Extra debugging info (experimental) -.IP \[bu] -\fBdebug\-info\fR - Produce debug info (experimental) -.IP \[bu] -\fBstatic\fR - Use or produce static libraries or binaries (experimental) -.RE .TP \fB\-v\fR, \fB\-\-version\fR Print version info and exit