@@ -241,11 +241,7 @@ impl<'a, 'tcx> SpecializedDecoder<hygiene::Mark> for DecodeContext<'a, 'tcx> {
241
241
fn specialized_decode ( & mut self ) -> Result < hygiene:: Mark , Self :: Error > {
242
242
let mark = u32:: decode ( self ) ?;
243
243
244
- // We only perform translation if hygiene info is already available and if the
245
- // mark actually needs translation. That way we avoid loops (as obtaining hygiene
246
- // info for an external crate involves decoding marks) and avoid incorrectly translated
247
- // default marks.
248
- if self . cdata ( ) . hygiene_data_import_info . borrow ( ) . is_some ( ) && mark != 0 {
244
+ if !self . cdata ( ) . hygiene_data_being_decoded . get ( ) && mark != 0 {
249
245
let imported_hygiene = self . cdata ( ) . imported_hygiene_data ( ) ;
250
246
251
247
Ok ( hygiene:: Mark :: from_u32 ( mark + imported_hygiene. mark_translation_offset ) )
@@ -259,11 +255,7 @@ impl<'a, 'tcx> SpecializedDecoder<SyntaxContext> for DecodeContext<'a, 'tcx> {
259
255
fn specialized_decode ( & mut self ) -> Result < SyntaxContext , Self :: Error > {
260
256
let ctxt = u32:: decode ( self ) ?;
261
257
262
- // We only perform translation if hygiene info is already available and if the
263
- // syntax context actually needs translation. That way we avoid loops (as obtaining
264
- // hygiene info for an external crate involves decoding syntax contexts) and avoid
265
- // incorrectly translated default contexts.
266
- if self . cdata ( ) . hygiene_data_import_info . borrow ( ) . is_some ( ) && ctxt != 0 {
258
+ if !self . cdata ( ) . hygiene_data_being_decoded . get ( ) && ctxt != 0 {
267
259
let imported_hygiene = self . cdata ( ) . imported_hygiene_data ( ) ;
268
260
269
261
Ok ( SyntaxContext :: from_u32 ( ctxt + imported_hygiene. ctxt_translation_offset ) )
@@ -1270,11 +1262,15 @@ impl<'a, 'tcx> CrateMetadata {
1270
1262
}
1271
1263
}
1272
1264
1265
+ self . hygiene_data_being_decoded . set ( true ) ;
1266
+
1273
1267
let external_hygiene_data = self . root . hygiene_data . decode ( self ) ;
1274
1268
1275
1269
// This shouldn't borrow twice, but there is no way to downgrade RefMut to Ref.
1276
1270
* self . hygiene_data_import_info . borrow_mut ( ) =
1277
1271
Some ( hygiene:: extend_hygiene_data ( external_hygiene_data) ) ;
1278
- Ref :: map ( self . hygiene_data_import_info . borrow ( ) , |d| d. as_ref ( ) . unwrap ( ) )
1272
+ self . hygiene_data_being_decoded . set ( false ) ;
1273
+
1274
+ Ref :: map ( self . hygiene_data_import_info . borrow ( ) , |d| d. as_ref ( ) . unwrap ( ) ) ;
1279
1275
}
1280
1276
}
0 commit comments