Remove unwrap_none/expect_none from compiler/.
This commit is contained in:
parent
895a8e71b1
commit
cfb4ad4f2a
10 changed files with 38 additions and 23 deletions
|
@ -1,6 +1,6 @@
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
|
#![feature(assert_matches)]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
#![feature(option_expect_none)]
|
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(drain_filter)]
|
#![feature(drain_filter)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
|
|
|
@ -45,7 +45,11 @@ impl<'ctx> rustc_ast::HashStableContext for StableHashingContext<'ctx> {
|
||||||
item.hash_stable(self, hasher);
|
item.hash_stable(self, hasher);
|
||||||
style.hash_stable(self, hasher);
|
style.hash_stable(self, hasher);
|
||||||
span.hash_stable(self, hasher);
|
span.hash_stable(self, hasher);
|
||||||
tokens.as_ref().expect_none("Tokens should have been removed during lowering!");
|
assert_matches!(
|
||||||
|
tokens.as_ref(),
|
||||||
|
None,
|
||||||
|
"Tokens should have been removed during lowering!"
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
|
#![feature(assert_matches)]
|
||||||
#![feature(assoc_char_funcs)]
|
#![feature(assoc_char_funcs)]
|
||||||
#![feature(backtrace)]
|
#![feature(backtrace)]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
|
@ -38,7 +39,6 @@
|
||||||
#![feature(extern_types)]
|
#![feature(extern_types)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(once_cell)]
|
#![feature(once_cell)]
|
||||||
#![feature(option_expect_none)]
|
|
||||||
#![feature(or_patterns)]
|
#![feature(or_patterns)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(trusted_len)]
|
#![feature(trusted_len)]
|
||||||
|
|
|
@ -339,7 +339,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
|
||||||
for dest in bytes {
|
for dest in bytes {
|
||||||
*dest = src.next().expect("iterator was shorter than it said it would be");
|
*dest = src.next().expect("iterator was shorter than it said it would be");
|
||||||
}
|
}
|
||||||
src.next().expect_none("iterator was longer than it said it would be");
|
assert_matches!(src.next(), None, "iterator was longer than it said it would be");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -854,7 +854,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
||||||
Some(ptr) => ptr,
|
Some(ptr) => ptr,
|
||||||
None => {
|
None => {
|
||||||
// zero-sized access
|
// zero-sized access
|
||||||
src.next().expect_none("iterator said it was empty but returned an element");
|
assert_matches!(
|
||||||
|
src.next(),
|
||||||
|
None,
|
||||||
|
"iterator said it was empty but returned an element"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -880,7 +884,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
||||||
Some(ptr) => ptr,
|
Some(ptr) => ptr,
|
||||||
None => {
|
None => {
|
||||||
// zero-sized access
|
// zero-sized access
|
||||||
src.next().expect_none("iterator said it was empty but returned an element");
|
assert_matches!(
|
||||||
|
src.next(),
|
||||||
|
None,
|
||||||
|
"iterator said it was empty but returned an element"
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -894,7 +902,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
||||||
let offset_ptr = ptr.offset(Size::from_bytes(idx) * 2, &tcx)?; // `Size` multiplication
|
let offset_ptr = ptr.offset(Size::from_bytes(idx) * 2, &tcx)?; // `Size` multiplication
|
||||||
allocation.write_scalar(&tcx, offset_ptr, val.into(), Size::from_bytes(2))?;
|
allocation.write_scalar(&tcx, offset_ptr, val.into(), Size::from_bytes(2))?;
|
||||||
}
|
}
|
||||||
src.next().expect_none("iterator was longer than it said it would be");
|
assert_matches!(src.next(), None, "iterator was longer than it said it would be");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ Rust MIR: a lowered representation of Rust.
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
|
#![feature(assert_matches)]
|
||||||
#![feature(bindings_after_at)]
|
#![feature(bindings_after_at)]
|
||||||
#![feature(bool_to_option)]
|
#![feature(bool_to_option)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
|
@ -18,13 +19,13 @@ Rust MIR: a lowered representation of Rust.
|
||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
|
#![feature(map_try_insert)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(trusted_len)]
|
#![feature(trusted_len)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
#![feature(option_expect_none)]
|
|
||||||
#![feature(option_get_or_insert_default)]
|
#![feature(option_get_or_insert_default)]
|
||||||
#![feature(or_patterns)]
|
#![feature(or_patterns)]
|
||||||
#![feature(once_cell)]
|
#![feature(once_cell)]
|
||||||
|
|
|
@ -285,10 +285,8 @@ impl DebugCounters {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
counters
|
counters
|
||||||
.insert(id, DebugCounter::new(counter_kind.clone(), some_block_label))
|
.try_insert(id, DebugCounter::new(counter_kind.clone(), some_block_label))
|
||||||
.expect_none(
|
.expect("attempt to add the same counter_kind to DebugCounters more than once");
|
||||||
"attempt to add the same counter_kind to DebugCounters more than once",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,9 +477,9 @@ impl GraphvizData {
|
||||||
counter_kind: &CoverageKind,
|
counter_kind: &CoverageKind,
|
||||||
) {
|
) {
|
||||||
if let Some(edge_to_counter) = self.some_edge_to_counter.as_mut() {
|
if let Some(edge_to_counter) = self.some_edge_to_counter.as_mut() {
|
||||||
edge_to_counter.insert((from_bcb, to_bb), counter_kind.clone()).expect_none(
|
edge_to_counter
|
||||||
"invalid attempt to insert more than one edge counter for the same edge",
|
.try_insert((from_bcb, to_bb), counter_kind.clone())
|
||||||
);
|
.expect("invalid attempt to insert more than one edge counter for the same edge");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ fn find_duplicates<'a, 'tcx>(body: &'a Body<'tcx>) -> FxHashMap<BasicBlock, Basi
|
||||||
// The basic block was already in the hashmap, which means we have a duplicate
|
// The basic block was already in the hashmap, which means we have a duplicate
|
||||||
let value = *occupied.get();
|
let value = *occupied.get();
|
||||||
debug!("Inserting {:?} -> {:?}", bb, value);
|
debug!("Inserting {:?} -> {:?}", bb, value);
|
||||||
duplicates.insert(bb, value).expect_none("key was already inserted");
|
duplicates.try_insert(bb, value).expect("key was already inserted");
|
||||||
}
|
}
|
||||||
Entry::Vacant(vacant) => {
|
Entry::Vacant(vacant) => {
|
||||||
vacant.insert(bb);
|
vacant.insert(bb);
|
||||||
|
|
|
@ -118,7 +118,8 @@ impl ExpnId {
|
||||||
HygieneData::with(|data| {
|
HygieneData::with(|data| {
|
||||||
let old_expn_data = &mut data.expn_data[self.0 as usize];
|
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");
|
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);
|
*old_expn_data = Some(expn_data);
|
||||||
});
|
});
|
||||||
update_disambiguator(self)
|
update_disambiguator(self)
|
||||||
|
@ -202,7 +203,8 @@ impl HygieneData {
|
||||||
fn fresh_expn(&mut self, mut expn_data: Option<ExpnData>) -> ExpnId {
|
fn fresh_expn(&mut self, mut expn_data: Option<ExpnData>) -> ExpnId {
|
||||||
let raw_id = self.expn_data.len() as u32;
|
let raw_id = self.expn_data.len() as u32;
|
||||||
if let Some(data) = expn_data.as_mut() {
|
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);
|
self.expn_data.push(expn_data);
|
||||||
ExpnId(raw_id)
|
ExpnId(raw_id)
|
||||||
|
@ -1410,9 +1412,11 @@ fn update_disambiguator(expn_id: ExpnId) {
|
||||||
let new_hash: Fingerprint = hasher.finish();
|
let new_hash: Fingerprint = hasher.finish();
|
||||||
|
|
||||||
HygieneData::with(|data| {
|
HygieneData::with(|data| {
|
||||||
data.expn_data_disambiguators
|
assert_eq!(
|
||||||
.get(&new_hash)
|
data.expn_data_disambiguators.get(&new_hash),
|
||||||
.expect_none("Hash collision after disambiguator update!");
|
None,
|
||||||
|
"Hash collision after disambiguator update!",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#![feature(negative_impls)]
|
#![feature(negative_impls)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(option_expect_none)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_macros;
|
extern crate rustc_macros;
|
||||||
|
@ -1996,7 +1995,8 @@ impl<CTX: HashStableContext> HashStable<CTX> for ExpnId {
|
||||||
if cache.len() < new_len {
|
if cache.len() < new_len {
|
||||||
cache.resize(new_len, None);
|
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);
|
sub_hash.hash_stable(ctx, hasher);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue