File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1226,11 +1226,25 @@ impl Resolver {
1226
1226
// the same module that declared the type.
1227
1227
1228
1228
// Bail out early if there are no static methods.
1229
+ let mut methods_seen = HashMap :: new ( ) ;
1229
1230
let mut has_static_methods = false ;
1230
1231
for methods. each |method| {
1231
1232
match method. explicit_self . node {
1232
1233
sty_static => has_static_methods = true ,
1233
- _ => { }
1234
+ _ => {
1235
+ // Make sure you can't define duplicate methods
1236
+ let ident = method. ident ;
1237
+ let span = method. span ;
1238
+ let old_sp = methods_seen. find_or_insert ( ident, span) ;
1239
+ if * old_sp != span {
1240
+ self . session . span_err ( span,
1241
+ fmt ! ( "duplicate definition of method %s" ,
1242
+ * self . session. str_of( ident) ) ) ;
1243
+ self . session . span_note ( * old_sp,
1244
+ fmt ! ( "first definition of method %s here" ,
1245
+ * self . session. str_of( ident) ) ) ;
1246
+ }
1247
+ }
1234
1248
}
1235
1249
}
1236
1250
You can’t perform that action at this time.
0 commit comments