Remove assert_matches users

This commit is contained in:
Mark Rousskov 2021-04-30 12:11:35 -04:00
parent 1406d06104
commit aa3e8d3e78
4 changed files with 5 additions and 28 deletions

View File

@ -45,11 +45,7 @@ impl<'ctx> rustc_ast::HashStableContext for StableHashingContext<'ctx> {
item.hash_stable(self, hasher);
style.hash_stable(self, hasher);
span.hash_stable(self, hasher);
assert_matches!(
tokens.as_ref(),
None,
"Tokens should have been removed during lowering!"
);
assert!(tokens.as_ref().is_none(), "Tokens should have been removed during lowering!");
} else {
unreachable!();
}

View File

@ -339,7 +339,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
for dest in bytes {
*dest = src.next().expect("iterator was shorter than it said it would be");
}
assert_matches!(src.next(), None, "iterator was longer than it said it would be");
assert!(src.next().is_none(), "iterator was longer than it said it would be");
Ok(())
}

View File

@ -854,11 +854,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
Some(ptr) => ptr,
None => {
// zero-sized access
assert_matches!(
src.next(),
None,
"iterator said it was empty but returned an element"
);
assert!(src.next().is_none(), "iterator said it was empty but returned an element");
return Ok(());
}
};
@ -884,11 +880,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
Some(ptr) => ptr,
None => {
// zero-sized access
assert_matches!(
src.next(),
None,
"iterator said it was empty but returned an element"
);
assert!(src.next().is_none(), "iterator said it was empty but returned an element");
return Ok(());
}
};
@ -902,7 +894,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
allocation.write_scalar(&tcx, offset_ptr, val.into(), Size::from_bytes(2))?;
}
assert_matches!(src.next(), None, "iterator was longer than it said it would be");
assert!(src.next().is_none(), "iterator was longer than it said it would be");
Ok(())
}

View File

@ -1,11 +0,0 @@
// run-fail
// error-pattern:panicked at 'assertion failed: `(left matches right)`
// error-pattern: left: `2`
// error-pattern:right: `3`: 1 + 1 definitely should be 3'
// ignore-emscripten no processes
#![feature(assert_matches)]
fn main() {
assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3");
}