Skip to content

Commit f1db9cd

Browse files
author
Nick Hamann
committed
s/method/associated function/ in E0201
1 parent dc1e79b commit f1db9cd

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
752752
let mut seen_methods = FnvHashSet();
753753
for (sig, id, ident, vis, span) in methods {
754754
if !seen_methods.insert(ident.name) {
755-
span_err!(tcx.sess, span, E0201, "duplicate method");
755+
span_err!(tcx.sess, span, E0201, "duplicate associated function");
756756
}
757757

758758
convert_method(ccx,

src/librustc_typeck/diagnostics.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -880,19 +880,29 @@ unsafe impl Bar for Foo { }
880880
"##,
881881

882882
E0201: r##"
883-
It is an error to define a method--a trait method or an inherent method--more
884-
than once.
883+
It is an error to define an associated function more than once.
885884
886-
For example,
885+
For example:
887886
888887
```
889888
struct Foo(u8);
890889
891890
impl Foo {
891+
fn bar(&self) -> bool { self.0 > 5 }
892+
893+
// error: duplicate associated function
892894
fn bar() {}
895+
}
893896
894-
// error: duplicate method
895-
fn bar(&self) -> bool { self.0 > 5 }
897+
trait Baz {
898+
fn baz(&self) -> bool;
899+
}
900+
901+
impl Baz for Foo {
902+
fn baz(&self) -> bool { true }
903+
904+
// error: duplicate associated function
905+
fn baz(&self) -> bool { self.0 > 5 }
896906
}
897907
```
898908
"##,

src/test/compile-fail/impl-duplicate-methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
struct Foo;
1212
impl Foo {
1313
fn orange(&self){}
14-
fn orange(&self){} //~ ERROR error: duplicate method
14+
fn orange(&self){} //~ ERROR duplicate associated function
1515
}
1616

1717
fn main() {}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Foo {
1717
Foo { baz: 0 }.bar();
1818
}
1919

20-
fn bar() { //~ ERROR duplicate method
20+
fn bar() { //~ ERROR duplicate associated function
2121
}
2222
}
2323

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait Bar {
1818

1919
impl Bar for Foo {
2020
fn bar(&self) -> isize {1}
21-
fn bar(&self) -> isize {2} //~ ERROR duplicate method
21+
fn bar(&self) -> isize {2} //~ ERROR duplicate associated function
2222
}
2323

2424
fn main() {

src/test/compile-fail/method-macro-backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl S {
2929

3030
// Cause an error. It shouldn't have any macro backtrace frames.
3131
fn bar(&self) { }
32-
fn bar(&self) { } //~ ERROR duplicate method
32+
fn bar(&self) { } //~ ERROR duplicate associated function
3333
}
3434

3535
fn main() { }

0 commit comments

Comments
 (0)