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 {
12261226 // the same module that declared the type.
12271227
12281228 // Bail out early if there are no static methods.
1229+ let mut methods_seen = HashMap :: new ( ) ;
12291230 let mut has_static_methods = false ;
12301231 for methods. each |method| {
12311232 match method. explicit_self . node {
12321233 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+ }
12341248 }
12351249 }
12361250
You can’t perform that action at this time.
0 commit comments