11use clippy_utils:: diagnostics:: { multispan_sugg_with_applicability, span_lint_and_then} ;
22use rustc_errors:: Applicability ;
33use rustc_hir:: { Block , Expr , ExprKind , Stmt , StmtKind } ;
4- use rustc_lint:: { LateContext , LateLintPass } ;
4+ use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
55use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
66use rustc_span:: Span ;
77
@@ -96,7 +96,8 @@ impl LateLintPass<'_> for SemicolonBlock {
9696}
9797
9898fn semicolon_inside_block ( cx : & LateContext < ' _ > , block : & Block < ' _ > , tail : & Expr < ' _ > , semi_span : Span ) {
99- let insert_span = tail. span . with_lo ( tail. span . hi ( ) ) ;
99+ let tail_span_end = tail. span . source_callsite ( ) . hi ( ) ;
100+ let insert_span = Span :: with_root_ctxt ( tail_span_end, tail_span_end) ;
100101 let remove_span = semi_span. with_lo ( block. span . hi ( ) ) ;
101102
102103 span_lint_and_then (
@@ -117,6 +118,8 @@ fn semicolon_inside_block(cx: &LateContext<'_>, block: &Block<'_>, tail: &Expr<'
117118
118119fn semicolon_outside_block ( cx : & LateContext < ' _ > , block : & Block < ' _ > , tail_stmt_expr : & Expr < ' _ > , semi_span : Span ) {
119120 let insert_span = block. span . with_lo ( block. span . hi ( ) ) ;
121+ // account for macro calls
122+ let semi_span = cx. sess ( ) . source_map ( ) . stmt_span ( semi_span, block. span ) ;
120123 let remove_span = semi_span. with_lo ( tail_stmt_expr. span . source_callsite ( ) . hi ( ) ) ;
121124
122125 span_lint_and_then (
0 commit comments