Skip to content

Commit 7044157

Browse files
committed
Run fmt
1 parent dfd183f commit 7044157

File tree

15 files changed

+124
-60
lines changed

15 files changed

+124
-60
lines changed

compiler/rustc_data_structures/src/stable_hasher.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ macro_rules! impl_hash_stable_eq_via_eq {
240240
self == other
241241
}
242242
}
243-
}
243+
};
244244
}
245245

246246
impl_stable_hash_via_hash!(i8);
@@ -325,12 +325,12 @@ impl<T1: HashStableEq, T2: HashStableEq> HashStableEq for (T1, T2) {
325325

326326
impl<T1: HashStableEq, T2: HashStableEq, T3: HashStableEq> HashStableEq for (T1, T2, T3) {
327327
fn hash_stable_eq(&self, other: &Self) -> bool {
328-
self.0.hash_stable_eq(&other.0) && self.1.hash_stable_eq(&other.1)
328+
self.0.hash_stable_eq(&other.0)
329+
&& self.1.hash_stable_eq(&other.1)
329330
&& self.2.hash_stable_eq(&other.2)
330331
}
331332
}
332333

333-
334334
impl<T1: HashStable<CTX>, CTX> HashStable<CTX> for (T1,) {
335335
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
336336
let (ref _0,) = *self;
@@ -396,7 +396,6 @@ impl<T: HashStableEq, const N: usize> HashStableEq for [T; N] {
396396
}
397397
}
398398

399-
400399
impl<T: HashStable<CTX>, CTX> HashStable<CTX> for [T] {
401400
default fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
402401
self.len().hash_stable(ctx, hasher);
@@ -436,16 +435,16 @@ impl<T: HashStableEq> HashStableEq for Vec<T> {
436435
}
437436
}
438437

439-
impl<K: HashStableEq + Eq + Hash, V: HashStableEq, R: BuildHasher> HashStableEq for indexmap::IndexMap<K, V, R> {
438+
impl<K: HashStableEq + Eq + Hash, V: HashStableEq, R: BuildHasher> HashStableEq
439+
for indexmap::IndexMap<K, V, R>
440+
{
440441
fn hash_stable_eq(&self, other: &Self) -> bool {
441442
if self.len() != other.len() {
442443
return false;
443444
}
444445
// Equal maps will have equal iteration orders
445446
// FIXME -is that actually right?
446-
self.iter().zip(other.iter()).all(|(first, second)| {
447-
first.hash_stable_eq(&second)
448-
})
447+
self.iter().zip(other.iter()).all(|(first, second)| first.hash_stable_eq(&second))
449448
}
450449
}
451450

@@ -494,7 +493,10 @@ where
494493
}
495494
}
496495

497-
impl<A: smallvec::Array> HashStableEq for SmallVec<A> where <A as smallvec::Array>::Item: HashStableEq {
496+
impl<A: smallvec::Array> HashStableEq for SmallVec<A>
497+
where
498+
<A as smallvec::Array>::Item: HashStableEq,
499+
{
498500
fn hash_stable_eq(&self, other: &Self) -> bool {
499501
(&self[..]).hash_stable_eq(other)
500502
}
@@ -587,7 +589,7 @@ impl<T: HashStableEq> HashStableEq for Option<T> {
587589
match (self, other) {
588590
(Some(first), Some(second)) => first.hash_stable_eq(second),
589591
(None, None) => true,
590-
_ => false
592+
_ => false,
591593
}
592594
}
593595
}
@@ -597,7 +599,7 @@ impl<T: HashStableEq, E: HashStableEq> HashStableEq for Result<T, E> {
597599
match (self, other) {
598600
(Ok(first), Ok(second)) => first.hash_stable_eq(second),
599601
(Err(first), Err(second)) => first.hash_stable_eq(second),
600-
_ => false
602+
_ => false,
601603
}
602604
}
603605
}

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,8 +3013,8 @@ impl ForeignItemId {
30133013
/// type or method, and whether it is public). This allows other
30143014
/// passes to find the impl they want without loading the ID (which
30153015
/// means fewer edges in the incremental compilation graph).
3016-
#[derive(Debug, HashStable_Generic)
3017-
]#[stable_hasher(no_hash_stable_eq)]
3016+
#[derive(Debug, HashStable_Generic)]
3017+
#[stable_hasher(no_hash_stable_eq)]
30183018
pub struct ForeignItemRef {
30193019
pub id: ForeignItemId,
30203020
pub ident: Ident,

compiler/rustc_hir/src/stable_hash_impls.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey, HashStableEq};
1+
use rustc_data_structures::stable_hasher::{
2+
HashStable, HashStableEq, StableHasher, ToStableHashKey,
3+
};
24

35
use crate::hir::{
46
AttributeMap, BodyId, Crate, Expr, ForeignItem, ForeignItemId, ImplItem, ImplItemId, Item,

compiler/rustc_macros/src/hash_stable.rs

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma
8181
}
8282
});
8383

84-
8584
let discriminant = match s.ast().data {
8685
syn::Data::Enum(_) => quote! {
8786
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
@@ -118,37 +117,45 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma
118117

119118
pub fn hash_stable_eq_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
120119
let mut other = s.clone();
121-
other.binding_name(|_bi, i| Ident::new(&format!("__binding_other_{}", i), proc_macro2::Span::call_site()));
122-
123-
let eq_body: proc_macro2::TokenStream = s.variants().iter().zip(other.variants()).map(|(variant1, variant2)| {
124-
125-
let first_pat = variant1.pat();
126-
let second_pat = variant2.pat();
127-
128-
let compare = std::iter::once(quote! { true }).chain(variant1.bindings().iter().zip(variant2.bindings()).map(|(binding1, binding2)| {
129-
let attrs = parse_attributes(binding1.ast());
130-
if attrs.ignore {
131-
quote! { true }
132-
} else if let Some(project) = attrs.project {
133-
quote! {
134-
::rustc_data_structures::stable_hasher::HashStableEq::hash_stable_eq(
135-
#binding1.#project, #binding2.#project
136-
)
137-
}
138-
} else {
139-
quote! {
140-
::rustc_data_structures::stable_hasher::HashStableEq::hash_stable_eq(
141-
#binding1, #binding2
142-
)
120+
other.binding_name(|_bi, i| {
121+
Ident::new(&format!("__binding_other_{}", i), proc_macro2::Span::call_site())
122+
});
123+
124+
let eq_body: proc_macro2::TokenStream = s
125+
.variants()
126+
.iter()
127+
.zip(other.variants())
128+
.map(|(variant1, variant2)| {
129+
let first_pat = variant1.pat();
130+
let second_pat = variant2.pat();
131+
132+
let compare = std::iter::once(quote! { true }).chain(
133+
variant1.bindings().iter().zip(variant2.bindings()).map(|(binding1, binding2)| {
134+
let attrs = parse_attributes(binding1.ast());
135+
if attrs.ignore {
136+
quote! { true }
137+
} else if let Some(project) = attrs.project {
138+
quote! {
139+
::rustc_data_structures::stable_hasher::HashStableEq::hash_stable_eq(
140+
#binding1.#project, #binding2.#project
141+
)
142+
}
143+
} else {
144+
quote! {
145+
::rustc_data_structures::stable_hasher::HashStableEq::hash_stable_eq(
146+
#binding1, #binding2
147+
)
148+
}
149+
}
150+
}),
151+
);
152+
quote! {
153+
(#first_pat, #second_pat) => {
154+
#(#compare)&&*
143155
}
144156
}
145-
}));
146-
quote! {
147-
(#first_pat, #second_pat) => {
148-
#(#compare)&&*
149-
}
150-
}
151-
}).collect();
157+
})
158+
.collect();
152159

153160
s.add_bounds(synstructure::AddBounds::Generics);
154161
s.bound_impl(
@@ -160,8 +167,8 @@ pub fn hash_stable_eq_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
160167
_ => false
161168
}
162169
}
163-
}
164-
)
170+
},
171+
)
165172
}
166173

