diff --git a/man/rustc.1 b/man/rustc.1 index 4db5be25b8272..9e92504e5a775 100644 --- a/man/rustc.1 +++ b/man/rustc.1 @@ -97,7 +97,7 @@ Set lint forbidden Set internal debugging options. Use "-Z help" to print available options. .TP \fB\-C\fR FLAG[=VAL], \fB\-\-codegen\fR FLAG[=VAL] -Set a codegen-related flag to the value specifie.d Use "-C help" to print +Set a codegen-related flag to the value specified. Use "-C help" to print available flags. See CODEGEN OPTIONS below .TP \fB\-v\fR, \fB\-\-version\fR @@ -119,7 +119,7 @@ is invoked. .TP \fBtarget-cpu\fR=help Selects a target processor. If the value is 'help', then a list of available -cpus is printed. +CPUs is printed. .TP \fBtarget-feature\fR='+feature1 -feature2' A space-separated list of features to enable or disable for the target. A @@ -132,7 +132,7 @@ cause rustc to print all known passes and exit. The passes specified are appended at the end of the normal pass manager. .TP \fBllvm-args\fR='-arg1 -arg2' -A space-separted list of argument to pass through to LLVM. +A space-separated list of arguments to pass through to LLVM. .TP \fBsave-temps\fR If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated diff --git a/mk/main.mk b/mk/main.mk index 685dd0b51829b..5c0bffda7be24 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -13,7 +13,7 @@ ###################################################################### # The version number -CFG_RELEASE_NUM=0.11 +CFG_RELEASE_NUM=0.11.0 CFG_RELEASE_LABEL=-pre ifndef CFG_ENABLE_NIGHTLY diff --git a/src/doc/README.md b/src/doc/README.md index 40980ee05604b..759a21af0ce5f 100644 --- a/src/doc/README.md +++ b/src/doc/README.md @@ -53,12 +53,12 @@ To generate .pot and .po files, do something like: ~~~~ po4a --copyright-holder="The Rust Project Developers" \ --package-name="Rust" \ - --package-version="0.11-pre" \ + --package-version="0.11.0-pre" \ -M UTF-8 -L UTF-8 \ src/doc/po4a.conf ~~~~ -(the version number must be changed if it is not 0.11-pre now.) +(the version number must be changed if it is not 0.11.0-pre now.) Now you can translate documents with .po files, commonly used with gettext. If you are not familiar with gettext-based translation, please read the online diff --git a/src/doc/po/ja/complement-cheatsheet.md.po b/src/doc/po/ja/complement-cheatsheet.md.po index 55dfacfe51e35..f387f3be9f363 100644 --- a/src/doc/po/ja/complement-cheatsheet.md.po +++ b/src/doc/po/ja/complement-cheatsheet.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/complement-lang-faq.md.po b/src/doc/po/ja/complement-lang-faq.md.po index 1f324ac2a9e8e..7744df579a0e6 100644 --- a/src/doc/po/ja/complement-lang-faq.md.po +++ b/src/doc/po/ja/complement-lang-faq.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/complement-project-faq.md.po b/src/doc/po/ja/complement-project-faq.md.po index 5060a77a128d6..0361c67b9dc36 100644 --- a/src/doc/po/ja/complement-project-faq.md.po +++ b/src/doc/po/ja/complement-project-faq.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/complement-usage-faq.md.po b/src/doc/po/ja/complement-usage-faq.md.po index aa3ed6effa00d..819e12ccd13a7 100644 --- a/src/doc/po/ja/complement-usage-faq.md.po +++ b/src/doc/po/ja/complement-usage-faq.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-02-03 08:13+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-conditions.md.po b/src/doc/po/ja/guide-conditions.md.po index 0e84562c22cdd..69f5ea1c73356 100644 --- a/src/doc/po/ja/guide-conditions.md.po +++ b/src/doc/po/ja/guide-conditions.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-container.md.po b/src/doc/po/ja/guide-container.md.po index 035a482cad9df..d20ad95687304 100644 --- a/src/doc/po/ja/guide-container.md.po +++ b/src/doc/po/ja/guide-container.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-ffi.md.po b/src/doc/po/ja/guide-ffi.md.po index 6c5f56bfedc91..fe7d1d911efdd 100644 --- a/src/doc/po/ja/guide-ffi.md.po +++ b/src/doc/po/ja/guide-ffi.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-lifetimes.md.po b/src/doc/po/ja/guide-lifetimes.md.po index 5d7246ede476e..44984c4a25fb7 100644 --- a/src/doc/po/ja/guide-lifetimes.md.po +++ b/src/doc/po/ja/guide-lifetimes.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-macros.md.po b/src/doc/po/ja/guide-macros.md.po index 5501b98f6e950..39d71dafd8c9f 100644 --- a/src/doc/po/ja/guide-macros.md.po +++ b/src/doc/po/ja/guide-macros.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-pointers.md.po b/src/doc/po/ja/guide-pointers.md.po index 0e421f5c7b14d..f1005caedd5c1 100644 --- a/src/doc/po/ja/guide-pointers.md.po +++ b/src/doc/po/ja/guide-pointers.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-runtime.md.po b/src/doc/po/ja/guide-runtime.md.po index c85dd997c4307..216a854db2a26 100644 --- a/src/doc/po/ja/guide-runtime.md.po +++ b/src/doc/po/ja/guide-runtime.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-02-03 08:13+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-tasks.md.po b/src/doc/po/ja/guide-tasks.md.po index 6fbb80f0fa56c..480d1351e5643 100644 --- a/src/doc/po/ja/guide-tasks.md.po +++ b/src/doc/po/ja/guide-tasks.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/guide-testing.md.po b/src/doc/po/ja/guide-testing.md.po index e4d123c8118d4..55a9e00f54d27 100644 --- a/src/doc/po/ja/guide-testing.md.po +++ b/src/doc/po/ja/guide-testing.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/index.md.po b/src/doc/po/ja/index.md.po index afe30505c8c20..6a2e512da2654 100644 --- a/src/doc/po/ja/index.md.po +++ b/src/doc/po/ja/index.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-14 21:02+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/po/ja/rustdoc.md.po b/src/doc/po/ja/rustdoc.md.po index d775929df5db2..eaf954333152e 100644 --- a/src/doc/po/ja/rustdoc.md.po +++ b/src/doc/po/ja/rustdoc.md.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Rust 0.11-pre\n" +"Project-Id-Version: Rust 0.11.0-pre\n" "POT-Creation-Date: 2014-02-03 08:13+0900\n" "PO-Revision-Date: 2014-01-13 12:01+0900\n" "Last-Translator: Automatically generated\n" diff --git a/src/doc/rust.md b/src/doc/rust.md index 6919bcfeb7a28..870b9dcb70bb3 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -208,7 +208,7 @@ The keywords are the following strings: ~~~~ {.notrust .keyword} as box break -crate +continue crate else enum extern false fn for if impl in @@ -2924,9 +2924,7 @@ while i < 10 { ### Infinite loops -The keyword `loop` in Rust appears both in _loop expressions_ and in _continue expressions_. -A loop expression denotes an infinite loop; -see [Continue expressions](#continue-expressions) for continue expressions. +A `loop` expression denotes an infinite loop. ~~~~ {.notrust .ebnf .gram} loop_expr : [ lifetime ':' ] "loop" '{' block '}'; @@ -2934,8 +2932,8 @@ loop_expr : [ lifetime ':' ] "loop" '{' block '}'; A `loop` expression may optionally have a _label_. If a label is present, -then labeled `break` and `loop` expressions nested within this loop may exit out of this loop or return control to its head. -See [Break expressions](#break-expressions). +then labeled `break` and `continue` expressions nested within this loop may exit out of this loop or return control to its head. +See [Break expressions](#break-expressions) and [Continue expressions](#continue-expressions). ### Break expressions @@ -2953,21 +2951,21 @@ but must enclose it. ### Continue expressions ~~~~ {.notrust .ebnf .gram} -continue_expr : "loop" [ lifetime ]; +continue_expr : "continue" [ lifetime ]; ~~~~ -A continue expression, written `loop`, also has an optional `label`. +A `continue` expression has an optional `label`. If the label is absent, -then executing a `loop` expression immediately terminates the current iteration of the innermost loop enclosing it, +then executing a `continue` expression immediately terminates the current iteration of the innermost loop enclosing it, returning control to the loop *head*. In the case of a `while` loop, the head is the conditional expression controlling the loop. In the case of a `for` loop, the head is the call-expression controlling the loop. -If the label is present, then `loop foo` returns control to the head of the loop with label `foo`, +If the label is present, then `continue foo` returns control to the head of the loop with label `foo`, which need not be the innermost label enclosing the `break` expression, but must enclose it. -A `loop` expression is only permitted in the body of a loop. +A `continue` expression is only permitted in the body of a loop. ### For expressions @@ -4008,26 +4006,15 @@ compiler must at some point make a choice between these two formats. With this in mind, the compiler follows these rules when determining what format of dependencies will be used: -1. If a dynamic library is being produced, then it is required for all upstream - Rust dependencies to also be dynamic. This is a limitation of the current - implementation of the linkage model. The reason behind this limitation is to - prevent multiple copies of the same upstream library from showing up, and in - the future it is planned to support a mixture of dynamic and static linking. - - When producing a dynamic library, the compiler will generate an error if an - upstream dependency could not be found, and also if an upstream dependency - could only be found in an `rlib` format. Remember that `staticlib` formats - are always ignored by `rustc` for crate-linking purposes. - -2. If a static library is being produced, all upstream dependencies are +1. If a static library is being produced, all upstream dependencies are required to be available in `rlib` formats. This requirement stems from the - same reasons that a dynamic library must have all dynamic dependencies. + reason that a dynamic library cannot be converted into a static format. Note that it is impossible to link in native dynamic dependencies to a static library, and in this case warnings will be printed about all unlinked native dynamic dependencies. -3. If an `rlib` file is being produced, then there are no restrictions on what +2. If an `rlib` file is being produced, then there are no restrictions on what format the upstream dependencies are available in. It is simply required that all upstream dependencies be available for reading metadata from. @@ -4035,18 +4022,29 @@ dependencies will be used: dependencies. It wouldn't be very efficient for all `rlib` files to contain a copy of `libstd.rlib`! -4. If an executable is being produced, then things get a little interesting. As - with the above limitations in dynamic and static libraries, it is required - for all upstream dependencies to be in the same format. The next question is - whether to prefer a dynamic or a static format. The compiler currently favors - static linking over dynamic linking, but this can be inverted with the `-C - prefer-dynamic` flag to the compiler. - - What this means is that first the compiler will attempt to find all upstream - dependencies as `rlib` files, and if successful, it will create a statically - linked executable. If an upstream dependency is missing as an `rlib` file, - then the compiler will force all dependencies to be dynamic and will generate - errors if dynamic versions could not be found. +3. If an executable is being produced and the `-C prefer-dynamic` flag is not + specified, then dependencies are first attempted to be found in the `rlib` + format. If some dependencies are not available in an rlib format, then + dynamic linking is attempted (see below). + +4. If a dynamic library or an executable that is being dynamically linked is + being produced, then the compiler will attempt to reconcile the available + dependencies in either the rlib or dylib format to create a final product. + + A major goal of the compiler is to ensure that a library never appears more + than once in any artifact. For example, if dynamic libraries B and C were + each statically linked to library A, then a crate could not link to B and C + together because there would be two copies of A. The compiler allows mixing + the rlib and dylib formats, but this restriction must be satisfied. + + The compiler currently implements no method of hinting what format a library + should be linked with. When dynamically linking, the compiler will attempt to + maximize dynamic dependencies while still allowing some dependencies to be + linked in via an rlib. + + For most situations, having all libraries available as a dylib is recommended + if dynamically linking. For other situations, the compiler will emit a + warning if it is unable to determine which formats to link each library with. In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for all compilation needs, and the other options are just available if more diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index b7122944ced66..454d5cf9ddfa7 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2155,7 +2155,7 @@ unless they contain references. * `Share` - Types that are *threadsafe* These are types that are safe to be used across several threads with access to -a `&T` pointer. `MutexArc` is an example of a *sharable* type with internal mutable data. +a `&T` pointer. `Mutex` is an example of a *sharable* type with internal mutable data. * `'static` - Non-borrowed types. These are types that do not contain any data whose lifetime is bound to diff --git a/src/etc/check-binaries.py b/src/etc/check-binaries.py index ebd2a9376b6b0..91c01b178075d 100755 --- a/src/etc/check-binaries.py +++ b/src/etc/check-binaries.py @@ -1,4 +1,6 @@ -# Copyright 2013 The Rust Project Developers. See the COPYRIGHT +#!/usr/bin/env python +# +# Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. # diff --git a/src/etc/check-summary.py b/src/etc/check-summary.py index c86e926003ff6..55428a6fcc4b6 100755 --- a/src/etc/check-summary.py +++ b/src/etc/check-summary.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python +# # Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. diff --git a/src/etc/emacs/rust-mode.el b/src/etc/emacs/rust-mode.el index f9142cd127686..175592d792bbf 100644 --- a/src/etc/emacs/rust-mode.el +++ b/src/etc/emacs/rust-mode.el @@ -217,7 +217,7 @@ 1 font-lock-preprocessor-face) ;; Syntax extension invocations like `foo!`, highlight including the ! - (,(concat (rust-re-grab (concat rust-re-ident "!")) "[({[:space:]]") + (,(concat (rust-re-grab (concat rust-re-ident "!")) "[({[:space:][]") 1 font-lock-preprocessor-face) ;; Field names like `foo:`, highlight excluding the : diff --git a/src/etc/extract_grammar.py b/src/etc/extract_grammar.py index 4e0fbe944988c..53781652902f5 100755 --- a/src/etc/extract_grammar.py +++ b/src/etc/extract_grammar.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python +# # Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. diff --git a/src/etc/get-snapshot.py b/src/etc/get-snapshot.py index faa21ca74df09..ec87c321f56f9 100755 --- a/src/etc/get-snapshot.py +++ b/src/etc/get-snapshot.py @@ -1,4 +1,6 @@ -# Copyright 2011-2013 The Rust Project Developers. See the COPYRIGHT +#!/usr/bin/env python +# +# Copyright 2011-2014 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. # diff --git a/src/etc/kate/rust.xml b/src/etc/kate/rust.xml index c28107fe9fa26..c0289fc6d83e1 100644 --- a/src/etc/kate/rust.xml +++ b/src/etc/kate/rust.xml @@ -7,7 +7,7 @@ ]> - + fn diff --git a/src/etc/make-snapshot.py b/src/etc/make-snapshot.py index fec78fc1aafdf..31a69a581e4e2 100755 --- a/src/etc/make-snapshot.py +++ b/src/etc/make-snapshot.py @@ -1,4 +1,6 @@ -# Copyright 2011-2013 The Rust Project Developers. See the COPYRIGHT +#!/usr/bin/env python +# +# Copyright 2011-2014 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. # diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 61b87c77163af..f9c27ae6ae59d 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -15,7 +15,7 @@ //! of individual objects while the arena itself is still alive. The benefit //! of an arena is very fast allocation; just a pointer bump. -#![crate_id = "arena#0.11-pre"] +#![crate_id = "arena#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 2121e129c3523..d45308bf193f4 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -12,7 +12,7 @@ * Collection types. */ -#![crate_id = "collections#0.11-pre"] +#![crate_id = "collections#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 41719d1354a16..06bd46fe9ad97 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -10,7 +10,7 @@ //! The Rust core library -#![crate_id = "core#0.11-pre"] +#![crate_id = "core#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/libcore/option.rs b/src/libcore/option.rs index fd6d174a7036e..886b7315152b8 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -30,20 +30,23 @@ //! of a value and take action, always accounting for the `None` case. //! //! ``` -//! # // FIXME This is not the greatest first example -//! // cow_says contains the word "moo" -//! let cow_says = Some("moo"); -//! // dog_says does not contain a value -//! let dog_says: Option<&str> = None; +//! fn divide(numerator: f64, denominator: f64) -> Option { +//! if denominator == 0.0 { +//! None +//! } else { +//! Some(numerator / denominator) +//! } +//! } +//! +//! // The return value of the function is an option +//! let result = divide(2.0, 3.0); //! //! // Pattern match to retrieve the value -//! match (cow_says, dog_says) { -//! (Some(cow_words), Some(dog_words)) => { -//! println!("Cow says {} and dog says {}!", cow_words, dog_words); -//! } -//! (Some(cow_words), None) => println!("Cow says {}", cow_words), -//! (None, Some(dog_words)) => println!("Dog says {}", dog_words), -//! (None, None) => println!("Cow and dog are suspiciously silent") +//! match result { +//! // The division was valid +//! Some(x) => println!("Result: {}", x), +//! // The division was invalid +//! None => println!("Cannot divide by 0") //! } //! ``` //! diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 11309b44a6006..d08e5492c82ad 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -505,7 +505,7 @@ pub trait ImmutableVector<'a, T> { fn bsearch(&self, f: |&T| -> Ordering) -> Option; /** - * Returns a mutable reference to the first element in this slice + * Returns an immutable reference to the first element in this slice * and adjusts the slice in place so that it no longer contains * that element. O(1). * @@ -523,7 +523,7 @@ pub trait ImmutableVector<'a, T> { fn shift_ref(&mut self) -> Option<&'a T>; /** - * Returns a mutable reference to the last element in this slice + * Returns an immutable reference to the last element in this slice * and adjusts the slice in place so that it no longer contains * that element. O(1). * @@ -693,18 +693,22 @@ impl<'a,T> ImmutableVector<'a, T> for &'a [T] { } fn shift_ref(&mut self) -> Option<&'a T> { - if self.len() == 0 { return None; } unsafe { let s: &mut Slice = transmute(self); - Some(&*raw::shift_ptr(s)) + match raw::shift_ptr(s) { + Some(p) => Some(&*p), + None => None + } } } fn pop_ref(&mut self) -> Option<&'a T> { - if self.len() == 0 { return None; } unsafe { let s: &mut Slice = transmute(self); - Some(&*raw::pop_ptr(s)) + match raw::pop_ptr(s) { + Some(p) => Some(&*p), + None => None + } } } } @@ -1059,22 +1063,26 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] { } fn mut_shift_ref(&mut self) -> Option<&'a mut T> { - if self.len() == 0 { return None; } unsafe { let s: &mut Slice = transmute(self); - // FIXME #13933: this `&` -> `&mut` cast is a little - // dubious - Some(&mut *(raw::shift_ptr(s) as *mut _)) + match raw::shift_ptr(s) { + // FIXME #13933: this `&` -> `&mut` cast is a little + // dubious + Some(p) => Some(&mut *(p as *mut _)), + None => None, + } } } fn mut_pop_ref(&mut self) -> Option<&'a mut T> { - if self.len() == 0 { return None; } unsafe { let s: &mut Slice = transmute(self); - // FIXME #13933: this `&` -> `&mut` cast is a little - // dubious - Some(&mut *(raw::pop_ptr(s) as *mut _)) + match raw::pop_ptr(s) { + // FIXME #13933: this `&` -> `&mut` cast is a little + // dubious + Some(p) => Some(&mut *(p as *mut _)), + None => None, + } } } @@ -1165,6 +1173,7 @@ pub mod raw { use iter::Iterator; use ptr::RawPtr; use raw::Slice; + use option::{None, Option, Some}; /** * Form a slice from a pointer and length (as a number of units, @@ -1198,27 +1207,29 @@ pub mod raw { /** * Returns a pointer to first element in slice and adjusts - * slice so it no longer contains that element. Fails if - * slice is empty. O(1). + * slice so it no longer contains that element. Returns None + * if the slice is empty. O(1). */ - pub unsafe fn shift_ptr(slice: &mut Slice) -> *T { - if slice.len == 0 { fail!("shift on empty slice"); } + #[inline] + pub unsafe fn shift_ptr(slice: &mut Slice) -> Option<*T> { + if slice.len == 0 { return None; } let head: *T = slice.data; slice.data = slice.data.offset(1); slice.len -= 1; - head + Some(head) } /** * Returns a pointer to last element in slice and adjusts - * slice so it no longer contains that element. Fails if - * slice is empty. O(1). + * slice so it no longer contains that element. Returns None + * if the slice is empty. O(1). */ - pub unsafe fn pop_ptr(slice: &mut Slice) -> *T { - if slice.len == 0 { fail!("pop on empty slice"); } + #[inline] + pub unsafe fn pop_ptr(slice: &mut Slice) -> Option<*T> { + if slice.len == 0 { return None; } let tail: *T = slice.data.offset((slice.len - 1) as int); slice.len -= 1; - tail + Some(tail) } } diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index ea5ffb9965a0f..391dd01e80812 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -14,7 +14,7 @@ Simple compression */ -#![crate_id = "flate#0.11-pre"] +#![crate_id = "flate#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 91b3fefdd02ae..2151e53548008 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -14,7 +14,7 @@ //! Parsing does not happen at runtime: structures of `std::fmt::rt` are //! generated instead. -#![crate_id = "fmt_macros#0.11-pre"] +#![crate_id = "fmt_macros#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] #![crate_type = "dylib"] diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index 34ff35a3ad629..93aa978add5c1 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -39,7 +39,7 @@ fn main() { */ -#![crate_id = "fourcc#0.11-pre"] +#![crate_id = "fourcc#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 3de1dde240c97..3ac01681be1a7 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -76,7 +76,7 @@ //! } //! ~~~ -#![crate_id = "getopts#0.11-pre"] +#![crate_id = "getopts#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libglob/lib.rs b/src/libglob/lib.rs index 05dd1bad569f5..cd6b61049e01d 100644 --- a/src/libglob/lib.rs +++ b/src/libglob/lib.rs @@ -23,7 +23,7 @@ * `glob`/`fnmatch` functions. */ -#![crate_id = "glob#0.11-pre"] +#![crate_id = "glob#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index f2d4d84f601f5..06ca5d2637738 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -266,7 +266,7 @@ pub fn main() { */ -#![crate_id = "graphviz#0.11-pre"] +#![crate_id = "graphviz#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index cd598346fc3e4..eec413635a50a 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -197,7 +197,7 @@ //! pool.shutdown(); //! ``` -#![crate_id = "green#0.11-pre"] +#![crate_id = "green#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] #![crate_type = "dylib"] diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs index fac4eaf9fe585..ac64f04c6fdb0 100644 --- a/src/libhexfloat/lib.rs +++ b/src/libhexfloat/lib.rs @@ -36,7 +36,7 @@ fn main() { */ -#![crate_id = "hexfloat#0.11-pre"] +#![crate_id = "hexfloat#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index 7258569e43315..696914f4c5a49 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -9,7 +9,7 @@ // except according to those terms. #![feature(globs)] -#![crate_id = "libc#0.11-pre"] +#![crate_id = "libc#0.11.0-pre"] #![experimental] #![no_std] // we don't need std, and we can't have std, since it doesn't exist // yet. std depends on us. diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index dbff4150d7274..ac69fc37d81b1 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -105,7 +105,7 @@ if logging is disabled, none of the components of the log will be executed. */ -#![crate_id = "log#0.11-pre"] +#![crate_id = "log#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] #![crate_type = "dylib"] diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index 87225a10e76d5..c2b69483fa1e0 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -166,6 +166,14 @@ impl rtio::RtioFileStream for FileDesc { libc::ftruncate(self.fd(), offset as libc::off_t) })) } + + fn fstat(&mut self) -> IoResult { + let mut stat: libc::stat = unsafe { mem::uninit() }; + match retry(|| unsafe { libc::fstat(self.fd(), &mut stat) }) { + 0 => Ok(mkstat(&stat)), + _ => Err(super::last_error()), + } + } } impl rtio::RtioPipe for FileDesc { @@ -317,6 +325,10 @@ impl rtio::RtioFileStream for CFile { fn truncate(&mut self, offset: i64) -> Result<(), IoError> { self.flush().and_then(|()| self.fd.truncate(offset)) } + + fn fstat(&mut self) -> IoResult { + self.flush().and_then(|()| self.fd.fstat()) + } } impl Drop for CFile { @@ -455,9 +467,7 @@ pub fn link(src: &CString, dst: &CString) -> IoResult<()> { })) } -fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { - let path = unsafe { CString::new(path.with_ref(|p| p), false) }; - +fn mkstat(stat: &libc::stat) -> io::FileStat { // FileStat times are in milliseconds fn mktime(secs: u64, nsecs: u64) -> u64 { secs * 1000 + nsecs / 1000000 } @@ -481,7 +491,6 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { fn gen(_stat: &libc::stat) -> u64 { 0 } io::FileStat { - path: Path::new(path), size: stat.st_size as u64, kind: kind, perm: unsafe { @@ -508,7 +517,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { pub fn stat(p: &CString) -> IoResult { let mut stat: libc::stat = unsafe { mem::uninit() }; match retry(|| unsafe { libc::stat(p.with_ref(|p| p), &mut stat) }) { - 0 => Ok(mkstat(&stat, p)), + 0 => Ok(mkstat(&stat)), _ => Err(super::last_error()), } } @@ -516,7 +525,7 @@ pub fn stat(p: &CString) -> IoResult { pub fn lstat(p: &CString) -> IoResult { let mut stat: libc::stat = unsafe { mem::uninit() }; match retry(|| unsafe { libc::lstat(p.with_ref(|p| p), &mut stat) }) { - 0 => Ok(mkstat(&stat, p)), + 0 => Ok(mkstat(&stat)), _ => Err(super::last_error()), } } diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs index 707b0c0cf3fd5..d721e1d67f1b9 100644 --- a/src/libnative/io/file_win32.rs +++ b/src/libnative/io/file_win32.rs @@ -197,6 +197,14 @@ impl rtio::RtioFileStream for FileDesc { let _ = self.seek(orig_pos as i64, io::SeekSet); return ret; } + + fn fstat(&mut self) -> IoResult { + let mut stat: libc::stat = unsafe { mem::uninit() }; + match unsafe { libc::fstat(self.fd(), &mut stat) } { + 0 => Ok(mkstat(&stat)), + _ => Err(super::last_error()), + } + } } impl rtio::RtioPipe for FileDesc { @@ -471,8 +479,7 @@ pub fn link(src: &CString, dst: &CString) -> IoResult<()> { })) } -fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { - let path = unsafe { CString::new(path.with_ref(|p| p), false) }; +fn mkstat(stat: &libc::stat) -> io::FileStat { let kind = match (stat.st_mode as c_int) & libc::S_IFMT { libc::S_IFREG => io::TypeFile, libc::S_IFDIR => io::TypeDirectory, @@ -483,7 +490,6 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { }; io::FileStat { - path: Path::new(path), size: stat.st_size as u64, kind: kind, perm: unsafe { @@ -511,7 +517,7 @@ pub fn stat(p: &CString) -> IoResult { let mut stat: libc::stat = unsafe { mem::uninit() }; as_utf16_p(p.as_str().unwrap(), |up| { match unsafe { libc::wstat(up, &mut stat) } { - 0 => Ok(mkstat(&stat, p)), + 0 => Ok(mkstat(&stat)), _ => Err(super::last_error()), } }) diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 3d5f4151a4b7e..05cf415ec78b0 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -41,7 +41,7 @@ //! } //! ``` -#![crate_id = "native#0.11-pre"] +#![crate_id = "native#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] #![crate_type = "dylib"] diff --git a/src/libnum/lib.rs b/src/libnum/lib.rs index e68c5f227289a..20d694d0d0939 100644 --- a/src/libnum/lib.rs +++ b/src/libnum/lib.rs @@ -10,7 +10,7 @@ #![feature(macro_rules)] -#![crate_id = "num#0.11-pre"] +#![crate_id = "num#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 006c4d89e2f85..0486d200691b9 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -62,7 +62,7 @@ println!("{:?}", tuple_ptr) ``` */ -#![crate_id = "rand#0.11-pre"] +#![crate_id = "rand#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "dylib"] #![crate_type = "rlib"] diff --git a/src/libregex/lib.rs b/src/libregex/lib.rs index b94271622d7e9..93254c773ffac 100644 --- a/src/libregex/lib.rs +++ b/src/libregex/lib.rs @@ -352,7 +352,7 @@ //! characters in the search text and `m` is the number of instructions in a //! compiled expression. -#![crate_id = "regex#0.11-pre"] +#![crate_id = "regex#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![experimental] diff --git a/src/libregex_macros/lib.rs b/src/libregex_macros/lib.rs index c2d3872950f0b..9d25adacd8108 100644 --- a/src/libregex_macros/lib.rs +++ b/src/libregex_macros/lib.rs @@ -11,7 +11,7 @@ //! This crate provides the `regex!` macro. Its use is documented in the //! `regex` crate. -#![crate_id = "regex_macros#0.11-pre"] +#![crate_id = "regex_macros#0.11.0-pre"] #![crate_type = "dylib"] #![experimental] #![license = "MIT/ASL2"] diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index f5f85d748bb27..51bdf9ef9edd5 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -193,7 +193,7 @@ pub fn phase_2_configure_and_expand(sess: &Session, krate = time(time_passes, "expansion", krate, |krate| { // Windows dlls do not have rpaths, so they don't know how to find their - // dependencies. It's up to use to tell the system where to find all the + // dependencies. It's up to us to tell the system where to find all the // dependent dlls. Note that this uses cfg!(windows) as opposed to // targ_cfg because syntax extensions are always loaded for the host // compiler, not for the target. diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index da1f7bce89bc9..66bf6a77f8cfc 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -22,7 +22,7 @@ use syntax::parse::token::InternedString; use syntax::parse::token; use syntax::util::small_vector::SmallVector; -pub static VERSION: &'static str = "0.11-pre"; +pub static VERSION: &'static str = "0.11.0-pre"; pub fn maybe_inject_crates_ref(sess: &Session, krate: ast::Crate) -> ast::Crate { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index d11c8898ad4cd..d3b5fb1ca470c 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -18,7 +18,7 @@ This API is completely unstable and subject to change. */ -#![crate_id = "rustc#0.11-pre"] +#![crate_id = "rustc#0.11.0-pre"] #![comment = "The Rust compiler"] #![license = "MIT/ASL2"] #![crate_type = "dylib"] diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 288e6ebffbaa3..0883d25770ef7 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1775,6 +1775,7 @@ impl<'a> fmt::Show for Sidebar<'a> { try!(block(fmt.buf, "enum", "Enums", it, cx)); try!(block(fmt.buf, "trait", "Traits", it, cx)); try!(block(fmt.buf, "fn", "Functions", it, cx)); + try!(block(fmt.buf, "macro", "Macros", it, cx)); Ok(()) } } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index cde4eac488fb5..6aee86fd68441 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "rustdoc#0.11-pre"] +#![crate_id = "rustdoc#0.11.0-pre"] #![desc = "rustdoc, the Rust documentation extractor"] #![license = "MIT/ASL2"] #![crate_type = "dylib"] diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 9ba8e1e9a963a..a449181747933 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -14,6 +14,7 @@ use std::cmp; use std::strbuf::StrBuf; use std::uint; use syntax::ast; +use syntax::ast_util; use clean; use clean::Item; @@ -206,7 +207,7 @@ impl<'a> fold::DocFolder for ImplStripper<'a> { match imp.trait_ { Some(clean::ResolvedPath{ did, .. }) => { let ImplStripper(s) = *self; - if !s.contains(&did.node) { + if ast_util::is_local(did) && !s.contains(&did.node) { return None; } } diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs index cd56e76aff667..06271e61ce7a0 100644 --- a/src/librustuv/file.rs +++ b/src/librustuv/file.rs @@ -70,6 +70,12 @@ impl FsRequest { }).map(|req| req.mkstat()) } + pub fn fstat(loop_: &Loop, fd: c_int) -> Result { + execute(|req, cb| unsafe { + uvll::uv_fs_fstat(loop_.handle, req, fd, cb) + }).map(|req| req.mkstat()) + } + pub fn write(loop_: &Loop, fd: c_int, buf: &[u8], offset: i64) -> Result<(), UvError> { @@ -262,8 +268,6 @@ impl FsRequest { } pub fn mkstat(&self) -> FileStat { - let path = unsafe { uvll::get_path_from_fs_req(self.req) }; - let path = unsafe { Path::new(CString::new(path, false)) }; let stat = self.get_stat(); fn to_msec(stat: uvll::uv_timespec_t) -> u64 { // Be sure to cast to u64 first to prevent overflowing if the tv_sec @@ -279,7 +283,6 @@ impl FsRequest { _ => io::TypeUnknown, }; FileStat { - path: path, size: stat.st_size as u64, kind: kind, perm: unsafe { @@ -463,6 +466,11 @@ impl rtio::RtioFileStream for FileWatcher { let r = FsRequest::truncate(&self.loop_, self.fd, offset); r.map_err(uv_error_to_io_error) } + + fn fstat(&mut self) -> Result { + let _m = self.fire_homing_missile(); + FsRequest::fstat(&self.loop_, self.fd).map_err(uv_error_to_io_error) + } } #[cfg(test)] @@ -537,6 +545,10 @@ mod test { assert!(result.is_ok()); assert_eq!(result.unwrap().size, 5); + let result = FsRequest::fstat(l(), file.fd); + assert!(result.is_ok()); + assert_eq!(result.unwrap().size, 5); + fn free(_: T) {} free(file); diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 6568254237620..c9bff2e80bfe6 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -34,7 +34,7 @@ via `close` and `delete` methods. */ -#![crate_id = "rustuv#0.11-pre"] +#![crate_id = "rustuv#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] #![crate_type = "dylib"] diff --git a/src/libsemver/lib.rs b/src/libsemver/lib.rs index 2f5c6309265c4..2707ccd4f0886 100644 --- a/src/libsemver/lib.rs +++ b/src/libsemver/lib.rs @@ -28,7 +28,7 @@ //! An example version number with all five components is //! `0.8.1-rc.3.0+20130922.linux`. -#![crate_id = "semver#0.11-pre"] +#![crate_id = "semver#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 7d50ad86aeb00..209a1439dda56 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -14,7 +14,7 @@ Core encoding and decoding interfaces. */ -#![crate_id = "serialize#0.11-pre"] +#![crate_id = "serialize#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 125b4ddad88f4..a497ffd40a070 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -214,6 +214,11 @@ impl File { pub fn eof(&self) -> bool { self.last_nread == 0 } + + /// Queries information about the underlying file. + pub fn stat(&mut self) -> IoResult { + self.fd.fstat() + } } /// Unlink a file from the underlying filesystem. @@ -887,9 +892,12 @@ mod test { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_file.txt"); { - let mut fs = File::open_mode(filename, Open, ReadWrite); + let mut fs = check!(File::open_mode(filename, Open, ReadWrite)); let msg = "hw"; fs.write(msg.as_bytes()).unwrap(); + + let fstat_res = check!(fs.stat()); + assert_eq!(fstat_res.kind, io::TypeFile); } let stat_res_fn = check!(stat(filename)); assert_eq!(stat_res_fn.kind, io::TypeFile); @@ -1228,12 +1236,12 @@ mod test { check!(file.fsync()); // Do some simple things with truncation - assert_eq!(check!(stat(&path)).size, 3); + assert_eq!(check!(file.stat()).size, 3); check!(file.truncate(10)); - assert_eq!(check!(stat(&path)).size, 10); + assert_eq!(check!(file.stat()).size, 10); check!(file.write(bytes!("bar"))); check!(file.fsync()); - assert_eq!(check!(stat(&path)).size, 10); + assert_eq!(check!(file.stat()).size, 10); assert_eq!(check!(File::open(&path).read_to_end()), (Vec::from_slice(bytes!("foobar", 0, 0, 0, 0)))); @@ -1241,10 +1249,10 @@ mod test { // Ensure that the intermediate zeroes are all filled in (we're seeked // past the end of the file). check!(file.truncate(2)); - assert_eq!(check!(stat(&path)).size, 2); + assert_eq!(check!(file.stat()).size, 2); check!(file.write(bytes!("wut"))); check!(file.fsync()); - assert_eq!(check!(stat(&path)).size, 9); + assert_eq!(check!(file.stat()).size, 9); assert_eq!(check!(File::open(&path).read_to_end()), (Vec::from_slice(bytes!("fo", 0, 0, 0, 0, "wut")))); drop(file); diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 37edab9991598..3c32b7ca802d7 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -228,7 +228,6 @@ use ops::{BitOr, BitAnd, Sub}; use option::{Option, Some, None}; use os; use owned::Box; -use path::Path; use result::{Ok, Err, Result}; use slice::{Vector, MutableVector, ImmutableVector}; use str::{StrSlice, StrAllocating}; @@ -1510,14 +1509,11 @@ pub enum FileType { /// Err(e) => fail!("couldn't read foo.txt: {}", e), /// }; /// -/// println!("path: {}", info.path.display()); /// println!("byte size: {}", info.size); /// # } /// ``` #[deriving(Hash)] pub struct FileStat { - /// The path that this stat structure is describing - pub path: Path, /// The size of the file, in bytes pub size: u64, /// The kind of file this path points to (directory, file, pipe, etc.) diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 3babef6126e8f..529fd25dc50e9 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -140,6 +140,7 @@ pub struct ProcessConfig<'a> { } /// The output of a finished process. +#[deriving(Eq, TotalEq, Clone)] pub struct ProcessOutput { /// The status (exit code) of the process. pub status: ProcessExit, diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8f0c1e4130971..34ed7933c397f 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -96,7 +96,7 @@ //! all the standard macros, such as `assert!`, `fail!`, `println!`, //! and `format!`, also available to all Rust code. -#![crate_id = "std#0.11-pre"] +#![crate_id = "std#0.11.0-pre"] #![comment = "The Rust standard library"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 8fbcd529b63b7..ad834f2b4d44b 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -30,20 +30,23 @@ //! of a value and take action, always accounting for the `None` case. //! //! ``` -//! # // FIXME This is not the greatest first example -//! // cow_says contains the word "moo" -//! let cow_says = Some("moo"); -//! // dog_says does not contain a value -//! let dog_says: Option<&str> = None; +//! fn divide(numerator: f64, denominator: f64) -> Option { +//! if denominator == 0.0 { +//! None +//! } else { +//! Some(numerator / denominator) +//! } +//! } +//! +//! // The return value of the function is an option +//! let result = divide(2.0, 3.0); //! //! // Pattern match to retrieve the value -//! match (cow_says, dog_says) { -//! (Some(cow_words), Some(dog_words)) => { -//! println!("Cow says {} and dog says {}!", cow_words, dog_words); -//! } -//! (Some(cow_words), None) => println!("Cow says {}", cow_words), -//! (None, Some(dog_words)) => println!("Dog says {}", dog_words), -//! (None, None) => println!("Cow and dog are suspiciously silent") +//! match result { +//! // The division was valid +//! Some(x) => println!("Result: {}", x), +//! // The division was invalid +//! None => println!("Cannot divide by 0") //! } //! ``` //! diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 134cfa89a37f3..f7324dc08b6d5 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -95,13 +95,12 @@ pub fn getcwd() -> Path { #[cfg(windows)] pub mod win32 { - use iter::Iterator; use libc::types::os::arch::extra::DWORD; use libc; use option::{None, Option, Expect}; use option; use os::TMPBUF_SZ; - use slice::{MutableVector, ImmutableVector, OwnedVector}; + use slice::{MutableVector, ImmutableVector}; use str::{StrSlice, StrAllocating}; use str; use vec::Vec; @@ -142,7 +141,7 @@ pub mod win32 { } pub fn as_utf16_p(s: &str, f: |*u16| -> T) -> T { - let mut t = s.to_utf16().move_iter().collect::>(); + let mut t = s.to_utf16(); // Null terminate before passing on. t.push(0u16); f(t.as_ptr()) diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs index bc3a483f30d2b..d23d327d55881 100644 --- a/src/libstd/rt/rtio.rs +++ b/src/libstd/rt/rtio.rs @@ -269,6 +269,7 @@ pub trait RtioFileStream { fn fsync(&mut self) -> IoResult<()>; fn datasync(&mut self) -> IoResult<()>; fn truncate(&mut self, offset: i64) -> IoResult<()>; + fn fstat(&mut self) -> IoResult; } pub trait RtioProcess { diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs index 58bd837104c58..e5d506301e370 100644 --- a/src/libsync/lib.rs +++ b/src/libsync/lib.rs @@ -12,7 +12,7 @@ * Concurrency-enabled mechanisms and primitives. */ -#![crate_id = "sync#0.11-pre"] +#![crate_id = "sync#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 5e1d988df5c30..1086295d427c9 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -18,7 +18,7 @@ This API is completely unstable and subject to change. */ -#![crate_id = "syntax#0.11-pre"] +#![crate_id = "syntax#0.11.0-pre"] #![license = "MIT/ASL2"] #![crate_type = "dylib"] #![crate_type = "rlib"] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 46a8960c3bece..2201b08f2ca48 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -125,7 +125,11 @@ enum ItemOrViewItem { IoviViewItem(ViewItem) } -/* The expr situation is not as complex as I thought it would be. + +// Possibly accept an `INTERPOLATED` expression (a pre-parsed expression +// dropped into the token stream, which happens while parsing the +// result of macro expansion) +/* Placement of these is not as complex as I feared it would be. The important thing is to make sure that lookahead doesn't balk at INTERPOLATED tokens */ macro_rules! maybe_whole_expr ( @@ -135,7 +139,7 @@ macro_rules! maybe_whole_expr ( INTERPOLATED(token::NtPath(ref pt)) => Some((**pt).clone()), _ => None, }; - let ret = match ($p).token { + let found = match ($p).token { INTERPOLATED(token::NtExpr(e)) => { Some(e) } @@ -145,7 +149,7 @@ macro_rules! maybe_whole_expr ( } _ => None }; - match ret { + match found { Some(e) => { $p.bump(); return e; @@ -156,16 +160,17 @@ macro_rules! maybe_whole_expr ( ) ) +// As above, but for things other than expressions macro_rules! maybe_whole ( ($p:expr, $constructor:ident) => ( { - let __found__ = match ($p).token { + let found = match ($p).token { INTERPOLATED(token::$constructor(_)) => { Some(($p).bump_and_get()) } _ => None }; - match __found__ { + match found { Some(INTERPOLATED(token::$constructor(x))) => { return x.clone() } @@ -175,13 +180,13 @@ macro_rules! maybe_whole ( ); (no_clone $p:expr, $constructor:ident) => ( { - let __found__ = match ($p).token { + let found = match ($p).token { INTERPOLATED(token::$constructor(_)) => { Some(($p).bump_and_get()) } _ => None }; - match __found__ { + match found { Some(INTERPOLATED(token::$constructor(x))) => { return x } @@ -191,13 +196,13 @@ macro_rules! maybe_whole ( ); (deref $p:expr, $constructor:ident) => ( { - let __found__ = match ($p).token { + let found = match ($p).token { INTERPOLATED(token::$constructor(_)) => { Some(($p).bump_and_get()) } _ => None }; - match __found__ { + match found { Some(INTERPOLATED(token::$constructor(x))) => { return (*x).clone() } @@ -207,13 +212,13 @@ macro_rules! maybe_whole ( ); (Some $p:expr, $constructor:ident) => ( { - let __found__ = match ($p).token { + let found = match ($p).token { INTERPOLATED(token::$constructor(_)) => { Some(($p).bump_and_get()) } _ => None }; - match __found__ { + match found { Some(INTERPOLATED(token::$constructor(x))) => { return Some(x.clone()), } @@ -223,13 +228,13 @@ macro_rules! maybe_whole ( ); (iovi $p:expr, $constructor:ident) => ( { - let __found__ = match ($p).token { + let found = match ($p).token { INTERPOLATED(token::$constructor(_)) => { Some(($p).bump_and_get()) } _ => None }; - match __found__ { + match found { Some(INTERPOLATED(token::$constructor(x))) => { return IoviItem(x.clone()) } @@ -239,13 +244,13 @@ macro_rules! maybe_whole ( ); (pair_empty $p:expr, $constructor:ident) => ( { - let __found__ = match ($p).token { + let found = match ($p).token { INTERPOLATED(token::$constructor(_)) => { Some(($p).bump_and_get()) } _ => None }; - match __found__ { + match found { Some(INTERPOLATED(token::$constructor(x))) => { return (Vec::new(), x) } diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 416c924310627..9918d45e0a55d 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -10,7 +10,7 @@ //! Simple ANSI color library -#![crate_id = "term#0.11-pre"] +#![crate_id = "term#0.11.0-pre"] #![comment = "Simple ANSI color library"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 4040e079224fd..ca09d2cce6be6 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -23,7 +23,7 @@ // running tests while providing a base that other test frameworks may // build off of. -#![crate_id = "test#0.11-pre"] +#![crate_id = "test#0.11.0-pre"] #![comment = "Rust internal test library only used by rustc"] #![license = "MIT/ASL2"] #![crate_type = "rlib"] diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 3a7b8a4d85cad..3cfc611f34c3f 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "time#0.11-pre"] +#![crate_id = "time#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/liburl/lib.rs b/src/liburl/lib.rs index 99d9e6ce478dd..b5c1c2d21f47a 100644 --- a/src/liburl/lib.rs +++ b/src/liburl/lib.rs @@ -10,7 +10,7 @@ //! Types/fns concerning URLs (see RFC 3986) -#![crate_id = "url#0.11-pre"] +#![crate_id = "url#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index 25188d699beb4..f1abc9ffaacca 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -54,7 +54,7 @@ Examples of string representations: */ -#![crate_id = "uuid#0.11-pre"] +#![crate_id = "uuid#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs index 9343de83d4d7c..1dd87f3954e4f 100644 --- a/src/libworkcache/lib.rs +++ b/src/libworkcache/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "workcache#0.11-pre"] +#![crate_id = "workcache#0.11.0-pre"] #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"] diff --git a/src/test/auxiliary/issue-11908-1.rs b/src/test/auxiliary/issue-11908-1.rs index 5a59a8d6ee9c2..207f47d214cae 100644 --- a/src/test/auxiliary/issue-11908-1.rs +++ b/src/test/auxiliary/issue-11908-1.rs @@ -10,5 +10,5 @@ // no-prefer-dynamic -#![crate_id = "collections#0.11-pre"] +#![crate_id = "collections#0.11.0-pre"] #![crate_type = "dylib"] diff --git a/src/test/auxiliary/issue-11908-2.rs b/src/test/auxiliary/issue-11908-2.rs index 01e7af0af712c..a25eeb12c5384 100644 --- a/src/test/auxiliary/issue-11908-2.rs +++ b/src/test/auxiliary/issue-11908-2.rs @@ -10,5 +10,5 @@ // no-prefer-dynamic -#![crate_id = "collections#0.11-pre"] +#![crate_id = "collections#0.11.0-pre"] #![crate_type = "rlib"] diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 319b5dbabc814..f9a84f276bf6e 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -70,33 +70,30 @@ struct Planet { fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: int) { for _ in range(0, steps) { - { - let mut b_slice = bodies.as_mut_slice(); - loop { - let bi = match b_slice.mut_shift_ref() { - Some(bi) => bi, - None => break - }; - for bj in b_slice.mut_iter() { - let dx = bi.x - bj.x; - let dy = bi.y - bj.y; - let dz = bi.z - bj.z; + let mut b_slice = bodies.as_mut_slice(); + loop { + let bi = match b_slice.mut_shift_ref() { + Some(bi) => bi, + None => break + }; + for bj in b_slice.mut_iter() { + let dx = bi.x - bj.x; + let dy = bi.y - bj.y; + let dz = bi.z - bj.z; - let d2 = dx * dx + dy * dy + dz * dz; - let mag = dt / (d2 * d2.sqrt()); + let d2 = dx * dx + dy * dy + dz * dz; + let mag = dt / (d2 * d2.sqrt()); - bi.vx -= dx * bj.mass * mag; - bi.vy -= dy * bj.mass * mag; - bi.vz -= dz * bj.mass * mag; + let massj_mag = bj.mass * mag; + bi.vx -= dx * massj_mag; + bi.vy -= dy * massj_mag; + bi.vz -= dz * massj_mag; - bj.vx += dx * bi.mass * mag; - bj.vy += dy * bi.mass * mag; - bj.vz += dz * bi.mass * mag; - } + let massi_mag = bi.mass * mag; + bj.vx += dx * massi_mag; + bj.vy += dy * massi_mag; + bj.vz += dz * massi_mag; } - } - - for bi in bodies.mut_iter() { bi.x += dt * bi.vx; bi.y += dt * bi.vy; bi.z += dt * bi.vz; diff --git a/src/test/run-make/crate-data-smoke/Makefile b/src/test/run-make/crate-data-smoke/Makefile index f2b246b643714..a72e24cf2c385 100644 --- a/src/test/run-make/crate-data-smoke/Makefile +++ b/src/test/run-make/crate-data-smoke/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: - [ `$(RUSTC) --crate-id crate.rs` = "foo#0.11-pre" ] + [ `$(RUSTC) --crate-id crate.rs` = "foo#0.11.0-pre" ] [ `$(RUSTC) --crate-name crate.rs` = "foo" ] [ `$(RUSTC) --crate-file-name crate.rs` = "foo" ] [ `$(RUSTC) --crate-file-name --crate-type=lib --test crate.rs` = "foo" ] diff --git a/src/test/run-make/crate-data-smoke/crate.rs b/src/test/run-make/crate-data-smoke/crate.rs index db3759036d8c0..31446a763e2dd 100644 --- a/src/test/run-make/crate-data-smoke/crate.rs +++ b/src/test/run-make/crate-data-smoke/crate.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "foo#0.11-pre"] +#![crate_id = "foo#0.11.0-pre"] // Querying about the crate metadata should *not* parse the entire crate, it // only needs the crate attributes (which are guaranteed to be at the top) be diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs index ee67cc86ea3fc..c42f392d2bce0 100644 --- a/src/test/run-pass/use.rs +++ b/src/test/run-pass/use.rs @@ -15,7 +15,7 @@ #![no_std] extern crate std; extern crate zed = "std"; -extern crate bar = "std#0.11-pre"; +extern crate bar = "std#0.11.0-pre"; use std::str;