@@ -413,7 +413,7 @@ impl ModuleOrUniformRoot<'_> {
413413 fn same_def ( lhs : Self , rhs : Self ) -> bool {
414414 match ( lhs, rhs) {
415415 ( ModuleOrUniformRoot :: Module ( lhs) , ModuleOrUniformRoot :: Module ( rhs) ) => {
416- lhs . def_id ( ) == rhs. def_id ( )
416+ ptr :: eq ( lhs , rhs)
417417 }
418418 (
419419 ModuleOrUniformRoot :: CrateRootAndExternPrelude ,
@@ -602,7 +602,11 @@ impl<'a> ModuleData<'a> {
602602 }
603603 }
604604
605- fn def_id ( & self ) -> Option < DefId > {
605+ fn def_id ( & self ) -> DefId {
606+ self . opt_def_id ( ) . expect ( "`ModuleData::def_id` is called on a block module" )
607+ }
608+
609+ fn opt_def_id ( & self ) -> Option < DefId > {
606610 match self . kind {
607611 ModuleKind :: Def ( _, def_id, _) => Some ( def_id) ,
608612 _ => None ,
@@ -1075,7 +1079,7 @@ impl<'a> ResolverArenas<'a> {
10751079 ) -> Module < ' a > {
10761080 let module =
10771081 self . modules . alloc ( ModuleData :: new ( parent, kind, expn_id, span, no_implicit_prelude) ) ;
1078- let def_id = module. def_id ( ) ;
1082+ let def_id = module. opt_def_id ( ) ;
10791083 if def_id. map_or ( true , |def_id| def_id. is_local ( ) ) {
10801084 self . local_modules . borrow_mut ( ) . push ( module) ;
10811085 }
@@ -1588,7 +1592,7 @@ impl<'a> Resolver<'a> {
15881592
15891593 if let Some ( module) = current_trait {
15901594 if self . trait_may_have_item ( Some ( module) , assoc_item) {
1591- let def_id = module. def_id ( ) . unwrap ( ) ;
1595+ let def_id = module. def_id ( ) ;
15921596 found_traits. push ( TraitCandidate { def_id, import_ids : smallvec ! [ ] } ) ;
15931597 }
15941598 }
@@ -2189,8 +2193,9 @@ impl<'a> Resolver<'a> {
21892193 return self . graph_root ;
21902194 }
21912195 } ;
2192- let module = self
2193- . expect_module ( module. def_id ( ) . map_or ( LOCAL_CRATE , |def_id| def_id. krate ) . as_def_id ( ) ) ;
2196+ let module = self . expect_module (
2197+ module. opt_def_id ( ) . map_or ( LOCAL_CRATE , |def_id| def_id. krate ) . as_def_id ( ) ,
2198+ ) ;
21942199 debug ! (
21952200 "resolve_crate_root({:?}): got module {:?} ({:?}) (ident.span = {:?})" ,
21962201 ident,
@@ -3017,7 +3022,7 @@ impl<'a> Resolver<'a> {
30173022 }
30183023
30193024 let container = match parent. kind {
3020- ModuleKind :: Def ( kind, _, _) => kind. descr ( parent. def_id ( ) . unwrap ( ) ) ,
3025+ ModuleKind :: Def ( kind, _, _) => kind. descr ( parent. def_id ( ) ) ,
30213026 ModuleKind :: Block ( ..) => "block" ,
30223027 } ;
30233028
0 commit comments