@@ -75,6 +75,18 @@ pub fn trap_unreachable(
75
75
fx. bcx . ins ( ) . trap ( TrapCode :: UnreachableCodeReached ) ;
76
76
}
77
77
78
+ /// Like `trap_unreachable` but returns a fake value of the specified type.
79
+ ///
80
+ /// Trap code: user65535
81
+ pub fn trap_unreachable_ret_value < ' tcx > (
82
+ fx : & mut FunctionCx < ' _ , ' tcx , impl cranelift_module:: Backend > ,
83
+ dest_layout : TyLayout < ' tcx > ,
84
+ msg : impl AsRef < str > ,
85
+ ) -> CValue < ' tcx > {
86
+ trap_unreachable ( fx, msg) ;
87
+ CValue :: by_ref ( Pointer :: const_addr ( fx, 0 ) , dest_layout)
88
+ }
89
+
78
90
/// Use this when something is unimplemented, but `libcore` or `libstd` requires it to codegen.
79
91
/// Unlike `trap_unreachable` this will not fill the current block, so you **must** add instructions
80
92
/// to it afterwards.
@@ -89,10 +101,10 @@ pub fn trap_unimplemented(
89
101
fx. bcx . ins ( ) . trapnz ( true_, TrapCode :: User ( !0 ) ) ;
90
102
}
91
103
92
- /// Like `trap_unreachable ` but returns a fake value of the specified type.
104
+ /// Like `trap_unimplemented ` but returns a fake value of the specified type.
93
105
///
94
106
/// Trap code: user65535
95
- pub fn trap_unreachable_ret_value < ' tcx > (
107
+ pub fn trap_unimplemented_ret_value < ' tcx > (
96
108
fx : & mut FunctionCx < ' _ , ' tcx , impl cranelift_module:: Backend > ,
97
109
dest_layout : TyLayout < ' tcx > ,
98
110
msg : impl AsRef < str > ,
0 commit comments