File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -168,25 +168,21 @@ impl CStore {
168
168
tcx : TyCtxt < ' tcx > ,
169
169
) -> Result < CrateNum , CrateError > {
170
170
assert_eq ! ( self . metas. len( ) , tcx. untracked( ) . stable_crate_ids. read( ) . len( ) ) ;
171
- if let Some ( & existing) =
172
- tcx. untracked ( ) . stable_crate_ids . read ( ) . get ( & root. stable_crate_id ( ) )
173
- {
171
+ let num = tcx. create_crate_num ( root. stable_crate_id ( ) ) . map_err ( |existing| {
174
172
// Check for (potential) conflicts with the local crate
175
173
if existing == LOCAL_CRATE {
176
- Err ( CrateError :: SymbolConflictsCurrent ( root. name ( ) ) )
174
+ CrateError :: SymbolConflictsCurrent ( root. name ( ) )
177
175
} else if let Some ( crate_name1) = self . metas [ existing] . as_ref ( ) . map ( |data| data. name ( ) )
178
176
{
179
177
let crate_name0 = root. name ( ) ;
180
- Err ( CrateError :: StableCrateIdCollision ( crate_name0, crate_name1) )
178
+ CrateError :: StableCrateIdCollision ( crate_name0, crate_name1)
181
179
} else {
182
- Err ( CrateError :: NotFound ( root. name ( ) ) )
180
+ CrateError :: NotFound ( root. name ( ) )
183
181
}
184
- } else {
185
- self . metas . push ( None ) ;
186
- let num = CrateNum :: new ( tcx. untracked ( ) . stable_crate_ids . read ( ) . len ( ) ) ;
187
- tcx. untracked ( ) . stable_crate_ids . write ( ) . insert ( root. stable_crate_id ( ) , num) ;
188
- Ok ( num)
189
- }
182
+ } ) ?;
183
+
184
+ self . metas . push ( None ) ;
185
+ Ok ( num)
190
186
}
191
187
192
188
pub fn has_crate_data ( & self , cnum : CrateNum ) -> bool {
Original file line number Diff line number Diff line change @@ -1173,6 +1173,16 @@ impl<'tcx> TyCtxt<'tcx> {
1173
1173
feed
1174
1174
}
1175
1175
1176
+ pub fn create_crate_num ( self , stable_crate_id : StableCrateId ) -> Result < CrateNum , CrateNum > {
1177
+ if let Some ( & existing) = self . untracked ( ) . stable_crate_ids . read ( ) . get ( & stable_crate_id) {
1178
+ return Err ( existing) ;
1179
+ }
1180
+
1181
+ let num = CrateNum :: new ( self . untracked ( ) . stable_crate_ids . read ( ) . len ( ) ) ;
1182
+ self . untracked ( ) . stable_crate_ids . write ( ) . insert ( stable_crate_id, num) ;
1183
+ Ok ( num)
1184
+ }
1185
+
1176
1186
pub fn iter_local_def_id ( self ) -> impl Iterator < Item = LocalDefId > + ' tcx {
1177
1187
// Create a dependency to the red node to be sure we re-execute this when the amount of
1178
1188
// definitions change.
You can’t perform that action at this time.
0 commit comments