Skip to content

Commit f57d5ba

Browse files
committed
Auto merge of rust-lang#86054 - JohnTitor:rollup-j40z7sm, r=JohnTitor
Rollup of 8 pull requests Successful merges: - rust-lang#85436 (Avoid cloning cache key) - rust-lang#85772 (Preserve metadata w/ Solaris-like linkers.) - rust-lang#85920 (Tweak wasm_base target spec to indicate linker is not GNU and update linker inferring logic for wasm-ld.) - rust-lang#85930 (Update standard library for IntoIterator implementation of arrays ) - rust-lang#85972 (Rustdoc html fixes) - rust-lang#86028 (Drop an `if let` that will always succeed) - rust-lang#86043 (don't clone attrs) - rust-lang#86047 (Don't fire `invalid_doc_attributes` on `extern crate` items) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3740ba2 + 19433c4 commit f57d5ba

File tree

22 files changed

+111
-88
lines changed

22 files changed

+111
-88
lines changed

compiler/rustc_ast/src/tokenstream.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ impl AttrAnnotatedTokenStream {
218218
AttrAnnotatedTokenTree::Attributes(data) => {
219219
let mut outer_attrs = Vec::new();
220220
let mut inner_attrs = Vec::new();
221-
let attrs: Vec<_> = data.attrs.clone().into();
222-
for attr in attrs {
221+
for attr in &data.attrs {
223222
match attr.style {
224223
crate::AttrStyle::Outer => {
225224
assert!(
@@ -264,7 +263,7 @@ impl AttrAnnotatedTokenStream {
264263
// so we never reach this code.
265264

266265
let mut builder = TokenStreamBuilder::new();
267-
for inner_attr in &inner_attrs {
266+
for inner_attr in inner_attrs {
268267
builder.push(inner_attr.tokens().to_tokenstream());
269268
}
270269
builder.push(delim_tokens.clone());

compiler/rustc_codegen_ssa/src/back/link.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,8 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
11991199
|| stem.ends_with("-clang")
12001200
{
12011201
LinkerFlavor::Gcc
1202+
} else if stem == "wasm-ld" || stem.ends_with("-wasm-ld") {
1203+
LinkerFlavor::Lld(LldFlavor::Wasm)
12021204
} else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") {
12031205
LinkerFlavor::Ld
12041206
} else if stem == "link" || stem == "lld-link" {
@@ -1836,10 +1838,16 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
18361838
// Make the binary compatible with data execution prevention schemes.
18371839
cmd.add_no_exec();
18381840

1841+
// OBJECT-FILES-YES
1842+
add_local_crate_metadata_objects(cmd, crate_type, codegen_results);
1843+
18391844
// NO-OPT-OUT, OBJECT-FILES-NO
18401845
// Avoid linking to dynamic libraries unless they satisfy some undefined symbols
18411846
// at the point at which they are specified on the command line.
18421847
// Must be passed before any dynamic libraries.
1848+
// On solaris-like systems, this also will ignore unreferenced ELF sections
1849+
// from relocatable objects. For that reason, we move the metadata objects
1850+
// to before this flag as they would otherwise be removed.
18431851
cmd.add_as_needed();
18441852

18451853
// NO-OPT-OUT, OBJECT-FILES-NO
@@ -1891,9 +1899,6 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
18911899
// dynamic library.
18921900
cmd.export_symbols(tmpdir, crate_type);
18931901

1894-
// OBJECT-FILES-YES
1895-
add_local_crate_metadata_objects(cmd, crate_type, codegen_results);
1896-
18971902
// OBJECT-FILES-YES
18981903
add_local_crate_allocator_objects(cmd, codegen_results);
18991904

compiler/rustc_codegen_ssa/src/back/linker.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -476,21 +476,23 @@ impl<'a> Linker for GccLinker<'a> {
476476
// eliminate the metadata. If we're building an executable, however,
477477
// --gc-sections drops the size of hello world from 1.8MB to 597K, a 67%
478478
// reduction.
479-
} else if self.sess.target.linker_is_gnu && !keep_metadata {
479+
} else if (self.sess.target.linker_is_gnu || self.sess.target.is_like_wasm)
480+
&& !keep_metadata
481+
{
480482
self.linker_arg("--gc-sections");
481483
}
482484
}
483485

484486
fn no_gc_sections(&mut self) {
485487
if self.sess.target.is_like_osx {
486488
self.linker_arg("-no_dead_strip");
487-
} else if self.sess.target.linker_is_gnu {
489+
} else if self.sess.target.linker_is_gnu || self.sess.target.is_like_wasm {
488490
self.linker_arg("--no-gc-sections");
489491
}
490492
}
491493

492494
fn optimize(&mut self) {
493-
if !self.sess.target.linker_is_gnu {
495+
if !self.sess.target.linker_is_gnu && !self.sess.target.is_like_wasm {
494496
return;
495497
}
496498

compiler/rustc_data_structures/src/obligation_forest/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<O: ForestObligation> ObligationForest<O> {
342342
return Ok(());
343343
}
344344

345-
match self.active_cache.entry(cache_key.clone()) {
345+
match self.active_cache.entry(cache_key) {
346346
Entry::Occupied(o) => {
347347
let node = &mut self.nodes[*o.get()];
348348
if let Some(parent_index) = parent {
@@ -366,8 +366,7 @@ impl<O: ForestObligation> ObligationForest<O> {
366366
&& self
367367
.error_cache
368368
.get(&obligation_tree_id)
369-
.map(|errors| errors.contains(&cache_key))
370-
.unwrap_or(false);
369+
.map_or(false, |errors| errors.contains(v.key()));
371370

372371
if already_failed {
373372
Err(())

compiler/rustc_mir/src/transform/check_consts/validation.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -729,13 +729,11 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
729729
let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty;
730730
if let ty::RawPtr(_) = base_ty.kind() {
731731
if proj_base.is_empty() {
732-
if let (local, []) = (place_local, proj_base) {
733-
let decl = &self.body.local_decls[local];
734-
if let Some(box LocalInfo::StaticRef { def_id, .. }) = decl.local_info {
735-
let span = decl.source_info.span;
736-
self.check_static(def_id, span);
737-
return;
738-
}
732+
let decl = &self.body.local_decls[place_local];
733+
if let Some(box LocalInfo::StaticRef { def_id, .. }) = decl.local_info {
734+
let span = decl.source_info.span;
735+
self.check_static(def_id, span);
736+
return;
739737
}
740738
}
741739
self.check_op(ops::RawPtrDeref);

compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl CheckAttrVisitor<'tcx> {
577577
target: Target,
578578
specified_inline: &mut Option<(bool, Span)>,
579579
) -> bool {
580-
if target == Target::Use {
580+
if target == Target::Use || target == Target::ExternCrate {
581581
let do_inline = meta.name_or_empty() == sym::inline;
582582
if let Some((prev_inline, prev_span)) = *specified_inline {
583583
if do_inline != prev_inline {

compiler/rustc_target/src/spec/wasm_base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub fn options() -> TargetOptions {
102102
// we use the LLD shipped with the Rust toolchain by default
103103
linker: Some("rust-lld".to_owned()),
104104
lld_flavor: LldFlavor::Wasm,
105+
linker_is_gnu: false,
105106

106107
pre_link_args,
107108

library/alloc/benches/vec.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -551,19 +551,13 @@ const LEN: usize = 16384;
551551
#[bench]
552552
fn bench_chain_collect(b: &mut Bencher) {
553553
let data = black_box([0; LEN]);
554-
b.iter(|| data.iter().cloned().chain([1].iter().cloned()).collect::<Vec<_>>());
554+
b.iter(|| data.iter().cloned().chain([1]).collect::<Vec<_>>());
555555
}
556556

557557
#[bench]
558558
fn bench_chain_chain_collect(b: &mut Bencher) {
559559
let data = black_box([0; LEN]);
560-
b.iter(|| {
561-
data.iter()
562-
.cloned()
563-
.chain([1].iter().cloned())
564-
.chain([2].iter().cloned())
565-
.collect::<Vec<_>>()
566-
});
560+
b.iter(|| data.iter().cloned().chain([1]).chain([2]).collect::<Vec<_>>());
567561
}
568562

569563
#[bench]

library/alloc/src/collections/vec_deque/pair_slices.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::array;
21
use core::cmp::{self};
32
use core::mem::replace;
43

@@ -37,7 +36,7 @@ impl<'a, 'b, T> PairSlices<'a, 'b, T> {
3736
}
3837

3938
pub fn remainder(self) -> impl Iterator<Item = &'b [T]> {
40-
array::IntoIter::new([self.b0, self.b1])
39+
IntoIterator::into_iter([self.b0, self.b1])
4140
}
4241
}
4342

library/alloc/src/vec/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ impl<T, A: Allocator> Vec<T, A> {
921921
///
922922
/// ```
923923
/// let mut vec = Vec::with_capacity(10);
924-
/// vec.extend([1, 2, 3].iter().cloned());
924+
/// vec.extend([1, 2, 3]);
925925
/// assert_eq!(vec.capacity(), 10);
926926
/// vec.shrink_to_fit();
927927
/// assert!(vec.capacity() >= 3);
@@ -950,7 +950,7 @@ impl<T, A: Allocator> Vec<T, A> {
950950
/// ```
951951
/// #![feature(shrink_to)]
952952
/// let mut vec = Vec::with_capacity(10);
953-
/// vec.extend([1, 2, 3].iter().cloned());
953+
/// vec.extend([1, 2, 3]);
954954
/// assert_eq!(vec.capacity(), 10);
955955
/// vec.shrink_to(4);
956956
/// assert!(vec.capacity() >= 4);
@@ -984,7 +984,7 @@ impl<T, A: Allocator> Vec<T, A> {
984984
///
985985
/// ```
986986
/// let mut vec = Vec::with_capacity(10);
987-
/// vec.extend([1, 2, 3].iter().cloned());
987+
/// vec.extend([1, 2, 3]);
988988
///
989989
/// assert_eq!(vec.capacity(), 10);
990990
/// let slice = vec.into_boxed_slice();
@@ -2586,7 +2586,7 @@ impl<T, A: Allocator> Vec<T, A> {
25862586
/// ```
25872587
/// let mut v = vec![1, 2, 3];
25882588
/// let new = [7, 8];
2589-
/// let u: Vec<_> = v.splice(..2, new.iter().cloned()).collect();
2589+
/// let u: Vec<_> = v.splice(..2, new).collect();
25902590
/// assert_eq!(v, &[7, 8, 3]);
25912591
/// assert_eq!(u, &[1, 2]);
25922592
/// ```

library/alloc/src/vec/splice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::{Drain, Vec};
1414
/// ```
1515
/// let mut v = vec![0, 1, 2];
1616
/// let new = [7, 8];
17-
/// let iter: std::vec::Splice<_> = v.splice(1.., new.iter().cloned());
17+
/// let iter: std::vec::Splice<_> = v.splice(1.., new);
1818
/// ```
1919
#[derive(Debug)]
2020
#[stable(feature = "vec_splice", since = "1.21.0")]

library/alloc/tests/vec.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ fn test_drain_leak() {
793793
fn test_splice() {
794794
let mut v = vec![1, 2, 3, 4, 5];
795795
let a = [10, 11, 12];
796-
v.splice(2..4, a.iter().cloned());
796+
v.splice(2..4, a);
797797
assert_eq!(v, &[1, 2, 10, 11, 12, 5]);
798798
v.splice(1..3, Some(20));
799799
assert_eq!(v, &[1, 20, 11, 12, 5]);
@@ -803,7 +803,7 @@ fn test_splice() {
803803
fn test_splice_inclusive_range() {
804804
let mut v = vec![1, 2, 3, 4, 5];
805805
let a = [10, 11, 12];
806-
let t1: Vec<_> = v.splice(2..=3, a.iter().cloned()).collect();
806+
let t1: Vec<_> = v.splice(2..=3, a).collect();
807807
assert_eq!(v, &[1, 2, 10, 11, 12, 5]);
808808
assert_eq!(t1, &[3, 4]);
809809
let t2: Vec<_> = v.splice(1..=2, Some(20)).collect();
@@ -816,15 +816,15 @@ fn test_splice_inclusive_range() {
816816
fn test_splice_out_of_bounds() {
817817
let mut v = vec![1, 2, 3, 4, 5];
818818
let a = [10, 11, 12];
819-
v.splice(5..6, a.iter().cloned());
819+
v.splice(5..6, a);
820820
}
821821

822822
#[test]
823823
#[should_panic]
824824
fn test_splice_inclusive_out_of_bounds() {
825825
let mut v = vec![1, 2, 3, 4, 5];
826826
let a = [10, 11, 12];
827-
v.splice(5..=5, a.iter().cloned());
827+
v.splice(5..=5, a);
828828
}
829829

830830
#[test]
@@ -848,7 +848,7 @@ fn test_splice_unbounded() {
848848
fn test_splice_forget() {
849849
let mut v = vec![1, 2, 3, 4, 5];
850850
let a = [10, 11, 12];
851-
std::mem::forget(v.splice(2..4, a.iter().cloned()));
851+
std::mem::forget(v.splice(2..4, a));
852852
assert_eq!(v, &[1, 2]);
853853
}
854854

library/core/src/array/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl<T, const N: usize> [T; N] {
416416
{
417417
// SAFETY: we know for certain that this iterator will yield exactly `N`
418418
// items.
419-
unsafe { collect_into_array_unchecked(&mut IntoIter::new(self).map(f)) }
419+
unsafe { collect_into_array_unchecked(&mut IntoIterator::into_iter(self).map(f)) }
420420
}
421421

422422
/// 'Zips up' two arrays into a single array of pairs.
@@ -437,7 +437,7 @@ impl<T, const N: usize> [T; N] {
437437
/// ```
438438
#[unstable(feature = "array_zip", issue = "80094")]
439439
pub fn zip<U>(self, rhs: [U; N]) -> [(T, U); N] {
440-
let mut iter = IntoIter::new(self).zip(IntoIter::new(rhs));
440+
let mut iter = IntoIterator::into_iter(self).zip(rhs);
441441

442442
// SAFETY: we know for certain that this iterator will yield exactly `N`
443443
// items.

library/core/src/char/methods.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl char {
5858
/// ];
5959
///
6060
/// assert_eq!(
61-
/// decode_utf16(v.iter().cloned())
61+
/// decode_utf16(v)
6262
/// .map(|r| r.map_err(|e| e.unpaired_surrogate()))
6363
/// .collect::<Vec<_>>(),
6464
/// vec![
@@ -82,7 +82,7 @@ impl char {
8282
/// ];
8383
///
8484
/// assert_eq!(
85-
/// decode_utf16(v.iter().cloned())
85+
/// decode_utf16(v)
8686
/// .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
8787
/// .collect::<String>(),
8888
/// "𝄞mus�ic�"

0 commit comments

Comments
 (0)