@@ -404,6 +404,29 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
404
404
}
405
405
406
406
ItemMod ( ..) => {
407
+ let child = parent. children . borrow ( ) . get ( & name) . cloned ( ) ;
408
+ if let Some ( child) = child {
409
+ // check if there's struct of the same name already defined
410
+ if child. defined_in_namespace ( TypeNS )
411
+ && child. get_module_if_available ( ) . is_none ( ) {
412
+ self . session . span_warn ( sp, & format ! (
413
+ "duplicate definition of {} `{}`. \
414
+ Defining a module and a struct with \
415
+ the same name will be disallowed \
416
+ soon.",
417
+ namespace_error_to_string( TypeError ) ,
418
+ name) ) ;
419
+ {
420
+ let r = child. span_for_namespace ( TypeNS ) ;
421
+ if let Some ( sp) = r {
422
+ self . session . span_note ( sp,
423
+ & format ! ( "first definition of {} `{}` here" ,
424
+ namespace_error_to_string( TypeError ) ,
425
+ name) ) ;
426
+ }
427
+ }
428
+ }
429
+ }
407
430
let name_bindings = self . add_child ( name, parent, ForbidDuplicateModules , sp) ;
408
431
409
432
let parent_link = self . get_parent_link ( parent, name) ;
@@ -495,6 +518,28 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
495
518
let ( forbid, ctor_id) = if struct_def. is_struct ( ) {
496
519
( ForbidDuplicateTypesAndModules , None )
497
520
} else {
521
+ let child = parent. children . borrow ( ) . get ( & name) . cloned ( ) ;
522
+ if let Some ( child) = child {
523
+ // check if theres a DefMod
524
+ if let Some ( DefMod ( _) ) = child. def_for_namespace ( TypeNS ) {
525
+ self . session . span_warn ( sp, & format ! (
526
+ "duplicate definition of {} `{}`. \
527
+ Defining a module and a struct with \
528
+ the same name will be disallowed \
529
+ soon.",
530
+ namespace_error_to_string( TypeError ) ,
531
+ name) ) ;
532
+ {
533
+ let r = child. span_for_namespace ( TypeNS ) ;
534
+ if let Some ( sp) = r {
535
+ self . session . span_note ( sp,
536
+ & format ! ( "first definition of {} `{}` here" ,
537
+ namespace_error_to_string( TypeError ) ,
538
+ name) ) ;
539
+ }
540
+ }
541
+ }
542
+ }
498
543
( ForbidDuplicateTypesAndValues , Some ( struct_def. id ( ) ) )
499
544
} ;
500
545
0 commit comments