diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2017-08-08 15:35:19 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2017-08-11 12:11:38 +0200 |
| commit | bdfd78db8ad4f5520414f346fdfbfb5449d5be48 (patch) | |
| tree | 95126906b7d5d677aa43865ba9492d8c67b9d305 /src | |
| parent | 4dcc3a4aae48d4ce856a2db2a1234af190fb2eb8 (diff) | |
| download | rust-bdfd78db8ad4f5520414f346fdfbfb5449d5be48.tar.gz rust-bdfd78db8ad4f5520414f346fdfbfb5449d5be48.zip | |
Improve documentation for TypeckTables::validate_hir_id().
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/context.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index bf412b57007..77964f6845b 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -396,8 +396,16 @@ impl<'tcx> TypeckTables<'tcx> { self.upvar_capture_map[&upvar_id] } - /// Validate that a NodeId can safely be converted to an ItemLocalId for - /// this table. + /// Validate that the given HirId (respectively its `local_id` part) can be + /// safely used as a key in the tables of this TypeckTable. For that to be + /// the case, the HirId must have the same `owner` as all the other IDs in + /// this table (signified by the `local_id_root` field). Otherwise the HirId + /// would be in a different frame of reference and using its `local_id` + /// would result in lookup errors, or worse, in silently wrong data being + /// stored/returned. + /// + /// Therefore it is advised to call this method anytime before using a given + /// HirId::local_id as a key. #[inline] pub fn validate_hir_id(&self, hir_id: hir::HirId) { #[cfg(debug_assertions)] |
