Skip to content

Commit d9dba76

Browse files
committed
Prefer 'associated function' over 'static method' in msg.
TRPL seems to refer to 'static functions' as 'associated functions'. This terminology should be used consistently.
1 parent 0ef8d42 commit d9dba76

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/librustc_typeck/check/method/suggest.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
141141
if !static_sources.is_empty() {
142142
err.fileline_note(
143143
span,
144-
"found defined static methods, maybe a `self` is missing?");
144+
"found the following associated functions; to be used as \
145+
methods, functions must have a `self` parameter");
145146

146147
report_candidates(fcx, &mut err, span, item_name, static_sources);
147148
}

src/test/compile-fail/issue-7575.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// Test the mechanism for warning about possible missing `self` declarations.
12+
// ignore-tidy-linelength
1213

1314
trait CtxtFn {
1415
fn f8(self, usize) -> usize;
@@ -72,15 +73,15 @@ impl ManyImplTrait for Myisize {}
7273
fn no_param_bound(u: usize, m: Myisize) -> usize {
7374
u.f8(42) + u.f9(342) + m.fff(42)
7475
//~^ ERROR no method named `f9` found for type `usize` in the current scope
75-
//~^^ NOTE found defined static methods, maybe a `self` is missing?
76+
//~^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
7677
//~^^^ ERROR no method named `fff` found for type `Myisize` in the current scope
77-
//~^^^^ NOTE found defined static methods, maybe a `self` is missing?
78+
//~^^^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
7879
}
7980

8081
fn param_bound<T: ManyImplTrait>(t: T) -> bool {
8182
t.is_str()
8283
//~^ ERROR no method named `is_str` found for type `T` in the current scope
83-
//~^^ NOTE found defined static methods, maybe a `self` is missing?
84+
//~^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
8485
}
8586

8687
fn main() {

0 commit comments

Comments
 (0)