@@ -114,6 +114,7 @@ register_builtin! {
114
114
( cfg, Cfg ) => cfg_expand,
115
115
( core_panic, CorePanic ) => panic_expand,
116
116
( std_panic, StdPanic ) => panic_expand,
117
+ ( unreachable, Unreachable ) => unreachable_expand,
117
118
( log_syntax, LogSyntax ) => log_syntax_expand,
118
119
( trace_macros, TraceMacros ) => trace_macros_expand,
119
120
@@ -354,6 +355,25 @@ fn panic_expand(
354
355
ExpandResult :: ok ( call)
355
356
}
356
357
358
+ fn unreachable_expand (
359
+ db : & dyn AstDatabase ,
360
+ id : MacroCallId ,
361
+ tt : & tt:: Subtree ,
362
+ ) -> ExpandResult < tt:: Subtree > {
363
+ let loc: MacroCallLoc = db. lookup_intern_macro_call ( id) ;
364
+ // Expand to a macro call `$crate::panic::unreachable_{edition}`
365
+ let krate = tt:: Ident { text : "$crate" . into ( ) , id : tt:: TokenId :: unspecified ( ) } ;
366
+ let mut call = if db. crate_graph ( ) [ loc. krate ] . edition == Edition :: Edition2021 {
367
+ quote ! ( #krate:: panic:: unreachable_2021!)
368
+ } else {
369
+ quote ! ( #krate:: panic:: unreachable_2015!)
370
+ } ;
371
+
372
+ // Pass the original arguments
373
+ call. token_trees . push ( tt:: TokenTree :: Subtree ( tt. clone ( ) ) ) ;
374
+ ExpandResult :: ok ( call)
375
+ }
376
+
357
377
fn unquote_str ( lit : & tt:: Literal ) -> Option < String > {
358
378
let lit = ast:: make:: tokens:: literal ( & lit. to_string ( ) ) ;
359
379
let token = ast:: String :: cast ( lit) ?;
0 commit comments