Skip to content

Commit

Permalink
Update test files
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Feb 10, 2021
1 parent ae2dd67 commit bb40db7
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 92 deletions.
41 changes: 13 additions & 28 deletions tests/ui/use_self.fixed
Expand Up @@ -3,7 +3,7 @@

#![warn(clippy::use_self)]
#![allow(dead_code)]
#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms)]
#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms, clippy::from_over_into)]

fn main() {}

Expand All @@ -15,16 +15,13 @@ mod use_self {
Self {}
}
fn test() -> Self {
// FIXME: applicable here
Foo::new()
Self::new()
}
}

impl Default for Foo {
// FIXME: applicable here
fn default() -> Foo {
// FIXME: applicable here
Foo::new()
fn default() -> Self {
Self::new()
}
}
}
Expand Down Expand Up @@ -74,13 +71,12 @@ mod lifetimes {

mod issue2894 {
trait IntoBytes {
#[allow(clippy::wrong_self_convention)]
fn into_bytes(&self) -> Vec<u8>;
fn to_bytes(&self) -> Vec<u8>;
}

// This should not be linted
impl IntoBytes for u8 {
fn into_bytes(&self) -> Vec<u8> {
fn to_bytes(&self) -> Vec<u8> {
vec![*self]
}
}
Expand All @@ -90,11 +86,7 @@ mod existential {
struct Foo;

impl Foo {
// FIXME:
// TyKind::Def (used for `impl Trait` types) does not include type parameters yet.
// See documentation in rustc_hir::hir::TyKind.
// The hir tree walk stops at `impl Iterator` level and does not inspect &Foo.
fn bad(foos: &[Self]) -> impl Iterator<Item = &Foo> {
fn bad(foos: &[Self]) -> impl Iterator<Item = &Self> {
foos.iter()
}

Expand Down Expand Up @@ -215,10 +207,8 @@ mod rustfix {
fn fun_1() {}

fn fun_2() {
// FIXME: applicable here
nested::A::fun_1();
// FIXME: applicable here
nested::A::A;
Self::fun_1();
Self::A;

Self {};
}
Expand All @@ -239,8 +229,7 @@ mod issue3567 {

impl Test for TestStruct {
fn test() -> TestStruct {
// FIXME: applicable here
TestStruct::from_something()
Self::from_something()
}
}
}
Expand All @@ -254,14 +243,12 @@ mod paths_created_by_lowering {
const A: usize = 0;
const B: usize = 1;

// FIXME: applicable here
async fn g() -> S {
async fn g() -> Self {
Self {}
}

fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
// FIXME: applicable here twice
&p[S::A..S::B]
&p[Self::A..Self::B]
}
}

Expand Down Expand Up @@ -381,7 +368,6 @@ mod issue4305 {

impl<T: Foo> From<T> for Box<dyn Foo> {
fn from(t: T) -> Self {
// FIXME: applicable here
Box::new(t)
}
}
Expand Down Expand Up @@ -461,8 +447,7 @@ mod nested_paths {

impl A<submod::C> {
fn test() -> Self {
// FIXME: applicable here
A::new::<submod::B>(submod::B {})
Self::new::<submod::B>(submod::B {})
}
}
}
21 changes: 3 additions & 18 deletions tests/ui/use_self.rs
Expand Up @@ -3,7 +3,7 @@

#![warn(clippy::use_self)]
#![allow(dead_code)]
#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms)]
#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms, clippy::from_over_into)]

fn main() {}

Expand All @@ -15,15 +15,12 @@ mod use_self {
Foo {}
}
fn test() -> Foo {
// FIXME: applicable here
Foo::new()
}
}

impl Default for Foo {
// FIXME: applicable here
fn default() -> Foo {
// FIXME: applicable here
Foo::new()
}
}
Expand Down Expand Up @@ -74,13 +71,12 @@ mod lifetimes {

mod issue2894 {
trait IntoBytes {
#[allow(clippy::wrong_self_convention)]
fn into_bytes(&self) -> Vec<u8>;
fn to_bytes(&self) -> Vec<u8>;
}

// This should not be linted
impl IntoBytes for u8 {
fn into_bytes(&self) -> Vec<u8> {
fn to_bytes(&self) -> Vec<u8> {
vec![*self]
}
}
Expand All @@ -90,10 +86,6 @@ mod existential {
struct Foo;

impl Foo {
// FIXME:
// TyKind::Def (used for `impl Trait` types) does not include type parameters yet.
// See documentation in rustc_hir::hir::TyKind.
// The hir tree walk stops at `impl Iterator` level and does not inspect &Foo.
fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
foos.iter()
}
Expand Down Expand Up @@ -215,9 +207,7 @@ mod rustfix {
fn fun_1() {}

fn fun_2() {
// FIXME: applicable here
nested::A::fun_1();
// FIXME: applicable here
nested::A::A;

nested::A {};
Expand All @@ -239,7 +229,6 @@ mod issue3567 {

impl Test for TestStruct {
fn test() -> TestStruct {
// FIXME: applicable here
TestStruct::from_something()
}
}
Expand All @@ -254,13 +243,11 @@ mod paths_created_by_lowering {
const A: usize = 0;
const B: usize = 1;

// FIXME: applicable here
async fn g() -> S {
S {}
}

fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
// FIXME: applicable here twice
&p[S::A..S::B]
}
}
Expand Down Expand Up @@ -381,7 +368,6 @@ mod issue4305 {

impl<T: Foo> From<T> for Box<dyn Foo> {
fn from(t: T) -> Self {
// FIXME: applicable here
Box::new(t)
}
}
Expand Down Expand Up @@ -461,7 +447,6 @@ mod nested_paths {

impl A<submod::C> {
fn test() -> Self {
// FIXME: applicable here
A::new::<submod::B>(submod::B {})
}
}
Expand Down

0 comments on commit bb40db7

Please sign in to comment.