1
Fork 0

Remove unwrap_none/expect_none from compiler/.

This commit is contained in:
Mara Bos 2021-03-04 13:06:01 +01:00
parent 895a8e71b1
commit cfb4ad4f2a
10 changed files with 38 additions and 23 deletions

View file

@ -118,7 +118,8 @@ impl ExpnId {
HygieneData::with(|data| {
let old_expn_data = &mut data.expn_data[self.0 as usize];
assert!(old_expn_data.is_none(), "expansion data is reset for an expansion ID");
expn_data.orig_id.replace(self.as_u32()).expect_none("orig_id should be None");
assert_eq!(expn_data.orig_id, None);
expn_data.orig_id = Some(self.as_u32());
*old_expn_data = Some(expn_data);
});
update_disambiguator(self)
@ -202,7 +203,8 @@ impl HygieneData {
fn fresh_expn(&mut self, mut expn_data: Option<ExpnData>) -> ExpnId {
let raw_id = self.expn_data.len() as u32;
if let Some(data) = expn_data.as_mut() {
data.orig_id.replace(raw_id).expect_none("orig_id should be None");
assert_eq!(data.orig_id, None);
data.orig_id = Some(raw_id);
}
self.expn_data.push(expn_data);
ExpnId(raw_id)
@ -1410,9 +1412,11 @@ fn update_disambiguator(expn_id: ExpnId) {
let new_hash: Fingerprint = hasher.finish();
HygieneData::with(|data| {
data.expn_data_disambiguators
.get(&new_hash)
.expect_none("Hash collision after disambiguator update!");
assert_eq!(
data.expn_data_disambiguators.get(&new_hash),
None,
"Hash collision after disambiguator update!",
);
});
};
}

View file

@ -21,7 +21,6 @@
#![feature(negative_impls)]
#![feature(nll)]
#![feature(min_specialization)]
#![feature(option_expect_none)]
#[macro_use]
extern crate rustc_macros;
@ -1996,7 +1995,8 @@ impl<CTX: HashStableContext> HashStable<CTX> for ExpnId {
if cache.len() < new_len {
cache.resize(new_len, None);
}
cache[index].replace(sub_hash).expect_none("Cache slot was filled");
let prev = cache[index].replace(sub_hash);
assert_eq!(prev, None, "Cache slot was filled");
});
sub_hash.hash_stable(ctx, hasher);
}