Tweak wording and logic

This commit is contained in:
Esteban Küber 2023-09-23 01:54:05 +00:00
parent 0e98682576
commit ac5e18756a
6 changed files with 20 additions and 15 deletions

View File

@ -243,15 +243,20 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
)); ));
None None
} }
AssocItemKind::Fn(fn_) => Some(( AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => Some((
sp, sp,
"consider using the associated function", "consider using the method on `Self`",
if fn_.sig.decl.has_self() { "self." } else { "Self::" }, "self.".to_string(),
)),
AssocItemKind::Fn(_) => Some((
sp,
"consider using the associated function on `Self`",
"Self::".to_string(),
)), )),
AssocItemKind::Const(..) => Some(( AssocItemKind::Const(..) => Some((
sp, sp,
"consider using the associated constant", "consider using the associated constant on `Self`",
"Self::", "Self::".to_string(),
)), )),
_ => None _ => None
} }

View File

@ -19,7 +19,7 @@ error[E0425]: cannot find function `first` in this scope
LL | first() LL | first()
| ^^^^^ not found in this scope | ^^^^^ not found in this scope
| |
help: consider using the associated function help: consider using the method on `Self`
| |
LL | self.first() LL | self.first()
| +++++ | +++++

View File

@ -73,7 +73,7 @@ error[E0425]: cannot find function `static_method` in this scope
LL | static_method(); LL | static_method();
| ^^^^^^^^^^^^^ not found in this scope | ^^^^^^^^^^^^^ not found in this scope
| |
help: consider using the associated function help: consider using the associated function on `Self`
| |
LL | Self::static_method(); LL | Self::static_method();
| ++++++ | ++++++
@ -102,7 +102,7 @@ error[E0425]: cannot find function `grow_older` in this scope
LL | grow_older(); LL | grow_older();
| ^^^^^^^^^^ not found in this scope | ^^^^^^^^^^ not found in this scope
| |
help: consider using the associated function help: consider using the associated function on `Self`
| |
LL | Self::grow_older(); LL | Self::grow_older();
| ++++++ | ++++++

View File

@ -10,7 +10,7 @@ error[E0425]: cannot find function `sleep` in this scope
LL | sleep(); LL | sleep();
| ^^^^^ not found in this scope | ^^^^^ not found in this scope
| |
help: consider using the associated function help: consider using the method on `Self`
| |
LL | self.sleep(); LL | self.sleep();
| +++++ | +++++

View File

@ -4,7 +4,7 @@ error[E0425]: cannot find value `A_CONST` in this scope
LL | A_CONST LL | A_CONST
| ^^^^^^^ not found in this scope | ^^^^^^^ not found in this scope
| |
help: consider using the associated constant help: consider using the associated constant on `Self`
| |
LL | Self::A_CONST LL | Self::A_CONST
| ++++++ | ++++++

View File

@ -4,7 +4,7 @@ error[E0425]: cannot find function `foo` in this scope
LL | foo(); LL | foo();
| ^^^ not found in this scope | ^^^ not found in this scope
| |
help: consider using the associated function help: consider using the associated function on `Self`
| |
LL | Self::foo(); LL | Self::foo();
| ++++++ | ++++++
@ -24,7 +24,7 @@ error[E0425]: cannot find function `baz` in this scope
LL | baz(2, 3); LL | baz(2, 3);
| ^^^ not found in this scope | ^^^ not found in this scope
| |
help: consider using the associated function help: consider using the associated function on `Self`
| |
LL | Self::baz(2, 3); LL | Self::baz(2, 3);
| ++++++ | ++++++
@ -41,7 +41,7 @@ error[E0425]: cannot find function `foo` in this scope
LL | foo(); LL | foo();
| ^^^ not found in this scope | ^^^ not found in this scope
| |
help: consider using the associated function help: consider using the associated function on `Self`
| |
LL | Self::foo(); LL | Self::foo();
| ++++++ | ++++++
@ -52,7 +52,7 @@ error[E0425]: cannot find function `bar` in this scope
LL | bar(); LL | bar();
| ^^^ not found in this scope | ^^^ not found in this scope
| |
help: consider using the associated function help: consider using the method on `Self`
| |
LL | self.bar(); LL | self.bar();
| +++++ | +++++
@ -63,7 +63,7 @@ error[E0425]: cannot find function `baz` in this scope
LL | baz(2, 3); LL | baz(2, 3);
| ^^^ not found in this scope | ^^^ not found in this scope
| |
help: consider using the associated function help: consider using the associated function on `Self`
| |
LL | Self::baz(2, 3); LL | Self::baz(2, 3);
| ++++++ | ++++++