@@ -1333,7 +1333,7 @@ impl Resolver {
1333
1333
}
1334
1334
1335
1335
// Add the names of all the methods to the trait info.
1336
- let mut method_names = HashSet :: new ( ) ;
1336
+ let mut method_names = HashMap :: new ( ) ;
1337
1337
for methods. each |method| {
1338
1338
let ty_m = trait_method_to_ty_method ( method) ;
1339
1339
@@ -1357,13 +1357,22 @@ impl Resolver {
1357
1357
ty_m. span ) ;
1358
1358
}
1359
1359
_ => {
1360
- method_names. insert ( ident) ;
1360
+ // Make sure you can't define duplicate methods
1361
+ let old_sp = method_names. find_or_insert ( ident, ty_m. span ) ;
1362
+ if * old_sp != ty_m. span {
1363
+ self . session . span_err ( ty_m. span ,
1364
+ fmt ! ( "duplicate definition of method %s" ,
1365
+ * self . session. str_of( ident) ) ) ;
1366
+ self . session . span_note ( * old_sp,
1367
+ fmt ! ( "first definition of method %s here" ,
1368
+ * self . session. str_of( ident) ) ) ;
1369
+ }
1361
1370
}
1362
1371
}
1363
1372
}
1364
1373
1365
1374
let def_id = local_def ( item. id ) ;
1366
- for method_names. each |name| {
1375
+ for method_names. each |name, _ | {
1367
1376
if !self . method_map . contains_key ( name) {
1368
1377
self . method_map . insert ( * name, HashSet :: new ( ) ) ;
1369
1378
}
0 commit comments