Skip to content

Commit c11691b

Browse files
committed
Check that trait_map is not moved twice.
1 parent 2737780 commit c11691b

File tree

1 file changed

+9
-0
lines changed
  • compiler/rustc_resolve/src

1 file changed

+9
-0
lines changed

compiler/rustc_resolve/src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,8 @@ pub struct Resolver<'a> {
910910
extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
911911
export_map: ExportMap<LocalDefId>,
912912
trait_map: NodeMap<Vec<TraitCandidate>>,
913+
#[cfg(debug_assertions)]
914+
took_trait_map: bool,
913915

914916
/// A map from nodes to anonymous modules.
915917
/// Anonymous modules are pseudo-modules that are implicitly created around items
@@ -1139,6 +1141,11 @@ impl ResolverAstLowering for Resolver<'_> {
11391141
}
11401142

11411143
fn trait_map(&mut self) -> NodeMap<Vec<TraitCandidate>> {
1144+
#[cfg(debug_assertions)]
1145+
{
1146+
debug_assert!(!self.took_trait_map);
1147+
self.took_trait_map = true;
1148+
}
11421149
std::mem::take(&mut self.trait_map)
11431150
}
11441151

@@ -1287,6 +1294,8 @@ impl<'a> Resolver<'a> {
12871294
extern_crate_map: Default::default(),
12881295
export_map: FxHashMap::default(),
12891296
trait_map: Default::default(),
1297+
#[cfg(debug_assertions)]
1298+
took_trait_map: false,
12901299
underscore_disambiguator: 0,
12911300
empty_module,
12921301
module_map,

0 commit comments

Comments
 (0)