@@ -458,6 +458,7 @@ pub struct ExprCollector<'db> {
458
458
current_binding_owner : Option < ExprId > ,
459
459
460
460
awaitable_context : Option < Awaitable > ,
461
+ krate : base_db:: Crate ,
461
462
}
462
463
463
464
#[ derive( Clone , Debug ) ]
@@ -547,7 +548,7 @@ impl ExprCollector<'_> {
547
548
let expander = Expander :: new ( db, current_file_id, def_map) ;
548
549
ExprCollector {
549
550
db,
550
- cfg_options : module. krate ( ) . cfg_options ( db) ,
551
+ cfg_options : module. krate ( db ) . cfg_options ( db) ,
551
552
module,
552
553
def_map,
553
554
local_def_map,
@@ -561,6 +562,7 @@ impl ExprCollector<'_> {
561
562
awaitable_context : None ,
562
563
current_block_legacy_macro_defs_count : FxHashMap :: default ( ) ,
563
564
outer_impl_trait : false ,
565
+ krate : module. krate ( db) ,
564
566
}
565
567
}
566
568
@@ -1940,9 +1942,8 @@ impl ExprCollector<'_> {
1940
1942
T : ast:: AstNode ,
1941
1943
{
1942
1944
let macro_call_ptr = self . expander . in_file ( syntax_ptr) ;
1943
- let module = self . module . local_id ;
1944
1945
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 (
1946
1947
self . expander . in_file ( self . expander . ast_id_map ( ) . ast_id_for_ptr ( syntax_ptr) ) ,
1947
1948
) ;
1948
1949
let res = match block_call {
@@ -1954,7 +1955,7 @@ impl ExprCollector<'_> {
1954
1955
. resolve_path (
1955
1956
self . local_def_map ,
1956
1957
self . db ,
1957
- module,
1958
+ self . module ,
1958
1959
path,
1959
1960
crate :: item_scope:: BuiltinShadowMode :: Other ,
1960
1961
Some ( MacroSubNs :: Bang ) ,
@@ -1965,7 +1966,7 @@ impl ExprCollector<'_> {
1965
1966
self . expander . enter_expand (
1966
1967
self . db ,
1967
1968
mcall,
1968
- self . module . krate ( ) ,
1969
+ self . krate ,
1969
1970
resolver,
1970
1971
& mut |ptr, call| {
1971
1972
_ = self . source_map . expansions . insert ( ptr. map ( |( it, _) | it) , call) ;
@@ -2095,7 +2096,8 @@ impl ExprCollector<'_> {
2095
2096
return ;
2096
2097
} ;
2097
2098
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 ( ) ;
2099
2101
self . collect_macro_def ( statements, macro_id) ;
2100
2102
}
2101
2103
ast:: Stmt :: Item ( ast:: Item :: MacroRules ( macro_) ) => {
@@ -2109,7 +2111,7 @@ impl ExprCollector<'_> {
2109
2111
let name = name. as_name ( ) ;
2110
2112
let macro_defs_count =
2111
2113
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 ]
2113
2115
. scope
2114
2116
. get_legacy_macro ( & name)
2115
2117
. and_then ( |it| it. get ( * macro_defs_count) )
@@ -2155,7 +2157,7 @@ impl ExprCollector<'_> {
2155
2157
match block_id. map ( |block_id| ( block_def_map ( self . db , block_id) , block_id) ) {
2156
2158
Some ( ( def_map, block_id) ) => {
2157
2159
self . store . block_scopes . push ( block_id) ;
2158
- ( def_map. module_id ( DefMap :: ROOT ) , def_map)
2160
+ ( def_map. root_module_id ( ) , def_map)
2159
2161
}
2160
2162
None => ( self . module , self . def_map ) ,
2161
2163
} ;
@@ -2238,7 +2240,7 @@ impl ExprCollector<'_> {
2238
2240
let ( resolved, _) = self . def_map . resolve_path (
2239
2241
self . local_def_map ,
2240
2242
self . db ,
2241
- self . module . local_id ,
2243
+ self . module ,
2242
2244
& name. clone ( ) . into ( ) ,
2243
2245
BuiltinShadowMode :: Other ,
2244
2246
None ,
@@ -2865,12 +2867,12 @@ impl ExprCollector<'_> {
2865
2867
2866
2868
let new_v1_formatted = LangItem :: FormatArguments . ty_rel_path (
2867
2869
self . db ,
2868
- self . module . krate ( ) ,
2870
+ self . krate ,
2869
2871
Name :: new_symbol_root ( sym:: new_v1_formatted) ,
2870
2872
) ;
2871
2873
let unsafe_arg_new = LangItem :: FormatUnsafeArg . ty_rel_path (
2872
2874
self . db ,
2873
- self . module . krate ( ) ,
2875
+ self . krate ,
2874
2876
Name :: new_symbol_root ( sym:: new) ,
2875
2877
) ;
2876
2878
let new_v1_formatted =
@@ -2961,7 +2963,7 @@ impl ExprCollector<'_> {
2961
2963
let precision_expr = self . make_count ( precision, argmap) ;
2962
2964
let width_expr = self . make_count ( width, argmap) ;
2963
2965
2964
- if self . module . krate ( ) . workspace_data ( self . db ) . is_atleast_187 ( ) {
2966
+ if self . krate . workspace_data ( self . db ) . is_atleast_187 ( ) {
2965
2967
// These need to match the constants in library/core/src/fmt/rt.rs.
2966
2968
let align = match alignment {
2967
2969
Some ( FormatAlignment :: Left ) => 0 ,
@@ -2996,15 +2998,15 @@ impl ExprCollector<'_> {
2996
2998
let width =
2997
2999
RecordLitField { name : Name :: new_symbol_root ( sym:: width) , expr : width_expr } ;
2998
3000
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) ,
3000
3002
fields : Box :: new ( [ position, flags, precision, width] ) ,
3001
3003
spread : None ,
3002
3004
} )
3003
3005
} else {
3004
3006
let format_placeholder_new = {
3005
3007
let format_placeholder_new = LangItem :: FormatPlaceholder . ty_rel_path (
3006
3008
self . db ,
3007
- self . module . krate ( ) ,
3009
+ self . krate ,
3008
3010
Name :: new_symbol_root ( sym:: new) ,
3009
3011
) ;
3010
3012
match format_placeholder_new {
@@ -3027,7 +3029,7 @@ impl ExprCollector<'_> {
3027
3029
let align = {
3028
3030
let align = LangItem :: FormatAlignment . ty_rel_path (
3029
3031
self . db ,
3030
- self . module . krate ( ) ,
3032
+ self . krate ,
3031
3033
match alignment {
3032
3034
Some ( FormatAlignment :: Left ) => Name :: new_symbol_root ( sym:: Left ) ,
3033
3035
Some ( FormatAlignment :: Right ) => Name :: new_symbol_root ( sym:: Right ) ,
@@ -3080,7 +3082,7 @@ impl ExprCollector<'_> {
3080
3082
) ) ) ;
3081
3083
let count_is = match LangItem :: FormatCount . ty_rel_path (
3082
3084
self . db ,
3083
- self . module . krate ( ) ,
3085
+ self . krate ,
3084
3086
Name :: new_symbol_root ( sym:: Is ) ,
3085
3087
) {
3086
3088
Some ( count_is) => self . alloc_expr_desugared ( Expr :: Path ( count_is) ) ,
@@ -3098,7 +3100,7 @@ impl ExprCollector<'_> {
3098
3100
) ) ) ;
3099
3101
let count_param = match LangItem :: FormatCount . ty_rel_path (
3100
3102
self . db ,
3101
- self . module . krate ( ) ,
3103
+ self . krate ,
3102
3104
Name :: new_symbol_root ( sym:: Param ) ,
3103
3105
) {
3104
3106
Some ( count_param) => self . alloc_expr_desugared ( Expr :: Path ( count_param) ) ,
@@ -3116,7 +3118,7 @@ impl ExprCollector<'_> {
3116
3118
}
3117
3119
None => match LangItem :: FormatCount . ty_rel_path (
3118
3120
self . db ,
3119
- self . module . krate ( ) ,
3121
+ self . krate ,
3120
3122
Name :: new_symbol_root ( sym:: Implied ) ,
3121
3123
) {
3122
3124
Some ( count_param) => self . alloc_expr_desugared ( Expr :: Path ( count_param) ) ,
@@ -3138,7 +3140,7 @@ impl ExprCollector<'_> {
3138
3140
3139
3141
let new_fn = match LangItem :: FormatArgument . ty_rel_path (
3140
3142
self . db ,
3141
- self . module . krate ( ) ,
3143
+ self . krate ,
3142
3144
Name :: new_symbol_root ( match ty {
3143
3145
Format ( Display ) => sym:: new_display,
3144
3146
Format ( Debug ) => sym:: new_debug,
@@ -3161,7 +3163,7 @@ impl ExprCollector<'_> {
3161
3163
// endregion: format
3162
3164
3163
3165
fn lang_path ( & self , lang : LangItem ) -> Option < Path > {
3164
- lang. path ( self . db , self . module . krate ( ) )
3166
+ lang. path ( self . db , self . krate )
3165
3167
}
3166
3168
}
3167
3169
0 commit comments