From 313eb328da6cbf06d17a221898f9e06588e07ce0 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 1 Apr 2016 10:18:41 -0400 Subject: Address FIXMEs related to short lifetimes in `HashMap`. --- src/libstd/collections/hash/map.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 80b5448800e..8ce36e814a8 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -428,10 +428,7 @@ fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>, mut val: V) -> &'a mut V { let starting_index = bucket.index(); - let size = { - let table = bucket.table(); // FIXME "lifetime too short". - table.size() - }; + let size = bucket.table().size(); // Save the *starting point*. let mut bucket = bucket.stash(); // There can be at most `size - dib` buckets to displace, because @@ -744,10 +741,9 @@ impl HashMap let h = bucket.hash(); let (b, k, v) = bucket.take(); self.insert_hashed_ordered(h, k, v); - { - let t = b.table(); // FIXME "lifetime too short". - if t.size() == 0 { break } - }; + if b.table().size() == 0 { + break; + } b.into_bucket() } Empty(b) => b.into_bucket() -- cgit 1.4.1-3-g733a5 From da4d7f59ad5b79baaec10aa85304e3dd2604d687 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 2 Apr 2016 20:20:52 -0400 Subject: Indicate `None` is code-like in doc comment. --- src/libstd/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 40f6528f63e..f67f7e098d3 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -181,7 +181,7 @@ fn _var(key: &OsStr) -> Result { } /// Fetches the environment variable `key` from the current process, returning -/// None if the variable isn't set. +/// `None` if the variable isn't set. /// /// # Examples /// -- cgit 1.4.1-3-g733a5 From 8f463ea98e1ce5763b2ecfb4480bc7cce83125ac Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Tue, 5 Apr 2016 17:55:14 +0200 Subject: doc: make env::consts summaries less confusing --- src/libstd/env.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/env.rs b/src/libstd/env.rs index fa48efb2788..cd541e63fb7 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -618,7 +618,7 @@ pub mod consts { #[stable(feature = "env", since = "1.0.0")] pub const ARCH: &'static str = super::arch::ARCH; - /// The family of the operating system. In this case, `unix`. + /// The family of the operating system. Example value is `unix`. /// /// Some possible values: /// @@ -627,8 +627,8 @@ pub mod consts { #[stable(feature = "env", since = "1.0.0")] pub const FAMILY: &'static str = super::os::FAMILY; - /// A string describing the specific operating system in use: in this - /// case, `linux`. + /// A string describing the specific operating system in use. + /// Example value is `linux`. /// /// Some possible values: /// @@ -647,7 +647,7 @@ pub mod consts { pub const OS: &'static str = super::os::OS; /// Specifies the filename prefix used for shared libraries on this - /// platform: in this case, `lib`. + /// platform. Example value is `lib`. /// /// Some possible values: /// @@ -657,7 +657,7 @@ pub mod consts { pub const DLL_PREFIX: &'static str = super::os::DLL_PREFIX; /// Specifies the filename suffix used for shared libraries on this - /// platform: in this case, `.so`. + /// platform. Example value is `.so`. /// /// Some possible values: /// @@ -668,7 +668,7 @@ pub mod consts { pub const DLL_SUFFIX: &'static str = super::os::DLL_SUFFIX; /// Specifies the file extension used for shared libraries on this - /// platform that goes after the dot: in this case, `so`. + /// platform that goes after the dot. Example value is `so`. /// /// Some possible values: /// @@ -679,7 +679,7 @@ pub mod consts { pub const DLL_EXTENSION: &'static str = super::os::DLL_EXTENSION; /// Specifies the filename suffix used for executable binaries on this - /// platform: in this case, the empty string. + /// platform. Example value is `.exe`. /// /// Some possible values: /// @@ -691,7 +691,7 @@ pub mod consts { pub const EXE_SUFFIX: &'static str = super::os::EXE_SUFFIX; /// Specifies the file extension, if any, used for executable binaries - /// on this platform: in this case, the empty string. + /// on this platform. Example value is `exe`. /// /// Some possible values: /// -- cgit 1.4.1-3-g733a5 From 922e666820fef2f5d9bd7fa450b4a45d85fdd84a Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Wed, 6 Apr 2016 06:24:19 +0200 Subject: avoid "==" in assert! when one of the values is a bool --- src/libcore/ptr.rs | 4 ++-- src/libstd/fs.rs | 2 +- src/libtest/lib.rs | 2 +- .../specialization/specialization-cross-crate-defaults.rs | 10 +++++----- .../run-pass/specialization/specialization-default-methods.rs | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/libstd') diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 37e9d18095f..42aef3ab3dd 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -220,7 +220,7 @@ impl *const T { /// ``` /// let s: &str = "Follow the rabbit"; /// let ptr: *const u8 = s.as_ptr(); - /// assert!(ptr.is_null() == false); + /// assert!(!ptr.is_null()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -306,7 +306,7 @@ impl *mut T { /// ``` /// let mut s = [1, 2, 3]; /// let ptr: *mut u32 = s.as_mut_ptr(); - /// assert!(ptr.is_null() == false); + /// assert!(!ptr.is_null()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index d8af73816c9..c4d6cb33365 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1708,7 +1708,7 @@ mod tests { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); check!(fs::create_dir(dir)); - assert!(dir.is_file() == false); + assert!(!dir.is_file()); check!(fs::remove_dir(dir)); } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index e7fe128a7ae..e78fd0dea29 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1509,7 +1509,7 @@ mod tests { assert_eq!(filtered.len(), 1); assert_eq!(filtered[0].desc.name.to_string(), "1"); - assert!(filtered[0].desc.ignore == false); + assert!(!filtered[0].desc.ignore); } #[test] diff --git a/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs b/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs index bc695ea821d..62c7e3e2e44 100644 --- a/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs +++ b/src/test/run-pass/specialization/specialization-cross-crate-defaults.rs @@ -26,12 +26,12 @@ impl Foo for LocalOverride { } fn test_foo() { - assert!(0i8.foo() == false); - assert!(0i32.foo() == false); - assert!(0i64.foo() == true); + assert!(!0i8.foo()); + assert!(!0i32.foo()); + assert!(0i64.foo()); - assert!(LocalDefault.foo() == false); - assert!(LocalOverride.foo() == true); + assert!(!LocalDefault.foo()); + assert!(LocalOverride.foo()); } fn test_bar() { diff --git a/src/test/run-pass/specialization/specialization-default-methods.rs b/src/test/run-pass/specialization/specialization-default-methods.rs index 3f0f21ff03f..9cfc6aabbb4 100644 --- a/src/test/run-pass/specialization/specialization-default-methods.rs +++ b/src/test/run-pass/specialization/specialization-default-methods.rs @@ -35,9 +35,9 @@ impl Foo for i64 { } fn test_foo() { - assert!(0i8.foo() == false); - assert!(0i32.foo() == false); - assert!(0i64.foo() == true); + assert!(!0i8.foo()); + assert!(!0i32.foo()); + assert!(0i64.foo()); } // Next, test mixture of explicit `default` and provided methods: -- cgit 1.4.1-3-g733a5 From 3e9b859af2b54130a898741706a736ade406774d Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Wed, 6 Apr 2016 20:10:33 +0200 Subject: Add `Copy` to the traits that are automatically implemented for tuples --- src/libstd/primitive_docs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index c8ea28c5ca3..e083605a2ac 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -425,10 +425,11 @@ mod prim_str { } /// /// # Trait implementations /// -/// If every type inside a tuple implements one of the following -/// traits, then a tuple itself also implements it. +/// If every type inside a tuple implements one of the following traits, then a +/// tuple itself also implements it. /// /// * [`Clone`] +/// * [`Copy`] /// * [`PartialEq`] /// * [`Eq`] /// * [`PartialOrd`] @@ -438,6 +439,7 @@ mod prim_str { } /// * [`Hash`] /// /// [`Clone`]: clone/trait.Clone.html +/// [`Copy`]: marker/trait.Copy.html /// [`PartialEq`]: cmp/trait.PartialEq.html /// [`Eq`]: cmp/trait.Eq.html /// [`PartialOrd`]: cmp/trait.PartialOrd.html -- cgit 1.4.1-3-g733a5