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 5 pull requests #86042

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
347ed00
proof of concept add test type on prints
ABouttefeux May 3, 2021
6e99cb3
change based on review
ABouttefeux May 3, 2021
f6b8b78
add bootstrap cfg
ABouttefeux May 9, 2021
4ce2e33
fix compiletest to search for two dash and run make fulldeps test
ABouttefeux May 9, 2021
3d81806
remove mode for run and ignore tests
ABouttefeux May 16, 2021
6de13c3
change based on review
ABouttefeux May 18, 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
894b42c
Disallow non-monomorphic calls to `needs_drop` in interpreter
tmiasko Jun 4, 2021
07a03b0
Explain that `ensure_monomorphic_enough` omission is intentional
tmiasko 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
149777f
Rollup merge of #84863 - ABouttefeux:libtest, r=m-ou-se
GuillaumeGomez Jun 5, 2021
678b012
Rollup merge of #85930 - mominul:array_into_iter, r=m-ou-se
GuillaumeGomez Jun 5, 2021
3ebc3e7
Rollup merge of #85972 - GuillaumeGomez:rustdoc-html-fixes, r=jsha
GuillaumeGomez Jun 5, 2021
1542950
Rollup merge of #85994 - tmiasko:monomorphic-needs-drop, r=RalfJung
GuillaumeGomez Jun 5, 2021
01bbae8
Rollup merge of #86028 - LingMan:dupe_empty_check, r=jyn514
GuillaumeGomez Jun 5, 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
4 changes: 4 additions & 0 deletions compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ pub fn expand_test_or_bench(
"allow_fail",
cx.expr_bool(sp, should_fail(&cx.sess, &item)),
),
// compile_fail: true | false
field("compile_fail", cx.expr_bool(sp, false)),
// no_run: true | false
field("no_run", cx.expr_bool(sp, false)),
// should_panic: ...
field(
"should_panic",
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_mir/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ crate fn eval_nullary_intrinsic<'tcx>(
let alloc = type_name::alloc_type_name(tcx, tp_ty);
ConstValue::Slice { data: alloc, start: 0, end: alloc.len() }
}
sym::needs_drop => ConstValue::from_bool(tp_ty.needs_drop(tcx, param_env)),
sym::needs_drop => {
ensure_monomorphic_enough(tcx, tp_ty)?;
ConstValue::from_bool(tp_ty.needs_drop(tcx, param_env))
}
sym::min_align_of | sym::pref_align_of => {
// Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
let layout = tcx.layout_of(param_env.and(tp_ty)).map_err(|e| err_inval!(Layout(e)))?;
let n = match name {
sym::pref_align_of => layout.align.pref.bytes(),
Expand All @@ -71,6 +75,7 @@ crate fn eval_nullary_intrinsic<'tcx>(
ConstValue::from_u64(tcx.type_id_hash(tp_ty))
}
sym::variant_count => match tp_ty.kind() {
// Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
ty::Adt(ref adt, _) => ConstValue::from_machine_usize(adt.variants.len() as u64, &tcx),
ty::Projection(_)
| ty::Opaque(_, _)
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
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
46 changes: 23 additions & 23 deletions library/core/tests/array.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::array::{self, IntoIter};
use core::array;
use core::convert::TryFrom;

#[test]
Expand Down Expand Up @@ -41,44 +41,44 @@ fn array_try_from() {
#[test]
fn iterator_collect() {
let arr = [0, 1, 2, 5, 9];
let v: Vec<_> = IntoIter::new(arr.clone()).collect();
let v: Vec<_> = IntoIterator::into_iter(arr.clone()).collect();
assert_eq!(&arr[..], &v[..]);
}

#[test]
fn iterator_rev_collect() {
let arr = [0, 1, 2, 5, 9];
let v: Vec<_> = IntoIter::new(arr.clone()).rev().collect();
let v: Vec<_> = IntoIterator::into_iter(arr.clone()).rev().collect();
assert_eq!(&v[..], &[9, 5, 2, 1, 0]);
}

#[test]
fn iterator_nth() {
let v = [0, 1, 2, 3, 4];
for i in 0..v.len() {
assert_eq!(IntoIter::new(v.clone()).nth(i).unwrap(), v[i]);
assert_eq!(IntoIterator::into_iter(v.clone()).nth(i).unwrap(), v[i]);
}
assert_eq!(IntoIter::new(v.clone()).nth(v.len()), None);
assert_eq!(IntoIterator::into_iter(v.clone()).nth(v.len()), None);

let mut iter = IntoIter::new(v);
let mut iter = IntoIterator::into_iter(v);
assert_eq!(iter.nth(2).unwrap(), v[2]);
assert_eq!(iter.nth(1).unwrap(), v[4]);
}

#[test]
fn iterator_last() {
let v = [0, 1, 2, 3, 4];
assert_eq!(IntoIter::new(v).last().unwrap(), 4);
assert_eq!(IntoIter::new([0]).last().unwrap(), 0);
assert_eq!(IntoIterator::into_iter(v).last().unwrap(), 4);
assert_eq!(IntoIterator::into_iter([0]).last().unwrap(), 0);

let mut it = IntoIter::new([0, 9, 2, 4]);
let mut it = IntoIterator::into_iter([0, 9, 2, 4]);
assert_eq!(it.next_back(), Some(4));
assert_eq!(it.last(), Some(2));
}

#[test]
fn iterator_clone() {
let mut it = IntoIter::new([0, 2, 4, 6, 8]);
let mut it = IntoIterator::into_iter([0, 2, 4, 6, 8]);
assert_eq!(it.next(), Some(0));
assert_eq!(it.next_back(), Some(8));
let mut clone = it.clone();
Expand All @@ -92,7 +92,7 @@ fn iterator_clone() {

#[test]
fn iterator_fused() {
let mut it = IntoIter::new([0, 9, 2]);
let mut it = IntoIterator::into_iter([0, 9, 2]);
assert_eq!(it.next(), Some(0));
assert_eq!(it.next(), Some(9));
assert_eq!(it.next(), Some(2));
Expand All @@ -105,7 +105,7 @@ fn iterator_fused() {

#[test]
fn iterator_len() {
let mut it = IntoIter::new([0, 1, 2, 5, 9]);
let mut it = IntoIterator::into_iter([0, 1, 2, 5, 9]);
assert_eq!(it.size_hint(), (5, Some(5)));
assert_eq!(it.len(), 5);
assert_eq!(it.is_empty(), false);
Expand All @@ -121,7 +121,7 @@ fn iterator_len() {
assert_eq!(it.is_empty(), false);

// Empty
let it = IntoIter::new([] as [String; 0]);
let it = IntoIterator::into_iter([] as [String; 0]);
assert_eq!(it.size_hint(), (0, Some(0)));
assert_eq!(it.len(), 0);
assert_eq!(it.is_empty(), true);
Expand All @@ -130,23 +130,23 @@ fn iterator_len() {
#[test]
fn iterator_count() {
let v = [0, 1, 2, 3, 4];
assert_eq!(IntoIter::new(v.clone()).count(), 5);
assert_eq!(IntoIterator::into_iter(v.clone()).count(), 5);

let mut iter2 = IntoIter::new(v);
let mut iter2 = IntoIterator::into_iter(v);
iter2.next();
iter2.next();
assert_eq!(iter2.count(), 3);
}

#[test]
fn iterator_flat_map() {
assert!((0..5).flat_map(|i| IntoIter::new([2 * i, 2 * i + 1])).eq(0..10));
assert!((0..5).flat_map(|i| IntoIterator::into_iter([2 * i, 2 * i + 1])).eq(0..10));
}

#[test]
fn iterator_debug() {
let arr = [0, 1, 2, 5, 9];
assert_eq!(format!("{:?}", IntoIter::new(arr)), "IntoIter([0, 1, 2, 5, 9])",);
assert_eq!(format!("{:?}", IntoIterator::into_iter(arr)), "IntoIter([0, 1, 2, 5, 9])",);
}

#[test]
Expand Down Expand Up @@ -176,14 +176,14 @@ fn iterator_drops() {
// Simple: drop new iterator.
let i = Cell::new(0);
{
IntoIter::new(five(&i));
IntoIterator::into_iter(five(&i));
}
assert_eq!(i.get(), 5);

// Call `next()` once.
let i = Cell::new(0);
{
let mut iter = IntoIter::new(five(&i));
let mut iter = IntoIterator::into_iter(five(&i));
let _x = iter.next();
assert_eq!(i.get(), 0);
assert_eq!(iter.count(), 4);
Expand All @@ -194,7 +194,7 @@ fn iterator_drops() {
// Check `clone` and calling `next`/`next_back`.
let i = Cell::new(0);
{
let mut iter = IntoIter::new(five(&i));
let mut iter = IntoIterator::into_iter(five(&i));
iter.next();
assert_eq!(i.get(), 1);
iter.next_back();
Expand All @@ -217,7 +217,7 @@ fn iterator_drops() {
// Check via `nth`.
let i = Cell::new(0);
{
let mut iter = IntoIter::new(five(&i));
let mut iter = IntoIterator::into_iter(five(&i));
let _x = iter.nth(2);
assert_eq!(i.get(), 2);
let _y = iter.last();
Expand All @@ -227,13 +227,13 @@ fn iterator_drops() {

// Check every element.
let i = Cell::new(0);
for (index, _x) in IntoIter::new(five(&i)).enumerate() {
for (index, _x) in IntoIterator::into_iter(five(&i)).enumerate() {
assert_eq!(i.get(), index);
}
assert_eq!(i.get(), 5);

let i = Cell::new(0);
for (index, _x) in IntoIter::new(five(&i)).rev().enumerate() {
for (index, _x) in IntoIterator::into_iter(five(&i)).rev().enumerate() {
assert_eq!(i.get(), index);
}
assert_eq!(i.get(), 5);
Expand Down
4 changes: 1 addition & 3 deletions library/core/tests/iter/adapters/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ fn test_zip_trusted_random_access_composition() {
fn test_double_ended_zip() {
let xs = [1, 2, 3, 4, 5, 6];
let ys = [1, 2, 3, 7];
let a = xs.iter().cloned();
let b = ys.iter().cloned();
let mut it = a.zip(b);
let mut it = xs.iter().cloned().zip(ys);
assert_eq!(it.next(), Some((1, 1)));
assert_eq!(it.next(), Some((2, 2)));
assert_eq!(it.next_back(), Some((4, 7)));
Expand Down
Loading