Skip to content

Commit 1d73897

Browse files
authored
Use core::convert::Infallible instead of our own Uninhabited type (#12115)
* Use `core::convert::Infallible` instead of our own `Uninhabited` type I didn't realize that the standard library already had an uninhabited type available for us to reuse. * Actually remove the uninhabited module and its re-exports
1 parent 9a6aa39 commit 1d73897

File tree

11 files changed

+31
-41
lines changed

11 files changed

+31
-41
lines changed

crates/wasmtime/src/runtime.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub(crate) mod trampoline;
5353
pub(crate) mod trap;
5454
pub(crate) mod type_registry;
5555
pub(crate) mod types;
56-
pub(crate) mod uninhabited;
5756
pub(crate) mod v128;
5857
pub(crate) mod values;
5958
pub(crate) mod vm;
@@ -100,8 +99,6 @@ pub use types::*;
10099
pub use v128::V128;
101100
pub use values::*;
102101

103-
pub(crate) use uninhabited::*;
104-
105102
#[cfg(feature = "pooling-allocator")]
106103
pub use vm::{PoolConcurrencyLimitError, PoolingAllocatorMetrics};
107104

crates/wasmtime/src/runtime/component/concurrent_disabled.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::Uninhabited;
21
use crate::component::Val;
32
use crate::component::func::{ComponentType, LiftContext, LowerContext};
43
use crate::runtime::vm::VMStore;
54
use anyhow::{Result, anyhow};
5+
use core::convert::Infallible;
66
use core::future::Future;
77
use core::marker::PhantomData;
88
use core::pin::pin;
@@ -56,7 +56,7 @@ pub(crate) fn lower_error_context_to_index<U>(
5656
should_have_failed_validation("use of `error-context`")
5757
}
5858

59-
pub struct ErrorContext(Uninhabited);
59+
pub struct ErrorContext(Infallible);
6060

6161
impl ErrorContext {
6262
pub(crate) fn into_val(self) -> Val {
@@ -81,7 +81,7 @@ impl ErrorContext {
8181
}
8282

8383
pub struct StreamReader<P> {
84-
uninhabited: Uninhabited,
84+
uninhabited: Infallible,
8585
_phantom: PhantomData<P>,
8686
}
8787

@@ -108,7 +108,7 @@ impl<P> StreamReader<P> {
108108
}
109109

110110
pub struct FutureReader<P> {
111-
uninhabited: Uninhabited,
111+
uninhabited: Infallible,
112112
_phantom: PhantomData<P>,
113113
}
114114

crates/wasmtime/src/runtime/func.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::prelude::*;
2-
use crate::runtime::Uninhabited;
32
use crate::runtime::vm::{
43
self, InterpreterRef, SendSyncPtr, StoreBox, VMArrayCallHostFuncContext,
54
VMCommonStackInformation, VMContext, VMFuncRef, VMFunctionImport, VMOpaqueContext,
@@ -12,6 +11,7 @@ use crate::{
1211
StoreContext, StoreContextMut, Val, ValRaw, ValType,
1312
};
1413
use alloc::sync::Arc;
14+
use core::convert::Infallible;
1515
use core::ffi::c_void;
1616
#[cfg(feature = "async")]
1717
use core::future::Future;
@@ -77,7 +77,7 @@ use wasmtime_environ::VMSharedTypeIndex;
7777
/// ```
7878
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
7979
pub struct NoFunc {
80-
_inner: Uninhabited,
80+
_inner: Infallible,
8181
}
8282

8383
impl NoFunc {

crates/wasmtime/src/runtime/gc/disabled/rooting.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::runtime::vm::{GcStore, VMGcRef};
22
use crate::{
33
AsContext, AsContextMut, GcRef, Result, RootedGcRef,
4-
runtime::Uninhabited,
54
store::{AutoAssertNoGc, StoreOpaque},
65
};
6+
use core::convert::Infallible;
77
use core::fmt::{self, Debug};
88
use core::hash::{Hash, Hasher};
99
use core::marker;
@@ -48,7 +48,7 @@ impl RootSet {
4848
/// This type is disabled because the `gc` cargo feature was not enabled at
4949
/// compile time.
5050
pub struct Rooted<T: GcRef> {
51-
pub(crate) inner: Uninhabited,
51+
pub(crate) inner: Infallible,
5252
_phantom: marker::PhantomData<T>,
5353
}
5454

@@ -122,7 +122,7 @@ pub struct RootScope<C>
122122
where
123123
C: AsContextMut,
124124
{
125-
inner: Uninhabited,
125+
inner: Infallible,
126126
_phantom: marker::PhantomData<C>,
127127
}
128128

@@ -161,7 +161,7 @@ pub struct OwnedRooted<T>
161161
where
162162
T: GcRef,
163163
{
164-
pub(crate) inner: Uninhabited,
164+
pub(crate) inner: Infallible,
165165
_phantom: marker::PhantomData<T>,
166166
}
167167

crates/wasmtime/src/runtime/gc/noextern.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::{
2-
HeapType, Ref, RefType, Result, Uninhabited, Val, ValRaw, ValType, WasmTy,
2+
HeapType, Ref, RefType, Result, Val, ValRaw, ValType, WasmTy,
33
store::{AutoAssertNoGc, StoreOpaque},
44
};
5+
use core::convert::Infallible;
56
use core::mem::MaybeUninit;
67

78
/// A reference to the abstract `noextern` heap value.
@@ -64,7 +65,7 @@ use core::mem::MaybeUninit;
6465
/// ```
6566
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6667
pub struct NoExtern {
67-
_inner: Uninhabited,
68+
_inner: Infallible,
6869
}
6970

7071
impl NoExtern {

crates/wasmtime/src/runtime/gc/none_ref.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::{
2-
HeapType, Ref, RefType, Result, Uninhabited, Val, ValRaw, ValType, WasmTy,
2+
HeapType, Ref, RefType, Result, Val, ValRaw, ValType, WasmTy,
33
store::{AutoAssertNoGc, StoreOpaque},
44
};
5+
use core::convert::Infallible;
56
use core::mem::MaybeUninit;
67

78
/// A reference to the abstract `none` heap value.
@@ -64,7 +65,7 @@ use core::mem::MaybeUninit;
6465
/// ```
6566
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6667
pub struct NoneRef {
67-
_inner: Uninhabited,
68+
_inner: Infallible,
6869
}
6970

7071
impl NoneRef {

crates/wasmtime/src/runtime/store.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ use crate::trampoline::VMHostGlobalContext;
106106
use crate::{Engine, Module, Val, ValRaw, module::ModuleRegistry};
107107
#[cfg(feature = "gc")]
108108
use crate::{ExnRef, Rooted};
109-
use crate::{Global, Instance, Table, Uninhabited};
109+
use crate::{Global, Instance, Table};
110110
use alloc::sync::Arc;
111+
use core::convert::Infallible;
111112
use core::fmt;
112113
use core::marker;
113114
use core::mem::{self, ManuallyDrop, MaybeUninit};
@@ -384,7 +385,7 @@ enum CallHookInner<T: 'static> {
384385
reason = "forcing, regardless of cfg, the type param to be used"
385386
)]
386387
ForceTypeParameterToBeUsed {
387-
uninhabited: Uninhabited,
388+
uninhabited: Infallible,
388389
_marker: marker::PhantomData<T>,
389390
},
390391
}

crates/wasmtime/src/runtime/uninhabited.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

crates/wasmtime/src/runtime/vm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ pub(crate) type f64x2 = core::arch::x86_64::__m128d;
2323
#[cfg(not(all(target_arch = "x86_64", target_feature = "sse")))]
2424
#[expect(non_camel_case_types, reason = "matching wasm conventions")]
2525
#[derive(Copy, Clone)]
26-
pub(crate) struct i8x16(crate::uninhabited::Uninhabited);
26+
pub(crate) struct i8x16(core::convert::Infallible);
2727
#[cfg(not(all(target_arch = "x86_64", target_feature = "sse")))]
2828
#[expect(non_camel_case_types, reason = "matching wasm conventions")]
2929
#[derive(Copy, Clone)]
30-
pub(crate) struct f32x4(crate::uninhabited::Uninhabited);
30+
pub(crate) struct f32x4(core::convert::Infallible);
3131
#[cfg(not(all(target_arch = "x86_64", target_feature = "sse")))]
3232
#[expect(non_camel_case_types, reason = "matching wasm conventions")]
3333
#[derive(Copy, Clone)]
34-
pub(crate) struct f64x2(crate::uninhabited::Uninhabited);
34+
pub(crate) struct f64x2(core::convert::Infallible);
3535

3636
use crate::StoreContextMut;
3737
use crate::prelude::*;

crates/wasmtime/src/runtime/vm/interpreter_disabled.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
//! `Option<Thing>` is also zero-sized so there should be no runtime cost for
55
//! having these structures plumbed around.
66
7-
use crate::runtime::Uninhabited;
87
use crate::runtime::vm::{VMContext, VMOpaqueContext};
98
use crate::{Engine, ValRaw};
9+
use core::convert::Infallible;
1010
use core::marker;
1111
use core::mem;
1212
use core::ptr::NonNull;
1313
use wasmtime_unwinder::Unwind;
1414

1515
pub struct Interpreter {
16-
empty: Uninhabited,
16+
empty: Infallible,
1717
}
1818

1919
const _: () = assert!(mem::size_of::<Interpreter>() == 0);
@@ -34,7 +34,7 @@ impl Interpreter {
3434
}
3535

3636
pub struct InterpreterRef<'a> {
37-
empty: Uninhabited,
37+
empty: Infallible,
3838
_marker: marker::PhantomData<&'a mut Interpreter>,
3939
}
4040

0 commit comments

Comments
 (0)