#[non_exhaustive]pub enum TryHook {
Template,
Intrinsic {
name: Symbol,
convert: Option<Symbol>,
},
}Expand description
How ?-style error propagation reaches the checker.
HIR lowers e? as a template (match e { Ok(v) => v, Err(x) => return Err(x) }, spec section 8.7), which needs no hook: it is ordinary code. A
language whose lowering keeps ? as a named intrinsic instead gets it
typed here: the operand is a carrier (a nullable T?, or a sum of two
variants that is either option-like, one unit variant and one with a
single field, or result-like, two single-field variants with the success
variant first); the expression has the success value’s type, and the
enclosing function must return a carrier of the same kind whose failure
type the operand’s failure converts to.
§Examples
use typeck_lang::TryHook;
assert_eq!(TryHook::default(), TryHook::Template);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Template
? arrives lowered as a match; nothing special.
Intrinsic
Intrinsic::Named(name) with one operand is ?.
Trait Implementations§
impl Copy for TryHook
impl Eq for TryHook
impl StructuralPartialEq for TryHook
Auto Trait Implementations§
impl Freeze for TryHook
impl RefUnwindSafe for TryHook
impl Send for TryHook
impl Sync for TryHook
impl Unpin for TryHook
impl UnsafeUnpin for TryHook
impl UnwindSafe for TryHook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more