Skip to content

Commit b6c8439

Browse files
committed
Update test files
1 parent e79a1b7 commit b6c8439

File tree

4 files changed

+188
-44
lines changed

4 files changed

+188
-44
lines changed

tests/ui/use_self.fixed

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ mod use_self {
1616
}
1717
fn test() -> Self {
1818
// FIXME: applicable here
19-
Foo::new()
19+
Self::new()
2020
}
2121
}
2222

2323
impl Default for Foo {
2424
// FIXME: applicable here
25-
fn default() -> Foo {
25+
fn default() -> Self {
2626
// FIXME: applicable here
27-
Foo::new()
27+
Self::new()
2828
}
2929
}
3030
}
@@ -93,7 +93,7 @@ mod existential {
9393
// TyKind::Def (used for `impl Trait` types) does not include type parameters yet.
9494
// See documentation in rustc_hir::hir::TyKind.
9595
// The hir tree walk stops at `impl Iterator` level and does not inspect &Foo.
96-
fn bad(foos: &[Self]) -> impl Iterator<Item = &Foo> {
96+
fn bad(foos: &[Self]) -> impl Iterator<Item = &Self> {
9797
foos.iter()
9898
}
9999

@@ -215,9 +215,9 @@ mod rustfix {
215215

216216
fn fun_2() {
217217
// FIXME: applicable here
218-
nested::A::fun_1();
218+
Self::fun_1();
219219
// FIXME: applicable here
220-
nested::A::A;
220+
Self::A;
221221

222222
Self {};
223223
}
@@ -239,7 +239,7 @@ mod issue3567 {
239239
impl Test for TestStruct {
240240
fn test() -> TestStruct {
241241
// FIXME: applicable here
242-
TestStruct::from_something()
242+
Self::from_something()
243243
}
244244
}
245245
}
@@ -254,13 +254,13 @@ mod paths_created_by_lowering {
254254
const B: usize = 1;
255255

256256
// FIXME: applicable here
257-
async fn g() -> S {
257+
async fn g() -> Self {
258258
Self {}
259259
}
260260

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

@@ -461,7 +461,7 @@ mod nested_paths {
461461
impl A<submod::C> {
462462
fn test() -> Self {
463463
// FIXME: applicable here
464-
A::new::<submod::B>(submod::B {})
464+
Self::new::<submod::B>(submod::B {})
465465
}
466466
}
467467
}

tests/ui/use_self.stderr

Lines changed: 91 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,105 @@
11
error: unnecessary structure name repetition
2-
--> $DIR/use_self.rs:15:13
2+
--> $DIR/use_self.rs:14:21
33
|
4-
LL | Foo {}
5-
| ^^^ help: use the applicable keyword: `Self`
4+
LL | fn new() -> Foo {
5+
| ^^^ help: use the applicable keyword: `Self`
66
|
77
= note: `-D clippy::use-self` implied by `-D warnings`
88

99
error: unnecessary structure name repetition
10-
--> $DIR/use_self.rs:14:21
10+
--> $DIR/use_self.rs:15:13
1111
|
12-
LL | fn new() -> Foo {
13-
| ^^^ help: use the applicable keyword: `Self`
12+
LL | Foo {}
13+
| ^^^ help: use the applicable keyword: `Self`
1414

1515
error: unnecessary structure name repetition
1616
--> $DIR/use_self.rs:17:22
1717
|
1818
LL | fn test() -> Foo {
1919
| ^^^ help: use the applicable keyword: `Self`
2020

21+
error: unnecessary structure name repetition
22+
--> $DIR/use_self.rs:19:13
23+
|
24+
LL | Foo::new()
25+
| ^^^ help: use the applicable keyword: `Self`
26+
27+
error: unnecessary structure name repetition
28+
--> $DIR/use_self.rs:25:25
29+
|
30+
LL | fn default() -> Foo {
31+
| ^^^ help: use the applicable keyword: `Self`
32+
33+
error: unnecessary structure name repetition
34+
--> $DIR/use_self.rs:27:13
35+
|
36+
LL | Foo::new()
37+
| ^^^ help: use the applicable keyword: `Self`
38+
2139
error: unnecessary structure name repetition
2240
--> $DIR/use_self.rs:96:24
2341
|
2442
LL | fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
2543
| ^^^ help: use the applicable keyword: `Self`
2644

45+
error: unnecessary structure name repetition
46+
--> $DIR/use_self.rs:96:55
47+
|
48+
LL | fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
49+
| ^^^ help: use the applicable keyword: `Self`
50+
2751
error: unnecessary structure name repetition
2852
--> $DIR/use_self.rs:111:13
2953
|
3054
LL | TS(0)
3155
| ^^ help: use the applicable keyword: `Self`
3256

3357
error: unnecessary structure name repetition
34-
--> $DIR/use_self.rs:120:17
58+
--> $DIR/use_self.rs:119:25
3559
|
36-
LL | Foo {}
37-
| ^^^ help: use the applicable keyword: `Self`
60+
LL | fn new() -> Foo {
61+
| ^^^ help: use the applicable keyword: `Self`
3862
...
3963
LL | use_self_expand!(); // Should lint in local macros
4064
| ------------------- in this macro invocation
4165
|
4266
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
4367

4468
error: unnecessary structure name repetition
45-
--> $DIR/use_self.rs:119:25
69+
--> $DIR/use_self.rs:120:17
4670
|
47-
LL | fn new() -> Foo {
48-
| ^^^ help: use the applicable keyword: `Self`
71+
LL | Foo {}
72+
| ^^^ help: use the applicable keyword: `Self`
4973
...
5074
LL | use_self_expand!(); // Should lint in local macros
5175
| ------------------- in this macro invocation
5276
|
5377
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
5478

55-
error: unnecessary structure name repetition
56-
--> $DIR/use_self.rs:144:21
57-
|
58-
LL | Bar { foo: Foo {} }
59-
| ^^^ help: use the applicable keyword: `Self`
60-
6179
error: unnecessary structure name repetition
6280
--> $DIR/use_self.rs:143:29
6381
|
6482
LL | fn bar() -> Bar {
6583
| ^^^ help: use the applicable keyword: `Self`
6684

6785
error: unnecessary structure name repetition
68-
--> $DIR/use_self.rs:156:13
86+
--> $DIR/use_self.rs:144:21
6987
|
70-
LL | Foo {}
71-
| ^^^ help: use the applicable keyword: `Self`
88+
LL | Bar { foo: Foo {} }
89+
| ^^^ help: use the applicable keyword: `Self`
7290

7391
error: unnecessary structure name repetition
7492
--> $DIR/use_self.rs:155:21
7593
|
7694
LL | fn baz() -> Foo {
7795
| ^^^ help: use the applicable keyword: `Self`
7896

97+
error: unnecessary structure name repetition
98+
--> $DIR/use_self.rs:156:13
99+
|
100+
LL | Foo {}
101+
| ^^^ help: use the applicable keyword: `Self`
102+
79103
error: unnecessary structure name repetition
80104
--> $DIR/use_self.rs:173:21
81105
|
@@ -94,30 +118,66 @@ error: unnecessary structure name repetition
94118
LL | let _ = Enum::A;
95119
| ^^^^ help: use the applicable keyword: `Self`
96120

121+
error: unnecessary structure name repetition
122+
--> $DIR/use_self.rs:218:13
123+
|
124+
LL | nested::A::fun_1();
125+
| ^^^^^^^^^ help: use the applicable keyword: `Self`
126+
127+
error: unnecessary structure name repetition
128+
--> $DIR/use_self.rs:220:13
129+
|
130+
LL | nested::A::A;
131+
| ^^^^^^^^^ help: use the applicable keyword: `Self`
132+
97133
error: unnecessary structure name repetition
98134
--> $DIR/use_self.rs:222:13
99135
|
100136
LL | nested::A {};
101137
| ^^^^^^^^^ help: use the applicable keyword: `Self`
102138

139+
error: unnecessary structure name repetition
140+
--> $DIR/use_self.rs:242:13
141+
|
142+
LL | TestStruct::from_something()
143+
| ^^^^^^^^^^ help: use the applicable keyword: `Self`
144+
145+
error: unnecessary structure name repetition
146+
--> $DIR/use_self.rs:257:25
147+
|
148+
LL | async fn g() -> S {
149+
| ^ help: use the applicable keyword: `Self`
150+
103151
error: unnecessary structure name repetition
104152
--> $DIR/use_self.rs:258:13
105153
|
106154
LL | S {}
107155
| ^ help: use the applicable keyword: `Self`
108156

109157
error: unnecessary structure name repetition
110-
--> $DIR/use_self.rs:287:13
158+
--> $DIR/use_self.rs:263:16
111159
|
112-
LL | Foo { value }
113-
| ^^^ help: use the applicable keyword: `Self`
160+
LL | &p[S::A..S::B]
161+
| ^ help: use the applicable keyword: `Self`
162+
163+
error: unnecessary structure name repetition
164+
--> $DIR/use_self.rs:263:22
165+
|
166+
LL | &p[S::A..S::B]
167+
| ^ help: use the applicable keyword: `Self`
114168

115169
error: unnecessary structure name repetition
116170
--> $DIR/use_self.rs:286:29
117171
|
118172
LL | fn foo(value: T) -> Foo<T> {
119173
| ^^^^^^ help: use the applicable keyword: `Self`
120174

175+
error: unnecessary structure name repetition
176+
--> $DIR/use_self.rs:287:13
177+
|
178+
LL | Foo { value }
179+
| ^^^ help: use the applicable keyword: `Self`
180+
121181
error: unnecessary structure name repetition
122182
--> $DIR/use_self.rs:324:21
123183
|
@@ -130,5 +190,11 @@ error: unnecessary structure name repetition
130190
LL | type To = T::To;
131191
| ^^^^^ help: use the applicable keyword: `Self`
132192

133-
error: aborting due to 20 previous errors
193+
error: unnecessary structure name repetition
194+
--> $DIR/use_self.rs:464:13
195+
|
196+
LL | A::new::<submod::B>(submod::B {})
197+
| ^ help: use the applicable keyword: `Self`
198+
199+
error: aborting due to 31 previous errors
134200

tests/ui/use_self_trait.fixed

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ trait SelfTrait {
1818
struct Bad;
1919

2020
impl SelfTrait for Bad {
21-
fn refs(p1: &Bad) -> &Bad {
21+
fn refs(p1: &Self) -> &Self {
2222
p1
2323
}
2424

25-
fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad {
25+
fn ref_refs<'a>(p1: &'a &'a Self) -> &'a &'a Self {
2626
p1
2727
}
2828

29-
fn mut_refs(p1: &mut Bad) -> &mut Bad {
29+
fn mut_refs(p1: &mut Self) -> &mut Self {
3030
p1
3131
}
3232

33-
fn nested(_p1: Box<Bad>, _p2: (&u8, &Bad)) {}
33+
fn nested(_p1: Box<Self>, _p2: (&u8, &Self)) {}
3434

35-
fn vals(_: Bad) -> Bad {
36-
Bad::default()
35+
fn vals(_: Self) -> Self {
36+
Self::default()
3737
}
3838
}
3939

4040
impl Mul for Bad {
4141
type Output = Self;
4242

43-
fn mul(self, rhs: Bad) -> Bad {
43+
fn mul(self, rhs: Self) -> Self {
4444
rhs
4545
}
4646
}

0 commit comments

Comments
 (0)