167174
pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {

compiler/rustc_middle/src/mir/interpret/allocation.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,18 @@ impl<Tag: Copy, Extra> Allocation<Tag, Extra> {
496496
}
497497

498498
/// "Relocations" stores the provenance information of pointers stored in memory.
499-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable, HashStableEq)]
499+
#[derive(
500+
Clone,
501+
PartialEq,
502+
Eq,
503+
PartialOrd,
504+
Ord,
505+
Hash,
506+
Debug,
507+
TyEncodable,
508+
TyDecodable,
509+
HashStableEq
510+
)]
500511
pub struct Relocations<Tag = AllocId>(SortedMap<Size, Tag>);
501512

502513
impl<Tag> Relocations<Tag> {

compiler/rustc_middle/src/ty/consts/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_apfloat::ieee::{Double, Single};
22
use rustc_apfloat::Float;
3+
use rustc_data_structures::stable_hasher::HashStableEq;
34
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
45
use rustc_target::abi::Size;
5-
use rustc_data_structures::stable_hasher::HashStableEq;
66
use std::convert::{TryFrom, TryInto};
77
use std::fmt;
88

compiler/rustc_middle/src/ty/fast_reject.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@ pub type SimplifiedType = SimplifiedTypeGen<DefId>;
1717
/// because we sometimes need to use SimplifiedTypeGen values as stable sorting
1818
/// keys (in which case we use a DefPathHash as id-type) but in the general case
1919
/// the non-stable but fast to construct DefId-version is the better choice.
20-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, TyEncodable, TyDecodable, HashStableEq)]
20+
#[derive(
21+
Clone,
22+
Copy,
23+
Debug,
24+
PartialEq,
25+
Eq,
26+
Hash,
27+
PartialOrd,
28+
Ord,
29+
TyEncodable,
30+
TyDecodable,
31+
HashStableEq
32+
)]
2133
pub enum SimplifiedTypeGen<D>
2234
where
2335
D: Copy + Debug + Eq,

compiler/rustc_middle/src/ty/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::arena::Arena;
2-
use rustc_serialize::{Encodable, Encoder};
32
use rustc_data_structures::stable_hasher::HashStableEq;
3+
use rustc_serialize::{Encodable, Encoder};
44
use std::alloc::Layout;
55
use std::cmp::Ordering;
66
use std::fmt;

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,19 @@ impl UniverseIndex {
11341134
/// identified by both a universe, as well as a name residing within that universe. Distinct bound
11351135
/// regions/types/consts within the same universe simply have an unknown relationship to one
11361136
/// another.
1137-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord, HashStableEq)]
1137+
#[derive(
1138+
Copy,
1139+
Clone,
1140+
Debug,
1141+
PartialEq,
1142+
Eq,
1143+
Hash,
1144+
TyEncodable,
1145+
TyDecodable,
1146+
PartialOrd,
1147+
Ord,
1148+
HashStableEq
1149+
)]
11381150
pub struct Placeholder<T> {
11391151
pub universe: UniverseIndex,
11401152
pub name: T,

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,19 @@ pub enum RegionKind {
15561556
ReErased,
15571557
}
15581558

1559-
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, PartialOrd, Ord, HashStableEq)]
1559+
#[derive(
1560+
Copy,
1561+
Clone,
1562+
PartialEq,
1563+
Eq,
1564+
Hash,
1565+
TyEncodable,
1566+
TyDecodable,
1567+
Debug,
1568+
PartialOrd,
1569+
Ord,
1570+
HashStableEq
1571+
)]
15601572
pub struct EarlyBoundRegion {
15611573
pub def_id: DefId,
15621574
pub index: u32,

0 commit comments

Comments
 (0)