Skip to content

Commit 374c63e

Browse files
committed
Auto merge of #61886 - Centril:rollup-3p3m2fu, r=Centril
Rollup of 6 pull requests Successful merges: - #61447 (Add some Vec <-> VecDeque documentation) - #61704 (Pass LLVM linker flags to librustc_llvm build) - #61829 (rustbuild: include llvm-libunwind in dist tarball) - #61832 (update miri) - #61866 (Remove redundant `clone()`s) - #61869 (Cleanup some new active feature gates) Failed merges: r? @ghost
2 parents 0dc9e9c + cd9bb48 commit 374c63e

File tree

21 files changed

+71
-20
lines changed

21 files changed

+71
-20
lines changed

src/bootstrap/compile.rs

+4
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,10 @@ pub fn build_codegen_backend(builder: &Builder<'_>,
775775
cargo.env("CFG_LLVM_ROOT", s);
776776
}
777777
}
778+
// Some LLVM linker flags (-L and -l) may be needed to link librustc_llvm.
779+
if let Some(ref s) = builder.config.llvm_ldflags {
780+
cargo.env("LLVM_LINKER_FLAGS", s);
781+
}
778782
// Building with a static libstdc++ is only supported on linux right now,
779783
// not for MSVC or macOS
780784
if builder.config.llvm_static_stdcpp &&

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
804804

