wasm_bindgen/rt/
marker.rs1#[cfg_attr(
3 wbg_diagnostic,
4 diagnostic::on_unimplemented(
5 message = "JavaScript constructors are not supported for `{Self}`",
6 label = "this function cannot be the constructor of `{Self}`",
7 note = "`#[wasm_bindgen(constructor)]` is only supported for `struct`s and cannot be used for `enum`s.",
8 note = "Consider removing the `constructor` option and using a regular static method instead."
9 )
10)]
11pub trait SupportsConstructor {}
12pub struct CheckSupportsConstructor<T: SupportsConstructor>(T);
13
14#[cfg_attr(
17 wbg_diagnostic,
18 diagnostic::on_unimplemented(
19 message = "JavaScript instance getters and setters are not supported for `{Self}`",
20 label = "this method cannot be a getter or setter for `{Self}`",
21 note = "`#[wasm_bindgen(getter)]` and `#[wasm_bindgen(setter)]` are only supported for `struct`s and cannot be used for `enum`s.",
22 )
23)]
24pub trait SupportsInstanceProperty {}
25pub struct CheckSupportsInstanceProperty<T: SupportsInstanceProperty>(T);
26
27#[cfg_attr(
30 wbg_diagnostic,
31 diagnostic::on_unimplemented(
32 message = "JavaScript static getters and setters are not supported for `{Self}`",
33 label = "this static function cannot be a static getter or setter on `{Self}`",
34 note = "`#[wasm_bindgen(getter)]` and `#[wasm_bindgen(setter)]` are only supported for `struct`s and cannot be used for `enum`s.",
35 )
36)]
37pub trait SupportsStaticProperty {}
38pub struct CheckSupportsStaticProperty<T: SupportsStaticProperty>(T);
39
40#[cfg(all(feature = "std", target_arch = "wasm32", panic = "unwind"))]
41use core::panic::UnwindSafe;
42
43pub trait MaybeUnwindSafe {}
45
46#[cfg(all(feature = "std", target_arch = "wasm32", panic = "unwind"))]
47impl<T: UnwindSafe + ?Sized> MaybeUnwindSafe for T {}
48
49#[cfg(not(all(feature = "std", target_arch = "wasm32", panic = "unwind")))]
50impl<T: ?Sized> MaybeUnwindSafe for T {}
51
52pub unsafe trait ErasableGeneric {
67 type Repr: 'static;
69}
70
71unsafe impl<T: ErasableGeneric> ErasableGeneric for &mut T {
72 type Repr = &'static mut T::Repr;
73}
74
75unsafe impl<T: ErasableGeneric> ErasableGeneric for &T {
76 type Repr = &'static T::Repr;
77}
78
79#[cfg_attr(
84 wbg_diagnostic,
85 diagnostic::on_unimplemented(
86 message = "Unable to call function, since the concrete generic argument or return value cannot be type-erased into the expected generic repr type for the function",
87 label = "passed concrete generic type does not match the expected generic repr type",
88 note = "Make sure that all erasable generic parameters satisfy the trait bound `ErasableGeneric` with the correct repr. Wasm Bindgen generic parameters and return values for functions are defined to work for specific type-erasable generic repr types only.",
89 )
90)]
91pub trait ErasableGenericOwn<ConcreteTarget>: ErasableGeneric {}
92
93impl<T, ConcreteTarget> ErasableGenericOwn<ConcreteTarget> for T
94where
95 ConcreteTarget: ErasableGeneric,
96 T: ErasableGeneric<Repr = <ConcreteTarget as ErasableGeneric>::Repr>,
97{
98}
99
100#[cfg_attr(
105 wbg_diagnostic,
106 diagnostic::on_unimplemented(
107 message = "Unable to call this function, since the concrete generic argument or return value cannot be type-erased into the expected generic repr type for the function",
108 label = "concrete generic type does not match the expected generic repr type",
109 note = "Make sure that all erasable generic parameters satisfy the trait bound `ErasableGeneric` with the correct repr. Wasm Bindgen generic parameters and return values for functions are defined to work for specific type-erasable generic repr types only.",
110 )
111)]
112pub trait ErasableGenericBorrow<Target: ?Sized> {}
113
114impl<'a, T: ?Sized + 'a, ConcreteTarget: ?Sized + 'static> ErasableGenericBorrow<ConcreteTarget>
115 for T
116where
117 &'static ConcreteTarget: ErasableGeneric,
118 &'a T: ErasableGeneric<Repr = <&'static ConcreteTarget as ErasableGeneric>::Repr>,
119{
120}
121
122#[cfg_attr(
127 wbg_diagnostic,
128 diagnostic::on_unimplemented(
129 message = "Unable to call this function, since the concrete generic argument or return value cannot be type-erased into the expected generic repr type for the function",
130 label = "concrete generic type does not match the expected generic repr type",
131 note = "Make sure that all erasable generic parameters satisfy the trait bound `ErasableGeneric` with the correct repr. Wasm Bindgen generic parameters and return values for functions are defined to work for specific type-erasable generic repr types only.",
132 )
133)]
134pub trait ErasableGenericBorrowMut<Target: ?Sized> {}
135
136impl<'a, T: ?Sized + 'a, ConcreteTarget: ?Sized + 'static> ErasableGenericBorrowMut<ConcreteTarget>
137 for T
138where
139 &'static mut ConcreteTarget: ErasableGeneric,
140 &'a mut T: ErasableGeneric<Repr = <&'static mut ConcreteTarget as ErasableGeneric>::Repr>,
141{
142}