Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #86054

Merged
merged 20 commits into from
Jun 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a36c636
Avoid cloning cache key
tamird May 18, 2021
42b9d3f
Simplify `map | unwrap_or` to `map_or`
tamird May 18, 2021
cffef33
Move metadata objects to before as-needed/zignore flags to make sure …
luqmana May 28, 2021
56a2a2a
don't clone attrs
klensy May 30, 2021
f667aca
Tweak wasm_base target spec to indicate linker is not GNU and update …
luqmana Jun 2, 2021
01d4d46
Replace IntoIter::new with IntoIterator::into_iter in std
mominul May 30, 2021
507d97b
Update expressions where we can use array's IntoIterator implementation
mominul Jun 2, 2021
f4080fc
Drop an `if let` that will always succeed
LingMan Jun 5, 2021
e1180f5
Escape <meta> content attribute value
GuillaumeGomez Jun 3, 2021
8c9200d
Add missing backslash in HTML layout string
GuillaumeGomez Jun 3, 2021
e078e56
Fix invalid ID value in all.html file
GuillaumeGomez Jun 3, 2021
b8ebf44
Don't fire `invalid_doc_attributes` on `extern crate` items
jyn514 Jun 6, 2021
b3bcf4a
Rollup merge of #85436 - tamird:save-clone, r=estebank
JohnTitor Jun 6, 2021
d69cd46
Rollup merge of #85772 - luqmana:ignored-metadata, r=petrochenkov
JohnTitor Jun 6, 2021
679a1d1
Rollup merge of #85920 - luqmana:wasm-linker-tweaks, r=petrochenkov
JohnTitor Jun 6, 2021
f923f73
Rollup merge of #85930 - mominul:array_into_iter, r=m-ou-se
JohnTitor Jun 6, 2021
302f3dc
Rollup merge of #85972 - GuillaumeGomez:rustdoc-html-fixes, r=jsha
JohnTitor Jun 6, 2021
1886123
Rollup merge of #86028 - LingMan:dupe_empty_check, r=jyn514
JohnTitor Jun 6, 2021
2f0a855
Rollup merge of #86043 - klensy:attr-clone, r=jyn514
JohnTitor Jun 6, 2021
19433c4
Rollup merge of #86047 - jyn514:doc-attrs, r=petrochenkov
JohnTitor Jun 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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