Skip to content

Commit

Permalink
Auto merge of rust-lang#86054 - JohnTitor:rollup-j40z7sm, r=JohnTitor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jun 6, 2021
2 parents 3740ba2 + 19433c4 commit f57d5ba
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 88 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ impl AttrAnnotatedTokenStream {
AttrAnnotatedTokenTree::Attributes(data) => {
let mut outer_attrs = Vec::new();
let mut inner_attrs = Vec::new();
let attrs: Vec<_> = data.attrs.clone().into();
for attr in attrs {
for attr in &data.attrs {
match attr.style {
crate::AttrStyle::Outer => {
assert!(
Expand Down Expand Up @@ -264,7 +263,7 @@ impl AttrAnnotatedTokenStream {
// so we never reach this code.

let mut builder = TokenStreamBuilder::new();
for inner_attr in &inner_attrs {
for inner_attr in inner_attrs {
builder.push(inner_attr.tokens().to_tokenstream());
}
builder.push(delim_tokens.clone());
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,8 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|| stem.ends_with("-clang")
{
LinkerFlavor::Gcc
} else if stem == "wasm-ld" || stem.ends_with("-wasm-ld") {
LinkerFlavor::Lld(LldFlavor::Wasm)
} else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") {
LinkerFlavor::Ld
} else if stem == "link" || stem == "lld-link" {
Expand Down Expand Up @@ -1836,10 +1838,16 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
// Make the binary compatible with data execution prevention schemes.
cmd.add_no_exec();

// OBJECT-FILES-YES
add_local_crate_metadata_objects(cmd, crate_type, codegen_results);

// NO-OPT-OUT, OBJECT-FILES-NO
// Avoid linking to dynamic libraries unless they satisfy some undefined symbols
// at the point at which they are specified on the command line.
// Must be passed before any dynamic libraries.
// On solaris-like systems, this also will ignore unreferenced ELF sections
// from relocatable objects. For that reason, we move the metadata objects
// to before this flag as they would otherwise be removed.
cmd.add_as_needed();

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

// OBJECT-FILES-YES
add_local_crate_metadata_objects(cmd, crate_type, codegen_results);

// OBJECT-FILES-YES
add_local_crate_allocator_objects(cmd, codegen_results);

Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,21 +476,23 @@ impl<'a> Linker for GccLinker<'a> {
// eliminate the metadata. If we're building an executable, however,
// --gc-sections drops the size of hello world from 1.8MB to 597K, a 67%
// reduction.
} else if self.sess.target.linker_is_gnu && !keep_metadata {
} else if (self.sess.target.linker_is_gnu || self.sess.target.is_like_wasm)
&& !keep_metadata
{
self.linker_arg("--gc-sections");
}
}

fn no_gc_sections(&mut self) {
if self.sess.target.is_like_osx {
self.linker_arg("-no_dead_strip");
} else if self.sess.target.linker_is_gnu {
} else if self.sess.target.linker_is_gnu || self.sess.target.is_like_wasm {
self.linker_arg("--no-gc-sections");
}
}

fn optimize(&mut self) {
if !self.sess.target.linker_is_gnu {
if !self.sess.target.linker_is_gnu && !self.sess.target.is_like_wasm {
return;
}

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_data_structures/src/obligation_forest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl<O: ForestObligation> ObligationForest<O> {
return Ok(());
}

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

if already_failed {
Err(())
Expand Down
12 changes: 5 additions & 7 deletions compiler/rustc_mir/src/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,11 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty;
if let ty::RawPtr(_) = base_ty.kind() {
if proj_base.is_empty() {
if let (local, []) = (place_local, proj_base) {
let decl = &self.body.local_decls[local];
if let Some(box LocalInfo::StaticRef { def_id, .. }) = decl.local_info {
let span = decl.source_info.span;
self.check_static(def_id, span);
return;
}
let decl = &self.body.local_decls[place_local];
if let Some(box LocalInfo::StaticRef { def_id, .. }) = decl.local_info {
let span = decl.source_info.span;
self.check_static(def_id, span);
return;
}
}
self.check_op(ops::RawPtrDeref);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl CheckAttrVisitor<'tcx> {
target: Target,
specified_inline: &mut Option<(bool, Span)>,
) -> bool {
if target == Target::Use {
if target == Target::Use || target == Target::ExternCrate {
let do_inline = meta.name_or_empty() == sym::inline;
if let Some((prev_inline, prev_span)) = *specified_inline {
if do_inline != prev_inline {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/wasm_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub fn options() -> TargetOptions {
// we use the LLD shipped with the Rust toolchain by default
linker: Some("rust-lld".to_owned()),
lld_flavor: LldFlavor::Wasm,
linker_is_gnu: false,

pre_link_args,

Expand Down
10 changes: 2 additions & 8 deletions library/alloc/benches/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,19 +551,13 @@ const LEN: usize = 16384;
#[bench]
fn bench_chain_collect(b: &mut Bencher) {
let data = black_box([0; LEN]);
b.iter(|| data.iter().cloned().chain([1].iter().cloned()).collect::<Vec<_>>());
b.iter(|| data.iter().cloned().chain([1]).collect::<Vec<_>>());
}

#[bench]
fn bench_chain_chain_collect(b: &mut Bencher) {
let data = black_box([0; LEN]);
b.iter(|| {
data.iter()
.cloned()
.chain([1].iter().cloned())
.chain([2].iter().cloned())
.collect::<Vec<_>>()
});
b.iter(|| data.iter().cloned().chain([1]).chain([2]).collect::<Vec<_>>());
}

#[bench]
Expand Down
3 changes: 1 addition & 2 deletions library/alloc/src/collections/vec_deque/pair_slices.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use core::array;
use core::cmp::{self};
use core::mem::replace;

Expand Down Expand Up @@ -37,7 +36,7 @@ impl<'a, 'b, T> PairSlices<'a, 'b, T> {
}

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

Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// ```
/// let mut vec = Vec::with_capacity(10);
/// vec.extend([1, 2, 3].iter().cloned());
/// vec.extend([1, 2, 3]);
/// assert_eq!(vec.capacity(), 10);
/// vec.shrink_to_fit();
/// assert!(vec.capacity() >= 3);
Expand Down Expand Up @@ -950,7 +950,7 @@ impl<T, A: Allocator> Vec<T, A> {
/// ```
/// #![feature(shrink_to)]
/// let mut vec = Vec::with_capacity(10);
/// vec.extend([1, 2, 3].iter().cloned());
/// vec.extend([1, 2, 3]);
/// assert_eq!(vec.capacity(), 10);
/// vec.shrink_to(4);
/// assert!(vec.capacity() >= 4);
Expand Down Expand Up @@ -984,7 +984,7 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// ```
/// let mut vec = Vec::with_capacity(10);
/// vec.extend([1, 2, 3].iter().cloned());
/// vec.extend([1, 2, 3]);
///
/// assert_eq!(vec.capacity(), 10);
/// let slice = vec.into_boxed_slice();
Expand Down Expand Up @@ -2586,7 +2586,7 @@ impl<T, A: Allocator> Vec<T, A> {
/// ```
/// let mut v = vec![1, 2, 3];
/// let new = [7, 8];
/// let u: Vec<_> = v.splice(..2, new.iter().cloned()).collect();
/// let u: Vec<_> = v.splice(..2, new).collect();
/// assert_eq!(v, &[7, 8, 3]);
/// assert_eq!(u, &[1, 2]);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/vec/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::{Drain, Vec};
/// ```
/// let mut v = vec![0, 1, 2];
/// let new = [7, 8];
/// let iter: std::vec::Splice<_> = v.splice(1.., new.iter().cloned());
/// let iter: std::vec::Splice<_> = v.splice(1.., new);
/// ```
#[derive(Debug)]
#[stable(feature = "vec_splice", since = "1.21.0")]
Expand Down
10 changes: 5 additions & 5 deletions library/alloc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ fn test_drain_leak() {
fn test_splice() {
let mut v = vec![1, 2, 3, 4, 5];
let a = [10, 11, 12];
v.splice(2..4, a.iter().cloned());
v.splice(2..4, a);
assert_eq!(v, &[1, 2, 10, 11, 12, 5]);
v.splice(1..3, Some(20));
assert_eq!(v, &[1, 20, 11, 12, 5]);
Expand All @@ -803,7 +803,7 @@ fn test_splice() {
fn test_splice_inclusive_range() {
let mut v = vec![1, 2, 3, 4, 5];
let a = [10, 11, 12];
let t1: Vec<_> = v.splice(2..=3, a.iter().cloned()).collect();
let t1: Vec<_> = v.splice(2..=3, a).collect();
assert_eq!(v, &[1, 2, 10, 11, 12, 5]);
assert_eq!(t1, &[3, 4]);
let t2: Vec<_> = v.splice(1..=2, Some(20)).collect();
Expand All @@ -816,15 +816,15 @@ fn test_splice_inclusive_range() {
fn test_splice_out_of_bounds() {
let mut v = vec![1, 2, 3, 4, 5];
let a = [10, 11, 12];
v.splice(5..6, a.iter().cloned());
v.splice(5..6, a);
}

#[test]
#[should_panic]
fn test_splice_inclusive_out_of_bounds() {
let mut v = vec![1, 2, 3, 4, 5];
let a = [10, 11, 12];
v.splice(5..=5, a.iter().cloned());
v.splice(5..=5, a);
}

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

Expand Down
4 changes: 2 additions & 2 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl<T, const N: usize> [T; N] {
{
// SAFETY: we know for certain that this iterator will yield exactly `N`
// items.
unsafe { collect_into_array_unchecked(&mut IntoIter::new(self).map(f)) }
unsafe { collect_into_array_unchecked(&mut IntoIterator::into_iter(self).map(f)) }
}

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

// SAFETY: we know for certain that this iterator will yield exactly `N`
// items.
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl char {
/// ];
///
/// assert_eq!(
/// decode_utf16(v.iter().cloned())
/// decode_utf16(v)
/// .map(|r| r.map_err(|e| e.unpaired_surrogate()))
/// .collect::<Vec<_>>(),
/// vec![
Expand All @@ -82,7 +82,7 @@ impl char {
/// ];
///
/// assert_eq!(
/// decode_utf16(v.iter().cloned())
/// decode_utf16(v)
/// .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
/// .collect::<String>(),
/// "𝄞mus�ic�"
Expand Down
Loading

0 comments on commit f57d5ba

Please sign in to comment.