|
5 | 5 | //! unexpanded macros in the fragment are visited and registered. |
6 | 6 | //! Imports are also considered items and placed into modules here, but not resolved yet. |
7 | 7 |
|
8 | | -use std::cell::Cell; |
9 | 8 | use std::sync::Arc; |
10 | 9 |
|
11 | 10 | use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind}; |
@@ -35,6 +34,7 @@ use crate::Namespace::{MacroNS, TypeNS, ValueNS}; |
35 | 34 | use crate::def_collector::collect_definitions; |
36 | 35 | use crate::imports::{ImportData, ImportKind}; |
37 | 36 | use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; |
| 37 | +use crate::ref_mut::CmCell; |
38 | 38 | use crate::{ |
39 | 39 | BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, ModuleOrUniformRoot, |
40 | 40 | NameBinding, ParentScope, PathResult, ResolutionError, Resolver, Segment, Used, |
@@ -87,7 +87,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
87 | 87 | // because they can be fetched by glob imports from those modules, and bring traits |
88 | 88 | // into scope both directly and through glob imports. |
89 | 89 | let key = BindingKey::new_disambiguated(ident, ns, || { |
90 | | - parent.underscore_disambiguator.update(|d| d + 1); |
| 90 | + // FIXME(batched): Will be fixed in batched resolution. |
| 91 | + parent.underscore_disambiguator.update_unchecked(|d| d + 1); |
91 | 92 | parent.underscore_disambiguator.get() |
92 | 93 | }); |
93 | 94 | if self |
@@ -477,7 +478,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
477 | 478 | kind, |
478 | 479 | parent_scope: self.parent_scope, |
479 | 480 | module_path, |
480 | | - imported_module: Cell::new(None), |
| 481 | + imported_module: CmCell::new(None), |
481 | 482 | span, |
482 | 483 | use_span: item.span, |
483 | 484 | use_span_with_attributes: item.span_with_attributes(), |
@@ -505,7 +506,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
505 | 506 | }); |
506 | 507 | } |
507 | 508 | } |
508 | | - ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(import), |
| 509 | + ImportKind::Glob { .. } => current_module.globs.borrow_mut(self.r).push(import), |
509 | 510 | _ => unreachable!(), |
510 | 511 | } |
511 | 512 | } |
@@ -668,7 +669,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
668 | 669 | } |
669 | 670 | ast::UseTreeKind::Glob => { |
670 | 671 | if !ast::attr::contains_name(&item.attrs, sym::prelude_import) { |
671 | | - let kind = ImportKind::Glob { max_vis: Cell::new(None), id }; |
| 672 | + let kind = ImportKind::Glob { max_vis: CmCell::new(None), id }; |
672 | 673 | self.add_import(prefix, kind, use_tree.span, item, root_span, item.id, vis); |
673 | 674 | } else { |
674 | 675 | // Resolve the prelude import early. |
@@ -971,7 +972,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
971 | 972 | kind: ImportKind::ExternCrate { source: orig_name, target: ident, id: item.id }, |
972 | 973 | root_id: item.id, |
973 | 974 | parent_scope: self.parent_scope, |
974 | | - imported_module: Cell::new(module), |
| 975 | + imported_module: CmCell::new(module), |
975 | 976 | has_attributes: !item.attrs.is_empty(), |
976 | 977 | use_span_with_attributes: item.span_with_attributes(), |
977 | 978 | use_span: item.span, |
@@ -1103,7 +1104,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
1103 | 1104 | kind: ImportKind::MacroUse { warn_private }, |
1104 | 1105 | root_id: item.id, |
1105 | 1106 | parent_scope: this.parent_scope, |
1106 | | - imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))), |
| 1107 | + imported_module: CmCell::new(Some(ModuleOrUniformRoot::Module(module))), |
1107 | 1108 | use_span_with_attributes: item.span_with_attributes(), |
1108 | 1109 | has_attributes: !item.attrs.is_empty(), |
1109 | 1110 | use_span: item.span, |
@@ -1196,7 +1197,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
1196 | 1197 | /// directly into its parent scope's module. |
1197 | 1198 | fn visit_invoc_in_module(&mut self, id: NodeId) -> MacroRulesScopeRef<'ra> { |
1198 | 1199 | let invoc_id = self.visit_invoc(id); |
1199 | | - self.parent_scope.module.unexpanded_invocations.borrow_mut().insert(invoc_id); |
| 1200 | + self.parent_scope.module.unexpanded_invocations.borrow_mut(self.r).insert(invoc_id); |
1200 | 1201 | self.r.arenas.alloc_macro_rules_scope(MacroRulesScope::Invocation(invoc_id)) |
1201 | 1202 | } |
1202 | 1203 |
|
@@ -1274,7 +1275,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { |
1274 | 1275 | kind: ImportKind::MacroExport, |
1275 | 1276 | root_id: item.id, |
1276 | 1277 | parent_scope: self.parent_scope, |
1277 | | - imported_module: Cell::new(None), |
| 1278 | + imported_module: CmCell::new(None), |
1278 | 1279 | has_attributes: false, |
1279 | 1280 | use_span_with_attributes: span, |
1280 | 1281 | use_span: span, |
|
0 commit comments