Skip to content

Commit ead2984

Browse files
bors[bot]HMPerson1
andcommitted
Merge #3357
3357: Check existential types in `use_self` r=oli-obk a=HMPerson1 Fixes #3231 Co-authored-by: HMPerson1 <[email protected]>
2 parents 9d69da7 + 3db14f1 commit ead2984

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

clippy_lints/src/use_self.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,6 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
226226
}
227227

228228
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
229-
NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir)
229+
NestedVisitorMap::All(&self.cx.tcx.hir)
230230
}
231231
}

tests/ui/use_self.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,17 @@ mod issue2894 {
205205
}
206206
}
207207
}
208+
209+
mod existential {
210+
struct Foo;
211+
212+
impl Foo {
213+
fn bad(foos: &[Self]) -> impl Iterator<Item=&Foo> {
214+
foos.iter()
215+
}
216+
217+
fn good(foos: &[Self]) -> impl Iterator<Item=&Self> {
218+
foos.iter()
219+
}
220+
}
221+
}

tests/ui/use_self.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,11 @@ error: unnecessary structure name repetition
120120
119 | fn mul(self, rhs: Bad) -> Bad {
121121
| ^^^ help: use the applicable keyword: `Self`
122122

123-
error: aborting due to 20 previous errors
123+
error: unnecessary structure name repetition
124+
--> $DIR/use_self.rs:213:54
125+
|
126+
213 | fn bad(foos: &[Self]) -> impl Iterator<Item=&Foo> {
127+
| ^^^ help: use the applicable keyword: `Self`
128+
129+
error: aborting due to 21 previous errors
124130

0 commit comments

Comments
 (0)