mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
parent
eae7b997dd
commit
a952708b6c
6 changed files with 63 additions and 2 deletions
|
@ -223,7 +223,7 @@ struct UseSelfVisitor<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
|
||||
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
|
||||
if path.segments.len() >= 2 {
|
||||
if path.segments.len() >= 2 && !path.segments.iter().any(|p| p.ident.span.is_dummy()) {
|
||||
let last_but_one = &path.segments[path.segments.len() - 2];
|
||||
if last_but_one.ident.name != kw::SelfUpper {
|
||||
let enum_def_id = match path.res {
|
||||
|
|
13
tests/ui/crashes/ice-4727-aux.rs
Normal file
13
tests/ui/crashes/ice-4727-aux.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
//ignore-test
|
||||
|
||||
// This file is used by the ice-4727 test but isn't itself a test.
|
||||
//
|
||||
pub trait Trait {
|
||||
fn fun(par: &str) -> &str;
|
||||
}
|
||||
|
||||
impl Trait for str {
|
||||
fn fun(par: &str) -> &str {
|
||||
&par[0..1]
|
||||
}
|
||||
}
|
8
tests/ui/crashes/ice-4727.rs
Normal file
8
tests/ui/crashes/ice-4727.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// run-pass
|
||||
|
||||
#![warn(clippy::use_self)]
|
||||
|
||||
#[path = "ice-4727-aux.rs"]
|
||||
mod aux;
|
||||
|
||||
fn main() {}
|
|
@ -332,3 +332,17 @@ mod issue3567 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test with paths in ranges
|
||||
mod paths_in_ranges {
|
||||
struct S {}
|
||||
|
||||
impl S {
|
||||
const A: usize = 0;
|
||||
const B: usize = 1;
|
||||
|
||||
fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
|
||||
&p[Self::A..Self::B]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,3 +332,17 @@ mod issue3567 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test with paths in ranges
|
||||
mod paths_in_ranges {
|
||||
struct S {}
|
||||
|
||||
impl S {
|
||||
const A: usize = 0;
|
||||
const B: usize = 1;
|
||||
|
||||
fn f<'a>(&self, p: &'a [u8]) -> &'a [u8] {
|
||||
&p[S::A..S::B]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,5 +222,17 @@ error: unnecessary structure name repetition
|
|||
LL | TestStruct::from_something()
|
||||
| ^^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:345:16
|
||||
|
|
||||
LL | &p[S::A..S::B]
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:345:22
|
||||
|
|
||||
LL | &p[S::A..S::B]
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: aborting due to 38 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue