Merge commit '26ac6aab02'
This commit is contained in:
parent
beeaee9785
commit
aa220c7ee7
157 changed files with 5167 additions and 820 deletions
|
|
@ -1,7 +1,7 @@
|
|||
//@no-rustfix
|
||||
|
||||
#![warn(clippy::unconditional_recursion)]
|
||||
#![allow(clippy::partialeq_ne_impl)]
|
||||
#![allow(clippy::partialeq_ne_impl, clippy::default_constructed_unit_structs)]
|
||||
|
||||
enum Foo {
|
||||
A,
|
||||
|
|
@ -158,6 +158,112 @@ struct S5;
|
|||
impl_partial_eq!(S5);
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
|
||||
struct S6 {
|
||||
field: String,
|
||||
}
|
||||
|
||||
impl PartialEq for S6 {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
let mine = &self.field;
|
||||
let theirs = &other.field;
|
||||
mine == theirs // Should not warn!
|
||||
}
|
||||
}
|
||||
|
||||
struct S7<'a> {
|
||||
field: &'a S7<'a>,
|
||||
}
|
||||
|
||||
impl<'a> PartialEq for S7<'a> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
let mine = &self.field;
|
||||
let theirs = &other.field;
|
||||
mine == theirs
|
||||
}
|
||||
}
|
||||
|
||||
struct S8 {
|
||||
num: i32,
|
||||
field: Option<Box<S8>>,
|
||||
}
|
||||
|
||||
impl PartialEq for S8 {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
if self.num != other.num {
|
||||
return false;
|
||||
}
|
||||
|
||||
let (this, other) = match (self.field.as_deref(), other.field.as_deref()) {
|
||||
(Some(x1), Some(x2)) => (x1, x2),
|
||||
(None, None) => return true,
|
||||
_ => return false,
|
||||
};
|
||||
|
||||
this == other
|
||||
}
|
||||
}
|
||||
|
||||
struct S9;
|
||||
|
||||
impl std::string::ToString for S9 {
|
||||
fn to_string(&self) -> String {
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
struct S10;
|
||||
|
||||
impl std::string::ToString for S10 {
|
||||
fn to_string(&self) -> String {
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
let x = self;
|
||||
x.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
struct S11;
|
||||
|
||||
impl std::string::ToString for S11 {
|
||||
fn to_string(&self) -> String {
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
(self as &Self).to_string()
|
||||
}
|
||||
}
|
||||
|
||||
struct S12;
|
||||
|
||||
impl std::default::Default for S12 {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl S12 {
|
||||
fn new() -> Self {
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
Self::default()
|
||||
}
|
||||
|
||||
fn bar() -> Self {
|
||||
// Should not warn!
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct S13 {
|
||||
f: u32,
|
||||
}
|
||||
|
||||
impl S13 {
|
||||
fn new() -> Self {
|
||||
// Shoud not warn!
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// test code goes here
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue