Skip to content

Commit c8725f7

Browse files
committed
add proc macro check to needless_return
1 parent 8ab744e commit c8725f7

File tree

4 files changed

+71
-55
lines changed

4 files changed

+71
-55
lines changed

clippy_lints/src/returns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ fn check_final_expr<'tcx>(
407407
}
408408
}
409409

410-
if ret_span.from_expansion() {
410+
if ret_span.from_expansion() || is_from_proc_macro(cx, expr) {
411411
return;
412412
}
413413

tests/ui/needless_return.fixed

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@aux-build:proc_macros.rs
12
#![feature(yeet_expr)]
23
#![allow(unused)]
34
#![allow(
@@ -9,6 +10,9 @@
910
)]
1011
#![warn(clippy::needless_return)]
1112

13+
extern crate proc_macros;
14+
use proc_macros::with_span;
15+
1216
use std::cell::RefCell;
1317

1418
macro_rules! the_answer {
@@ -359,4 +363,8 @@ fn issue12907() -> String {
359363
"".split("").next().unwrap().to_string()
360364
}
361365

366+
fn issue13458() {
367+
with_span!(span return);
368+
}
369+
362370
fn main() {}

tests/ui/needless_return.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@aux-build:proc_macros.rs
12
#![feature(yeet_expr)]
23
#![allow(unused)]
34
#![allow(
@@ -9,6 +10,9 @@
910
)]
1011
#![warn(clippy::needless_return)]
1112

13+
extern crate proc_macros;
14+
use proc_macros::with_span;
15+
1216
use std::cell::RefCell;
1317

1418
macro_rules! the_answer {
@@ -369,4 +373,8 @@ fn issue12907() -> String {
369373
return "".split("").next().unwrap().to_string();
370374
}
371375

376+
fn issue13458() {
377+
with_span!(span return);
378+
}
379+
372380
fn main() {}

0 commit comments

Comments
 (0)