From c589f867f89d4e6e48c6602aed8e878208d4822f Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Sat, 26 Aug 2017 00:06:13 -0600 Subject: [PATCH 01/40] Add clamp functions --- src/libcore/cmp.rs | 26 ++++++++++++++++++++++++++ src/libstd/f32.rs | 20 ++++++++++++++++++++ src/libstd/f64.rs | 20 ++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index ec6525485f7a1..174ceb6b8a7e6 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -481,6 +481,32 @@ pub trait Ord: Eq + PartialOrd { where Self: Sized { if self <= other { self } else { other } } + + /// Returns max if self is greater than max, and min if self is less than min. + /// Otherwise this will return self. Panics if min > max. + /// + /// # Examples + /// + /// ``` + /// #![feature(clamp)] + /// + /// assert!((-3).clamp(-2, 1) == -2); + /// assert!(0.clamp(-2, 1) == 0); + /// assert!(2.clamp(-2, 1) == 1); + /// ``` + #[unstable(feature = "clamp", issue = "44095")] + fn clamp(self, min: Self, max: Self) -> Self + where Self: Sized { + assert!(min <= max); + if self < min { + min + } + else if self > max { + max + } else { + self + } + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 0135cd0a588cf..18bc27faa8227 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1080,6 +1080,26 @@ impl f32 { 0.5 * ((2.0 * self) / (1.0 - self)).ln_1p() } + /// Returns max if self is greater than max, and min if self is less than min. + /// Otherwise this returns self. Panics if min > max, min equals NaN, or max equals NaN. + /// + /// # Examples + /// + /// ``` + /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); + /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); + /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); + /// ``` + #[unstable(feature = "clamp", issue = "44095")] + #[inline] + pub fn clamp(self, min: f32, max: f32) -> f32 { + assert!(min <= max); + let mut x = self; + if x < min { x = min; } + if x > max { x = max; } + x + } + /// Raw transmutation to `u32`. /// /// Converts the `f32` into its raw memory representation, diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index d73d7cd2c7bd1..b04ba9eabdbb3 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -970,6 +970,26 @@ impl f64 { 0.5 * ((2.0 * self) / (1.0 - self)).ln_1p() } + /// Returns max if self is greater than max, and min if self is less than min. + /// Otherwise this returns self. Panics if min > max, min equals NaN, or max equals NaN. + /// + /// # Examples + /// + /// ``` + /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); + /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); + /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); + /// ``` + #[unstable(feature = "clamp", issue = "44095")] + #[inline] + pub fn clamp(self, min: f64, max: f64) -> f64 { + assert!(min <= max); + let mut x = self; + if x < min { x = min; } + if x > max { x = max; } + x + } + // Solaris/Illumos requires a wrapper around log, log2, and log10 functions // because of their non-standard behavior (e.g. log(-n) returns -Inf instead // of expected NaN). From f74c5d2e18e50c24de2cc1192bf2088cdaa61916 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Sat, 26 Aug 2017 10:36:14 -0600 Subject: [PATCH 02/40] Add NAN examples --- src/libstd/f32.rs | 1 + src/libstd/f64.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 18bc27faa8227..cef53671e806c 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1089,6 +1089,7 @@ impl f32 { /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); + /// assert!((NAN).clamp(-2.0f32, 1.0f32) == NAN); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index b04ba9eabdbb3..ab8f2cd2fdfbd 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -979,6 +979,7 @@ impl f64 { /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); + /// assert!((NAN).clamp(-2.0f64, 1.0f64) == NAN); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] From 61f20f8df02e53ee60dc1719ce0e502eecebf8b4 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Sat, 26 Aug 2017 17:53:01 -0600 Subject: [PATCH 03/40] Fix f32 examples. --- src/libstd/f32.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index cef53671e806c..6b6bd39e7e84c 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1081,15 +1081,17 @@ impl f32 { } /// Returns max if self is greater than max, and min if self is less than min. - /// Otherwise this returns self. Panics if min > max, min equals NaN, or max equals NaN. + /// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN. /// /// # Examples /// /// ``` + /// #![feature(clamp)] + /// use std::f32::NAN; /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); - /// assert!((NAN).clamp(-2.0f32, 1.0f32) == NAN); + /// assert!((NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] From 576426a05a1a6cb33eece7082d7341b7c6bb5277 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Sat, 26 Aug 2017 17:54:51 -0600 Subject: [PATCH 04/40] Fix f64 examples --- src/libstd/f64.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index ab8f2cd2fdfbd..0a7176f9cc75e 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -971,15 +971,17 @@ impl f64 { } /// Returns max if self is greater than max, and min if self is less than min. - /// Otherwise this returns self. Panics if min > max, min equals NaN, or max equals NaN. + /// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN. /// /// # Examples /// /// ``` + /// #![feature(clamp)] + /// use std::f64::NAN; /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); - /// assert!((NAN).clamp(-2.0f64, 1.0f64) == NAN); + /// assert!((NAN).clamp(-2.0f64, 1.0f64).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] From 1d69c985be6a196e4a30f6deb0d8347aaad62662 Mon Sep 17 00:00:00 2001 From: MarkMcCaskey Date: Wed, 30 Aug 2017 22:26:54 -0400 Subject: [PATCH 05/40] update unimplemented! docs --- src/libcore/macros.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 684b81a27f82e..375c1f10db2c3 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -516,13 +516,16 @@ macro_rules! unreachable { }); } -/// A standardized placeholder for marking unfinished code. It panics with the -/// message `"not yet implemented"` when executed. +/// A standardized placeholder for marking unfinished code. /// /// This can be useful if you are prototyping and are just looking to have your /// code typecheck, or if you're implementing a trait that requires multiple /// methods, and you're only planning on using one of them. /// +/// # Panics +/// +/// This will always [panic!](macro.panic.html) +/// /// # Examples /// /// Here's an example of some in-progress code. We have a trait `Foo`: From de038b746e267a4270cf4ac038fbfd92ce788526 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 31 Aug 2017 16:37:14 +0200 Subject: [PATCH 06/40] Add full git commit hash to release channel manifests The full hash is necessary to build the download URL for "alternate" compiler builds. This is a first step for https://github.com/rust-lang-nursery/rustup.rs/issues/1099 --- src/bootstrap/dist.rs | 2 ++ src/bootstrap/lib.rs | 5 +++ src/tools/build-manifest/src/main.rs | 53 +++++++++++++++++----------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 746f85a9d59d6..b7fcfc75c4f25 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -364,7 +364,9 @@ impl Step for Rustc { cp("README.md"); // tiny morsel of metadata is used by rust-packaging let version = build.rust_version(); + let sha = build.rust_sha().unwrap_or(""); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); + t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); // On MinGW we've got a few runtime DLL dependencies that we need to // include. The first argument to this script is where to put these DLLs diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f21b382619d0a..67791e8758c0b 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -797,6 +797,11 @@ impl Build { self.rust_info.version(self, channel::CFG_RELEASE_NUM) } + /// Return the full commit hash + fn rust_sha(&self) -> Option<&str> { + self.rust_info.sha() + } + /// Returns the `a.b.c` version that the given package is at. fn release_num(&self, package: &str) -> String { let mut toml = String::new(); diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index e2be021e7cc39..39b5d275dffaa 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -107,6 +107,7 @@ static MINGW: &'static [&'static str] = &[ struct Manifest { manifest_version: String, date: String, + git_commit_hash: String, pkg: BTreeMap, } @@ -205,15 +206,10 @@ impl Builder { self.digest_and_sign(); let manifest = self.build_manifest(); - let filename = format!("channel-rust-{}.toml", self.rust_release); - self.write_manifest(&toml::to_string(&manifest).unwrap(), &filename); - - let filename = format!("channel-rust-{}-date.txt", self.rust_release); - self.write_date_stamp(&manifest.date, &filename); + self.write_channel_files(&self.rust_release, &manifest); if self.rust_release != "beta" && self.rust_release != "nightly" { - self.write_manifest(&toml::to_string(&manifest).unwrap(), "channel-rust-stable.toml"); - self.write_date_stamp(&manifest.date, "channel-rust-stable-date.txt"); + self.write_channel_files("stable", &manifest); } } @@ -230,6 +226,7 @@ impl Builder { let mut manifest = Manifest { manifest_version: "2".to_string(), date: self.date.to_string(), + git_commit_hash: self.git_commit_hash("rust", "x86_64-unknown-linux-gnu"), pkg: BTreeMap::new(), }; @@ -382,14 +379,31 @@ impl Builder { .arg(self.input.join(&filename)) .arg(format!("{}/version", filename.replace(".tar.gz", ""))) .arg("-O"); - let version = t!(cmd.output()); - if !version.status.success() { + let output = t!(cmd.output()); + if !output.status.success() { panic!("failed to learn version:\n\n{:?}\n\n{}\n\n{}", cmd, - String::from_utf8_lossy(&version.stdout), - String::from_utf8_lossy(&version.stderr)); + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr)); + } + String::from_utf8_lossy(&output.stdout).trim().to_string() + } + + fn git_commit_hash(&self, component: &str, target: &str) -> String { + let mut cmd = Command::new("tar"); + let filename = self.filename(component, target); + cmd.arg("xf") + .arg(self.input.join(&filename)) + .arg(format!("{}/git-commit-hash", filename.replace(".tar.gz", ""))) + .arg("-O"); + let output = t!(cmd.output()); + if !output.status.success() { + panic!("failed to learn git commit hash:\n\n{:?}\n\n{}\n\n{}", + cmd, + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr)); } - String::from_utf8_lossy(&version.stdout).trim().to_string() + String::from_utf8_lossy(&output.stdout).trim().to_string() } fn hash(&self, path: &Path) -> String { @@ -425,16 +439,15 @@ impl Builder { assert!(t!(child.wait()).success()); } - fn write_manifest(&self, manifest: &str, name: &str) { - let dst = self.output.join(name); - t!(t!(File::create(&dst)).write_all(manifest.as_bytes())); - self.hash(&dst); - self.sign(&dst); + fn write_channel_files(&self, channel_name: &str, manifest: &Manifest) { + self.write(&toml::to_string(&manifest).unwrap(), channel_name, ".toml"); + self.write(&manifest.date, channel_name, "-date.txt"); + self.write(&manifest.git_commit_hash, channel_name, "-git-commit-hash.txt"); } - fn write_date_stamp(&self, date: &str, name: &str) { - let dst = self.output.join(name); - t!(t!(File::create(&dst)).write_all(date.as_bytes())); + fn write(&self, contents: &str, channel_name: &str, suffix: &str) { + let dst = self.output.join(format!("channel-rust-{}{}", channel_name, suffix)); + t!(t!(File::create(&dst)).write_all(contents.as_bytes())); self.hash(&dst); self.sign(&dst); } From d308b0bf56b21ad1d6ee21ecd73251a46de6dc11 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 4 Aug 2017 00:19:58 +0000 Subject: [PATCH 07/40] Add support for Vector Multiply Add Saturated on PowerPC --- src/etc/platform-intrinsics/powerpc.json | 7 +++++++ src/librustc_platform_intrinsics/powerpc.rs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/etc/platform-intrinsics/powerpc.json b/src/etc/platform-intrinsics/powerpc.json index d615037b632d7..9f9cceb15258d 100644 --- a/src/etc/platform-intrinsics/powerpc.json +++ b/src/etc/platform-intrinsics/powerpc.json @@ -156,6 +156,13 @@ "llvm": "vupkh{1.kind}{1.data_type_short}", "ret": "s(16-32)", "args": ["0N"] + }, + { + "intrinsic": "madds", + "width": [128], + "llvm": "vmhaddshs", + "ret": "s16", + "args": ["0", "0", "0"] } ] } diff --git a/src/librustc_platform_intrinsics/powerpc.rs b/src/librustc_platform_intrinsics/powerpc.rs index 1a2e8e9c5d868..fce3d5ed538ef 100644 --- a/src/librustc_platform_intrinsics/powerpc.rs +++ b/src/librustc_platform_intrinsics/powerpc.rs @@ -337,6 +337,11 @@ pub fn find(name: &str) -> Option { output: &::I32x4, definition: Named("llvm.ppc.altivec.vupkhsh") }, + "_vec_madds" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 3] = [&::I16x8, &::I16x8, &::I16x8]; &INPUTS }, + output: &::I16x8, + definition: Named("llvm.ppc.altivec.vmhaddshs") + }, _ => return None, }) } From 078c3ddbe387d906ff32bad2ed3fc0876ec1de89 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 4 Aug 2017 00:19:58 +0000 Subject: [PATCH 08/40] Add support for Vector Multiply Sum on PowerPC --- src/etc/platform-intrinsics/powerpc.json | 21 +++++++++++++++++++++ src/librustc_platform_intrinsics/powerpc.rs | 20 ++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/etc/platform-intrinsics/powerpc.json b/src/etc/platform-intrinsics/powerpc.json index 9f9cceb15258d..306ccea903ed5 100644 --- a/src/etc/platform-intrinsics/powerpc.json +++ b/src/etc/platform-intrinsics/powerpc.json @@ -163,6 +163,27 @@ "llvm": "vmhaddshs", "ret": "s16", "args": ["0", "0", "0"] + }, + { + "intrinsic": "msumu{1.data_type_short}m", + "width": [128], + "llvm": "vmsumu{1.data_type_short}m", + "ret": "u32", + "args": ["u(8-16)", "1", "u32"] + }, + { + "intrinsic": "msummbm", + "width": [128], + "llvm": "vmsummbm", + "ret": "s32", + "args": ["s8", "u8", "s32"] + }, + { + "intrinsic": "msumshm", + "width": [128], + "llvm": "vmsumshm", + "ret": "s32", + "args": ["s16", "s16", "s32"] } ] } diff --git a/src/librustc_platform_intrinsics/powerpc.rs b/src/librustc_platform_intrinsics/powerpc.rs index fce3d5ed538ef..437dae48913e5 100644 --- a/src/librustc_platform_intrinsics/powerpc.rs +++ b/src/librustc_platform_intrinsics/powerpc.rs @@ -342,6 +342,26 @@ pub fn find(name: &str) -> Option { output: &::I16x8, definition: Named("llvm.ppc.altivec.vmhaddshs") }, + "_vec_msumubm" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 3] = [&::U8x16, &::U8x16, &::U32x4]; &INPUTS }, + output: &::U32x4, + definition: Named("llvm.ppc.altivec.vmsumubm") + }, + "_vec_msumuhm" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 3] = [&::U16x8, &::U16x8, &::U32x4]; &INPUTS }, + output: &::U32x4, + definition: Named("llvm.ppc.altivec.vmsumuhm") + }, + "_vec_msummbm" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 3] = [&::I8x16, &::U8x16, &::I32x4]; &INPUTS }, + output: &::I32x4, + definition: Named("llvm.ppc.altivec.vmsummbm") + }, + "_vec_msumshm" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 3] = [&::I16x8, &::I16x8, &::I32x4]; &INPUTS }, + output: &::I32x4, + definition: Named("llvm.ppc.altivec.vmsumshm") + }, _ => return None, }) } From cccf3e7a5c728efcab668697e6f7fa1235c6c9bd Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 4 Aug 2017 00:19:58 +0000 Subject: [PATCH 09/40] Add support for Vector Multiply Sum Saturated on PowerPC --- src/etc/platform-intrinsics/powerpc.json | 7 +++++++ src/librustc_platform_intrinsics/powerpc.rs | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/etc/platform-intrinsics/powerpc.json b/src/etc/platform-intrinsics/powerpc.json index 306ccea903ed5..4ed1ecd76393e 100644 --- a/src/etc/platform-intrinsics/powerpc.json +++ b/src/etc/platform-intrinsics/powerpc.json @@ -184,6 +184,13 @@ "llvm": "vmsumshm", "ret": "s32", "args": ["s16", "s16", "s32"] + }, + { + "intrinsic": "msum{0.kind}hs", + "width": [128], + "llvm": "vmsum{0.kind}hs", + "ret": "i32", + "args": ["0N", "0N", "0"] } ] } diff --git a/src/librustc_platform_intrinsics/powerpc.rs b/src/librustc_platform_intrinsics/powerpc.rs index 437dae48913e5..b205321d10f4a 100644 --- a/src/librustc_platform_intrinsics/powerpc.rs +++ b/src/librustc_platform_intrinsics/powerpc.rs @@ -362,6 +362,16 @@ pub fn find(name: &str) -> Option { output: &::I32x4, definition: Named("llvm.ppc.altivec.vmsumshm") }, + "_vec_msumshs" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 3] = [&::I16x8, &::I16x8, &::I32x4]; &INPUTS }, + output: &::I32x4, + definition: Named("llvm.ppc.altivec.vmsumshs") + }, + "_vec_msumuhs" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 3] = [&::U16x8, &::U16x8, &::U32x4]; &INPUTS }, + output: &::U32x4, + definition: Named("llvm.ppc.altivec.vmsumuhs") + }, _ => return None, }) } From 2e34ff767113c6a15c5862b0646ca9ad7ffd81b1 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Fri, 1 Sep 2017 00:07:26 -0600 Subject: [PATCH 10/40] Fix documentation and formatting. --- src/libcore/cmp.rs | 16 +++++++--------- src/libstd/f32.rs | 5 ++++- src/libstd/f64.rs | 5 ++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 174ceb6b8a7e6..dc1f2981a50ad 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -483,7 +483,7 @@ pub trait Ord: Eq + PartialOrd { } /// Returns max if self is greater than max, and min if self is less than min. - /// Otherwise this will return self. Panics if min > max. + /// Otherwise this will return self. /// /// # Examples /// @@ -494,18 +494,16 @@ pub trait Ord: Eq + PartialOrd { /// assert!(0.clamp(-2, 1) == 0); /// assert!(2.clamp(-2, 1) == 1); /// ``` + /// + /// # Panics + /// Panics if min > max. #[unstable(feature = "clamp", issue = "44095")] fn clamp(self, min: Self, max: Self) -> Self where Self: Sized { assert!(min <= max); - if self < min { - min - } - else if self > max { - max - } else { - self - } + if self < min { min } + else if self > max { max } + else { self } } } diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 6b6bd39e7e84c..aaeac06535ee6 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1081,7 +1081,7 @@ impl f32 { } /// Returns max if self is greater than max, and min if self is less than min. - /// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN. + /// Otherwise this returns self. /// /// # Examples /// @@ -1093,6 +1093,9 @@ impl f32 { /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); /// assert!((NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` + /// + /// # Panics + /// Panics if min > max, min is NaN, or max is NaN. #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f32, max: f32) -> f32 { diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 0a7176f9cc75e..4ab319c3cf100 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -971,7 +971,7 @@ impl f64 { } /// Returns max if self is greater than max, and min if self is less than min. - /// Otherwise this returns self. Panics if min > max, min is NaN, or max is NaN. + /// Otherwise this returns self. /// /// # Examples /// @@ -983,6 +983,9 @@ impl f64 { /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); /// assert!((NAN).clamp(-2.0f64, 1.0f64).is_nan()); /// ``` + /// + /// # Panics + /// Panics if min > max, min is NaN, or max is NaN. #[unstable(feature = "clamp", issue = "44095")] #[inline] pub fn clamp(self, min: f64, max: f64) -> f64 { From 9abc549aa1ce16bf4099a56a91e9dbf6af2baa24 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 1 Sep 2017 09:08:59 +0200 Subject: [PATCH 11/40] Add git-commit-hash in source and extended tarballs too. --- src/bootstrap/dist.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index b7fcfc75c4f25..07ef043072096 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -846,6 +846,8 @@ impl Step for PlainSourceTarball { // Create the version file write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes()); + let sha = build.rust_sha().unwrap_or(""); + write_file(&plain_dst_src.join("git-commit-hash"), sha.as_bytes()); // If we're building from git sources, we need to vendor a complete distribution. if build.rust_info.is_git() { @@ -1158,7 +1160,9 @@ impl Step for Extended { install(&build.src.join("LICENSE-APACHE"), &overlay, 0o644); install(&build.src.join("LICENSE-MIT"), &overlay, 0o644); let version = build.rust_version(); + let sha = build.rust_sha().unwrap_or(""); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); + t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); install(&etc.join("README.md"), &overlay, 0o644); // When rust-std package split from rustc, we needed to ensure that during From ad5fc2a313ed09d34304d8700271447431b6cb04 Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Sat, 2 Sep 2017 12:38:25 -0500 Subject: [PATCH 12/40] Add test for #35676 Closes #35676 --- src/test/run-pass/issue-35376.rs | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/test/run-pass/issue-35376.rs diff --git a/src/test/run-pass/issue-35376.rs b/src/test/run-pass/issue-35376.rs new file mode 100644 index 0000000000000..25895cd0753e4 --- /dev/null +++ b/src/test/run-pass/issue-35376.rs @@ -0,0 +1,51 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +fn main() {} + +pub trait Alpha { } + +pub trait Beta { + type Event; +} + +pub trait Delta { + type Handle; + fn process(&self); +} + +pub struct Parent(A, T); + +impl Delta for Parent +where A: Alpha, + T: Delta, + T::Handle: Beta::Event> { + type Handle = Handle; + default fn process(&self) { + unimplemented!() + } +} + +impl Delta for Parent +where A: Alpha + Alpha, + T: Delta, + T::Handle: Beta::Event> { + fn process(&self) { + unimplemented!() + } +} + +pub struct Handle; + +impl Beta for Handle { + type Event = (); +} \ No newline at end of file From f2250c4b01e103d1289662ae31c5e2508b014af5 Mon Sep 17 00:00:00 2001 From: Matt Ickstadt Date: Sat, 2 Sep 2017 13:01:34 -0500 Subject: [PATCH 13/40] Add test for #33185 Closes #33185 --- src/test/run-pass/issue-33185.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/run-pass/issue-33185.rs diff --git a/src/test/run-pass/issue-33185.rs b/src/test/run-pass/issue-33185.rs new file mode 100644 index 0000000000000..f12e65323bc95 --- /dev/null +++ b/src/test/run-pass/issue-33185.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +#[macro_export] +macro_rules! state { + ( $( $name:ident : $field:ty )* ) => ( + #[derive(Default)] + struct State { + $($name : $field),* + } + ) +} + +state! { x: i64 } + +pub fn main() { +} From 3333262f05aef40c1403f15b22fcf0356d60085b Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Sun, 3 Sep 2017 12:27:31 -0700 Subject: [PATCH 14/40] Minor documentation improvements for StmtKind --- src/libsyntax/ast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 720f6cd32bdf8..2b13bd9c410d5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -761,9 +761,9 @@ pub enum StmtKind { /// Expr without trailing semi-colon. Expr(P), - + /// Expr with a trailing semi-colon. Semi(P), - + /// Macro. Mac(P<(Mac, MacStmtStyle, ThinVec)>), } From 4260e4395e5a7a1de4c64d81c7fd0157eac45ad3 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Sun, 3 Sep 2017 19:13:01 -0400 Subject: [PATCH 15/40] impl Debug for SplitWhitespace. --- src/libstd_unicode/u_str.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd_unicode/u_str.rs b/src/libstd_unicode/u_str.rs index 1274b0625875b..0046e3f7bd093 100644 --- a/src/libstd_unicode/u_str.rs +++ b/src/libstd_unicode/u_str.rs @@ -26,7 +26,7 @@ use core::str::Split; /// [`split_whitespace`]: ../../std/primitive.str.html#method.split_whitespace /// [`str`]: ../../std/primitive.str.html #[stable(feature = "split_whitespace", since = "1.1.0")] -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct SplitWhitespace<'a> { inner: Filter, IsNotEmpty>, } From adbb820352cdda9490b72261a809f04c5559a654 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 4 Sep 2017 13:04:53 +0200 Subject: [PATCH 16/40] rustbook: remove dead test functions --- src/tools/rustbook/src/main.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 33326de9c1cc3..41e88aa245f42 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -41,7 +41,6 @@ fn main() { // Check which subcomamnd the user ran... let res = match matches.subcommand() { ("build", Some(sub_matches)) => build(sub_matches), - ("test", Some(sub_matches)) => test(sub_matches), (_, _) => unreachable!(), }; @@ -65,14 +64,6 @@ fn build(args: &ArgMatches) -> Result<(), Box> { Ok(()) } -fn test(args: &ArgMatches) -> Result<(), Box> { - let mut book = build_mdbook_struct(args); - - try!(book.test()); - - Ok(()) -} - fn build_mdbook_struct(args: &ArgMatches) -> mdbook::MDBook { let book_dir = get_book_dir(args); let mut book = MDBook::new(&book_dir).read_config(); From 9412fd7371bfb8cc8e6b20240b84168a88ac9d21 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 4 Sep 2017 16:29:57 +0200 Subject: [PATCH 17/40] Only include git-commit-hash in tarballs when available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … instead of writing an empty file. --- src/bootstrap/dist.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 07ef043072096..2920b91b25530 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -364,9 +364,10 @@ impl Step for Rustc { cp("README.md"); // tiny morsel of metadata is used by rust-packaging let version = build.rust_version(); - let sha = build.rust_sha().unwrap_or(""); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); - t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + if let Some(sha) = build.rust_sha() { + t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + } // On MinGW we've got a few runtime DLL dependencies that we need to // include. The first argument to this script is where to put these DLLs @@ -846,8 +847,9 @@ impl Step for PlainSourceTarball { // Create the version file write_file(&plain_dst_src.join("version"), build.rust_version().as_bytes()); - let sha = build.rust_sha().unwrap_or(""); - write_file(&plain_dst_src.join("git-commit-hash"), sha.as_bytes()); + if let Some(sha) = build.rust_sha() { + write_file(&plain_dst_src.join("git-commit-hash"), sha.as_bytes()); + } // If we're building from git sources, we need to vendor a complete distribution. if build.rust_info.is_git() { @@ -1160,9 +1162,10 @@ impl Step for Extended { install(&build.src.join("LICENSE-APACHE"), &overlay, 0o644); install(&build.src.join("LICENSE-MIT"), &overlay, 0o644); let version = build.rust_version(); - let sha = build.rust_sha().unwrap_or(""); t!(t!(File::create(overlay.join("version"))).write_all(version.as_bytes())); - t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + if let Some(sha) = build.rust_sha() { + t!(t!(File::create(overlay.join("git-commit-hash"))).write_all(sha.as_bytes())); + } install(&etc.join("README.md"), &overlay, 0o644); // When rust-std package split from rustc, we needed to ensure that during From 49f1fc5bb77d6e492dea4d9a11e71e9bfa6875d6 Mon Sep 17 00:00:00 2001 From: "Evgeniy A. Dushistov" Date: Mon, 4 Sep 2017 09:59:27 +0300 Subject: [PATCH 18/40] Add test for #22706 Closes #22706 --- src/test/compile-fail/issue-22706.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/compile-fail/issue-22706.rs diff --git a/src/test/compile-fail/issue-22706.rs b/src/test/compile-fail/issue-22706.rs new file mode 100644 index 0000000000000..3d9ec0a6581d6 --- /dev/null +++ b/src/test/compile-fail/issue-22706.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn is_copy::Copy>() {} +//~^ ERROR type parameters are not allowed on this type [E0109] +fn main() {} From fcefe36ce70d87cfb26cc1b10c8668aaf9eca1f6 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Mon, 4 Sep 2017 15:41:55 -0500 Subject: [PATCH 19/40] bootstrap: only include docs in extended distribution if enabled Issue #44163 --- src/bootstrap/dist.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 05d59e7d59565..2f3a8d1763edb 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1164,7 +1164,10 @@ impl Step for Extended { // the std files during uninstall. To do this ensure that rustc comes // before rust-std in the list below. let mut tarballs = vec![rustc_installer, cargo_installer, rls_installer, - analysis_installer, docs_installer, std_installer]; + analysis_installer, std_installer]; + if build.config.docs { + tarballs.push(docs_installer); + } if target.contains("pc-windows-gnu") { tarballs.push(mingw_installer.unwrap()); } From b8cf07ee1fbc8c564e70318b8ba1931814238733 Mon Sep 17 00:00:00 2001 From: est31 Date: Mon, 4 Sep 2017 22:41:01 +0200 Subject: [PATCH 20/40] Improve DefIndex formatting to be more semantic --- src/librustc/hir/def_id.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index 7f76e1bf770bf..78daff9f67aa5 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -93,10 +93,19 @@ impl serialize::UseSpecializedDecodable for CrateNum { /// /// Since the DefIndex is mostly treated as an opaque ID, you probably /// don't have to care about these ranges. -#[derive(Clone, Debug, Eq, Ord, PartialOrd, PartialEq, RustcEncodable, +#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable, RustcDecodable, Hash, Copy)] pub struct DefIndex(u32); +impl fmt::Debug for DefIndex { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, + "DefIndex({}:{})", + self.address_space().index(), + self.as_array_index()) + } +} + impl DefIndex { #[inline] pub fn new(x: usize) -> DefIndex { From 69c472897fb74ba98584c9b33f60ca6f04b04afe Mon Sep 17 00:00:00 2001 From: Niels Egberts Date: Mon, 4 Sep 2017 22:59:34 +0100 Subject: [PATCH 21/40] Make slice::split_at_mut example demonstrate mutability Moved the examples from split_at_mut to split_at so the example at split_at_mut can just demonstrate mutability. --- src/liballoc/slice.rs | 45 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 7787ace944119..2045d5ddd972d 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -671,10 +671,25 @@ impl [T] { /// # Examples /// /// ``` - /// let v = [10, 40, 30, 20, 50]; - /// let (v1, v2) = v.split_at(2); - /// assert_eq!([10, 40], v1); - /// assert_eq!([30, 20, 50], v2); + /// let v = [1, 2, 3, 4, 5, 6]; + /// + /// { + /// let (left, right) = v.split_at(0); + /// assert!(left == []); + /// assert!(right == [1, 2, 3, 4, 5, 6]); + /// } + /// + /// { + /// let (left, right) = v.split_at(2); + /// assert!(left == [1, 2]); + /// assert!(right == [3, 4, 5, 6]); + /// } + /// + /// { + /// let (left, right) = v.split_at(6); + /// assert!(left == [1, 2, 3, 4, 5, 6]); + /// assert!(right == []); + /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -695,26 +710,16 @@ impl [T] { /// # Examples /// /// ``` - /// let mut v = [1, 2, 3, 4, 5, 6]; - /// + /// let mut v = [1, 0, 3, 0, 5, 6]; /// // scoped to restrict the lifetime of the borrows /// { - /// let (left, right) = v.split_at_mut(0); - /// assert!(left == []); - /// assert!(right == [1, 2, 3, 4, 5, 6]); - /// } - /// - /// { /// let (left, right) = v.split_at_mut(2); - /// assert!(left == [1, 2]); - /// assert!(right == [3, 4, 5, 6]); - /// } - /// - /// { - /// let (left, right) = v.split_at_mut(6); - /// assert!(left == [1, 2, 3, 4, 5, 6]); - /// assert!(right == []); + /// assert!(left == [1, 0]); + /// assert!(right == [3, 0, 5, 6]); + /// left[1] = 2; + /// right[1] = 4; /// } + /// assert!(v == [1, 2, 3, 4, 5, 6]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] From 76fae7197bd8182cba166422e8888148f3474575 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 5 Sep 2017 00:23:34 +0200 Subject: [PATCH 22/40] Fix tests --- src/test/mir-opt/validate_1.rs | 4 ++-- src/test/mir-opt/validate_4.rs | 12 ++++++------ src/test/mir-opt/validate_5.rs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/mir-opt/validate_1.rs b/src/test/mir-opt/validate_1.rs index ae9dcf8b7352d..f9833ffecc280 100644 --- a/src/test/mir-opt/validate_1.rs +++ b/src/test/mir-opt/validate_1.rs @@ -30,7 +30,7 @@ fn main() { // END RUST SOURCE // START rustc.node12.EraseRegions.after.mir // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(0:5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(0:5) => validate_1/8cd878b::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]); // return; // } // END rustc.node12.EraseRegions.after.mir @@ -57,7 +57,7 @@ fn main() { // START rustc.node50.EraseRegions.after.mir // fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 { // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_1/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_1/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:15) => validate_1/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:15) => validate_1/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // StorageLive(_3); // _3 = _2; // StorageLive(_4); diff --git a/src/test/mir-opt/validate_4.rs b/src/test/mir-opt/validate_4.rs index 2ee459d6809c5..cd5beae8e91fb 100644 --- a/src/test/mir-opt/validate_4.rs +++ b/src/test/mir-opt/validate_4.rs @@ -48,8 +48,8 @@ fn main() { // START rustc.node22.EraseRegions.after.mir // fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () { // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483659) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483659) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:11) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:11) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]); // StorageLive(_3); // _3 = _2; // (*_3) = const 23i32; @@ -61,8 +61,8 @@ fn main() { // START rustc.node31.EraseRegions.after.mir // fn test(_1: &ReErased mut i32) -> () { // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(4) => validate_4/8cd878b::test[0] }, BrAnon(0)) mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(4) => validate_4/8cd878b::test[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(0:4) => validate_4/8cd878b::test[0] }, BrAnon(0)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(0:4) => validate_4/8cd878b::test[0] }, BrAnon(0)) mut i32]); // _3 = const write_42(_4) -> bb1; // } // bb1: { @@ -74,8 +74,8 @@ fn main() { // START rustc.node60.EraseRegions.after.mir // fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool { // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:15) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:15) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:15) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:15) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // StorageLive(_3); // _0 = const write_42(_4) -> bb1; // } diff --git a/src/test/mir-opt/validate_5.rs b/src/test/mir-opt/validate_5.rs index ef2073dcc4b0f..dc3daee7ad3a4 100644 --- a/src/test/mir-opt/validate_5.rs +++ b/src/test/mir-opt/validate_5.rs @@ -36,7 +36,7 @@ fn main() { // START rustc.node17.EraseRegions.after.mir // fn test(_1: &ReErased mut i32) -> () { // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(4) => validate_5/8cd878b::test[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(0:4) => validate_5/8cd878b::test[0] }, BrAnon(0)) mut i32]); // Validate(Release, [_3: bool, _4: *mut i32]); // _3 = const write_42(_4) -> bb1; // } @@ -45,7 +45,7 @@ fn main() { // START rustc.node46.EraseRegions.after.mir // fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool { // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:12) => validate_5/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(1:12) => validate_5/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // StorageLive(_3); // _3 = _2; // StorageLive(_4); From e90f4236e0b06b52c0023ea46049736e45438ebf Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Mon, 4 Sep 2017 19:59:16 -0400 Subject: [PATCH 23/40] #33490 is closed remove the FIXME --- src/test/run-pass/issue-23338-ensure-param-drop-order.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/run-pass/issue-23338-ensure-param-drop-order.rs b/src/test/run-pass/issue-23338-ensure-param-drop-order.rs index 9d0612f2a8daa..42c72e647fd2e 100644 --- a/src/test/run-pass/issue-23338-ensure-param-drop-order.rs +++ b/src/test/run-pass/issue-23338-ensure-param-drop-order.rs @@ -64,8 +64,7 @@ fn test<'a>(log: d::Log<'a>) { d::println(&format!("result {}", result)); } -// FIXME(#33490) Remove the double braces when old trans is gone. -fn foo<'a>(da0: D<'a>, de1: D<'a>) -> D<'a> {{ +fn foo<'a>(da0: D<'a>, de1: D<'a>) -> D<'a> { d::println("entered foo"); let de2 = de1.incr(); // creates D(de_2, 2) let de4 = { @@ -74,7 +73,7 @@ fn foo<'a>(da0: D<'a>, de1: D<'a>) -> D<'a> {{ }; d::println("eval tail of foo"); de4.incr().incr() // creates D(de_5, 6) and D(de_6, 7) -}} +} // This module provides simultaneous printouts of the dynamic extents // of all of the D values, in addition to logging the order that each From b88ec735aa9173c7075c77adbbd7084cdaeedd61 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Mon, 4 Sep 2017 20:06:39 -0400 Subject: [PATCH 24/40] #12808 is closed remove the FIXME --- src/test/run-pass/overloaded-autoderef-order.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/run-pass/overloaded-autoderef-order.rs b/src/test/run-pass/overloaded-autoderef-order.rs index 7433494dec677..8ea8b375b17b4 100644 --- a/src/test/run-pass/overloaded-autoderef-order.rs +++ b/src/test/run-pass/overloaded-autoderef-order.rs @@ -75,7 +75,6 @@ pub fn main() { assert_eq!(Rc::new(nested).x, true); let nested_priv = priv_test::DerefWrapperHideX::new(true, DerefWrapper {x: 0, y: 1}); - // FIXME(eddyb) #12808 should skip private fields. - // assert_eq!(nested_priv.x, 0); + assert_eq!(nested_priv.x, 0); assert_eq!((*nested_priv).x, 0); } From 1c5bf2468b7f0fe2aa63c6037c82521bff1dac17 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Mon, 4 Sep 2017 11:08:08 -0500 Subject: [PATCH 25/40] std/time: Give an example to get UNIX_EPOCH in seconds --- src/libstd/time/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index 5b893505b34d2..e0dd8cfe62e6f 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -382,6 +382,17 @@ impl fmt::Debug for SystemTime { /// [`SystemTime`] instance to represent another fixed point in time. /// /// [`SystemTime`]: ../../std/time/struct.SystemTime.html +/// +/// # Examples +/// +/// ```no_run +/// use std::time::{SystemTime, UNIX_EPOCH}; +/// +/// match SystemTime::now().duration_since(UNIX_EPOCH) { +/// Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()), +/// Err(_) => panic!("SystemTime before UNIX EPOCH!"), +/// } +/// ``` #[stable(feature = "time2", since = "1.8.0")] pub const UNIX_EPOCH: SystemTime = SystemTime(time::UNIX_EPOCH); From 7d94ca618c1627e1751dd7744e781d864c5887bb Mon Sep 17 00:00:00 2001 From: Max Comstock Date: Mon, 4 Sep 2017 22:16:15 -0400 Subject: [PATCH 26/40] Removed the incorrect documentation for from_str --- src/libcore/num/dec2flt/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index f353770a736e4..f93564c2849f5 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -121,7 +121,6 @@ macro_rules! from_str_float_impl { /// * '-3.14' /// * '2.5E10', or equivalently, '2.5e10' /// * '2.5E-10' - /// * '.' (understood as 0) /// * '5.' /// * '.5', or, equivalently, '0.5' /// * 'inf', '-inf', 'NaN' From b762283e57ff71f6763effb9cfc7fc0c7967b6b0 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Mon, 4 Sep 2017 20:49:46 -0600 Subject: [PATCH 27/40] Add panic unit tests --- src/libstd/f32.rs | 18 ++++++++++++++++++ src/libstd/f64.rs | 18 ++++++++++++++++++ src/libstd/lib.rs | 1 + 3 files changed, 37 insertions(+) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index aaeac06535ee6..69ca77f54b44a 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1777,4 +1777,22 @@ mod tests { assert_ne!(nan_masked & QNAN_MASK, 0); assert!(nan_masked_fl.is_nan()); } + + #[test] + #[should_panic] + fn test_clamp_min_greater_than_max() { + 1.0f32.clamp(3.0, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_min_is_nan() { + 1.0f32.clamp(NAN, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_max_is_nan() { + 1.0f32.clamp(3.0, NAN); + } } diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 4ab319c3cf100..6ec633bfaaac1 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -1668,4 +1668,22 @@ mod tests { assert_approx_eq!(f64::from_bits(0x4094e40000000000), 1337.0); assert_approx_eq!(f64::from_bits(0xc02c800000000000), -14.25); } + + #[test] + #[should_panic] + fn test_clamp_min_greater_than_max() { + 1.0f64.clamp(3.0, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_min_is_nan() { + 1.0f64.clamp(NAN, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_max_is_nan() { + 1.0f64.clamp(3.0, NAN); + } } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index cf1eb5cd52ea4..191f7fe648ed2 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -249,6 +249,7 @@ #![feature(cfg_target_vendor)] #![feature(char_error_internals)] #![feature(char_internals)] +#![feature(clamp)] #![feature(collections_range)] #![feature(compiler_builtins_lib)] #![feature(const_fn)] From 280e6d8f1710105747da196ad91991891e0dbf83 Mon Sep 17 00:00:00 2001 From: Wangshan Lu Date: Tue, 5 Sep 2017 12:27:14 +0800 Subject: [PATCH 28/40] Fix link typo in 1.20.0 release notes --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 5815cb0f97260..2979ffe136c90 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -170,7 +170,7 @@ Compatibility Notes [`slice::sort_unstable_by_key`]: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable_by_key [`slice::sort_unstable_by`]: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable_by [`slice::sort_unstable`]: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable -[`ste::from_boxed_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_boxed_utf8_unchecked.html +[`str::from_boxed_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_boxed_utf8_unchecked.html [`str::as_bytes_mut`]: https://doc.rust-lang.org/std/primitive.str.html#method.as_bytes_mut [`str::from_utf8_mut`]: https://doc.rust-lang.org/std/str/fn.from_utf8_mut.html [`str::from_utf8_unchecked_mut`]: https://doc.rust-lang.org/std/str/fn.from_utf8_unchecked_mut.html From f912d771badbe981d7caa89b754248eb141e14c3 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 4 Sep 2017 17:31:29 +0200 Subject: [PATCH 29/40] Make git commit info optional and per-package in channel manifests At the moment it is always missing for Cargo and RLS. Their respective build systems need to be modified to include `git-commit-hash` files in their "dist" tarballs. --- src/tools/build-manifest/src/main.rs | 43 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 39b5d275dffaa..0e91fa9c6022b 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -107,13 +107,13 @@ static MINGW: &'static [&'static str] = &[ struct Manifest { manifest_version: String, date: String, - git_commit_hash: String, pkg: BTreeMap, } #[derive(Serialize)] struct Package { version: String, + git_commit_hash: Option, target: BTreeMap, } @@ -168,6 +168,9 @@ struct Builder { rust_version: String, cargo_version: String, rls_version: String, + rust_git_commit_hash: Option, + cargo_git_commit_hash: Option, + rls_git_commit_hash: Option, } fn main() { @@ -195,6 +198,9 @@ fn main() { rust_version: String::new(), cargo_version: String::new(), rls_version: String::new(), + rust_git_commit_hash: None, + cargo_git_commit_hash: None, + rls_git_commit_hash: None, }.build(); } @@ -203,6 +209,9 @@ impl Builder { self.rust_version = self.version("rust", "x86_64-unknown-linux-gnu"); self.cargo_version = self.version("cargo", "x86_64-unknown-linux-gnu"); self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu"); + self.rust_git_commit_hash = self.git_commit_hash("rust", "x86_64-unknown-linux-gnu"); + self.cargo_git_commit_hash = self.git_commit_hash("cargo", "x86_64-unknown-linux-gnu"); + self.rls_git_commit_hash = self.git_commit_hash("rls", "x86_64-unknown-linux-gnu"); self.digest_and_sign(); let manifest = self.build_manifest(); @@ -226,7 +235,6 @@ impl Builder { let mut manifest = Manifest { manifest_version: "2".to_string(), date: self.date.to_string(), - git_commit_hash: self.git_commit_hash("rust", "x86_64-unknown-linux-gnu"), pkg: BTreeMap::new(), }; @@ -246,6 +254,7 @@ impl Builder { let mut pkg = Package { version: self.cached_version("rust").to_string(), + git_commit_hash: self.cached_git_commit_hash("rust").clone(), target: BTreeMap::new(), }; for host in HOSTS { @@ -339,6 +348,7 @@ impl Builder { dst.insert(pkgname.to_string(), Package { version: self.cached_version(pkgname).to_string(), + git_commit_hash: self.cached_git_commit_hash(pkgname).clone(), target: targets, }); } @@ -372,6 +382,16 @@ impl Builder { } } + fn cached_git_commit_hash(&self, component: &str) -> &Option { + if component == "cargo" { + &self.cargo_git_commit_hash + } else if component == "rls" || component == "rls-preview" { + &self.rls_git_commit_hash + } else { + &self.rust_git_commit_hash + } + } + fn version(&self, component: &str, target: &str) -> String { let mut cmd = Command::new("tar"); let filename = self.filename(component, target); @@ -389,7 +409,7 @@ impl Builder { String::from_utf8_lossy(&output.stdout).trim().to_string() } - fn git_commit_hash(&self, component: &str, target: &str) -> String { + fn git_commit_hash(&self, component: &str, target: &str) -> Option { let mut cmd = Command::new("tar"); let filename = self.filename(component, target); cmd.arg("xf") @@ -397,13 +417,15 @@ impl Builder { .arg(format!("{}/git-commit-hash", filename.replace(".tar.gz", ""))) .arg("-O"); let output = t!(cmd.output()); - if !output.status.success() { - panic!("failed to learn git commit hash:\n\n{:?}\n\n{}\n\n{}", - cmd, - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr)); + if output.status.success() { + Some(String::from_utf8_lossy(&output.stdout).trim().to_string()) + } else { + // This is always called after `.version()`. + // So if that didn’t fail but this does, + // that’s very probably because the tarball is valid + // but does not contain a `git-commit-hash` file. + None } - String::from_utf8_lossy(&output.stdout).trim().to_string() } fn hash(&self, path: &Path) -> String { @@ -442,7 +464,8 @@ impl Builder { fn write_channel_files(&self, channel_name: &str, manifest: &Manifest) { self.write(&toml::to_string(&manifest).unwrap(), channel_name, ".toml"); self.write(&manifest.date, channel_name, "-date.txt"); - self.write(&manifest.git_commit_hash, channel_name, "-git-commit-hash.txt"); + self.write(manifest.pkg["rust"].git_commit_hash.as_ref().unwrap(), + channel_name, "-git-commit-hash.txt"); } fn write(&self, contents: &str, channel_name: &str, suffix: &str) { From 668d8ff262bb55276c6028c7e5d903a71fec2906 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 4 Aug 2017 00:19:58 +0000 Subject: [PATCH 30/40] Add support for Vector Sum Across Partial 1/2 Saturated on PowerPC --- src/etc/platform-intrinsics/powerpc.json | 7 +++++++ src/librustc_platform_intrinsics/powerpc.rs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/etc/platform-intrinsics/powerpc.json b/src/etc/platform-intrinsics/powerpc.json index 4ed1ecd76393e..eb443f2077ae3 100644 --- a/src/etc/platform-intrinsics/powerpc.json +++ b/src/etc/platform-intrinsics/powerpc.json @@ -191,6 +191,13 @@ "llvm": "vmsum{0.kind}hs", "ret": "i32", "args": ["0N", "0N", "0"] + }, + { + "intrinsic": "sum2s", + "width": [128], + "llvm": "vsum2sws", + "ret": "s32", + "args": ["0", "0"] } ] } diff --git a/src/librustc_platform_intrinsics/powerpc.rs b/src/librustc_platform_intrinsics/powerpc.rs index b205321d10f4a..dd0967beda4dd 100644 --- a/src/librustc_platform_intrinsics/powerpc.rs +++ b/src/librustc_platform_intrinsics/powerpc.rs @@ -372,6 +372,11 @@ pub fn find(name: &str) -> Option { output: &::U32x4, definition: Named("llvm.ppc.altivec.vmsumuhs") }, + "_vec_sum2s" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 2] = [&::I32x4, &::I32x4]; &INPUTS }, + output: &::I32x4, + definition: Named("llvm.ppc.altivec.vsum2sws") + }, _ => return None, }) } From eec1c178b3ebddfeb86ce76472b0285f871d2255 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 4 Aug 2017 00:19:58 +0000 Subject: [PATCH 31/40] Add support for Vector Sum Across Partial 1/4 Saturated on PowerPC --- src/etc/platform-intrinsics/powerpc.json | 14 ++++++++++++++ src/librustc_platform_intrinsics/powerpc.rs | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/etc/platform-intrinsics/powerpc.json b/src/etc/platform-intrinsics/powerpc.json index eb443f2077ae3..1f78363e43b7e 100644 --- a/src/etc/platform-intrinsics/powerpc.json +++ b/src/etc/platform-intrinsics/powerpc.json @@ -198,6 +198,20 @@ "llvm": "vsum2sws", "ret": "s32", "args": ["0", "0"] + }, + { + "intrinsic": "sum4{0.kind}bs", + "width": [128], + "llvm": "vsum4{0.kind}bs", + "ret": "i32", + "args": ["0NN", "0"] + }, + { + "intrinsic": "sum4shs", + "width": [128], + "llvm": "vsum4shs", + "ret": "s32", + "args": ["0N", "0"] } ] } diff --git a/src/librustc_platform_intrinsics/powerpc.rs b/src/librustc_platform_intrinsics/powerpc.rs index dd0967beda4dd..4d71c42edda3f 100644 --- a/src/librustc_platform_intrinsics/powerpc.rs +++ b/src/librustc_platform_intrinsics/powerpc.rs @@ -377,6 +377,21 @@ pub fn find(name: &str) -> Option { output: &::I32x4, definition: Named("llvm.ppc.altivec.vsum2sws") }, + "_vec_sum4sbs" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 2] = [&::I8x16, &::I32x4]; &INPUTS }, + output: &::I32x4, + definition: Named("llvm.ppc.altivec.vsum4sbs") + }, + "_vec_sum4ubs" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 2] = [&::U8x16, &::U32x4]; &INPUTS }, + output: &::U32x4, + definition: Named("llvm.ppc.altivec.vsum4ubs") + }, + "_vec_sum4shs" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 2] = [&::I16x8, &::I32x4]; &INPUTS }, + output: &::I32x4, + definition: Named("llvm.ppc.altivec.vsum4shs") + }, _ => return None, }) } From c3041e8b9e2d2a21addb8afd346af293293f1d68 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 4 Aug 2017 00:19:58 +0000 Subject: [PATCH 32/40] Add support for Vector Sum Saturated on PowerPC --- src/etc/platform-intrinsics/powerpc.json | 7 +++++++ src/librustc_platform_intrinsics/powerpc.rs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/etc/platform-intrinsics/powerpc.json b/src/etc/platform-intrinsics/powerpc.json index 1f78363e43b7e..6268438184254 100644 --- a/src/etc/platform-intrinsics/powerpc.json +++ b/src/etc/platform-intrinsics/powerpc.json @@ -212,6 +212,13 @@ "llvm": "vsum4shs", "ret": "s32", "args": ["0N", "0"] + }, + { + "intrinsic": "sums", + "width": [128], + "llvm": "vsumsws", + "ret": "s32", + "args": ["0", "0"] } ] } diff --git a/src/librustc_platform_intrinsics/powerpc.rs b/src/librustc_platform_intrinsics/powerpc.rs index 4d71c42edda3f..a9c56309aa8ba 100644 --- a/src/librustc_platform_intrinsics/powerpc.rs +++ b/src/librustc_platform_intrinsics/powerpc.rs @@ -392,6 +392,11 @@ pub fn find(name: &str) -> Option { output: &::I32x4, definition: Named("llvm.ppc.altivec.vsum4shs") }, + "_vec_sums" => Intrinsic { + inputs: { static INPUTS: [&'static Type; 2] = [&::I32x4, &::I32x4]; &INPUTS }, + output: &::I32x4, + definition: Named("llvm.ppc.altivec.vsumsws") + }, _ => return None, }) } From 110efe25fae60570c00e00d4c6d609f3f9666fb3 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 5 Sep 2017 14:19:22 -0700 Subject: [PATCH 33/40] Include rustc in the default `./x.py install` The default install used to include rustc, rust-std, and rust-docs, but the refactoring in commit 6b3413d825fa6 make rustc only default in extended builds. This commit makes rustc installed by default again. --- src/bootstrap/install.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 89690e444d1f6..608924c9c28d1 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -200,7 +200,7 @@ install!((self, builder, _config), builder.ensure(dist::Src); install_src(builder, self.stage); }, ONLY_BUILD; - Rustc, "src/librustc", _config.extended, only_hosts: true, { + Rustc, "src/librustc", true, only_hosts: true, { builder.ensure(dist::Rustc { compiler: builder.compiler(self.stage, self.target), }); From 2047a0d083ad8bf651d00287267e0ef418ef50f5 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Thu, 31 Aug 2017 09:34:03 -0500 Subject: [PATCH 34/40] bootstrap: add openssl config for sparc64-unknown-netbsd --- src/bootstrap/native.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 8173903c03440..ee00ee57e94d8 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -416,6 +416,7 @@ impl Step for Openssl { "powerpc64-unknown-linux-gnu" => "linux-ppc64", "powerpc64le-unknown-linux-gnu" => "linux-ppc64le", "s390x-unknown-linux-gnu" => "linux64-s390x", + "sparc64-unknown-netbsd" => "BSD-sparc64", "x86_64-apple-darwin" => "darwin64-x86_64-cc", "x86_64-linux-android" => "linux-x86_64", "x86_64-unknown-freebsd" => "BSD-x86_64", @@ -435,6 +436,10 @@ impl Step for Openssl { configure.arg("-mandroid"); configure.arg("-fomit-frame-pointer"); } + if target == "sparc64-unknown-netbsd" { + // Need -m64 to get assembly generated correctly for sparc64. + configure.arg("-m64"); + } // Make PIE binaries // Non-PIE linker support was removed in Lollipop // https://source.android.com/security/enhancements/enhancements50 From 847d1ffbe95729f4e22db022298a7b22c94ad18b Mon Sep 17 00:00:00 2001 From: "Jonathan A. Kollasch" Date: Thu, 31 Aug 2017 09:36:10 -0500 Subject: [PATCH 35/40] bootstrap: avoid m4 -B for NetBSD-built sparc64 OpenSSL --- src/bootstrap/native.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index ee00ee57e94d8..b3929516470a6 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -439,6 +439,11 @@ impl Step for Openssl { if target == "sparc64-unknown-netbsd" { // Need -m64 to get assembly generated correctly for sparc64. configure.arg("-m64"); + if build.build.contains("netbsd") { + // Disable sparc64 asm on NetBSD builders, it uses + // m4(1)'s -B flag, which NetBSD m4 does not support. + configure.arg("no-asm"); + } } // Make PIE binaries // Non-PIE linker support was removed in Lollipop From af3536dbbcc4efe6e3020a2720f0594934d5cf3c Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Tue, 5 Sep 2017 18:46:21 -0700 Subject: [PATCH 36/40] Remove trailing white space --- src/libsyntax/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 2b13bd9c410d5..5248f874a6e97 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -763,7 +763,7 @@ pub enum StmtKind { Expr(P), /// Expr with a trailing semi-colon. Semi(P), - /// Macro. + /// Macro. Mac(P<(Mac, MacStmtStyle, ThinVec)>), } From ddd01455e9eb7d6356c43e7802337d3e4202d846 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 6 Sep 2017 10:09:25 +0200 Subject: [PATCH 37/40] Suggest changing literals instead of calling methods (fixes #44307) --- src/librustc_typeck/check/demand.rs | 24 +++++++++++++++++- src/test/ui/str-lit-type-mismatch.rs | 16 ++++++++++++ src/test/ui/str-lit-type-mismatch.stderr | 32 ++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/str-lit-type-mismatch.rs create mode 100644 src/test/ui/str-lit-type-mismatch.stderr diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index fc241c023cdaf..65900dc3f36e7 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -207,7 +207,29 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expected: Ty<'tcx>) -> Option { match (&expected.sty, &checked_ty.sty) { - (&ty::TyRef(_, _), &ty::TyRef(_, _)) => None, + (&ty::TyRef(_, exp), &ty::TyRef(_, check)) => match (&exp.ty.sty, &check.ty.sty) { + (&ty::TyStr, &ty::TyArray(arr, _)) | + (&ty::TyStr, &ty::TySlice(arr)) if arr == self.tcx.types.u8 => { + if let hir::ExprLit(_) = expr.node { + let sp = self.sess().codemap().call_span_if_macro(expr.span); + if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(sp) { + return Some(format!("try `{}`", &src[1..])); + } + } + None + }, + (&ty::TyArray(arr, _), &ty::TyStr) | + (&ty::TySlice(arr), &ty::TyStr) if arr == self.tcx.types.u8 => { + if let hir::ExprLit(_) = expr.node { + let sp = self.sess().codemap().call_span_if_macro(expr.span); + if let Ok(src) = self.tcx.sess.codemap().span_to_snippet(sp) { + return Some(format!("try `b{}`", src)); + } + } + None + } + _ => None, + }, (&ty::TyRef(_, mutability), _) => { // Check if it can work when put into a ref. For example: // diff --git a/src/test/ui/str-lit-type-mismatch.rs b/src/test/ui/str-lit-type-mismatch.rs new file mode 100644 index 0000000000000..0fd7d3a9d869e --- /dev/null +++ b/src/test/ui/str-lit-type-mismatch.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn main() { + let x: &[u8] = "foo"; + let y: &[u8; 4] = "baaa"; + let z: &str = b"foo"; +} diff --git a/src/test/ui/str-lit-type-mismatch.stderr b/src/test/ui/str-lit-type-mismatch.stderr new file mode 100644 index 0000000000000..47418522df8ac --- /dev/null +++ b/src/test/ui/str-lit-type-mismatch.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/str-lit-type-mismatch.rs:13:20 + | +13 | let x: &[u8] = "foo"; + | ^^^^^ expected slice, found str + | + = note: expected type `&[u8]` + found type `&'static str` + = help: try `b"foo"` + +error[E0308]: mismatched types + --> $DIR/str-lit-type-mismatch.rs:14:23 + | +14 | let y: &[u8; 4] = "baaa"; + | ^^^^^^ expected array of 4 elements, found str + | + = note: expected type `&[u8; 4]` + found type `&'static str` + = help: try `b"baaa"` + +error[E0308]: mismatched types + --> $DIR/str-lit-type-mismatch.rs:15:19 + | +15 | let z: &str = b"foo"; + | ^^^^^^ expected str, found array of 3 elements + | + = note: expected type `&str` + found type `&'static [u8; 3]` + = help: try `"foo"` + +error: aborting due to 3 previous errors + From 02fb1b0b724abef67591b3ff2ff966e6b031cdab Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 6 Sep 2017 10:33:53 +0200 Subject: [PATCH 38/40] Fix a bug in the inliner --- src/librustc_mir/transform/inline.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 3f8070fb3aa31..dc27da81978c1 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -616,8 +616,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { Operand::Consume(Lvalue::Local(l)) => *local = l, ref op => bug!("Arg operand `{:?}` is {:?}, not local", idx, op) } + } else { + *local = self.local_map[Local::new(idx - self.args.len())]; } - *local = self.local_map[Local::new(idx - self.args.len())]; } fn visit_lvalue(&mut self, From 5bb870faca71bd139c5c4a00381974f66f29e859 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 6 Sep 2017 12:25:46 +0200 Subject: [PATCH 39/40] Reintroduce the early returns --- src/librustc_mir/transform/inline.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index dc27da81978c1..b2572b2d0aba6 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -606,19 +606,24 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { _location: Location) { if *local == RETURN_POINTER { match self.destination { - Lvalue::Local(l) => *local = l, + Lvalue::Local(l) => { + *local = l; + return; + }, ref lval => bug!("Return lvalue is {:?}, not local", lval) } } let idx = local.index() - 1; if idx < self.args.len() { match self.args[idx] { - Operand::Consume(Lvalue::Local(l)) => *local = l, + Operand::Consume(Lvalue::Local(l)) => { + *local = l; + return; + }, ref op => bug!("Arg operand `{:?}` is {:?}, not local", idx, op) } - } else { - *local = self.local_map[Local::new(idx - self.args.len())]; } + *local = self.local_map[Local::new(idx - self.args.len())]; } fn visit_lvalue(&mut self, From 04cbf6eece5170e544680ebd24617f498b24cc92 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 6 Sep 2017 18:22:32 -0400 Subject: [PATCH 40/40] config.toml.example: fix some typos --- config.toml.example | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config.toml.example b/config.toml.example index 3f5101ebf342f..266f425013213 100644 --- a/config.toml.example +++ b/config.toml.example @@ -146,10 +146,10 @@ # option to true. #full-bootstrap = false -# Enable a build of the and extended rust tool set which is not only the -# compiler but also tools such as Cargo. This will also produce "combined -# installers" which are used to install Rust and Cargo together. This is -# disabled by default. +# Enable a build of the extended rust tool set which is not only the compiler +# but also tools such as Cargo. This will also produce "combined installers" +# which are used to install Rust and Cargo together. This is disabled by +# default. #extended = false # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose @@ -175,7 +175,7 @@ # script. #configure-args = [] -# Indicates that a local rebuild is ocurring instead of a full bootstrap, +# Indicates that a local rebuild is occurring instead of a full bootstrap, # essentially skipping stage0 as the local compiler is recompiling itself again. #local-rebuild = false