@@ -458,6 +458,7 @@ pub struct ExprCollector<'db> {
458458 current_binding_owner : Option < ExprId > ,
459459
460460 awaitable_context : Option < Awaitable > ,
461+ krate : base_db:: Crate ,
461462}
462463
463464#[ derive( Clone , Debug ) ]
@@ -547,7 +548,7 @@ impl ExprCollector<'_> {
547548 let expander = Expander :: new ( db, current_file_id, def_map) ;
548549 ExprCollector {
549550 db,
550- cfg_options : module. krate ( ) . cfg_options ( db) ,
551+ cfg_options : module. krate ( db ) . cfg_options ( db) ,
551552 module,
552553 def_map,
553554 local_def_map,
@@ -561,6 +562,7 @@ impl ExprCollector<'_> {
561562 awaitable_context : None ,
562563 current_block_legacy_macro_defs_count : FxHashMap :: default ( ) ,
563564 outer_impl_trait : false ,
565+ krate : module. krate ( db) ,
564566 }
565567 }
566568
@@ -1940,9 +1942,8 @@ impl ExprCollector<'_> {
19401942 T : ast:: AstNode ,
19411943 {
19421944 let macro_call_ptr = self . expander . in_file ( syntax_ptr) ;
1943- let module = self . module . local_id ;
19441945
1945- let block_call = self . def_map . modules [ self . module . local_id ] . scope . macro_invoc (
1946+ let block_call = self . def_map . modules [ self . module ] . scope . macro_invoc (
19461947 self . expander . in_file ( self . expander . ast_id_map ( ) . ast_id_for_ptr ( syntax_ptr) ) ,
19471948 ) ;
19481949 let res = match block_call {
@@ -1954,7 +1955,7 @@ impl ExprCollector<'_> {
19541955 . resolve_path (
19551956 self . local_def_map ,
19561957 self . db ,
1957- module,
1958+ self . module ,
19581959 path,
19591960 crate :: item_scope:: BuiltinShadowMode :: Other ,
19601961 Some ( MacroSubNs :: Bang ) ,
@@ -1965,7 +1966,7 @@ impl ExprCollector<'_> {
19651966 self . expander . enter_expand (
19661967 self . db ,
19671968 mcall,
1968- self . module . krate ( ) ,
1969+ self . krate ,
19691970 resolver,
19701971 & mut |ptr, call| {
19711972 _ = self . source_map . expansions . insert ( ptr. map ( |( it, _) | it) , call) ;
@@ -2095,7 +2096,8 @@ impl ExprCollector<'_> {
20952096 return ;
20962097 } ;
20972098 let name = name. as_name ( ) ;
2098- let macro_id = self . def_map . modules [ DefMap :: ROOT ] . scope . get ( & name) . take_macros ( ) ;
2099+ let macro_id =
2100+ self . def_map . modules [ self . def_map . root ] . scope . get ( & name) . take_macros ( ) ;
20992101 self . collect_macro_def ( statements, macro_id) ;
21002102 }
21012103 ast:: Stmt :: Item ( ast:: Item :: MacroRules ( macro_) ) => {
@@ -2109,7 +2111,7 @@ impl ExprCollector<'_> {
21092111 let name = name. as_name ( ) ;
21102112 let macro_defs_count =
21112113 self . current_block_legacy_macro_defs_count . entry ( name. clone ( ) ) . or_insert ( 0 ) ;
2112- let macro_id = self . def_map . modules [ DefMap :: ROOT ]
2114+ let macro_id = self . def_map . modules [ self . def_map . root ]
21132115 . scope
21142116 . get_legacy_macro ( & name)
21152117 . and_then ( |it| it. get ( * macro_defs_count) )
@@ -2155,7 +2157,7 @@ impl ExprCollector<'_> {
21552157 match block_id. map ( |block_id| ( block_def_map ( self . db , block_id) , block_id) ) {
21562158 Some ( ( def_map, block_id) ) => {
21572159 self . store . block_scopes . push ( block_id) ;
2158- ( def_map. module_id ( DefMap :: ROOT ) , def_map)
2160+ ( def_map. root_module_id ( ) , def_map)
21592161 }
21602162 None => ( self . module , self . def_map ) ,
21612163 } ;
@@ -2238,7 +2240,7 @@ impl ExprCollector<'_> {
22382240 let ( resolved, _) = self . def_map . resolve_path (
22392241 self . local_def_map ,
22402242 self . db ,
2241- self . module . local_id ,
2243+ self . module ,
22422244 & name. clone ( ) . into ( ) ,
22432245 BuiltinShadowMode :: Other ,
22442246 None ,
@@ -2865,12 +2867,12 @@ impl ExprCollector<'_> {
28652867
28662868 let new_v1_formatted = LangItem :: FormatArguments . ty_rel_path (
28672869 self . db ,
2868- self . module . krate ( ) ,
2870+ self . krate ,
28692871 Name :: new_symbol_root ( sym:: new_v1_formatted) ,
28702872 ) ;
28712873 let unsafe_arg_new = LangItem :: FormatUnsafeArg . ty_rel_path (
28722874 self . db ,
2873- self . module . krate ( ) ,
2875+ self . krate ,
28742876 Name :: new_symbol_root ( sym:: new) ,
28752877 ) ;
28762878 let new_v1_formatted =
@@ -2961,7 +2963,7 @@ impl ExprCollector<'_> {
29612963 let precision_expr = self . make_count ( precision, argmap) ;
29622964 let width_expr = self . make_count ( width, argmap) ;
29632965
2964- if self . module . krate ( ) . workspace_data ( self . db ) . is_atleast_187 ( ) {
2966+ if self . krate . workspace_data ( self . db ) . is_atleast_187 ( ) {
29652967 // These need to match the constants in library/core/src/fmt/rt.rs.
29662968 let align = match alignment {
29672969 Some ( FormatAlignment :: Left ) => 0 ,
@@ -2996,15 +2998,15 @@ impl ExprCollector<'_> {
29962998 let width =
29972999 RecordLitField { name : Name :: new_symbol_root ( sym:: width) , expr : width_expr } ;
29983000 self . alloc_expr_desugared ( Expr :: RecordLit {
2999- path : LangItem :: FormatPlaceholder . path ( self . db , self . module . krate ( ) ) . map ( Box :: new) ,
3001+ path : LangItem :: FormatPlaceholder . path ( self . db , self . krate ) . map ( Box :: new) ,
30003002 fields : Box :: new ( [ position, flags, precision, width] ) ,
30013003 spread : None ,
30023004 } )
30033005 } else {
30043006 let format_placeholder_new = {
30053007 let format_placeholder_new = LangItem :: FormatPlaceholder . ty_rel_path (
30063008 self . db ,
3007- self . module . krate ( ) ,
3009+ self . krate ,
30083010 Name :: new_symbol_root ( sym:: new) ,
30093011 ) ;
30103012 match format_placeholder_new {
@@ -3027,7 +3029,7 @@ impl ExprCollector<'_> {
30273029 let align = {
30283030 let align = LangItem :: FormatAlignment . ty_rel_path (
30293031 self . db ,
3030- self . module . krate ( ) ,
3032+ self . krate ,
30313033 match alignment {
30323034 Some ( FormatAlignment :: Left ) => Name :: new_symbol_root ( sym:: Left ) ,
30333035 Some ( FormatAlignment :: Right ) => Name :: new_symbol_root ( sym:: Right ) ,
@@ -3080,7 +3082,7 @@ impl ExprCollector<'_> {
30803082 ) ) ) ;
30813083 let count_is = match LangItem :: FormatCount . ty_rel_path (
30823084 self . db ,
3083- self . module . krate ( ) ,
3085+ self . krate ,
30843086 Name :: new_symbol_root ( sym:: Is ) ,
30853087 ) {
30863088 Some ( count_is) => self . alloc_expr_desugared ( Expr :: Path ( count_is) ) ,
@@ -3098,7 +3100,7 @@ impl ExprCollector<'_> {
30983100 ) ) ) ;
30993101 let count_param = match LangItem :: FormatCount . ty_rel_path (
31003102 self . db ,
3101- self . module . krate ( ) ,
3103+ self . krate ,
31023104 Name :: new_symbol_root ( sym:: Param ) ,
31033105 ) {
31043106 Some ( count_param) => self . alloc_expr_desugared ( Expr :: Path ( count_param) ) ,
@@ -3116,7 +3118,7 @@ impl ExprCollector<'_> {
31163118 }
31173119 None => match LangItem :: FormatCount . ty_rel_path (
31183120 self . db ,
3119- self . module . krate ( ) ,
3121+ self . krate ,
31203122 Name :: new_symbol_root ( sym:: Implied ) ,
31213123 ) {
31223124 Some ( count_param) => self . alloc_expr_desugared ( Expr :: Path ( count_param) ) ,
@@ -3138,7 +3140,7 @@ impl ExprCollector<'_> {
31383140
31393141 let new_fn = match LangItem :: FormatArgument . ty_rel_path (
31403142 self . db ,
3141- self . module . krate ( ) ,
3143+ self . krate ,
31423144 Name :: new_symbol_root ( match ty {
31433145 Format ( Display ) => sym:: new_display,
31443146 Format ( Debug ) => sym:: new_debug,
@@ -3161,7 +3163,7 @@ impl ExprCollector<'_> {
31613163 // endregion: format
31623164
31633165 fn lang_path ( & self , lang : LangItem ) -> Option < Path > {
3164- lang. path ( self . db , self . module . krate ( ) )
3166+ lang. path ( self . db , self . krate )
31653167 }
31663168}
31673169
0 commit comments