From bb43f580e5a291ee02a99b6dca6ec9b757151a19 Mon Sep 17 00:00:00 2001 From: Aidan Hobson Sayers Date: Sun, 20 Mar 2016 23:12:20 +0000 Subject: [PATCH 1/6] Document heap allocation location guarantee --- src/doc/reference.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/reference.md b/src/doc/reference.md index 4c5fd31b96ed1..cdf54b39e6803 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3909,6 +3909,9 @@ The _heap_ is a general term that describes boxes. The lifetime of an allocation in the heap depends on the lifetime of the box values pointing to it. Since box values may themselves be passed in and out of frames, or stored in the heap, heap allocations may outlive the frame they are allocated within. +An allocation in the heap is guaranteed to reside at a single location in the +heap for the whole lifetime of the allocation - it will never be relocated as +a result of moving a box value. ### Memory ownership From bef69a116e0042fbd92dfa08de68da73765f4c14 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 20 Mar 2016 22:07:49 -0700 Subject: [PATCH 2/6] std: Add regression test for #32074 Just to make sure we don't accidentally break this in the future. --- src/libstd/ascii.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 031a9b8bec274..f0fd30a38991a 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -669,4 +669,10 @@ mod tests { &from_u32(lower).unwrap().to_string())); } } + + #[test] + fn inference_works() { + let x = "a".to_string(); + x.eq_ignore_ascii_case("A"); + } } From 2c48214a1b8e8a609fbe36b10bc62cbf6bd7b9e3 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Tue, 22 Mar 2016 23:09:43 +0200 Subject: [PATCH 3/6] doc: remove needless bindings --- src/librustc_unicode/char.rs | 180 ++++++++++------------------------- 1 file changed, 48 insertions(+), 132 deletions(-) diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index 5bc5c78616093..dad72b0ddccd6 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -151,14 +151,9 @@ impl char { /// Basic usage: /// /// ``` - /// let d = '1'; - /// - /// assert!(d.is_digit(10)); - /// - /// let d = 'f'; - /// - /// assert!(d.is_digit(16)); - /// assert!(!d.is_digit(10)); + /// assert!('1'.is_digit(10)); + /// assert!('f'.is_digit(16)); + /// assert!(!'f'.is_digit(10)); /// ``` /// /// Passing a large radix, causing a panic: @@ -167,10 +162,8 @@ impl char { /// use std::thread; /// /// let result = thread::spawn(|| { - /// let d = '1'; - /// /// // this panics - /// d.is_digit(37); + /// '1'.is_digit(37); /// }).join(); /// /// assert!(result.is_err()); @@ -207,25 +200,15 @@ impl char { /// Basic usage: /// /// ``` - /// let d = '1'; - /// - /// assert_eq!(d.to_digit(10), Some(1)); - /// - /// let d = 'f'; - /// - /// assert_eq!(d.to_digit(16), Some(15)); + /// assert_eq!('1'.to_digit(10), Some(1)); + /// assert_eq!('f'.to_digit(16), Some(15)); /// ``` /// /// Passing a non-digit results in failure: /// /// ``` - /// let d = 'f'; - /// - /// assert_eq!(d.to_digit(10), None); - /// - /// let d = 'z'; - /// - /// assert_eq!(d.to_digit(16), None); + /// assert_eq!('f'.to_digit(10), None); + /// assert_eq!('z'.to_digit(16), None); /// ``` /// /// Passing a large radix, causing a panic: @@ -234,9 +217,7 @@ impl char { /// use std::thread; /// /// let result = thread::spawn(|| { - /// let d = '1'; - /// - /// d.to_digit(37); + /// '1'.to_digit(37); /// }).join(); /// /// assert!(result.is_err()); @@ -495,12 +476,8 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'a'; - /// - /// assert!(c.is_alphabetic()); - /// - /// let c = '京'; - /// assert!(c.is_alphabetic()); + /// assert!('a'.is_alphabetic()); + /// assert!('京'.is_alphabetic()); /// /// let c = '💝'; /// // love is many things, but it is not alphabetic @@ -554,21 +531,13 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'a'; - /// assert!(c.is_lowercase()); - /// - /// let c = 'δ'; - /// assert!(c.is_lowercase()); - /// - /// let c = 'A'; - /// assert!(!c.is_lowercase()); - /// - /// let c = 'Δ'; - /// assert!(!c.is_lowercase()); + /// assert!('a'.is_lowercase()); + /// assert!('δ'.is_lowercase()); + /// assert!(!'A'.is_lowercase()); + /// assert!(!'Δ'.is_lowercase()); /// /// // The various Chinese scripts do not have case, and so: - /// let c = '中'; - /// assert!(!c.is_lowercase()); + /// assert!(!'中'.is_lowercase()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -590,21 +559,13 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'a'; - /// assert!(!c.is_uppercase()); - /// - /// let c = 'δ'; - /// assert!(!c.is_uppercase()); - /// - /// let c = 'A'; - /// assert!(c.is_uppercase()); - /// - /// let c = 'Δ'; - /// assert!(c.is_uppercase()); + /// assert!(!'a'.is_uppercase()); + /// assert!(!'δ'.is_uppercase()); + /// assert!('A'.is_uppercase()); + /// assert!('Δ'.is_uppercase()); /// /// // The various Chinese scripts do not have case, and so: - /// let c = '中'; - /// assert!(!c.is_uppercase()); + /// assert!(!'中'.is_uppercase()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -626,15 +587,12 @@ impl char { /// Basic usage: /// /// ``` - /// let c = ' '; - /// assert!(c.is_whitespace()); + /// assert!(' '.is_whitespace()); /// /// // a non-breaking space - /// let c = '\u{A0}'; - /// assert!(c.is_whitespace()); + /// assert!('\u{A0}'.is_whitespace()); /// - /// let c = '越'; - /// assert!(!c.is_whitespace()); + /// assert!(!'越'.is_whitespace()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -656,29 +614,14 @@ impl char { /// Basic usage: /// /// ``` - /// let c = '٣'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '7'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '৬'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = 'K'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = 'و'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '藏'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '¾'; - /// assert!(!c.is_alphanumeric()); - /// - /// let c = '①'; - /// assert!(!c.is_alphanumeric()); + /// assert!('٣'.is_alphanumeric()); + /// assert!('7'.is_alphanumeric()); + /// assert!('৬'.is_alphanumeric()); + /// assert!('K'.is_alphanumeric()); + /// assert!('و'.is_alphanumeric()); + /// assert!('藏'.is_alphanumeric()); + /// assert!(!'¾'.is_alphanumeric()); + /// assert!(!'①'.is_alphanumeric()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -697,11 +640,8 @@ impl char { /// /// ``` /// // U+009C, STRING TERMINATOR - /// let c = 'œ'; - /// assert!(c.is_control()); - /// - /// let c = 'q'; - /// assert!(!c.is_control()); + /// assert!('œ'.is_control()); + /// assert!(!'q'.is_control()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -719,29 +659,14 @@ impl char { /// Basic usage: /// /// ``` - /// let c = '٣'; - /// assert!(c.is_numeric()); - /// - /// let c = '7'; - /// assert!(c.is_numeric()); - /// - /// let c = '৬'; - /// assert!(c.is_numeric()); - /// - /// let c = 'K'; - /// assert!(!c.is_numeric()); - /// - /// let c = 'و'; - /// assert!(!c.is_numeric()); - /// - /// let c = '藏'; - /// assert!(!c.is_numeric()); - /// - /// let c = '¾'; - /// assert!(!c.is_numeric()); - /// - /// let c = '①'; - /// assert!(!c.is_numeric()); + /// assert!('٣'.is_numeric()); + /// assert!('7'.is_numeric()); + /// assert!('৬'.is_numeric()); + /// assert!(!'K'.is_numeric()); + /// assert!(!'و'.is_numeric()); + /// assert!(!'藏'.is_numeric()); + /// assert!(!'¾'.is_numeric()); + /// assert!(!'①'.is_numeric()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -776,13 +701,10 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'C'; - /// - /// assert_eq!(c.to_lowercase().next(), Some('c')); + /// assert_eq!('C'.to_lowercase().next(), Some('c')); /// /// // Japanese scripts do not have case, and so: - /// let c = '山'; - /// assert_eq!(c.to_lowercase().next(), Some('山')); + /// assert_eq!('山'.to_lowercase().next(), Some('山')); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -813,12 +735,10 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'c'; - /// assert_eq!(c.to_uppercase().next(), Some('C')); + /// assert_eq!('c'.to_uppercase().next(), Some('C')); /// /// // Japanese does not have case, and so: - /// let c = '山'; - /// assert_eq!(c.to_uppercase().next(), Some('山')); + /// assert_eq!('山'.to_uppercase().next(), Some('山')); /// ``` /// /// In Turkish, the equivalent of 'i' in Latin has five forms instead of two: @@ -829,9 +749,7 @@ impl char { /// Note that the lowercase dotted 'i' is the same as the Latin. Therefore: /// /// ``` - /// let i = 'i'; - /// - /// let upper_i = i.to_uppercase().next(); + /// let upper_i = 'i'.to_uppercase().next(); /// ``` /// /// The value of `upper_i` here relies on the language of the text: if we're @@ -839,9 +757,7 @@ impl char { /// be `Some('İ')`. `to_uppercase()` does not take this into account, and so: /// /// ``` - /// let i = 'i'; - /// - /// let upper_i = i.to_uppercase().next(); + /// let upper_i = 'i'.to_uppercase().next(); /// /// assert_eq!(Some('I'), upper_i); /// ``` From 7124ea4f18b5b18d61af395055e261bc7d913bef Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 24 Mar 2016 17:27:15 -0400 Subject: [PATCH 4/6] remove broken config Fixes #32412 --- src/etc/CONFIGS.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/etc/CONFIGS.md b/src/etc/CONFIGS.md index 74837a06faecd..cde7094cec41e 100644 --- a/src/etc/CONFIGS.md +++ b/src/etc/CONFIGS.md @@ -10,7 +10,3 @@ These are some links to repos with configs which ease the use of rust. * [kate-config](https://github.com/rust-lang/kate-config) * [nano-config](https://github.com/rust-lang/nano-config) * [zsh-config](https://github.com/rust-lang/zsh-config) - -## Community-maintained Configs - -* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/)) From 6ce63fb3f1bf37004868f79beacb180283c0750e Mon Sep 17 00:00:00 2001 From: Alejandro Wainzinger Date: Fri, 25 Mar 2016 23:25:40 +0900 Subject: [PATCH 5/6] Add note on `str` being an unsized type in strings section of book. --- src/doc/book/strings.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/doc/book/strings.md b/src/doc/book/strings.md index 5ed1f3de06249..f5ebceedd363a 100644 --- a/src/doc/book/strings.md +++ b/src/doc/book/strings.md @@ -44,6 +44,11 @@ let s = "foo\ assert_eq!("foobar", s); ``` +Note that you normally cannot access a `str` directly, but only through a `&str` +reference. This is because `str` is an unsized type which requires additional +runtime information to be usable. For more information see the chapter on +[unsized types][ut]. + Rust has more than only `&str`s though. A `String` is a heap-allocated string. This string is growable, and is also guaranteed to be UTF-8. `String`s are commonly created by converting from a string slice using the `to_string` @@ -185,5 +190,6 @@ let hello_world = hello + &world; This is because `&String` can automatically coerce to a `&str`. This is a feature called ‘[`Deref` coercions][dc]’. +[ut]: unsized-types.html [dc]: deref-coercions.html [connect]: ../std/net/struct.TcpStream.html#method.connect From 88ab9382ae79346969d79c15a27c77368a928dd8 Mon Sep 17 00:00:00 2001 From: "Novotnik, Petr" Date: Fri, 25 Mar 2016 21:35:10 +0100 Subject: [PATCH 6/6] Avoid page reload upon hitting "S" when browing in local mode --- src/librustdoc/html/static/main.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 8fb58f58e8a5f..1d1e78926f120 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -742,8 +742,6 @@ if ($(this).val().length === 0) { if (browserSupportsHistoryApi()) { history.replaceState("", "std - Rust", "?search="); - } else { - location.replace("?search="); } $('#main.content').removeClass('hidden'); $('#search.content').addClass('hidden');