mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Fix lint detection on macro expansion.
This commit is contained in:
parent
fc24fce73f
commit
b5587a894f
@ -116,14 +116,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
_: FnKind<'tcx>,
|
||||
_: &'tcx FnDecl,
|
||||
body: &'tcx Body,
|
||||
_: Span,
|
||||
span: Span,
|
||||
_: NodeId,
|
||||
) {
|
||||
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
|
||||
let mir = cx.tcx.optimized_mir(def_id);
|
||||
|
||||
// checking return type through MIR, HIR is not able to determine inferred closure return types
|
||||
if !mir.return_ty().is_unit() {
|
||||
// make sure it's not a macro
|
||||
if !mir.return_ty().is_unit() && span.macro_backtrace().is_empty() {
|
||||
Self::expr_match(cx, &body.value);
|
||||
}
|
||||
}
|
||||
|
@ -478,6 +478,11 @@ impl LintPass for Pass {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
// we don't want to check expanded macros
|
||||
if !expr.span.macro_backtrace().is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some((pat, arg, body)) = higher::for_loop(expr) {
|
||||
check_for_loop(cx, pat, arg, body, expr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user