Also ignore cases with comments in let_and_return (#16461)
Related to the example in https://github.com/rust-lang/rust-clippy/issues/16451 but doesn't fix the issue itself changelog: [`let_and_return`]: No longer lints when there's a comment between the `let` and return
This commit is contained in:
commit
7ffda539e6
4 changed files with 25 additions and 1 deletions
|
|
@ -27,7 +27,7 @@ pub(super) fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>)
|
|||
&& !initexpr.span.in_external_macro(cx.sess().source_map())
|
||||
&& !retexpr.span.in_external_macro(cx.sess().source_map())
|
||||
&& !local.span.from_expansion()
|
||||
&& !span_contains_non_whitespace(cx, stmt.span.between(retexpr.span), true)
|
||||
&& !span_contains_non_whitespace(cx, stmt.span.between(retexpr.span), false)
|
||||
{
|
||||
span_lint_hir_and_then(
|
||||
cx,
|
||||
|
|
|
|||
|
|
@ -271,4 +271,12 @@ fn issue15987() -> i32 {
|
|||
r
|
||||
}
|
||||
|
||||
fn has_comment() -> Vec<usize> {
|
||||
let v = Vec::new();
|
||||
|
||||
// TODO: stuff
|
||||
|
||||
v
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -271,4 +271,12 @@ fn issue15987() -> i32 {
|
|||
r
|
||||
}
|
||||
|
||||
fn has_comment() -> Vec<usize> {
|
||||
let v = Vec::new();
|
||||
|
||||
// TODO: stuff
|
||||
|
||||
v
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -271,4 +271,12 @@ fn issue15987() -> i32 {
|
|||
r
|
||||
}
|
||||
|
||||
fn has_comment() -> Vec<usize> {
|
||||
let v = Vec::new();
|
||||
|
||||
// TODO: stuff
|
||||
|
||||
v
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue