mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
Do not trigger let_and_return
lint on macros
This commit is contained in:
parent
e8642c7a29
commit
2213989a01
@ -8,7 +8,7 @@ use rustc_span::BytePos;
|
||||
use syntax::ast;
|
||||
use syntax::visit::FnKind;
|
||||
|
||||
use crate::utils::{match_path_ast, snippet_opt, span_lint_and_then};
|
||||
use crate::utils::{in_macro, match_path_ast, snippet_opt, span_lint_and_then};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for return statements at the end of a block.
|
||||
@ -205,6 +205,7 @@ impl Return {
|
||||
if !in_external_macro(cx.sess(), initexpr.span);
|
||||
if !in_external_macro(cx.sess(), retexpr.span);
|
||||
if !in_external_macro(cx.sess(), local.span);
|
||||
if !in_macro(local.span);
|
||||
then {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
|
@ -45,4 +45,26 @@ fn test_nowarn_5(x: i16) -> u16 {
|
||||
x
|
||||
}
|
||||
|
||||
// False positive example
|
||||
trait Decode {
|
||||
fn decode<D: std::io::Read>(d: D) -> Result<Self, ()>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
macro_rules! tuple_encode {
|
||||
($($x:ident),*) => (
|
||||
impl<$($x: Decode),*> Decode for ($($x),*) {
|
||||
#[inline]
|
||||
#[allow(non_snake_case)]
|
||||
fn decode<D: std::io::Read>(mut d: D) -> Result<Self, ()> {
|
||||
// Shouldn't trigger lint
|
||||
Ok(($({let $x = Decode::decode(&mut d)?; $x }),*))
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
tuple_encode!(T0, T1, T2, T3, T4, T5, T6, T7);
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user