Skip to content

Commit

Permalink
Use rustfmt::skip for some cases
Browse files Browse the repository at this point in the history
This does not include all cases of rejected reformatting;
only ones where rustfmt is not expected to do well.
  • Loading branch information
dhardy committed Jan 2, 2020
1 parent 3a51c3e commit 3a5d5a8
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rand_chacha/src/chacha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub struct Array64<T>([T; 64]);
impl<T> Default for Array64<T>
where T: Default
{
#[rustfmt::skip]
fn default() -> Self {
#[rustfmt::skip]
Self([
T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(),
Expand Down
3 changes: 3 additions & 0 deletions rand_distr/benches/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#![feature(test)]

// Rustfmt slits many macro invocations to shorten lines; in this case longer-lines are more readable
#![rustfmt::skip]

extern crate test;

const RAND_BENCH_N: u64 = 1000;
Expand Down
4 changes: 4 additions & 0 deletions rand_distr/src/ziggurat_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

pub type ZigTable = &'static [f64; 257];
pub const ZIG_NORM_R: f64 = 3.654152885361008796;
#[rustfmt::skip]
pub static ZIG_NORM_X: [f64; 257] =
[3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
Expand Down Expand Up @@ -78,6 +79,7 @@ pub static ZIG_NORM_X: [f64; 257] =
0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746,
0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806,
0.000000000000000000];
#[rustfmt::skip]
pub static ZIG_NORM_F: [f64; 257] =
[0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872,
0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100,
Expand Down Expand Up @@ -145,6 +147,7 @@ pub static ZIG_NORM_F: [f64; 257] =
0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
1.000000000000000000];
pub const ZIG_EXP_R: f64 = 7.697117470131050077;
#[rustfmt::skip]
pub static ZIG_EXP_X: [f64; 257] =
[8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
Expand Down Expand Up @@ -211,6 +214,7 @@ pub static ZIG_EXP_X: [f64; 257] =
0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842,
0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570,
0.000000000000000000];
#[rustfmt::skip]
pub static ZIG_EXP_F: [f64; 257] =
[0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573,
0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797,
Expand Down
12 changes: 12 additions & 0 deletions rand_hc/src/hc128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ mod test {
#[test]
// Test vector 1 from the paper "The Stream Cipher HC-128"
fn test_hc128_true_values_a() {
#[rustfmt::skip]
let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
let mut rng = Hc128Rng::from_seed(seed);
Expand All @@ -356,6 +357,7 @@ mod test {
for i in results.iter_mut() {
*i = rng.next_u32();
}
#[rustfmt::skip]
let expected = [0x73150082, 0x3bfd03a0, 0xfb2fd77f, 0xaa63af0e,
0xde122fc6, 0xa7dc29b6, 0x62a68527, 0x8b75ec68,
0x9036db1e, 0x81896005, 0x00ade078, 0x491fbf9a,
Expand All @@ -366,6 +368,7 @@ mod test {
#[test]
// Test vector 2 from the paper "The Stream Cipher HC-128"
fn test_hc128_true_values_b() {
#[rustfmt::skip]
let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
1,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
let mut rng = Hc128Rng::from_seed(seed);
Expand All @@ -374,6 +377,7 @@ mod test {
for i in results.iter_mut() {
*i = rng.next_u32();
}
#[rustfmt::skip]
let expected = [0xc01893d5, 0xb7dbe958, 0x8f65ec98, 0x64176604,
0x36fc6724, 0xc82c6eec, 0x1b1c38a7, 0xc9b42a95,
0x323ef123, 0x0a6a908b, 0xce757b68, 0x9f14f7bb,
Expand All @@ -384,6 +388,7 @@ mod test {
#[test]
// Test vector 3 from the paper "The Stream Cipher HC-128"
fn test_hc128_true_values_c() {
#[rustfmt::skip]
let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
let mut rng = Hc128Rng::from_seed(seed);
Expand All @@ -392,6 +397,7 @@ mod test {
for i in results.iter_mut() {
*i = rng.next_u32();
}
#[rustfmt::skip]
let expected = [0x518251a4, 0x04b4930a, 0xb02af931, 0x0639f032,
0xbcb4a47a, 0x5722480b, 0x2bf99f72, 0xcdc0e566,
0x310f0c56, 0xd3cc83e8, 0x663db8ef, 0x62dfe07f,
Expand All @@ -401,6 +407,7 @@ mod test {

#[test]
fn test_hc128_true_values_u64() {
#[rustfmt::skip]
let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
let mut rng = Hc128Rng::from_seed(seed);
Expand All @@ -409,6 +416,7 @@ mod test {
for i in results.iter_mut() {
*i = rng.next_u64();
}
#[rustfmt::skip]
let expected = [0x3bfd03a073150082, 0xaa63af0efb2fd77f,
0xa7dc29b6de122fc6, 0x8b75ec6862a68527,
0x818960059036db1e, 0x491fbf9a00ade078,
Expand All @@ -425,6 +433,7 @@ mod test {
for i in results.iter_mut() {
*i = rng.next_u64();
}
#[rustfmt::skip]
let expected = [0xd8c4d6ca84d0fc10, 0xf16a5d91dc66e8e7,
0xd800de5bc37a8653, 0x7bae1f88c0dfbb4c,
0x3bfe1f374e6d4d14, 0x424b55676be3fa06,
Expand All @@ -434,9 +443,11 @@ mod test {

#[test]
fn test_hc128_true_values_bytes() {
#[rustfmt::skip]
let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
let mut rng = Hc128Rng::from_seed(seed);
#[rustfmt::skip]
let expected = [0x31, 0xf9, 0x2a, 0xb0, 0x32, 0xf0, 0x39, 0x06,
0x7a, 0xa4, 0xb4, 0xbc, 0x0b, 0x48, 0x22, 0x57,
0x72, 0x9f, 0xf9, 0x2b, 0x66, 0xe5, 0xc0, 0xcd,
Expand Down Expand Up @@ -471,6 +482,7 @@ mod test {

#[test]
fn test_hc128_clone() {
#[rustfmt::skip]
let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv
let mut rng1 = Hc128Rng::from_seed(seed);
Expand Down
1 change: 1 addition & 0 deletions rand_pcg/tests/lcg128xsl64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use rand_pcg::{Lcg128Xsl64, Pcg64};
#[test]
fn test_lcg128xsl64_construction() {
// Test that various construction techniques produce a working RNG.
#[rustfmt::skip]
let seed = [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16,
17,18,19,20, 21,22,23,24, 25,26,27,28, 29,30,31,32];
let mut rng1 = Lcg128Xsl64::from_seed(seed);
Expand Down
4 changes: 4 additions & 0 deletions src/distributions/ziggurat_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

pub type ZigTable = &'static [f64; 257];
pub const ZIG_NORM_R: f64 = 3.654152885361008796;
#[rustfmt::skip]
pub static ZIG_NORM_X: [f64; 257] =
[3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074,
3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434,
Expand Down Expand Up @@ -78,6 +79,7 @@ pub static ZIG_NORM_X: [f64; 257] =
0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746,
0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806,
0.000000000000000000];
#[rustfmt::skip]
pub static ZIG_NORM_F: [f64; 257] =
[0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872,
0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100,
Expand Down Expand Up @@ -145,6 +147,7 @@ pub static ZIG_NORM_F: [f64; 257] =
0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328,
1.000000000000000000];
pub const ZIG_EXP_R: f64 = 7.697117470131050077;
#[rustfmt::skip]
pub static ZIG_EXP_X: [f64; 257] =
[8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696,
6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488,
Expand Down Expand Up @@ -211,6 +214,7 @@ pub static ZIG_EXP_X: [f64; 257] =
0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842,
0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570,
0.000000000000000000];
#[rustfmt::skip]
pub static ZIG_EXP_F: [f64; 257] =
[0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573,
0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ macro_rules! impl_as_byte_slice_arrays {
impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*);
};
}
#[rustfmt::skip]
impl_as_byte_slice_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,);
impl_as_byte_slice_arrays!(!div 4096, N,N,N,N,N,N,N,);

Expand Down
1 change: 1 addition & 0 deletions src/rngs/adapter/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ mod test {
#[test]
fn test_reader_rng_u64() {
// transmute from the target to avoid endianness concerns.
#[rustfmt::skip]
let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1,
0 , 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 3];
Expand Down
1 change: 1 addition & 0 deletions src/rngs/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ mod test {
fn test_stdrng_construction() {
// Test value-stability of StdRng. This is expected to break any time
// the algorithm is changed.
#[rustfmt::skip]
let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];

Expand Down

0 comments on commit 3a5d5a8

Please sign in to comment.