mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
fix: Specifying reason in expect(clippy::needless_return) no longer triggers false positive
chore: Moved new tests into needless_return.rs chore: Ran cargo uibless Initial commit
This commit is contained in:
parent
2b7d80b80a
commit
ae5f857096
3 changed files with 41 additions and 1 deletions
|
@ -421,7 +421,7 @@ fn check_final_expr<'tcx>(
|
|||
if matches!(Level::from_attr(attr), Some(Level::Expect(_)))
|
||||
&& let metas = attr.meta_item_list()
|
||||
&& let Some(lst) = metas
|
||||
&& let [NestedMetaItem::MetaItem(meta_item)] = lst.as_slice()
|
||||
&& let [NestedMetaItem::MetaItem(meta_item), ..] = lst.as_slice()
|
||||
&& let [tool, lint_name] = meta_item.path.segments.as_slice()
|
||||
&& tool.ident.name == sym::clippy
|
||||
&& matches!(
|
||||
|
|
|
@ -360,3 +360,23 @@ fn issue12907() -> String {
|
|||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn a(x: Option<u8>) -> Option<u8> {
|
||||
match x {
|
||||
Some(_) => None,
|
||||
None => {
|
||||
#[expect(clippy::needless_return, reason = "Use early return for errors.")]
|
||||
return None;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn b(x: Option<u8>) -> Option<u8> {
|
||||
match x {
|
||||
Some(_) => None,
|
||||
None => {
|
||||
#[expect(clippy::needless_return)]
|
||||
return None;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,3 +370,23 @@ fn issue12907() -> String {
|
|||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn a(x: Option<u8>) -> Option<u8> {
|
||||
match x {
|
||||
Some(_) => None,
|
||||
None => {
|
||||
#[expect(clippy::needless_return, reason = "Use early return for errors.")]
|
||||
return None;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn b(x: Option<u8>) -> Option<u8> {
|
||||
match x {
|
||||
Some(_) => None,
|
||||
None => {
|
||||
#[expect(clippy::needless_return)]
|
||||
return None;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue