Skip to content

Commit

Permalink
Rollup merge of #119853 - klensy:rustfmt-ignore, r=cuviper
Browse files Browse the repository at this point in the history
rustfmt.toml: don't ignore just any tests path, only root one

Previously ignored any `tests` path, now only /tests at repo root.

For reference, https://git-scm.com/docs/gitignore#_pattern_format
  • Loading branch information
matthiaskrgr authored Jan 11, 2024
2 parents ca17ce4 + aa696c5 commit b3d15eb
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 96 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_errors/src/markdown/tests/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use termcolor::{BufferWriter, ColorChoice};
use super::*;

const INPUT: &str = include_str!("input.md");
const OUTPUT_PATH: &[&str] = &[env!("CARGO_MANIFEST_DIR"), "src","markdown","tests","output.stdout"];
const OUTPUT_PATH: &[&str] =
&[env!("CARGO_MANIFEST_DIR"), "src", "markdown", "tests", "output.stdout"];

const TEST_WIDTH: usize = 80;

Expand Down Expand Up @@ -34,7 +35,7 @@ quis dolor non venenatis. Aliquam ut. ";
fn test_wrapping_write() {
WIDTH.with(|w| w.set(TEST_WIDTH));
let mut buf = BufWriter::new(Vec::new());
let txt = TXT.replace("-\n","-").replace("_\n","_").replace('\n', " ").replace(" ", "");
let txt = TXT.replace("-\n", "-").replace("_\n", "_").replace('\n', " ").replace(" ", "");
write_wrapping(&mut buf, &txt, 0, None).unwrap();
write_wrapping(&mut buf, &txt, 4, None).unwrap();
write_wrapping(
Expand Down
7 changes: 1 addition & 6 deletions library/alloc/tests/autotraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ fn test_btree_map() {

require_send_sync(async {
let _v = None::<
alloc::collections::btree_map::ExtractIf<
'_,
&u32,
&u32,
fn(&&u32, &mut &u32) -> bool,
>,
alloc::collections::btree_map::ExtractIf<'_, &u32, &u32, fn(&&u32, &mut &u32) -> bool>,
>;
async {}.await;
});
Expand Down
10 changes: 3 additions & 7 deletions library/alloc/tests/vec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::alloc::{Allocator, Layout};
use core::{assert_eq, assert_ne};
use core::num::NonZeroUsize;
use core::ptr::NonNull;
use core::{assert_eq, assert_ne};
use std::alloc::System;
use std::assert_matches::assert_matches;
use std::borrow::Cow;
Expand Down Expand Up @@ -1212,7 +1212,7 @@ fn test_in_place_specialization_step_up_down() {
assert_eq!(sink.len(), 2);

let mut src: Vec<[u8; 3]> = Vec::with_capacity(17);
src.resize( 8, [0; 3]);
src.resize(8, [0; 3]);
let iter = src.into_iter().map(|[a, b, _]| [a, b]);
assert_in_place_trait(&iter);
let sink: Vec<[u8; 2]> = iter.collect();
Expand All @@ -1221,11 +1221,7 @@ fn test_in_place_specialization_step_up_down() {

let src = vec![[0u8; 4]; 256];
let srcptr = src.as_ptr();
let iter = src
.into_iter()
.flat_map(|a| {
a.into_iter().map(|b| b.wrapping_add(1))
});
let iter = src.into_iter().flat_map(|a| a.into_iter().map(|b| b.wrapping_add(1)));
assert_in_place_trait(&iter);
let sink = iter.collect::<Vec<_>>();
assert_eq!(srcptr as *const u8, sink.as_ptr());
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/array.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::{array, assert_eq};
use core::num::NonZeroUsize;
use core::sync::atomic::{AtomicUsize, Ordering};
use core::{array, assert_eq};

#[test]
fn array_from_ref() {
Expand Down
16 changes: 8 additions & 8 deletions library/core/tests/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ fn const_cells() {
const CELL: Cell<i32> = Cell::new(3);
const _: i32 = CELL.into_inner();

/* FIXME(#110395)
const UNSAFE_CELL_FROM: UnsafeCell<i32> = UnsafeCell::from(3);
const _: i32 = UNSAFE_CELL.into_inner();
/* FIXME(#110395)
const UNSAFE_CELL_FROM: UnsafeCell<i32> = UnsafeCell::from(3);
const _: i32 = UNSAFE_CELL.into_inner();
const REF_CELL_FROM: RefCell<i32> = RefCell::from(3);
const _: i32 = REF_CELL.into_inner();
const REF_CELL_FROM: RefCell<i32> = RefCell::from(3);
const _: i32 = REF_CELL.into_inner();
const CELL_FROM: Cell<i32> = Cell::from(3);
const _: i32 = CELL.into_inner();
*/
const CELL_FROM: Cell<i32> = Cell::from(3);
const _: i32 = CELL.into_inner();
*/
}
2 changes: 1 addition & 1 deletion library/core/tests/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::error::{request_value, request_ref, Request};
use core::error::{request_ref, request_value, Request};

// Test the `Request` API.
#[derive(Debug)]
Expand Down
8 changes: 4 additions & 4 deletions library/core/tests/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ fn test_pointer_formats_data_pointer() {
#[test]
fn test_estimated_capacity() {
assert_eq!(format_args!("").estimated_capacity(), 0);
assert_eq!(format_args!("{}", {""}).estimated_capacity(), 0);
assert_eq!(format_args!("{}", { "" }).estimated_capacity(), 0);
assert_eq!(format_args!("Hello").estimated_capacity(), 5);
assert_eq!(format_args!("Hello, {}!", {""}).estimated_capacity(), 16);
assert_eq!(format_args!("{}, hello!", {"World"}).estimated_capacity(), 0);
assert_eq!(format_args!("{}. 16-bytes piece", {"World"}).estimated_capacity(), 32);
assert_eq!(format_args!("Hello, {}!", { "" }).estimated_capacity(), 16);
assert_eq!(format_args!("{}, hello!", { "World" }).estimated_capacity(), 0);
assert_eq!(format_args!("{}. 16-bytes piece", { "World" }).estimated_capacity(), 32);
}

#[test]
Expand Down
6 changes: 4 additions & 2 deletions library/core/tests/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ impl Hasher for MyHasher {
#[test]
fn test_writer_hasher() {
// FIXME(#110395)
/* const */ fn hash<T: Hash>(t: &T) -> u64 {
/* const */
fn hash<T: Hash>(t: &T) -> u64 {
let mut s = MyHasher { hash: 0 };
t.hash(&mut s);
s.finish()
Expand Down Expand Up @@ -140,7 +141,8 @@ impl Hash for Custom {
#[test]
fn test_custom_state() {
// FIXME(#110395)
/* const */ fn hash<T: Hash>(t: &T) -> u64 {
/* const */
fn hash<T: Hash>(t: &T) -> u64 {
let mut c = CustomHasher { output: 0 };
t.hash(&mut c);
c.finish()
Expand Down
15 changes: 12 additions & 3 deletions library/core/tests/iter/adapters/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ fn test_iterator_chain_advance_by() {
let mut iter = Unfuse::new(xs).chain(Unfuse::new(ys));
assert_eq!(iter.advance_by(xs.len() + i), Ok(()));
assert_eq!(iter.next(), Some(&ys[i]));
assert_eq!(iter.advance_by(100), Err(NonZeroUsize::new(100 - (ys.len() - i - 1)).unwrap()));
assert_eq!(
iter.advance_by(100),
Err(NonZeroUsize::new(100 - (ys.len() - i - 1)).unwrap())
);
assert_eq!(iter.advance_by(0), Ok(()));
}

Expand Down Expand Up @@ -71,15 +74,21 @@ fn test_iterator_chain_advance_back_by() {
let mut iter = Unfuse::new(xs).chain(Unfuse::new(ys));
assert_eq!(iter.advance_back_by(i), Ok(()));
assert_eq!(iter.next_back(), Some(&ys[ys.len() - i - 1]));
assert_eq!(iter.advance_back_by(100), Err(NonZeroUsize::new(100 - (len - i - 1)).unwrap()));
assert_eq!(
iter.advance_back_by(100),
Err(NonZeroUsize::new(100 - (len - i - 1)).unwrap())
);
assert_eq!(iter.advance_back_by(0), Ok(()));
}

for i in 0..xs.len() {
let mut iter = Unfuse::new(xs).chain(Unfuse::new(ys));
assert_eq!(iter.advance_back_by(ys.len() + i), Ok(()));
assert_eq!(iter.next_back(), Some(&xs[xs.len() - i - 1]));
assert_eq!(iter.advance_back_by(100), Err(NonZeroUsize::new(100 - (xs.len() - i - 1)).unwrap()));
assert_eq!(
iter.advance_back_by(100),
Err(NonZeroUsize::new(100 - (xs.len() - i - 1)).unwrap())
);
assert_eq!(iter.advance_back_by(0), Ok(()));
}

Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/iter/adapters/flatten.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::assert_eq;
use super::*;
use core::assert_eq;
use core::iter::*;
use core::num::NonZeroUsize;

Expand Down
22 changes: 9 additions & 13 deletions library/core/tests/iter/adapters/step_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ fn test_step_by_skip() {
assert_eq!((200..=255u8).step_by(10).nth(3), Some(230));
}


struct DeOpt<I: Iterator>(I);

impl<I: Iterator> Iterator for DeOpt<I> {
Expand All @@ -265,17 +264,15 @@ impl<I: DoubleEndedIterator> DoubleEndedIterator for DeOpt<I> {
#[test]
fn test_step_by_fold_range_specialization() {
macro_rules! t {
($range:expr, $var: ident, $body:tt) => {
{
// run the same tests for the non-optimized version
let mut $var = DeOpt($range);
$body
}
{
let mut $var = $range;
$body
}
($range:expr, $var: ident, $body:tt) => {{
// run the same tests for the non-optimized version
let mut $var = DeOpt($range);
$body
}
{
let mut $var = $range;
$body
}};
}

t!((1usize..5).step_by(1), r, {
Expand All @@ -288,13 +285,12 @@ fn test_step_by_fold_range_specialization() {
assert_eq!(r.sum::<usize>(), 2);
});


t!((0usize..5).step_by(2), r, {
assert_eq!(r.next(), Some(0));
assert_eq!(r.sum::<usize>(), 6);
});

t!((usize::MAX - 6 .. usize::MAX).step_by(5), r, {
t!((usize::MAX - 6..usize::MAX).step_by(5), r, {
assert_eq!(r.next(), Some(usize::MAX - 6));
assert_eq!(r.sum::<usize>(), usize::MAX - 1);
});
Expand Down
5 changes: 4 additions & 1 deletion library/core/tests/iter/adapters/take.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ fn test_take_advance_by() {
assert_eq!((0..2).take(1).advance_back_by(10), Err(NonZeroUsize::new(9).unwrap()));
assert_eq!((0..0).take(1).advance_back_by(1), Err(NonZeroUsize::new(1).unwrap()));
assert_eq!((0..0).take(1).advance_back_by(0), Ok(()));
assert_eq!((0..usize::MAX).take(100).advance_back_by(usize::MAX), Err(NonZeroUsize::new(usize::MAX - 100).unwrap()));
assert_eq!(
(0..usize::MAX).take(100).advance_back_by(usize::MAX),
Err(NonZeroUsize::new(usize::MAX - 100).unwrap())
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion library/core/tests/iter/adapters/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn test_zip_nested_sideffectful() {
let it = xs.iter_mut().map(|x| *x = 1).enumerate().zip(&ys);
it.count();
}
let length_aware = &xs == &[1, 1, 1, 1, 0, 0];
let length_aware = &xs == &[1, 1, 1, 1, 0, 0];
let probe_first = &xs == &[1, 1, 1, 1, 1, 0];

// either implementation is valid according to zip documentation
Expand Down
10 changes: 8 additions & 2 deletions library/core/tests/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ fn test_iterator_advance_back_by() {
let mut iter = v.iter();
assert_eq!(iter.advance_back_by(i), Ok(()));
assert_eq!(iter.next_back().unwrap(), &v[v.len() - 1 - i]);
assert_eq!(iter.advance_back_by(100), Err(NonZeroUsize::new(100 - (v.len() - 1 - i)).unwrap()));
assert_eq!(
iter.advance_back_by(100),
Err(NonZeroUsize::new(100 - (v.len() - 1 - i)).unwrap())
);
}

assert_eq!(v.iter().advance_back_by(v.len()), Ok(()));
Expand All @@ -183,7 +186,10 @@ fn test_iterator_rev_advance_back_by() {
let mut iter = v.iter().rev();
assert_eq!(iter.advance_back_by(i), Ok(()));
assert_eq!(iter.next_back().unwrap(), &v[i]);
assert_eq!(iter.advance_back_by(100), Err(NonZeroUsize::new(100 - (v.len() - 1 - i)).unwrap()));
assert_eq!(
iter.advance_back_by(100),
Err(NonZeroUsize::new(100 - (v.len() - 1 - i)).unwrap())
);
}

assert_eq!(v.iter().rev().advance_back_by(v.len()), Ok(()));
Expand Down
6 changes: 5 additions & 1 deletion library/core/tests/net/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,11 @@ fn ipv6_properties() {
&[0x20, 1, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
global | unicast_global
);
check!("2001:30::", &[0x20, 1, 0, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], global | unicast_global);
check!(
"2001:30::",
&[0x20, 1, 0, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
global | unicast_global
);
check!("2001:40::", &[0x20, 1, 0, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], unicast_global);

check!(
Expand Down
42 changes: 21 additions & 21 deletions library/core/tests/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@ fn test_or_else() {
assert_eq!(x.or_else(two), Some(2));
assert_eq!(x.or_else(none), None);

/* FIXME(#110395)
const FOO: Option<isize> = Some(1);
const A: Option<isize> = FOO.or_else(two);
const B: Option<isize> = FOO.or_else(none);
assert_eq!(A, Some(1));
assert_eq!(B, Some(1));
const BAR: Option<isize> = None;
const C: Option<isize> = BAR.or_else(two);
const D: Option<isize> = BAR.or_else(none);
assert_eq!(C, Some(2));
assert_eq!(D, None);
*/
/* FIXME(#110395)
const FOO: Option<isize> = Some(1);
const A: Option<isize> = FOO.or_else(two);
const B: Option<isize> = FOO.or_else(none);
assert_eq!(A, Some(1));
assert_eq!(B, Some(1));
const BAR: Option<isize> = None;
const C: Option<isize> = BAR.or_else(two);
const D: Option<isize> = BAR.or_else(none);
assert_eq!(C, Some(2));
assert_eq!(D, None);
*/
}

#[test]
Expand Down Expand Up @@ -486,15 +486,15 @@ const fn option_const_mut() {
None => unreachable!(),
}
}
/* FIXME(const-hack)
{
let as_mut: Option<&mut usize> = Option::from(&mut option);
match as_mut {
Some(v) => *v = 42,
None => unreachable!(),
/* FIXME(const-hack)
{
let as_mut: Option<&mut usize> = Option::from(&mut option);
match as_mut {
Some(v) => *v = 42,
None => unreachable!(),
}
}
}
*/
*/
}

#[test]
Expand Down
24 changes: 20 additions & 4 deletions library/core/tests/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,11 @@ fn align_offset_various_strides() {
x |= test_stride::<A9>(ptr::invalid::<A9>(ptr), align);

#[repr(packed)]
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
struct A10(
#[allow(dead_code)] u32,
#[allow(dead_code)] u32,
#[allow(dead_code)] u16,
);
x |= test_stride::<A10>(ptr::invalid::<A10>(ptr), align);

x |= test_stride::<u32>(ptr::invalid::<u32>(ptr), align);
Expand Down Expand Up @@ -532,19 +536,31 @@ fn align_offset_various_strides_const() {
test_stride::<A6>(ptr::invalid::<A6>(ptr), ptr, align);

#[repr(packed)]
struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8);
struct A7(
#[allow(dead_code)] u32,
#[allow(dead_code)] u16,
#[allow(dead_code)] u8,
);
test_stride::<A7>(ptr::invalid::<A7>(ptr), ptr, align);

#[repr(packed)]
struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32);
test_stride::<A8>(ptr::invalid::<A8>(ptr), ptr, align);

#[repr(packed)]
struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8);
struct A9(
#[allow(dead_code)] u32,
#[allow(dead_code)] u32,
#[allow(dead_code)] u8,
);
test_stride::<A9>(ptr::invalid::<A9>(ptr), ptr, align);

#[repr(packed)]
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
struct A10(
#[allow(dead_code)] u32,
#[allow(dead_code)] u32,
#[allow(dead_code)] u16,
);
test_stride::<A10>(ptr::invalid::<A10>(ptr), ptr, align);

test_stride::<u32>(ptr::invalid::<u32>(ptr), ptr, align);
Expand Down
Loading

0 comments on commit b3d15eb

Please sign in to comment.