805805
const LLVM_PROJECTS: &[&str] = &[
806806
"llvm-project/clang", "llvm-project\\clang",
807+
"llvm-project/libunwind", "llvm-project\\libunwind",
807808
"llvm-project/lld", "llvm-project\\lld",
808809
"llvm-project/lldb", "llvm-project\\lldb",
809810
"llvm-project/llvm", "llvm-project\\llvm",

src/liballoc/collections/vec_deque.rs

+31
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,11 @@ impl<T: fmt::Debug> fmt::Debug for VecDeque<T> {
27092709

27102710
#[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")]
27112711
impl<T> From<Vec<T>> for VecDeque<T> {
2712+
/// Turn a [`Vec<T>`] into a [`VecDeque<T>`].
2713+
///
2714+
/// This avoids reallocating where possible, but the conditions for that are
2715+
/// strict, and subject to change, and so shouldn't be relied upon unless the
2716+
/// `Vec<T>` came from `From<VecDeque<T>>` and hasn't been reallocated.
27122717
fn from(mut other: Vec<T>) -> Self {
27132718
unsafe {
27142719
let other_buf = other.as_mut_ptr();
@@ -2735,6 +2740,32 @@ impl<T> From<Vec<T>> for VecDeque<T> {
27352740

27362741
#[stable(feature = "vecdeque_vec_conversions", since = "1.10.0")]
27372742
impl<T> From<VecDeque<T>> for Vec<T> {
2743+
/// Turn a [`VecDeque<T>`] into a [`Vec<T>`].
2744+
///
2745+
/// This never needs to re-allocate, but does need to do O(n) data movement if
2746+
/// the circular buffer doesn't happen to be at the beginning of the allocation.
2747+
///
2748+
/// # Examples
2749+
///
2750+
/// ```
2751+
/// use std::collections::VecDeque;
2752+
///
2753+
/// // This one is O(1).
2754+
/// let deque: VecDeque<_> = (1..5).collect();
2755+
/// let ptr = deque.as_slices().0.as_ptr();
2756+
/// let vec = Vec::from(deque);
2757+
/// assert_eq!(vec, [1, 2, 3, 4]);
2758+
/// assert_eq!(vec.as_ptr(), ptr);
2759+
///
2760+
/// // This one needs data rearranging.
2761+
/// let mut deque: VecDeque<_> = (1..5).collect();
2762+
/// deque.push_front(9);
2763+
/// deque.push_front(8);
2764+
/// let ptr = deque.as_slices().1.as_ptr();
2765+
/// let vec = Vec::from(deque);
2766+
/// assert_eq!(vec, [8, 9, 1, 2, 3, 4]);
2767+
/// assert_eq!(vec.as_ptr(), ptr);
2768+
/// ```
27382769
fn from(other: VecDeque<T>) -> Self {
27392770
unsafe {
27402771
let buf = other.buf.ptr();

src/librustc/infer/opaque_types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
307307

308308
let required_region_bounds = tcx.required_region_bounds(
309309
opaque_type,
310-
bounds.predicates.clone(),
310+
bounds.predicates,
311311
);
312312
debug_assert!(!required_region_bounds.is_empty());
313313

src/librustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
16171617
self.ir.tcx.lint_hir_note(
16181618
lint::builtin::UNUSED_VARIABLES,
16191619
hir_id,
1620-
spans.clone(),
1620+
spans,
16211621
&format!("variable `{}` is assigned to, but never used", name),
16221622
&format!("consider using `_{}` instead", name),
16231623
);

src/librustc_borrowck/borrowck/check_loans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn owned_ptr_base_path<'a, 'tcx>(loan_path: &'a LoanPath<'tcx>) -> &'a LoanPath<
3636
3737
return match helper(loan_path) {
3838
Some(new_loan_path) => new_loan_path,
39-
None => loan_path.clone()
39+
None => loan_path,
4040
};
4141

4242
fn helper<'a, 'tcx>(loan_path: &'a LoanPath<'tcx>) -> Option<&'a LoanPath<'tcx>> {

src/librustc_codegen_llvm/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ fn fat_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
279279
}
280280
}));
281281
serialized_modules.extend(cached_modules.into_iter().map(|(buffer, wp)| {
282-
(buffer, CString::new(wp.cgu_name.clone()).unwrap())
282+
(buffer, CString::new(wp.cgu_name).unwrap())
283283
}));
284284

285285
// For all serialized bitcode files we parse them and link them in as we did

src/librustc_codegen_llvm/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl CodegenCx<'b, 'tcx> {
459459
};
460460
let f = self.declare_cfn(name, fn_ty);
461461
llvm::SetUnnamedAddr(f, false);
462-
self.intrinsics.borrow_mut().insert(name, f.clone());
462+
self.intrinsics.borrow_mut().insert(name, f);
463463
f
464464
}
465465

src/librustc_codegen_llvm/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ impl<'tcx> VariantInfo<'tcx> {
16091609
// with every variant, make each variant name be just the value
16101610
// of the discriminant. The struct name for the variant includes
16111611
// the actual variant description.
1612-
format!("{}", variant_index.as_usize()).to_string()
1612+
format!("{}", variant_index.as_usize())
16131613
}
16141614
}
16151615
}

src/librustc_errors/annotate_snippet_emitter_writer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl AnnotateSnippetEmitterWriter {
194194
let converter = DiagnosticConverter {
195195
source_map: self.source_map.clone(),
196196
level: level.clone(),
197-
message: message.clone(),
197+
message,
198198
code: code.clone(),
199199
msp: msp.clone(),
200200
children,

src/librustc_llvm/build.rs

+15
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,21 @@ fn main() {
234234
}
235235
}
236236

237+
// Some LLVM linker flags (-L and -l) may be needed even when linking
238+
// librustc_llvm, for example when using static libc++, we may need to
239+
// manually specify the library search path and -ldl -lpthread as link
240+
// dependencies.
241+
let llvm_linker_flags = env::var_os("LLVM_LINKER_FLAGS");
242+
if let Some(s) = llvm_linker_flags {
243+
for lib in s.into_string().unwrap().split_whitespace() {
244+
if lib.starts_with("-l") {
245+
println!("cargo:rustc-link-lib={}", &lib[2..]);
246+
} else if lib.starts_with("-L") {
247+
println!("cargo:rustc-link-search=native={}", &lib[2..]);
248+
}
249+
}
250+
}
251+
237252
let llvm_static_stdcpp = env::var_os("LLVM_STATIC_STDCPP");
238253
let llvm_use_libcxx = env::var_os("LLVM_USE_LIBCXX");
239254

src/librustc_metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'a> CrateLoader<'a> {
236236
let host_lib = host_lib.unwrap();
237237
self.load_derive_macros(
238238
&host_lib.metadata.get_root(),
239-
host_lib.dylib.clone().map(|p| p.0),
239+
host_lib.dylib.map(|p| p.0),
240240
span
241241
)
242242
} else {

src/librustc_mir/build/matches/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17371737
pat_span,
17381738
}))),
17391739
};
1740-
let for_arm_body = self.local_decls.push(local.clone());
1740+
let for_arm_body = self.local_decls.push(local);
17411741
let locals = if has_guard.0 {
17421742
let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> {
17431743
// This variable isn't mutated but has a name, so has to be

src/librustc_typeck/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ fn receiver_is_valid<'fcx, 'tcx>(
922922
};
923923

924924
let obligation = traits::Obligation::new(
925-
cause.clone(),
925+
cause,
926926
fcx.param_env,
927927
trait_ref.to_predicate()
928928
);

src/librustdoc/core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
317317
// Ensure that rustdoc works even if rustc is feature-staged
318318
unstable_features: UnstableFeatures::Allow,
319319
actually_rustdoc: true,
320-
debugging_opts: debugging_options.clone(),
320+
debugging_opts: debugging_options,
321321
error_format,
322322
edition,
323323
describe_lints,

src/librustdoc/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ impl Tester for Collector {
740740
debug!("Creating test {}: {}", name, test);
741741
self.tests.push(testing::TestDescAndFn {
742742
desc: testing::TestDesc {
743-
name: testing::DynTestName(name.clone()),
743+
name: testing::DynTestName(name),
744744
ignore: config.ignore,
745745
// compiler failures are test failures
746746
should_panic: testing::ShouldPanic::No,

src/libsyntax/ext/tt/macro_rules.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use log::debug;
2323
use rustc_data_structures::fx::{FxHashMap};
2424
use std::borrow::Cow;
2525
use std::collections::hash_map::Entry;
26+
use std::slice;
2627

2728
use rustc_data_structures::sync::Lrc;
2829
use errors::Applicability;
@@ -359,10 +360,10 @@ pub fn compile(
359360

360361
// don't abort iteration early, so that errors for multiple lhses can be reported
361362
for lhs in &lhses {
362-
valid &= check_lhs_no_empty_seq(sess, &[lhs.clone()]);
363+
valid &= check_lhs_no_empty_seq(sess, slice::from_ref(lhs));
363364
valid &= check_lhs_duplicate_matcher_bindings(
364365
sess,
365-
&[lhs.clone()],
366+
slice::from_ref(lhs),
366367
&mut FxHashMap::default(),
367368
def.id
368369
);

src/libsyntax/feature_gate.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,10 @@ declare_features! (
557557
// Allows the user of associated type bounds.
558558
(active, associated_type_bounds, "1.34.0", Some(52662), None),
559559

560-
// Attributes on formal function params
560+
// Attributes on formal function params.
561561
(active, param_attrs, "1.36.0", Some(60406), None),
562562

563-
// Allows calling constructor functions in `const fn`
564-
// FIXME Create issue
563+
// Allows calling constructor functions in `const fn`.
565564
(active, const_constructor, "1.37.0", Some(61456), None),
566565

567566
// #[repr(transparent)] on enums.

src/libsyntax_ext/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt<'_>,
887887
};
888888

889889
let fmt_str = &*fmt.node.0.as_str(); // for the suggestions below
890-
let mut parser = parse::Parser::new(fmt_str, str_style, skips.clone(), append_newline);
890+
let mut parser = parse::Parser::new(fmt_str, str_style, skips, append_newline);
891891

892892
let mut unverified_pieces = Vec::new();
893893
while let Some(piece) = parser.next() {

src/libsyntax_ext/proc_macro_server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl server::TokenStream for Rustc<'_> {
409409
}
410410
fn from_str(&mut self, src: &str) -> Self::TokenStream {
411411
parse::parse_stream_from_source_str(
412-
FileName::proc_macro_source_code(src.clone()),
412+
FileName::proc_macro_source_code(src),
413413
src.to_string(),
414414
self.sess,
415415
Some(self.call_site),

0 commit comments

Comments
 (0)