Skip to content

Commit ac5e187

Browse files
committed
Tweak wording and logic
1 parent 0e98682 commit ac5e187

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,20 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
243243
));
244244
None
245245
}
246-
AssocItemKind::Fn(fn_) => Some((
246+
AssocItemKind::Fn(fn_) if fn_.sig.decl.has_self() => Some((
247247
sp,
248-
"consider using the associated function",
249-
if fn_.sig.decl.has_self() { "self." } else { "Self::" },
248+
"consider using the method on `Self`",
249+
"self.".to_string(),
250+
)),
251+
AssocItemKind::Fn(_) => Some((
252+
sp,
253+
"consider using the associated function on `Self`",
254+
"Self::".to_string(),
250255
)),
251256
AssocItemKind::Const(..) => Some((
252257
sp,
253-
"consider using the associated constant",
254-
"Self::",
258+
"consider using the associated constant on `Self`",
259+
"Self::".to_string(),
255260
)),
256261
_ => None
257262
}

tests/ui/resolve/issue-103474.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ error[E0425]: cannot find function `first` in this scope
1919
LL | first()
2020
| ^^^^^ not found in this scope
2121
|
22-
help: consider using the associated function
22+
help: consider using the method on `Self`
2323
|
2424
LL | self.first()
2525
| +++++

tests/ui/resolve/issue-2356.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ error[E0425]: cannot find function `static_method` in this scope
7373
LL | static_method();
7474
| ^^^^^^^^^^^^^ not found in this scope
7575
|
76-
help: consider using the associated function
76+
help: consider using the associated function on `Self`
7777
|
7878
LL | Self::static_method();
7979
| ++++++
@@ -102,7 +102,7 @@ error[E0425]: cannot find function `grow_older` in this scope
102102
LL | grow_older();
103103
| ^^^^^^^^^^ not found in this scope
104104
|
105-
help: consider using the associated function
105+
help: consider using the associated function on `Self`
106106
|
107107
LL | Self::grow_older();
108108
| ++++++

tests/ui/self/class-missing-self.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0425]: cannot find function `sleep` in this scope
1010
LL | sleep();
1111
| ^^^^^ not found in this scope
1212
|
13-
help: consider using the associated function
13+
help: consider using the method on `Self`
1414
|
1515
LL | self.sleep();
1616
| +++++

tests/ui/suggestions/assoc-const-without-self.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0425]: cannot find value `A_CONST` in this scope
44
LL | A_CONST
55
| ^^^^^^^ not found in this scope
66
|
7-
help: consider using the associated constant
7+
help: consider using the associated constant on `Self`
88
|
99
LL | Self::A_CONST
1010
| ++++++

tests/ui/suggestions/assoc_fn_without_self.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0425]: cannot find function `foo` in this scope
44
LL | foo();
55
| ^^^ not found in this scope
66
|
7-
help: consider using the associated function
7+
help: consider using the associated function on `Self`
88
|
99
LL | Self::foo();
1010
| ++++++
@@ -24,7 +24,7 @@ error[E0425]: cannot find function `baz` in this scope
2424
LL | baz(2, 3);
2525
| ^^^ not found in this scope
2626
|
27-
help: consider using the associated function
27+
help: consider using the associated function on `Self`
2828
|
2929
LL | Self::baz(2, 3);
3030
| ++++++
@@ -41,7 +41,7 @@ error[E0425]: cannot find function `foo` in this scope
4141
LL | foo();
4242
| ^^^ not found in this scope
4343
|
44-
help: consider using the associated function
44+
help: consider using the associated function on `Self`
4545
|
4646
LL | Self::foo();
4747
| ++++++
@@ -52,7 +52,7 @@ error[E0425]: cannot find function `bar` in this scope
5252
LL | bar();
5353
| ^^^ not found in this scope
5454
|
55-
help: consider using the associated function
55+
help: consider using the method on `Self`
5656
|
5757
LL | self.bar();
5858
| +++++
@@ -63,7 +63,7 @@ error[E0425]: cannot find function `baz` in this scope
6363
LL | baz(2, 3);
6464
| ^^^ not found in this scope
6565
|
66-
help: consider using the associated function
66+
help: consider using the associated function on `Self`
6767
|
6868
LL | Self::baz(2, 3);
6969
| ++++++

0 commit comments

Comments
 (0)