11use std:: collections:: BTreeSet ;
22
33use either:: Either ;
4- use hir:: {
5- FileRange , PathResolution , Semantics , TypeInfo ,
6- db:: { ExpandDatabase , HirDatabase } ,
7- sym,
8- } ;
4+ use hir:: { FileRange , PathResolution , Semantics , TypeInfo , db:: HirDatabase , sym} ;
95use ide_db:: {
106 EditionedFileId , FxHashMap , RootDatabase ,
117 base_db:: Crate ,
128 defs:: Definition ,
139 imports:: insert_use:: remove_use_tree_if_simple,
1410 path_transform:: PathTransform ,
1511 search:: { FileReference , FileReferenceNode , SearchScope } ,
16- syntax_helpers:: { node_ext:: expr_as_name_ref, prettify_macro_expansion } ,
12+ syntax_helpers:: node_ext:: expr_as_name_ref,
1713} ;
1814use itertools:: { Itertools , izip} ;
1915use syntax:: {
@@ -29,6 +25,7 @@ use syntax::{
2925use crate :: {
3026 AssistId ,
3127 assist_context:: { AssistContext , Assists } ,
28+ utils:: pretty_node_inside_macro,
3229} ;
3330
3431// Assist: inline_into_callers
@@ -350,15 +347,10 @@ fn inline(
350347) -> ast:: Expr {
351348 let make = file_editor. make ( ) ;
352349 let file_id = sema. hir_file_for ( fn_body. syntax ( ) ) ;
353- let body_to_clone = if let Some ( macro_file ) = file_id. macro_file ( ) {
350+ if file_id. is_macro ( ) {
354351 cov_mark:: hit!( inline_call_defined_in_macro) ;
355- let span_map = sema. db . expansion_span_map ( macro_file) ;
356- let body_prettified =
357- prettify_macro_expansion ( sema. db , fn_body. syntax ( ) . clone ( ) , span_map, * krate) ;
358- if let Some ( body) = ast:: BlockExpr :: cast ( body_prettified) { body } else { fn_body. clone ( ) }
359- } else {
360- fn_body. clone ( )
361- } ;
352+ }
353+ let body_to_clone = pretty_node_inside_macro ( fn_body. clone ( ) , sema, file_id, * krate) ;
362354
363355 // Capture before `with_ast_node` re-roots and loses the source-relative position.
364356 let mut original_body_indent = IndentLevel :: from_node ( body_to_clone. syntax ( ) ) ;
@@ -493,21 +485,9 @@ fn inline(
493485 let expr: & ast:: Expr = expr;
494486
495487 let mut insert_let_stmt = || {
496- let param_ty = param_ty. clone ( ) . map ( |param_ty| {
497- let file_id = sema. hir_file_for ( param_ty. syntax ( ) ) ;
498- if let Some ( macro_file) = file_id. macro_file ( ) {
499- let span_map = sema. db . expansion_span_map ( macro_file) ;
500- let param_ty_prettified = prettify_macro_expansion (
501- sema. db ,
502- param_ty. syntax ( ) . clone ( ) ,
503- span_map,
504- * krate,
505- ) ;
506- ast:: Type :: cast ( param_ty_prettified) . unwrap_or ( param_ty)
507- } else {
508- param_ty
509- }
510- } ) ;
488+ let param_ty = param_ty
489+ . clone ( )
490+ . map ( |param_ty| pretty_node_inside_macro ( param_ty, sema, file_id, * krate) ) ;
511491
512492 let ty = sema. type_of_expr ( expr) . filter ( TypeInfo :: has_adjustment) . and ( param_ty) ;
513493
0 commit comments