We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 46b0f8b commit d9624edCopy full SHA for d9624ed
compiler/rustc_hir/src/lang_items.rs
@@ -45,7 +45,16 @@ impl LanguageItems {
45
46
pub fn set(&mut self, item: LangItem, def_id: DefId) {
47
self.items[item as usize] = Some(def_id);
48
- self.reverse_items.insert(def_id, item);
+ let preexisting = self.reverse_items.insert(def_id, item);
49
+
50
+ // This needs to be a bijection.
51
+ if let Some(preexisting) = preexisting {
52
+ panic!(
53
+ "For the bijection of LangItem <=> DefId to work,\
54
+ one item DefId may only be assigned one LangItem. \
55
+ Separate the LangItem definitions for {item:?} and {preexisting:?}."
56
+ );
57
+ }
58
}
59
60
pub fn from_def_id(&self, def_id: DefId) -> Option<LangItem> {
0 commit comments