s/method/associated function/ in E0201
This commit is contained in:
parent
dc1e79b3c2
commit
f1db9cd7c3
6 changed files with 21 additions and 11 deletions
|
@ -752,7 +752,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
let mut seen_methods = FnvHashSet();
|
let mut seen_methods = FnvHashSet();
|
||||||
for (sig, id, ident, vis, span) in methods {
|
for (sig, id, ident, vis, span) in methods {
|
||||||
if !seen_methods.insert(ident.name) {
|
if !seen_methods.insert(ident.name) {
|
||||||
span_err!(tcx.sess, span, E0201, "duplicate method");
|
span_err!(tcx.sess, span, E0201, "duplicate associated function");
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_method(ccx,
|
convert_method(ccx,
|
||||||
|
|
|
@ -880,19 +880,29 @@ unsafe impl Bar for Foo { }
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
E0201: r##"
|
E0201: r##"
|
||||||
It is an error to define a method--a trait method or an inherent method--more
|
It is an error to define an associated function more than once.
|
||||||
than once.
|
|
||||||
|
|
||||||
For example,
|
For example:
|
||||||
|
|
||||||
```
|
```
|
||||||
struct Foo(u8);
|
struct Foo(u8);
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn bar() {}
|
|
||||||
|
|
||||||
// error: duplicate method
|
|
||||||
fn bar(&self) -> bool { self.0 > 5 }
|
fn bar(&self) -> bool { self.0 > 5 }
|
||||||
|
|
||||||
|
// error: duplicate associated function
|
||||||
|
fn bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Baz {
|
||||||
|
fn baz(&self) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Baz for Foo {
|
||||||
|
fn baz(&self) -> bool { true }
|
||||||
|
|
||||||
|
// error: duplicate associated function
|
||||||
|
fn baz(&self) -> bool { self.0 > 5 }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
"##,
|
"##,
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
struct Foo;
|
struct Foo;
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn orange(&self){}
|
fn orange(&self){}
|
||||||
fn orange(&self){} //~ ERROR error: duplicate method
|
fn orange(&self){} //~ ERROR duplicate associated function
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -17,7 +17,7 @@ impl Foo {
|
||||||
Foo { baz: 0 }.bar();
|
Foo { baz: 0 }.bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bar() { //~ ERROR duplicate method
|
fn bar() { //~ ERROR duplicate associated function
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ trait Bar {
|
||||||
|
|
||||||
impl Bar for Foo {
|
impl Bar for Foo {
|
||||||
fn bar(&self) -> isize {1}
|
fn bar(&self) -> isize {1}
|
||||||
fn bar(&self) -> isize {2} //~ ERROR duplicate method
|
fn bar(&self) -> isize {2} //~ ERROR duplicate associated function
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl S {
|
||||||
|
|
||||||
// Cause an error. It shouldn't have any macro backtrace frames.
|
// Cause an error. It shouldn't have any macro backtrace frames.
|
||||||
fn bar(&self) { }
|
fn bar(&self) { }
|
||||||
fn bar(&self) { } //~ ERROR duplicate method
|
fn bar(&self) { } //~ ERROR duplicate associated function
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue