about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_resolve/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs
index 7f97be9434c..e181b30f0e3 100644
--- a/compiler/rustc_resolve/src/lib.rs
+++ b/compiler/rustc_resolve/src/lib.rs
@@ -910,6 +910,8 @@ pub struct Resolver<'a> {
     extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
     export_map: ExportMap<LocalDefId>,
     trait_map: NodeMap<Vec<TraitCandidate>>,
+    #[cfg(debug_assertions)]
+    took_trait_map: bool,
 
     /// A map from nodes to anonymous modules.
     /// Anonymous modules are pseudo-modules that are implicitly created around items
@@ -1139,6 +1141,11 @@ impl ResolverAstLowering for Resolver<'_> {
     }
 
     fn trait_map(&mut self) -> NodeMap<Vec<TraitCandidate>> {
+        #[cfg(debug_assertions)]
+        {
+            debug_assert!(!self.took_trait_map);
+            self.took_trait_map = true;
+        }
         std::mem::take(&mut self.trait_map)
     }
 
@@ -1287,6 +1294,8 @@ impl<'a> Resolver<'a> {
             extern_crate_map: Default::default(),
             export_map: FxHashMap::default(),
             trait_map: Default::default(),
+            #[cfg(debug_assertions)]
+            took_trait_map: false,
             underscore_disambiguator: 0,
             empty_module,
             module_map,