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 @@ fn make_base_error(
));
None
}
AssocItemKind::Fn(fn_) => Some((
AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => Some((
sp,
"consider using the associated function",
if fn_.sig.decl.has_self() { "self." } else { "Self::" },
"consider using the method on `Self`",
"self.".to_string(),
)),
AssocItemKind::Fn(_) => Some((
sp,
"consider using the associated function on `Self`",
"Self::".to_string(),
)),
AssocItemKind::Const(..) => Some((
sp,
"consider using the associated constant",
"Self::",
"consider using the associated constant on `Self`",
"Self::".to_string(),
)),
_ => None
}

View File

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

View File

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

View File

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

View File

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

View File

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