]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/unused_unit.rs
Auto merge of #7165 - camsteffen:question-mark, r=Manishearth
[rust.git] / clippy_lints / src / unused_unit.rs
index ce2d0b3ab2f24962599d2ca957d5564641a2e193..e14945651f5010551820308a272693951cc992ab 100644 (file)
@@ -47,7 +47,9 @@ fn check_block(&mut self, cx: &EarlyContext<'_>, block: &ast::Block) {
         if_chain! {
             if let Some(stmt) = block.stmts.last();
             if let ast::StmtKind::Expr(ref expr) = stmt.kind;
-            if is_unit_expr(expr) && !stmt.span.from_expansion();
+            if is_unit_expr(expr);
+            let ctxt = block.span.ctxt();
+            if stmt.span.ctxt() == ctxt && expr.span.ctxt() == ctxt;
             then {
                 let sp = expr.span;
                 span_lint_and_sugg(