File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -396,8 +396,16 @@ impl<'tcx> TypeckTables<'tcx> {
396396 self . upvar_capture_map [ & upvar_id]
397397 }
398398
399- /// Validate that a NodeId can safely be converted to an ItemLocalId for
400- /// this table.
399+ /// Validate that the given HirId (respectively its `local_id` part) can be
400+ /// safely used as a key in the tables of this TypeckTable. For that to be
401+ /// the case, the HirId must have the same `owner` as all the other IDs in
402+ /// this table (signified by the `local_id_root` field). Otherwise the HirId
403+ /// would be in a different frame of reference and using its `local_id`
404+ /// would result in lookup errors, or worse, in silently wrong data being
405+ /// stored/returned.
406+ ///
407+ /// Therefore it is advised to call this method anytime before using a given
408+ /// HirId::local_id as a key.
401409 #[ inline]
402410 pub fn validate_hir_id ( & self , hir_id : hir:: HirId ) {
403411 #[ cfg( debug_assertions) ]
You can’t perform that action at this time.
0 commit comments