From cc2a2808d078b0a7d49f7a89fa7d14ead1ebc0df Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 1 Jun 2019 17:29:05 -0700 Subject: [PATCH 01/12] Add some Vec <-> VecDeque documentation These are more than just `.into_iter().collect()`, so talk about some of their nuances. --- src/liballoc/collections/vec_deque.rs | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 31e49d06a7b5a..8cda28a5e4023 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2707,6 +2707,33 @@ impl fmt::Debug for VecDeque { } } +/// Turn a `Vec` into a `VecDeque`. +/// +/// This avoids reallocating where possible, but the conditions for that are +/// strict, and subject to change, so shouldn't be relied upon unless the +/// `Vec` came from `From` has hasn't been reallocated. +/// +/// # Examples +/// +/// ``` +/// use std::collections::VecDeque; +/// +/// // Start with a VecDeque +/// let deque: VecDeque<_> = (1..5).collect(); +/// +/// // Turn it into a Vec (no allocation needed) +/// let mut vec = Vec::from(deque); +/// +/// // modify it, being careful to not trigger reallocation +/// vec.pop(); +/// vec.push(100); +/// +/// // Turn it back into a VecDeque (no allocation needed) +/// let ptr = vec.as_ptr(); +/// let deque = VecDeque::from(vec); +/// assert_eq!(deque, [1, 2, 3, 100]); +/// assert_eq!(deque.as_slices().0.as_ptr(), ptr); +/// ``` #[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")] impl From> for VecDeque { fn from(mut other: Vec) -> Self { @@ -2733,6 +2760,32 @@ impl From> for VecDeque { } } +/// Turn a `VecDeque` into a `Vec`. +/// +/// This never needs to re-allocate, but does need to do O(n) data movement if +/// the circular buffer doesn't happen to be at the beginning of the allocation. +/// +/// # Examples +/// +/// ``` +/// use std::collections::VecDeque; +/// +/// // This one is O(1) +/// let deque: VecDeque<_> = (1..5).collect(); +/// let ptr = deque.as_slices().0.as_ptr(); +/// let vec = Vec::from(deque); +/// assert_eq!(vec, [1, 2, 3, 4]); +/// assert_eq!(vec.as_ptr(), ptr); +/// +/// // This one need data rearranging +/// let mut deque: VecDeque<_> = (1..5).collect(); +/// deque.push_front(9); +/// deque.push_front(8); +/// let ptr = deque.as_slices().1.as_ptr(); +/// let vec = Vec::from(deque); +/// assert_eq!(vec, [8, 9, 1, 2, 3, 4]); +/// assert_eq!(vec.as_ptr(), ptr); +/// ``` #[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")] impl From> for Vec { fn from(other: VecDeque) -> Self { From 2da4f9ad5ed80bb1488377711699c5f320ae89db Mon Sep 17 00:00:00 2001 From: scottmcm Date: Sat, 1 Jun 2019 19:47:50 -0700 Subject: [PATCH 02/12] Apply suggestions from code review Co-Authored-By: Mazdak Farrokhzad --- src/liballoc/collections/vec_deque.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 8cda28a5e4023..d1c9de7c83cf1 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2707,28 +2707,28 @@ impl fmt::Debug for VecDeque { } } -/// Turn a `Vec` into a `VecDeque`. +/// Turn a `Vec` into a `VecDeque`. /// /// This avoids reallocating where possible, but the conditions for that are -/// strict, and subject to change, so shouldn't be relied upon unless the -/// `Vec` came from `From` has hasn't been reallocated. +/// strict, and subject to change, and so shouldn't be relied upon unless the +/// `Vec` came from `From>` has hasn't been reallocated. /// /// # Examples /// /// ``` /// use std::collections::VecDeque; /// -/// // Start with a VecDeque +/// // Start with a `VecDeque`. /// let deque: VecDeque<_> = (1..5).collect(); /// -/// // Turn it into a Vec (no allocation needed) +/// // Turn it into a `Vec` with no allocation needed. /// let mut vec = Vec::from(deque); /// -/// // modify it, being careful to not trigger reallocation +/// // Modify it, being careful not to trigger reallocation. /// vec.pop(); /// vec.push(100); /// -/// // Turn it back into a VecDeque (no allocation needed) +/// // Turn it back into a `VecDeque` with no allocation needed. /// let ptr = vec.as_ptr(); /// let deque = VecDeque::from(vec); /// assert_eq!(deque, [1, 2, 3, 100]); @@ -2760,7 +2760,7 @@ impl From> for VecDeque { } } -/// Turn a `VecDeque` into a `Vec`. +/// Turn a `VecDeque` into a `Vec`. /// /// This never needs to re-allocate, but does need to do O(n) data movement if /// the circular buffer doesn't happen to be at the beginning of the allocation. @@ -2770,14 +2770,14 @@ impl From> for VecDeque { /// ``` /// use std::collections::VecDeque; /// -/// // This one is O(1) +/// // This one is O(1). /// let deque: VecDeque<_> = (1..5).collect(); /// let ptr = deque.as_slices().0.as_ptr(); /// let vec = Vec::from(deque); /// assert_eq!(vec, [1, 2, 3, 4]); /// assert_eq!(vec.as_ptr(), ptr); /// -/// // This one need data rearranging +/// // This one needs data rearranging. /// let mut deque: VecDeque<_> = (1..5).collect(); /// deque.push_front(9); /// deque.push_front(8); From 1f4a262d85e4a87ebbdded023b2422cd41ce3fef Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 1 Jun 2019 19:52:18 -0700 Subject: [PATCH 03/12] Put the docs on the methods instead of the impls Since simulacrum suggested (on Discord) they're better there. --- src/liballoc/collections/vec_deque.rs | 106 +++++++++++++------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index d1c9de7c83cf1..79a36d7248df4 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2707,35 +2707,35 @@ impl fmt::Debug for VecDeque { } } -/// Turn a `Vec` into a `VecDeque`. -/// -/// This avoids reallocating where possible, but the conditions for that are -/// strict, and subject to change, and so shouldn't be relied upon unless the -/// `Vec` came from `From>` has hasn't been reallocated. -/// -/// # Examples -/// -/// ``` -/// use std::collections::VecDeque; -/// -/// // Start with a `VecDeque`. -/// let deque: VecDeque<_> = (1..5).collect(); -/// -/// // Turn it into a `Vec` with no allocation needed. -/// let mut vec = Vec::from(deque); -/// -/// // Modify it, being careful not to trigger reallocation. -/// vec.pop(); -/// vec.push(100); -/// -/// // Turn it back into a `VecDeque` with no allocation needed. -/// let ptr = vec.as_ptr(); -/// let deque = VecDeque::from(vec); -/// assert_eq!(deque, [1, 2, 3, 100]); -/// assert_eq!(deque.as_slices().0.as_ptr(), ptr); -/// ``` #[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")] impl From> for VecDeque { + /// Turn a `Vec` into a `VecDeque`. + /// + /// This avoids reallocating where possible, but the conditions for that are + /// strict, and subject to change, and so shouldn't be relied upon unless the + /// `Vec` came from `From>` has hasn't been reallocated. + /// + /// # Examples + /// + /// ``` + /// use std::collections::VecDeque; + /// + /// // Start with a `VecDeque`. + /// let deque: VecDeque<_> = (1..5).collect(); + /// + /// // Turn it into a `Vec` with no allocation needed. + /// let mut vec = Vec::from(deque); + /// + /// // Modify it, being careful not to trigger reallocation. + /// vec.pop(); + /// vec.push(100); + /// + /// // Turn it back into a `VecDeque` with no allocation needed. + /// let ptr = vec.as_ptr(); + /// let deque = VecDeque::from(vec); + /// assert_eq!(deque, [1, 2, 3, 100]); + /// assert_eq!(deque.as_slices().0.as_ptr(), ptr); + /// ``` fn from(mut other: Vec) -> Self { unsafe { let other_buf = other.as_mut_ptr(); @@ -2760,34 +2760,34 @@ impl From> for VecDeque { } } -/// Turn a `VecDeque` into a `Vec`. -/// -/// This never needs to re-allocate, but does need to do O(n) data movement if -/// the circular buffer doesn't happen to be at the beginning of the allocation. -/// -/// # Examples -/// -/// ``` -/// use std::collections::VecDeque; -/// -/// // This one is O(1). -/// let deque: VecDeque<_> = (1..5).collect(); -/// let ptr = deque.as_slices().0.as_ptr(); -/// let vec = Vec::from(deque); -/// assert_eq!(vec, [1, 2, 3, 4]); -/// assert_eq!(vec.as_ptr(), ptr); -/// -/// // This one needs data rearranging. -/// let mut deque: VecDeque<_> = (1..5).collect(); -/// deque.push_front(9); -/// deque.push_front(8); -/// let ptr = deque.as_slices().1.as_ptr(); -/// let vec = Vec::from(deque); -/// assert_eq!(vec, [8, 9, 1, 2, 3, 4]); -/// assert_eq!(vec.as_ptr(), ptr); -/// ``` #[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")] impl From> for Vec { + /// Turn a `VecDeque` into a `Vec`. + /// + /// This never needs to re-allocate, but does need to do O(n) data movement if + /// the circular buffer doesn't happen to be at the beginning of the allocation. + /// + /// # Examples + /// + /// ``` + /// use std::collections::VecDeque; + /// + /// // This one is O(1). + /// let deque: VecDeque<_> = (1..5).collect(); + /// let ptr = deque.as_slices().0.as_ptr(); + /// let vec = Vec::from(deque); + /// assert_eq!(vec, [1, 2, 3, 4]); + /// assert_eq!(vec.as_ptr(), ptr); + /// + /// // This one needs data rearranging. + /// let mut deque: VecDeque<_> = (1..5).collect(); + /// deque.push_front(9); + /// deque.push_front(8); + /// let ptr = deque.as_slices().1.as_ptr(); + /// let vec = Vec::from(deque); + /// assert_eq!(vec, [8, 9, 1, 2, 3, 4]); + /// assert_eq!(vec.as_ptr(), ptr); + /// ``` fn from(other: VecDeque) -> Self { unsafe { let buf = other.buf.ptr(); From 8da94ef84921213aa42d9da8b48251503e5ad7be Mon Sep 17 00:00:00 2001 From: scottmcm Date: Sun, 2 Jun 2019 12:14:56 -0700 Subject: [PATCH 04/12] Apply suggestions from code review Co-Authored-By: Joe ST --- src/liballoc/collections/vec_deque.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 79a36d7248df4..329c1437f29f1 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2713,7 +2713,7 @@ impl From> for VecDeque { /// /// This avoids reallocating where possible, but the conditions for that are /// strict, and subject to change, and so shouldn't be relied upon unless the - /// `Vec` came from `From>` has hasn't been reallocated. + /// `Vec` came from `From>` and hasn't been reallocated. /// /// # Examples /// From 5168f5d220d0b30d322f254f51142931a9054056 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 7 Jun 2019 21:37:52 -0700 Subject: [PATCH 05/12] Add hyperlinks to Vec and VecDeque Let's try the auto-linking instead, since the relative ones don't work. --- src/liballoc/collections/vec_deque.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 329c1437f29f1..f01b315552500 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2709,7 +2709,7 @@ impl fmt::Debug for VecDeque { #[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")] impl From> for VecDeque { - /// Turn a `Vec` into a `VecDeque`. + /// Turn a [`Vec`] into a [`VecDeque`]. /// /// This avoids reallocating where possible, but the conditions for that are /// strict, and subject to change, and so shouldn't be relied upon unless the @@ -2762,7 +2762,7 @@ impl From> for VecDeque { #[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")] impl From> for Vec { - /// Turn a `VecDeque` into a `Vec`. + /// Turn a [`VecDeque`] into a [`Vec`]. /// /// This never needs to re-allocate, but does need to do O(n) data movement if /// the circular buffer doesn't happen to be at the beginning of the allocation. From 48f205d496213ac64e7596b1e3e3807b28833e14 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Sun, 9 Jun 2019 16:28:25 -0700 Subject: [PATCH 06/12] Pass LLVM linker flags to librustc_llvm build Some -L and -l flags may be needed even when building librustc_llvm, for example when using static libc++ on Linux we may need to manually specify the library search path and -ldl -lpthread as additional link dependencies. We pass LLVM linker flags from config to librustc_llvm build to make sure these cases are handled. --- src/bootstrap/compile.rs | 4 ++++ src/librustc_llvm/build.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index c7fa8e788b573..576267e6948f5 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -775,6 +775,10 @@ pub fn build_codegen_backend(builder: &Builder<'_>, cargo.env("CFG_LLVM_ROOT", s); } } + // Some LLVM linker flags (-L and -l) may be needed to link librustc_llvm. + if let Some(ref s) = builder.config.llvm_ldflags { + cargo.env("LLVM_LINKER_FLAGS", s); + } // Building with a static libstdc++ is only supported on linux right now, // not for MSVC or macOS if builder.config.llvm_static_stdcpp && diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 7fa83dd977950..21fa872c8dadb 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -234,6 +234,21 @@ fn main() { } } + // Some LLVM linker flags (-L and -l) may be needed even when linking + // librustc_llvm, for example when using static libc++, we may need to + // manually specify the library search path and -ldl -lpthread as link + // dependencies. + let llvm_linker_flags = env::var_os("LLVM_LINKER_FLAGS"); + if let Some(s) = llvm_linker_flags { + for lib in s.into_string().unwrap().split_whitespace() { + if lib.starts_with("-l") { + println!("cargo:rustc-link-lib={}", &lib[2..]); + } else if lib.starts_with("-L") { + println!("cargo:rustc-link-search=native={}", &lib[2..]); + } + } + } + let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP"); let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX"); From 0150448f1b5474bb0c5fe3297eed0c51dae44dc8 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Tue, 11 Jun 2019 21:13:48 -0700 Subject: [PATCH 07/12] Remove the questionably-useful example --- src/liballoc/collections/vec_deque.rs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index f01b315552500..71faf672962b3 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2714,28 +2714,6 @@ impl From> for VecDeque { /// This avoids reallocating where possible, but the conditions for that are /// strict, and subject to change, and so shouldn't be relied upon unless the /// `Vec` came from `From>` and hasn't been reallocated. - /// - /// # Examples - /// - /// ``` - /// use std::collections::VecDeque; - /// - /// // Start with a `VecDeque`. - /// let deque: VecDeque<_> = (1..5).collect(); - /// - /// // Turn it into a `Vec` with no allocation needed. - /// let mut vec = Vec::from(deque); - /// - /// // Modify it, being careful not to trigger reallocation. - /// vec.pop(); - /// vec.push(100); - /// - /// // Turn it back into a `VecDeque` with no allocation needed. - /// let ptr = vec.as_ptr(); - /// let deque = VecDeque::from(vec); - /// assert_eq!(deque, [1, 2, 3, 100]); - /// assert_eq!(deque.as_slices().0.as_ptr(), ptr); - /// ``` fn from(mut other: Vec) -> Self { unsafe { let other_buf = other.as_mut_ptr(); From 4d5f97e8337e40f920ec51cbc237a9d5e208965a Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Fri, 14 Jun 2019 11:24:59 +0200 Subject: [PATCH 08/12] rustbuild: include llvm-libunwind in dist tarball Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/dist.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 274961916183a..45bc77ec97d47 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -804,6 +804,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str] const LLVM_PROJECTS: &[&str] = &[ "llvm-project/clang", "llvm-project\\clang", + "llvm-project/libunwind", "llvm-project\\libunwind", "llvm-project/lld", "llvm-project\\lld", "llvm-project/lldb", "llvm-project\\lldb", "llvm-project/llvm", "llvm-project\\llvm", From d54b27d33ac7f3560bce59e14177c5a0780048a3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 14 Jun 2019 21:58:33 +0200 Subject: [PATCH 09/12] update miri --- src/tools/miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri b/src/tools/miri index 965160d4d7976..fd0dccd4b1216 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 965160d4d7976ddead182b4a65b73f59818537de +Subproject commit fd0dccd4b12169e0aac42aff8addbb26b6d72197 From 165842ba1fe09b6e0f142dc3cb27597b85b96e85 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Sat, 8 Jun 2019 18:37:37 +0900 Subject: [PATCH 10/12] Use `slice::from_ref` instead of cloning --- src/libsyntax/ext/tt/macro_rules.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 5dbf21867afa6..ae35d98881078 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -23,6 +23,7 @@ use log::debug; use rustc_data_structures::fx::{FxHashMap}; use std::borrow::Cow; use std::collections::hash_map::Entry; +use std::slice; use rustc_data_structures::sync::Lrc; use errors::Applicability; @@ -358,10 +359,10 @@ pub fn compile( // don't abort iteration early, so that errors for multiple lhses can be reported for lhs in &lhses { - valid &= check_lhs_no_empty_seq(sess, &[lhs.clone()]); + valid &= check_lhs_no_empty_seq(sess, slice::from_ref(lhs)); valid &= check_lhs_duplicate_matcher_bindings( sess, - &[lhs.clone()], + slice::from_ref(lhs), &mut FxHashMap::default(), def.id ); From 6a0abd60486d7301dea849e7107bc92380e6045e Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Sat, 8 Jun 2019 19:06:58 +0900 Subject: [PATCH 11/12] Remove unnecessary `.clone()` --- src/librustc/infer/opaque_types/mod.rs | 2 +- src/librustc/middle/liveness.rs | 2 +- src/librustc_borrowck/borrowck/check_loans.rs | 2 +- src/librustc_codegen_llvm/back/lto.rs | 2 +- src/librustc_codegen_llvm/context.rs | 2 +- src/librustc_codegen_llvm/debuginfo/metadata.rs | 2 +- src/librustc_errors/annotate_snippet_emitter_writer.rs | 2 +- src/librustc_metadata/creader.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 2 +- src/librustdoc/core.rs | 2 +- src/librustdoc/test.rs | 2 +- src/libsyntax_ext/format.rs | 2 +- src/libsyntax_ext/proc_macro_server.rs | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 8e9af8b39385f..1c52b5775a0cc 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -307,7 +307,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { let required_region_bounds = tcx.required_region_bounds( opaque_type, - bounds.predicates.clone(), + bounds.predicates, ); debug_assert!(!required_region_bounds.is_empty()); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 260935a38d6d4..29c624575c3c2 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1617,7 +1617,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.ir.tcx.lint_hir_note( lint::builtin::UNUSED_VARIABLES, hir_id, - spans.clone(), + spans, &format!("variable `{}` is assigned to, but never used", name), &format!("consider using `_{}` instead", name), ); diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 4a36d441d3d9f..54989db46c1c5 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -36,7 +36,7 @@ fn owned_ptr_base_path<'a, 'tcx>(loan_path: &'a LoanPath<'tcx>) -> &'a LoanPath< return match helper(loan_path) { Some(new_loan_path) => new_loan_path, - None => loan_path.clone() + None => loan_path, }; fn helper<'a, 'tcx>(loan_path: &'a LoanPath<'tcx>) -> Option<&'a LoanPath<'tcx>> { diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index 74cda2d2fd182..5d3cc0c0a255f 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -279,7 +279,7 @@ fn fat_lto(cgcx: &CodegenContext, } })); serialized_modules.extend(cached_modules.into_iter().map(|(buffer, wp)| { - (buffer, CString::new(wp.cgu_name.clone()).unwrap()) + (buffer, CString::new(wp.cgu_name).unwrap()) })); // For all serialized bitcode files we parse them and link them in as we did diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 967fe877fd1ad..588f7481cc060 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -459,7 +459,7 @@ impl CodegenCx<'b, 'tcx> { }; let f = self.declare_cfn(name, fn_ty); llvm::SetUnnamedAddr(f, false); - self.intrinsics.borrow_mut().insert(name, f.clone()); + self.intrinsics.borrow_mut().insert(name, f); f } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index d43adc9cb92c5..fbeda43af42b0 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -1609,7 +1609,7 @@ impl<'tcx> VariantInfo<'tcx> { // with every variant, make each variant name be just the value // of the discriminant. The struct name for the variant includes // the actual variant description. - format!("{}", variant_index.as_usize()).to_string() + format!("{}", variant_index.as_usize()) } } } diff --git a/src/librustc_errors/annotate_snippet_emitter_writer.rs b/src/librustc_errors/annotate_snippet_emitter_writer.rs index 9f9c7588d977b..7ed2fddf72d23 100644 --- a/src/librustc_errors/annotate_snippet_emitter_writer.rs +++ b/src/librustc_errors/annotate_snippet_emitter_writer.rs @@ -194,7 +194,7 @@ impl AnnotateSnippetEmitterWriter { let converter = DiagnosticConverter { source_map: self.source_map.clone(), level: level.clone(), - message: message.clone(), + message, code: code.clone(), msp: msp.clone(), children, diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 7ffba41e2569a..5fef8e53e1d0c 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -236,7 +236,7 @@ impl<'a> CrateLoader<'a> { let host_lib = host_lib.unwrap(); self.load_derive_macros( &host_lib.metadata.get_root(), - host_lib.dylib.clone().map(|p| p.0), + host_lib.dylib.map(|p| p.0), span ) } else { diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 4f73c92be504e..f9e503ee69b12 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1737,7 +1737,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pat_span, }))), }; - let for_arm_body = self.local_decls.push(local.clone()); + let for_arm_body = self.local_decls.push(local); let locals = if has_guard.0 { let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> { // This variable isn't mutated but has a name, so has to be diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 77ac2b96160a6..bf64643e5a745 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -922,7 +922,7 @@ fn receiver_is_valid<'fcx, 'tcx>( }; let obligation = traits::Obligation::new( - cause.clone(), + cause, fcx.param_env, trait_ref.to_predicate() ); diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 985bb02614b61..20a4f86aedb90 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -317,7 +317,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt // Ensure that rustdoc works even if rustc is feature-staged unstable_features: UnstableFeatures::Allow, actually_rustdoc: true, - debugging_opts: debugging_options.clone(), + debugging_opts: debugging_options, error_format, edition, describe_lints, diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 5bce5d6ba5de1..baf99bacb8ee6 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -740,7 +740,7 @@ impl Tester for Collector { debug!("Creating test {}: {}", name, test); self.tests.push(testing::TestDescAndFn { desc: testing::TestDesc { - name: testing::DynTestName(name.clone()), + name: testing::DynTestName(name), ignore: config.ignore, // compiler failures are test failures should_panic: testing::ShouldPanic::No, diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 85b524786b2f5..f44a6e7efa4f1 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -887,7 +887,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>, }; let fmt_str = &*fmt.node.0.as_str(); // for the suggestions below - let mut parser = parse::Parser::new(fmt_str, str_style, skips.clone(), append_newline); + let mut parser = parse::Parser::new(fmt_str, str_style, skips, append_newline); let mut unverified_pieces = Vec::new(); while let Some(piece) = parser.next() { diff --git a/src/libsyntax_ext/proc_macro_server.rs b/src/libsyntax_ext/proc_macro_server.rs index 00a420d3fa899..b5d5a38ce5b38 100644 --- a/src/libsyntax_ext/proc_macro_server.rs +++ b/src/libsyntax_ext/proc_macro_server.rs @@ -409,7 +409,7 @@ impl server::TokenStream for Rustc<'_> { } fn from_str(&mut self, src: &str) -> Self::TokenStream { parse::parse_stream_from_source_str( - FileName::proc_macro_source_code(src.clone()), + FileName::proc_macro_source_code(src), src.to_string(), self.sess, Some(self.call_site), From 281d787f6b422fe089960d84d6c68a65a93590d7 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 15 Jun 2019 19:00:49 +0200 Subject: [PATCH 12/12] cleanup some new active feature gates. --- src/libsyntax/feature_gate.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 004323301a22a..1d8f68ec63a41 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -557,11 +557,10 @@ declare_features! ( // Allows the user of associated type bounds. (active, associated_type_bounds, "1.34.0", Some(52662), None), - // Attributes on formal function params + // Attributes on formal function params. (active, param_attrs, "1.36.0", Some(60406), None), - // Allows calling constructor functions in `const fn` - // FIXME Create issue + // Allows calling constructor functions in `const fn`. (active, const_constructor, "1.37.0", Some(61456), None), // #[repr(transparent)] on enums.