Skip to content

Commit 02446e2

Browse files
committed
Rollup merge of rust-lang#31830 - frewsxcv:assoc-func, r=aturon
Prefer 'associated function' over 'static method' in msg. TRPL seems to refer to 'static functions' as 'associated functions'. This terminology should be used consistently.
2 parents 17682e4 + f41dfec commit 02446e2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/librustc_typeck/check/method/suggest.rs

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ impl ManyImplTrait for Myisize {}
7272
fn no_param_bound(u: usize, m: Myisize) -> usize {
7373
u.f8(42) + u.f9(342) + m.fff(42)
7474
//~^ ERROR no method named `f9` found for type `usize` in the current scope
75-
//~^^ NOTE found defined static methods, maybe a `self` is missing?
75+
//~^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
7676
//~^^^ ERROR no method named `fff` found for type `Myisize` in the current scope
77-
//~^^^^ NOTE found defined static methods, maybe a `self` is missing?
77+
//~^^^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
7878
}
7979

8080
fn param_bound<T: ManyImplTrait>(t: T) -> bool {
8181
t.is_str()
8282
//~^ 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?
83+
//~^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
8484
}
8585

8686
fn main() {

0 commit comments

Comments
 (0)