Don't trigger needless_return lint in macros

This commit is contained in:
flip1995 2021-01-15 10:41:29 +01:00
parent 0c5ba9a883
commit f18cf82ca8
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
3 changed files with 33 additions and 0 deletions

View file

@ -217,6 +217,9 @@ fn check_final_expr<'tcx>(
}
fn emit_return_lint(cx: &LateContext<'_>, ret_span: Span, inner_span: Option<Span>, replacement: RetReplacement) {
if ret_span.from_expansion() {
return;
}
match inner_span {
Some(inner_span) => {
if in_external_macro(cx.tcx.sess, inner_span) || inner_span.from_expansion() {