From e727dd58116e9d493163d9839f20837aff10e6ba Mon Sep 17 00:00:00 2001 From: Christian Weinz Date: Tue, 30 Jun 2015 17:02:10 -0300 Subject: [PATCH 1/7] Update complement-design-faq.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ‘_‘ wildcard handles exactly not specific cases but all nut specified. --- src/doc/complement-design-faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/complement-design-faq.md b/src/doc/complement-design-faq.md index e887ed0cc529..5e99876f5dab 100644 --- a/src/doc/complement-design-faq.md +++ b/src/doc/complement-design-faq.md @@ -99,7 +99,7 @@ Second, it makes cost explicit. In general, the only safe way to have a non-exhaustive match would be to panic the thread if nothing is matched, though it could fall through if the type of the `match` expression is `()`. This sort of hidden cost and special casing is against the language's philosophy. It's -easy to ignore certain cases by using the `_` wildcard: +easy to ignore all unspecified cases by using the `_` wildcard: ```rust,ignore match val.do_something() { From df73abedd585a0f797eb393264fc01ff5a442c40 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 5 Jul 2015 11:59:33 +0200 Subject: [PATCH 2/7] std: small doc fixes for BufReader and BufWriter * fix probable copy-paste error in BufWriter.get_mut() * more consistent punctuation --- src/libstd/io/buffered.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 1d0152e27511..d389a0be117b 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -21,7 +21,7 @@ use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; use ptr; use iter; -/// Wraps a `Read` and buffers input from it +/// Wraps a `Read` and buffers input from it. /// /// It can be excessively inefficient to work directly with a `Read` instance. /// For example, every call to `read` on `TcpStream` results in a system call. @@ -54,13 +54,13 @@ pub struct BufReader { } impl BufReader { - /// Creates a new `BufReader` with a default buffer capacity + /// Creates a new `BufReader` with a default buffer capacity. #[stable(feature = "rust1", since = "1.0.0")] pub fn new(inner: R) -> BufReader { BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) } - /// Creates a new `BufReader` with the specified buffer capacity + /// Creates a new `BufReader` with the specified buffer capacity. #[stable(feature = "rust1", since = "1.0.0")] pub fn with_capacity(cap: usize, inner: R) -> BufReader { let mut buf = Vec::with_capacity(cap); @@ -183,7 +183,7 @@ impl Seek for BufReader { } } -/// Wraps a Writer and buffers output to it +/// Wraps a Writer and buffers output to it. /// /// It can be excessively inefficient to work directly with a `Write`. For /// example, every call to `write` on `TcpStream` results in a system call. A @@ -205,13 +205,13 @@ pub struct BufWriter { pub struct IntoInnerError(W, Error); impl BufWriter { - /// Creates a new `BufWriter` with a default buffer capacity + /// Creates a new `BufWriter` with a default buffer capacity. #[stable(feature = "rust1", since = "1.0.0")] pub fn new(inner: W) -> BufWriter { BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) } - /// Creates a new `BufWriter` with the specified buffer capacity + /// Creates a new `BufWriter` with the specified buffer capacity. #[stable(feature = "rust1", since = "1.0.0")] pub fn with_capacity(cap: usize, inner: W) -> BufWriter { BufWriter { @@ -253,11 +253,11 @@ impl BufWriter { #[stable(feature = "rust1", since = "1.0.0")] pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } - /// Gets a mutable reference to the underlying write. + /// Gets a mutable reference to the underlying writer. /// /// # Warning /// - /// It is inadvisable to directly read from the underlying writer. + /// It is inadvisable to directly write to the underlying writer. #[stable(feature = "rust1", since = "1.0.0")] pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } From 8d9f1bab756720fce7337d3d8cc5960b036a266e Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Wed, 8 Jul 2015 23:30:19 +0900 Subject: [PATCH 3/7] Remove a FIXME --- src/librustc_resolve/lib.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 5d10b0d9a57b..0ec3979ccfb3 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1844,11 +1844,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { visit::walk_ty_param_bounds_helper(this, bounds); for trait_item in trait_items { - // Create a new rib for the trait_item-specific type - // parameters. - // - // FIXME #4951: Do we need a node ID here? - match trait_item.node { ast::ConstTraitItem(_, ref default) => { // Only impose the restrictions of From 6c5290389170cc024e1ecfb09efdd88ae0303d02 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 7 Jul 2015 09:07:05 -0400 Subject: [PATCH 4/7] Make mention of alternate flags in std::fmt traits https://www.reddit.com/r/rust/comments/3ceaui/psa_produces_prettyprinted_debug_output/ --- src/libcore/fmt/mod.rs | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 0bb519ec0951..47030bf0fb31 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -273,6 +273,8 @@ impl<'a> Display for Arguments<'a> { /// /// Generally speaking, you should just `derive` a `Debug` implementation. /// +/// When used with the alternate format specifier `#?`, the output is pretty-printed. +/// /// For more information on formatters, see [the module-level documentation][module]. /// /// [module]: ../index.html @@ -314,6 +316,12 @@ impl<'a> Display for Arguments<'a> { /// println!("The origin is: {:?}", origin); /// ``` /// +/// This outputs: +/// +/// ```text +/// The origin is: Point { x: 0, y: 0 } +/// ``` +/// /// There are a number of `debug_*` methods on `Formatter` to help you with manual /// implementations, such as [`debug_struct`][debug_struct]. /// @@ -321,6 +329,29 @@ impl<'a> Display for Arguments<'a> { /// on `Formatter` support pretty printing using the alternate flag: `{:#?}`. /// /// [debug_struct]: ../std/fmt/struct.Formatter.html#method.debug_struct +/// +/// Pretty printing with `#?`: +/// +/// ``` +/// #[derive(Debug)] +/// struct Point { +/// x: i32, +/// y: i32, +/// } +/// +/// let origin = Point { x: 0, y: 0 }; +/// +/// println!("The origin is: {:#?}", origin); +/// ``` +/// +/// This outputs: +/// +/// ```text +/// The origin is: Point { +/// x: 0, +/// y: 0 +/// } +/// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \ defined in your crate, add `#[derive(Debug)]` or \ @@ -379,6 +410,8 @@ pub trait Display { /// /// The `Octal` trait should format its output as a number in base-8. /// +/// The alternate flag, `#`, adds a `0o` in front of the output. +/// /// For more information on formatters, see [the module-level documentation][module]. /// /// [module]: ../index.html @@ -391,6 +424,7 @@ pub trait Display { /// let x = 42; // 42 is '52' in octal /// /// assert_eq!(format!("{:o}", x), "52"); +/// assert_eq!(format!("{:#o}", x), "0o52"); /// ``` /// /// Implementing `Octal` on a type: @@ -423,6 +457,8 @@ pub trait Octal { /// /// The `Binary` trait should format its output as a number in binary. /// +/// The alternate flag, `#`, adds a `0b` in front of the output. +/// /// For more information on formatters, see [the module-level documentation][module]. /// /// [module]: ../index.html @@ -435,6 +471,7 @@ pub trait Octal { /// let x = 42; // 42 is '101010' in binary /// /// assert_eq!(format!("{:b}", x), "101010"); +/// assert_eq!(format!("{:#b}", x), "0b101010"); /// ``` /// /// Implementing `Binary` on a type: @@ -468,6 +505,8 @@ pub trait Binary { /// The `LowerHex` trait should format its output as a number in hexidecimal, with `a` through `f` /// in lower case. /// +/// The alternate flag, `#`, adds a `0x` in front of the output. +/// /// For more information on formatters, see [the module-level documentation][module]. /// /// [module]: ../index.html @@ -480,6 +519,7 @@ pub trait Binary { /// let x = 42; // 42 is '2a' in hex /// /// assert_eq!(format!("{:x}", x), "2a"); +/// assert_eq!(format!("{:#x}", x), "0x2a"); /// ``` /// /// Implementing `LowerHex` on a type: @@ -513,6 +553,8 @@ pub trait LowerHex { /// The `UpperHex` trait should format its output as a number in hexidecimal, with `A` through `F` /// in upper case. /// +/// The alternate flag, `#`, adds a `0x` in front of the output. +/// /// For more information on formatters, see [the module-level documentation][module]. /// /// [module]: ../index.html @@ -525,6 +567,7 @@ pub trait LowerHex { /// let x = 42; // 42 is '2A' in hex /// /// assert_eq!(format!("{:X}", x), "2A"); +/// assert_eq!(format!("{:#X}", x), "0x2A"); /// ``` /// /// Implementing `UpperHex` on a type: From 80f269259c734d25bb4e9586d1cbde8638dcda26 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 8 Jul 2015 13:04:41 -0400 Subject: [PATCH 5/7] Fix up unsafe section of slice::from_raw_parts Added a proper Unsafety header, as well as mentioning that the pointer shouldn't be null. Fixes #26552 --- src/libcore/slice.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index a8c995f37cce..797f9c368720 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1368,10 +1368,14 @@ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { /// /// The `len` argument is the number of **elements**, not the number of bytes. /// +/// # Unsafety +/// /// This function is unsafe as there is no guarantee that the given pointer is /// valid for `len` elements, nor whether the lifetime inferred is a suitable /// lifetime for the returned slice. /// +/// `p` must be non-null, even for zero-length slices. +/// /// # Caveat /// /// The lifetime for the returned slice is inferred from its usage. To From 1ae77026813e8b5dab36ce8ad0a09de25da15a44 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 8 Jul 2015 13:09:22 -0400 Subject: [PATCH 6/7] TRPL: make version constraits explicit We weren't explicit enough about Cargo's default version behavior. For rust-lang/rust at least, Fixes #26482 --- src/doc/trpl/guessing-game.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/doc/trpl/guessing-game.md b/src/doc/trpl/guessing-game.md index a599b8a855e9..1784c253f7f4 100644 --- a/src/doc/trpl/guessing-game.md +++ b/src/doc/trpl/guessing-game.md @@ -360,10 +360,12 @@ rand="0.3.0" The `[dependencies]` section of `Cargo.toml` is like the `[package]` section: everything that follows it is part of it, until the next section starts. Cargo uses the dependencies section to know what dependencies on external -crates you have, and what versions you require. In this case, we’ve used version `0.3.0`. +crates you have, and what versions you require. In this case, we’ve specified version `0.3.0`, +which Cargo understands to be any release that’s compatible with this specific version. Cargo understands [Semantic Versioning][semver], which is a standard for writing version -numbers. If we wanted to use the latest version we could use `*` or we could use a range -of versions. [Cargo’s documentation][cargodoc] contains more details. +numbers. If we wanted to use only `0.3.0` exactly, we could use `=0.3.0`. If we +wanted to use the latest version we could use `*`; We could use a range of +versions. [Cargo’s documentation][cargodoc] contains more details. [semver]: http://semver.org [cargodoc]: http://doc.crates.io/crates-io.html From b77985fcfb9f0af810f387f79477234b1e110ef9 Mon Sep 17 00:00:00 2001 From: Dave Huseby Date: Wed, 8 Jul 2015 10:31:27 -0700 Subject: [PATCH 7/7] this fixes the test failures on freebsd --- src/compiletest/runtest.rs | 5 ++++- src/test/run-make/execution-engine/Makefile | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 39d99af8d6a8..93054f397908 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1702,8 +1702,11 @@ fn run_codegen_test(config: &Config, props: &TestProps, testfile: &Path) { } fn charset() -> &'static str { - if cfg!(any(target_os = "bitrig", target_os = "freebsd")) { + // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset + if cfg!(target_os = "bitrig") { "auto" + } else if cfg!(target_os = "freebsd") { + "ISO-8859-1" } else { "UTF-8" } diff --git a/src/test/run-make/execution-engine/Makefile b/src/test/run-make/execution-engine/Makefile index 387905f45d84..ef646c5bf5d6 100644 --- a/src/test/run-make/execution-engine/Makefile +++ b/src/test/run-make/execution-engine/Makefile @@ -1,8 +1,14 @@ -include ../tools.mk +# FIXME: ignore freebsd # This is a basic test of LLVM ExecutionEngine functionality using compiled # Rust code built using the `rustc` crate. +ifneq ($(shell uname),FreeBSD) all: $(RUSTC) test.rs $(call RUN,test $(RUSTC)) +else +all: + +endif