Don't lint needless_return in fns across a macro boundary

This commit is contained in:
Alex Macleod 2023-07-17 13:40:55 +00:00
parent 54fa92287b
commit d24f0d056f
2 changed files with 14 additions and 0 deletions

View file

@ -174,6 +174,10 @@ impl<'tcx> LateLintPass<'tcx> for Return {
sp: Span, sp: Span,
_: LocalDefId, _: LocalDefId,
) { ) {
if sp.from_expansion() {
return;
}
match kind { match kind {
FnKind::Closure => { FnKind::Closure => {
// when returning without value in closure, replace this `return` // when returning without value in closure, replace this `return`

View file

@ -169,4 +169,14 @@ mod issue_5729 {
} }
} }
// https://github.com/rust-lang/rust-clippy/issues/11167
macro_rules! fn_in_macro {
($b:block) => {
fn f() -> usize $b
}
}
fn_in_macro!({
return 1;
});
fn main() {} fn main() {}