Remove unwrap_none as it won't be stabilized.

This upgrades to the latest rustc to be able to use try_insert()
instead.
This commit is contained in:
Mara Bos 2021-03-08 16:57:09 +01:00
parent 0a0e366ccf
commit 5bd5ea21ea
9 changed files with 13 additions and 18 deletions

View file

@ -1 +1 @@
09db05762b283bed62d4f92729cfee4646519833
1d6b0f626aad4ee9f2eaec4d5582f45620ccab80

View file

@ -179,7 +179,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
)?;
this.write_immediate(*arg, &callee_arg)?;
}
callee_args.next().expect_none("callee has more arguments than expected");
assert_eq!(callee_args.next(), None, "callee has more arguments than expected");
Ok(())
}

View file

@ -1,6 +1,6 @@
#![feature(rustc_private)]
#![feature(option_expect_none, option_unwrap_none)]
#![feature(map_first_last)]
#![feature(map_try_insert)]
#![feature(never_type)]
#![feature(or_patterns)]
#![feature(try_blocks)]

View file

@ -179,8 +179,8 @@ impl MemoryExtra {
this.memory
.extra
.extern_statics
.insert(Symbol::intern(name), ptr.alloc_id)
.unwrap_none();
.try_insert(Symbol::intern(name), ptr.alloc_id)
.unwrap();
}
/// Sets up the "extern statics" for this machine.

View file

@ -223,7 +223,7 @@ impl<'tcx> FileHandler {
self.handles.last_key_value().map(|(fd, _)| fd.checked_add(1).unwrap()).unwrap_or(min_fd)
});
self.handles.insert(new_fd, file_handle).unwrap_none();
self.handles.try_insert(new_fd, file_handle).unwrap();
new_fd
}
}
@ -381,7 +381,7 @@ impl DirHandler {
fn insert_new(&mut self, read_dir: ReadDir) -> u64 {
let id = self.next_id;
self.next_id += 1;
self.streams.insert(id, read_dir).unwrap_none();
self.streams.try_insert(id, read_dir).unwrap();
id
}
}

View file

@ -65,7 +65,7 @@ impl<'tcx> TlsData<'tcx> {
pub fn create_tls_key(&mut self, dtor: Option<ty::Instance<'tcx>>, max_size: Size) -> InterpResult<'tcx, TlsKey> {
let new_key = self.next_key;
self.next_key += 1;
self.keys.insert(new_key, TlsEntry { data: Default::default(), dtor }).unwrap_none();
self.keys.try_insert(new_key, TlsEntry { data: Default::default(), dtor }).unwrap();
trace!("New TLS key allocated: {} with dtor {:?}", new_key, dtor);
if max_size.bits() < 128 && new_key >= (1u128 << max_size.bits() as u128) {

View file

@ -201,7 +201,7 @@ impl GlobalState {
self.base_ptr_ids.get(&id).copied().unwrap_or_else(|| {
let tag = Tag::Tagged(self.new_ptr());
trace!("New allocation {:?} has base tag {:?}", id, tag);
self.base_ptr_ids.insert(id, tag).unwrap_none();
self.base_ptr_ids.try_insert(id, tag).unwrap();
tag
})
}

View file

@ -257,8 +257,8 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
fn set_thread_local_alloc_id(&self, def_id: DefId, new_alloc_id: AllocId) {
self.thread_local_alloc_ids
.borrow_mut()
.insert((def_id, self.active_thread), new_alloc_id)
.unwrap_none();
.try_insert((def_id, self.active_thread), new_alloc_id)
.unwrap();
}
/// Borrow the stack of the active thread.
@ -404,8 +404,8 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
callback: TimeoutCallback<'mir, 'tcx>,
) {
self.timeout_callbacks
.insert(thread, TimeoutCallbackInfo { call_time, callback })
.unwrap_none();
.try_insert(thread, TimeoutCallbackInfo { call_time, callback })
.unwrap();
}
/// Unregister the callback for the `thread`.

View file

@ -1,4 +1,3 @@
#![feature(option_expect_none, option_unwrap_none)]
//! Test that panic locations for `#[track_caller]` functions in std have the correct
//! location reported.
@ -25,10 +24,6 @@ fn main() {
assert_panicked(|| nope.unwrap());
assert_panicked(|| nope.expect(""));
let yep: Option<()> = Some(());
assert_panicked(|| yep.unwrap_none());
assert_panicked(|| yep.expect_none(""));
let oops: Result<(), ()> = Err(());
assert_panicked(|| oops.unwrap());
assert_panicked(|| oops.expect(""));