From 85796dd0bad3486f52e3ff9ecb0db6f52d3c460f Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 11 Jun 2018 23:10:51 +0200 Subject: [PATCH 1/8] stabilize Iterator::flatten in 1.29, fixes #48115. --- src/libcore/iter/iterator.rs | 8 +------- src/libcore/iter/mod.rs | 12 ++++++------ src/libcore/lib.rs | 1 - src/libcore/tests/lib.rs | 1 - 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 1972b0099053e..102e46dc0f48a 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -1036,8 +1036,6 @@ pub trait Iterator { /// Basic usage: /// /// ``` - /// #![feature(iterator_flatten)] - /// /// let data = vec![vec![1, 2, 3, 4], vec![5, 6]]; /// let flattened = data.into_iter().flatten().collect::>(); /// assert_eq!(flattened, &[1, 2, 3, 4, 5, 6]); @@ -1046,8 +1044,6 @@ pub trait Iterator { /// Mapping and then flattening: /// /// ``` - /// #![feature(iterator_flatten)] - /// /// let words = ["alpha", "beta", "gamma"]; /// /// // chars() returns an iterator @@ -1074,8 +1070,6 @@ pub trait Iterator { /// Flattening once only removes one level of nesting: /// /// ``` - /// #![feature(iterator_flatten)] - /// /// let d3 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]; /// /// let d2 = d3.iter().flatten().collect::>(); @@ -1093,7 +1087,7 @@ pub trait Iterator { /// /// [`flat_map()`]: #method.flat_map #[inline] - #[unstable(feature = "iterator_flatten", issue = "48213")] + #[stable(feature = "iterator_flatten", since = "1.29")] fn flatten(self) -> Flatten where Self: Sized, Self::Item: IntoIterator { Flatten { inner: flatten_compat(self) } diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index f152ee73b6996..9ab3b786e9218 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -2524,13 +2524,13 @@ impl FusedIterator for FlatMap /// [`flatten`]: trait.Iterator.html#method.flatten /// [`Iterator`]: trait.Iterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] -#[unstable(feature = "iterator_flatten", issue = "48213")] +#[stable(feature = "iterator_flatten", since = "1.29")] pub struct Flatten where I::Item: IntoIterator { inner: FlattenCompat::IntoIter>, } -#[unstable(feature = "iterator_flatten", issue = "48213")] +#[stable(feature = "iterator_flatten", since = "1.29")] impl fmt::Debug for Flatten where I: Iterator + fmt::Debug, U: Iterator + fmt::Debug, I::Item: IntoIterator, @@ -2540,7 +2540,7 @@ impl fmt::Debug for Flatten } } -#[unstable(feature = "iterator_flatten", issue = "48213")] +#[stable(feature = "iterator_flatten", since = "1.29")] impl Clone for Flatten where I: Iterator + Clone, U: Iterator + Clone, I::Item: IntoIterator, @@ -2548,7 +2548,7 @@ impl Clone for Flatten fn clone(&self) -> Self { Flatten { inner: self.inner.clone() } } } -#[unstable(feature = "iterator_flatten", issue = "48213")] +#[stable(feature = "iterator_flatten", since = "1.29")] impl Iterator for Flatten where I: Iterator, U: Iterator, I::Item: IntoIterator @@ -2576,7 +2576,7 @@ impl Iterator for Flatten } } -#[unstable(feature = "iterator_flatten", issue = "48213")] +#[stable(feature = "iterator_flatten", since = "1.29")] impl DoubleEndedIterator for Flatten where I: DoubleEndedIterator, U: DoubleEndedIterator, I::Item: IntoIterator @@ -2599,7 +2599,7 @@ impl DoubleEndedIterator for Flatten } } -#[unstable(feature = "iterator_flatten", issue = "48213")] +#[stable(feature = "iterator_flatten", since = "1.29")] impl FusedIterator for Flatten where I: FusedIterator, U: Iterator, I::Item: IntoIterator {} diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index a2ee0033872d3..4edfb06944ba9 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -89,7 +89,6 @@ #![feature(extern_types)] #![feature(fundamental)] #![feature(intrinsics)] -#![feature(iterator_flatten)] #![feature(lang_items)] #![feature(link_llvm_intrinsics)] #![feature(never_type)] diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 11765e3ef56ee..4c8f72010a2d2 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -23,7 +23,6 @@ #![feature(flt2dec)] #![feature(fmt_internals)] #![feature(hashmap_internals)] -#![feature(iterator_flatten)] #![feature(pattern)] #![feature(range_is_empty)] #![feature(raw)] From 30d825ce72c6e56a3c82f338897a437eaa8cd882 Mon Sep 17 00:00:00 2001 From: Josef Reinhard Brandl Date: Wed, 27 Jun 2018 20:15:24 +0200 Subject: [PATCH 2/8] Fix doc links --- src/libcore/future.rs | 14 +++++++++----- src/libstd/error.rs | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libcore/future.rs b/src/libcore/future.rs index a8c8f69411ea6..153cd6c0724d6 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -45,18 +45,18 @@ pub trait Future { /// /// This function returns: /// - /// - `Poll::Pending` if the future is not ready yet - /// - `Poll::Ready(val)` with the result `val` of this future if it finished - /// successfully. + /// - [`Poll::Pending`] if the future is not ready yet + /// - [`Poll::Ready(val)`] with the result `val` of this future if it + /// finished successfully. /// /// Once a future has finished, clients should not `poll` it again. /// /// When a future is not ready yet, `poll` returns - /// [`Poll::Pending`](::task::Poll). The future will *also* register the + /// `Poll::Pending`. The future will *also* register the /// interest of the current task in the value being produced. For example, /// if the future represents the availability of data on a socket, then the /// task is recorded so that when data arrives, it is woken up (via - /// [`cx.waker()`](::task::Context::waker)). Once a task has been woken up, + /// [`cx.waker()`]). Once a task has been woken up, /// it should attempt to `poll` the future again, which may or may not /// produce a final value. /// @@ -90,6 +90,10 @@ pub trait Future { /// then any future calls to `poll` may panic, block forever, or otherwise /// cause bad behavior. The `Future` trait itself provides no guarantees /// about the behavior of `poll` after a future has completed. + /// + /// [`Poll::Pending`]: ../task/enum.Poll.html#variant.Pending + /// [`Poll::Ready(val)`]: ../task/enum.Poll.html#variant.Ready + /// [`cx.waker()`]: ../task/struct.Context.html#method.waker fn poll(self: PinMut, cx: &mut task::Context) -> Poll; } diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 3160485375f6d..1958915602f83 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -49,6 +49,7 @@ use string; /// /// [`Result`]: ../result/enum.Result.html /// [`Display`]: ../fmt/trait.Display.html +/// [`Debug`]: ../fmt/trait.Debug.html /// [`cause`]: trait.Error.html#method.cause #[stable(feature = "rust1", since = "1.0.0")] pub trait Error: Debug + Display { From d6cf1821bffbaa92f07481e24749ac84bce5bfdc Mon Sep 17 00:00:00 2001 From: Ixrec Date: Fri, 29 Jun 2018 03:12:02 +0100 Subject: [PATCH 3/8] Fix inconsequential typo in GlobalAlloc doc example --- src/libstd/alloc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index f28e91e19b73c..f6cecbea11f8d 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -61,7 +61,7 @@ //! ```rust,ignore (demonstrates crates.io usage) //! extern crate jemallocator; //! -//! use jemallacator::Jemalloc; +//! use jemallocator::Jemalloc; //! //! #[global_allocator] //! static GLOBAL: Jemalloc = Jemalloc; From 28c4813920545dd3c15b1ad2f8ffdbe8c4c5bd52 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Fri, 29 Jun 2018 13:17:56 -0400 Subject: [PATCH 4/8] use literal span for concrete type suggestion Fixes #51874. --- src/librustc_typeck/check/method/suggest.rs | 7 +++---- src/test/ui/issue-51874.rs | 13 +++++++++++++ src/test/ui/issue-51874.stderr | 13 +++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/issue-51874.rs create mode 100644 src/test/ui/issue-51874.stderr diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 35d237d94de82..68c71f4ce90e9 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -245,12 +245,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "f32" }; match expr.node { - hir::ExprLit(_) => { // numeric literal - let snippet = tcx.sess.codemap().span_to_snippet(expr.span) + hir::ExprLit(ref lit) => { // numeric literal + let snippet = tcx.sess.codemap().span_to_snippet(lit.span) .unwrap_or("".to_string()); - // FIXME: use the literal for missing snippet - err.span_suggestion(expr.span, + err.span_suggestion(lit.span, &format!("you must specify a concrete type for \ this numeric value, like `{}`", concrete_type), diff --git a/src/test/ui/issue-51874.rs b/src/test/ui/issue-51874.rs new file mode 100644 index 0000000000000..63425274d4c49 --- /dev/null +++ b/src/test/ui/issue-51874.rs @@ -0,0 +1,13 @@ +// Copyright 2018 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 a = (1.0).pow(1.0); //~ ERROR can't call method `pow` on ambiguous numeric type +} diff --git a/src/test/ui/issue-51874.stderr b/src/test/ui/issue-51874.stderr new file mode 100644 index 0000000000000..8674645357189 --- /dev/null +++ b/src/test/ui/issue-51874.stderr @@ -0,0 +1,13 @@ +error[E0689]: can't call method `pow` on ambiguous numeric type `{float}` + --> $DIR/issue-51874.rs:12:19 + | +LL | let a = (1.0).pow(1.0); //~ ERROR can't call method `pow` on ambiguous numeric type + | ^^^ +help: you must specify a concrete type for this numeric value, like `f32` + | +LL | let a = (1.0_f32).pow(1.0); //~ ERROR can't call method `pow` on ambiguous numeric type + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0689`. From c67566ac27b7f578596cb4cc9811d04fdc2eb8e4 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 29 Jun 2018 16:13:40 -0500 Subject: [PATCH 5/8] rename the llvm-tools component to llvm-tools-preview and tweak its image --- src/bootstrap/dist.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 4fd6c81e59786..b5f34cdf336db 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1787,15 +1787,18 @@ impl Step for LlvmTools { let tmp = tmpdir(builder); let image = tmp.join("llvm-tools-image"); drop(fs::remove_dir_all(&image)); - t!(fs::create_dir_all(&image.join("bin"))); // Prepare the image directory + let bindir = builder + .llvm_out(target) + .join("bin"); + let dst = image.join("lib/rustlib") + .join(target) + .join("bin"); + t!(fs::create_dir_all(&dst)); for tool in LLVM_TOOLS { - let exe = builder - .llvm_out(target) - .join("bin") - .join(exe(tool, &target)); - builder.install(&exe, &image.join("bin"), 0o755); + let exe = bindir.join(exe(tool, &target)); + builder.install(&exe, &dst, 0o755); } // Prepare the overlay @@ -1818,7 +1821,7 @@ impl Step for LlvmTools { .arg("--non-installed-overlay").arg(&overlay) .arg(format!("--package-name={}-{}", name, target)) .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--component-name=llvm-tools"); + .arg("--component-name=llvm-tools-preview"); builder.run(&mut cmd); From 807cd3638192a86e51c9bd0018144d32214f2b9d Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 29 Jun 2018 22:20:00 -0500 Subject: [PATCH 6/8] rename rustc's lld to rust-lld to not shadow the system installed LLD when linking with LLD. Before: - `-C linker=lld -Z linker-flavor=ld.lld` uses rustc's LLD - It's not possible to use a system installed LLD that's named `lld` With this commit: - `-C linker=rust-lld -Z linker-flavor=ld.lld` uses rustc's LLD - `-C linker=lld -Z linker-flavor=ld.lld` uses the system installed LLD --- src/bootstrap/compile.rs | 7 +++++-- src/bootstrap/dist.rs | 8 +++++--- src/librustc_target/spec/wasm32_unknown_unknown.rs | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 11d9154ba696c..50023b3a3be8d 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -786,8 +786,11 @@ fn copy_lld_to_sysroot(builder: &Builder, .join("bin"); t!(fs::create_dir_all(&dst)); - let exe = exe("lld", &target); - builder.copy(&lld_install_root.join("bin").join(&exe), &dst.join(&exe)); + let src_exe = exe("lld", &target); + let dst_exe = exe("rust-lld", &target); + // we prepend this bin directory to the user PATH when linking Rust binaries. To + // avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`. + builder.copy(&lld_install_root.join("bin").join(&src_exe), &dst.join(&dst_exe)); } /// Cargo's output path for the standard library in a given stage, compiled diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 4fd6c81e59786..c61f360544ff8 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -491,16 +491,18 @@ impl Step for Rustc { // Copy over lld if it's there if builder.config.lld_enabled { - let exe = exe("lld", &compiler.host); + let src_exe = exe("lld", &compiler.host); + let dst_exe = exe("rust-lld", &compiler.host); let src = builder.sysroot_libdir(compiler, host) .parent() .unwrap() .join("bin") - .join(&exe); + .join(&src_exe); + // for the rationale about this rename check `compile::copy_lld_to_sysroot` let dst = image.join("lib/rustlib") .join(&*host) .join("bin") - .join(&exe); + .join(&dst_exe); t!(fs::create_dir_all(&dst.parent().unwrap())); builder.copy(&src, &dst); } diff --git a/src/librustc_target/spec/wasm32_unknown_unknown.rs b/src/librustc_target/spec/wasm32_unknown_unknown.rs index 56170bbb869f3..6f51495bae9d6 100644 --- a/src/librustc_target/spec/wasm32_unknown_unknown.rs +++ b/src/librustc_target/spec/wasm32_unknown_unknown.rs @@ -51,6 +51,9 @@ pub fn target() -> Result { // no dynamic linking, no need for default visibility! default_hidden_visibility: true, + // we use the LLD shipped with the Rust toolchain by default + linker: Some("rust-lld".to_owned()), + .. Default::default() }; Ok(Target { From 6531879e91aebd4be282ccafeb761c19b3116a31 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 30 Jun 2018 14:40:36 -0500 Subject: [PATCH 7/8] more s/llvm-tools/llvm-tools-preview/ --- src/tools/build-manifest/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 35fc2182313c9..6add6495a9351 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -298,11 +298,11 @@ impl Builder { self.package("rls-preview", &mut manifest.pkg, HOSTS); self.package("rustfmt-preview", &mut manifest.pkg, HOSTS); self.package("rust-analysis", &mut manifest.pkg, TARGETS); - self.package("llvm-tools", &mut manifest.pkg, TARGETS); + self.package("llvm-tools-preview", &mut manifest.pkg, TARGETS); let rls_present = manifest.pkg.contains_key("rls-preview"); let rustfmt_present = manifest.pkg.contains_key("rustfmt-preview"); - let llvm_tools_present = manifest.pkg.contains_key("llvm-tools"); + let llvm_tools_present = manifest.pkg.contains_key("llvm-tools-preview"); if rls_present { manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() }); @@ -359,7 +359,7 @@ impl Builder { } if llvm_tools_present { extensions.push(Component { - pkg: "llvm-tools".to_string(), + pkg: "llvm-tools-preview".to_string(), target: host.to_string(), }); } @@ -486,7 +486,7 @@ impl Builder { &self.rls_version } else if component == "rustfmt" || component == "rustfmt-preview" { &self.rustfmt_version - } else if component == "llvm-tools" { + } else if component == "llvm-tools" || component == "llvm-tools-preview" { &self.llvm_tools_version } else { &self.rust_version @@ -500,7 +500,7 @@ impl Builder { &self.rls_git_commit_hash } else if component == "rustfmt" || component == "rustfmt-preview" { &self.rustfmt_git_commit_hash - } else if component == "llvm-tools" { + } else if component == "llvm-tools" || component == "llvm-tools-preview" { &self.llvm_tools_git_commit_hash } else { &self.rust_git_commit_hash From 2e8d9d7a25029e7d5c2ea17f156da19073372f1c Mon Sep 17 00:00:00 2001 From: Takanori Ishibashi Date: Sun, 1 Jul 2018 17:37:42 +0900 Subject: [PATCH 8/8] absoluate -> absolute --- src/librustc_resolve/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 9f36f888b581b..b8dfd21e54076 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2794,7 +2794,7 @@ impl<'a> Resolver<'a> { /// A variant of `smart_resolve_path` where you also specify extra /// information about where the path came from; this extra info is /// sometimes needed for the lint that recommends rewriting - /// absoluate paths to `crate`, so that it knows how to frame the + /// absolute paths to `crate`, so that it knows how to frame the /// suggestion. If you are just resolving a path like `foo::bar` /// that appears...somewhere, though, then you just want /// `CrateLint::SimplePath`, which is what `smart_resolve_path`