Skip to content

Commit 47772bc

Browse files
committed
Add tests for duplicate methods on traits/impls.
1 parent c6f3103 commit 47772bc

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

src/librustc/middle/resolve.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,10 +1238,10 @@ impl Resolver {
12381238
let old_sp = methods_seen.find_or_insert(ident, span);
12391239
if *old_sp != span {
12401240
self.session.span_err(span,
1241-
fmt!("duplicate definition of method %s",
1241+
fmt!("duplicate definition of method `%s`",
12421242
*self.session.str_of(ident)));
12431243
self.session.span_note(*old_sp,
1244-
fmt!("first definition of method %s here",
1244+
fmt!("first definition of method `%s` here",
12451245
*self.session.str_of(ident)));
12461246
}
12471247
}
@@ -1375,10 +1375,10 @@ impl Resolver {
13751375
let old_sp = method_names.find_or_insert(ident, ty_m.span);
13761376
if *old_sp != ty_m.span {
13771377
self.session.span_err(ty_m.span,
1378-
fmt!("duplicate definition of method %s",
1378+
fmt!("duplicate definition of method `%s`",
13791379
*self.session.str_of(ident)));
13801380
self.session.span_note(*old_sp,
1381-
fmt!("first definition of method %s here",
1381+
fmt!("first definition of method `%s` here",
13821382
*self.session.str_of(ident)));
13831383
}
13841384
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo;
12+
impl Foo {
13+
fn orange(&self){}
14+
fn orange(&self){} //~ ERROR error: duplicate definition of method `orange`
15+
}
16+
17+
fn main() {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Foo {
12+
fn orange(&self);
13+
fn orange(&self); //~ ERROR error: duplicate definition of method `orange`
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)