From a6cbb97d104e439bdfb73ddd57cc6a7e6686c371 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 16 Nov 2015 21:16:44 +0300 Subject: [PATCH 1/7] Do not generate comparefoo.gv and simpleeq.gv during testing --- src/test/run-pass/mir_raw_fat_ptr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/run-pass/mir_raw_fat_ptr.rs b/src/test/run-pass/mir_raw_fat_ptr.rs index 20c3357d7d232..9bbfbb6822463 100644 --- a/src/test/run-pass/mir_raw_fat_ptr.rs +++ b/src/test/run-pass/mir_raw_fat_ptr.rs @@ -76,7 +76,7 @@ fn compare_au8(a: *const [u8], b: *const [u8]) -> ComparisonResults { } } -#[rustc_mir(graphviz="comparefoo.gv")] +#[rustc_mir] fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults { ComparisonResults { lt: a < b, @@ -88,7 +88,7 @@ fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults } } -#[rustc_mir(graphviz="simpleeq.gv")] +#[rustc_mir] fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool { let result = a == b; result From 9e25a1ccd32b3dd3e02ba841174fd620651bfb67 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 16:51:58 -0500 Subject: [PATCH 2/7] Improve UFCS example Fixes #29493 --- src/doc/trpl/ufcs.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/doc/trpl/ufcs.md b/src/doc/trpl/ufcs.md index 2353c63a606af..7725970564be0 100644 --- a/src/doc/trpl/ufcs.md +++ b/src/doc/trpl/ufcs.md @@ -109,19 +109,28 @@ Here’s an example of using the longer form. ```rust trait Foo { - fn clone(&self); + fn foo() -> i32; } -#[derive(Clone)] struct Bar; -impl Foo for Bar { - fn clone(&self) { - println!("Making a clone of Bar"); +impl Bar { + fn foo() -> i32 { + 20 + } +} - ::clone(self); +impl Foo for Bar { + fn foo() -> i32 { + 10 } } + +fn main() { + assert_eq!(10, ::foo()); + assert_eq!(20, Bar::foo()); +} ``` -This will call the `Clone` trait’s `clone()` method, rather than `Foo`’s. +Using the angle bracket syntax lets you call the trait method instead of the +inherent one. From 646128d79a0f6c096470422f7748ba1566135b84 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 16:58:52 -0500 Subject: [PATCH 3/7] Remove nomicon reference to copy_lifetime Fixes #29784 --- src/doc/nomicon/unbounded-lifetimes.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doc/nomicon/unbounded-lifetimes.md b/src/doc/nomicon/unbounded-lifetimes.md index 2c5ba79a5078f..1f2961b586136 100644 --- a/src/doc/nomicon/unbounded-lifetimes.md +++ b/src/doc/nomicon/unbounded-lifetimes.md @@ -32,6 +32,5 @@ Within a function, bounding lifetimes is more error-prone. The safest and easies way to bound a lifetime is to return it from a function with a bound lifetime. However if this is unacceptable, the reference can be placed in a location with a specific lifetime. Unfortunately it's impossible to name all lifetimes involved -in a function. To get around this, you can in principle use `copy_lifetime`, though -these are unstable due to their awkward nature and questionable utility. +in a function. From 19bd051c86f04952d107a780e25b64c38b3388b6 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 16 Nov 2015 17:01:58 -0600 Subject: [PATCH 4/7] mk/platform: support i486 and i586 target CHOST On distros that use i486 or i586 in their CHOST, Rust will fail to build because it is not handling i486 or i586 like i686 is handled. This changes the match to do work for all instances of i?86 instead of just i686. The Yocto Project still uses i586 as a target. Signed-off-by: Doug Goldstein --- mk/platform.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/platform.mk b/mk/platform.mk index b8058882f9d94..5faa3b15e2ef6 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -14,7 +14,7 @@ # would create a variable HOST_i686-darwin-macos with the value # i386. define DEF_HOST_VAR - HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1)))) + HOST_$(1) = $(patsubst i%86,i386,$(word 1,$(subst -, ,$(1)))) endef $(foreach t,$(CFG_TARGET),$(eval $(call DEF_HOST_VAR,$(t)))) $(foreach t,$(CFG_TARGET),$(info cfg: host for $(t) is $(HOST_$(t)))) From e4a0b48027d3d800617f05b228f0f6dfa24f6627 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 16:57:37 -0500 Subject: [PATCH 5/7] Make note about traits that can be derived in their API docs Fixes #29711 --- src/libcore/clone.rs | 2 ++ src/libcore/cmp.rs | 8 ++++++++ src/libcore/fmt/mod.rs | 2 ++ src/libcore/hash/mod.rs | 2 ++ src/libcore/marker.rs | 4 ++++ 5 files changed, 18 insertions(+) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 979ddd454121d..769faedf46e8e 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -24,6 +24,8 @@ use marker::Sized; /// A common trait for cloning an object. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Clone : Sized { /// Returns a copy of the value. diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 5458a7b9c38b0..3ac4ffb22364f 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -43,6 +43,8 @@ use option::Option::{self, Some}; /// in terms of it by default. Any manual implementation of `ne` *must* respect /// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and /// only if `a != b`. +/// +/// This trait can be used with `#[derive]`. #[lang = "eq"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialEq { @@ -69,6 +71,8 @@ pub trait PartialEq { /// /// This property cannot be checked by the compiler, and therefore `Eq` implies /// `PartialEq`, and has no extra methods. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Eq: PartialEq { // FIXME #13101: this method is used solely by #[deriving] to @@ -171,6 +175,8 @@ impl Ordering { /// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`. /// /// When this trait is `derive`d, it produces a lexicographic ordering. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Ord: Eq + PartialOrd { /// This method returns an `Ordering` between `self` and `other`. @@ -227,6 +233,8 @@ impl PartialOrd for Ordering { /// However it remains possible to implement the others separately for types which do not have a /// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 == /// false` (cf. IEEE 754-2008 section 5.11). +/// +/// This trait can be used with `#[derive]`. #[lang = "ord"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialOrd: PartialEq { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 8fe65e27c0308..dfcc5781f0873 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -300,6 +300,8 @@ impl<'a> Display for Arguments<'a> { /// /// [module]: ../../std/fmt/index.html /// +/// This trait can be used with `#[derive]`. +/// /// # Examples /// /// Deriving an implementation: diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 0899dc2884819..ea3a2f78d564a 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -93,6 +93,8 @@ mod sip; /// /// In other words, if two keys are equal, their hashes should also be equal. /// `HashMap` and `HashSet` both rely on this behavior. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Hash { /// Feeds this value into the state given, updating the hasher as necessary. diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 6e6ae61852787..84a6196cc87ae 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -165,6 +165,10 @@ pub trait Unsize { /// to consider though: if you think your type may _not_ be able to implement `Copy` in the future, /// then it might be prudent to not implement `Copy`. This is because removing `Copy` is a breaking /// change: that second example would fail to compile if we made `Foo` non-`Copy`. +/// +/// # Derivable +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] #[lang = "copy"] pub trait Copy : Clone { From 8600fefd9c71bf30ad3e23ffc1ef2b7cabe990b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Kr=C3=BCger?= Date: Tue, 17 Nov 2015 01:53:06 +0100 Subject: [PATCH 6/7] Fix libc module name for FreeBSD --- src/libstd/sys/unix/os.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 3c53db53f85f1..c0754ed3b940e 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -167,22 +167,20 @@ impl StdError for JoinPathsError { #[cfg(target_os = "freebsd")] pub fn current_exe() -> io::Result { unsafe { - use libc::funcs::bsd44::*; - use libc::consts::os::extra::*; - let mut mib = [CTL_KERN as c_int, - KERN_PROC as c_int, - KERN_PROC_PATHNAME as c_int, + let mut mib = [libc::CTL_KERN as c_int, + libc::KERN_PROC as c_int, + libc::KERN_PROC_PATHNAME as c_int, -1 as c_int]; let mut sz: libc::size_t = 0; - let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, - ptr::null_mut(), &mut sz, ptr::null_mut(), - 0 as libc::size_t); + let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + ptr::null_mut(), &mut sz, ptr::null_mut(), + 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } let mut v: Vec = Vec::with_capacity(sz as usize); - let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, - v.as_mut_ptr() as *mut libc::c_void, &mut sz, - ptr::null_mut(), 0 as libc::size_t); + let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + v.as_mut_ptr() as *mut libc::c_void, &mut sz, + ptr::null_mut(), 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } v.set_len(sz as usize - 1); // chop off trailing NUL From 4ff4d3220677796f651dcd26bcaf048b61f79683 Mon Sep 17 00:00:00 2001 From: Jean Maillard Date: Tue, 17 Nov 2015 02:39:09 +0000 Subject: [PATCH 7/7] Fix grammar Change conditional perfect to past perfect. --- src/doc/trpl/ownership.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/ownership.md b/src/doc/trpl/ownership.md index d8ef44b782a1d..17b263ef00ab7 100644 --- a/src/doc/trpl/ownership.md +++ b/src/doc/trpl/ownership.md @@ -187,7 +187,7 @@ fn change_truth(x: bool) -> bool { } ``` -If we would have used types that do not implement the `Copy` trait, +If we had used types that do not implement the `Copy` trait, we would have gotten a compile error because we tried to use a moved value. ```text