diff options
| author | lcnr <rust@lcnr.de> | 2022-05-02 09:31:56 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2022-05-10 12:07:35 +0200 |
| commit | 6c8265dc56d221dce7f3535ecf8cdee6b9d2d618 (patch) | |
| tree | 7200aad6861c9464113121f124b093c69038c2cb /compiler/rustc_metadata/src | |
| parent | fc128b67647533258e0bc52cc935438e6480732d (diff) | |
| download | rust-6c8265dc56d221dce7f3535ecf8cdee6b9d2d618.tar.gz rust-6c8265dc56d221dce7f3535ecf8cdee6b9d2d618.zip | |
only_local: always check for misuse
Diffstat (limited to 'compiler/rustc_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 2f006dfabec..1de7dae3c25 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -985,15 +985,17 @@ fn should_encode_generics(def_kind: DefKind) -> bool { } impl<'a, 'tcx> EncodeContext<'a, 'tcx> { - fn encode_attrs(&mut self, def_id: DefId) { + fn encode_attrs(&mut self, def_id: LocalDefId) { let mut attrs = self .tcx - .get_attrs(def_id) + .hir() + .attrs(self.tcx.hir().local_def_id_to_hir_id(def_id)) .iter() .filter(|attr| !rustc_feature::is_builtin_only_local(attr.name_or_empty())); - record!(self.tables.attributes[def_id] <- attrs.clone()); + + record!(self.tables.attributes[def_id.to_def_id()] <- attrs.clone()); if attrs.any(|attr| attr.may_have_doc_links()) { - self.tables.may_have_doc_links.set(def_id.index, ()); + self.tables.may_have_doc_links.set(def_id.local_def_index, ()); } } @@ -1009,7 +1011,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let Some(def_kind) = def_kind else { continue }; self.tables.opt_def_kind.set(def_id.index, def_kind); record!(self.tables.def_span[def_id] <- tcx.def_span(def_id)); - self.encode_attrs(def_id); + self.encode_attrs(local_id); record!(self.tables.expn_that_defined[def_id] <- self.tcx.expn_that_defined(def_id)); if def_kind.has_codegen_attrs() { record!(self.tables.codegen_fn_attrs[def_id] <- self.tcx.codegen_fn_attrs(def_id)); @@ -1674,7 +1676,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { self.tables.opt_def_kind.set(LOCAL_CRATE.as_def_id().index, DefKind::Mod); record!(self.tables.def_span[LOCAL_CRATE.as_def_id()] <- tcx.def_span(LOCAL_CRATE.as_def_id())); - self.encode_attrs(LOCAL_CRATE.as_def_id()); + self.encode_attrs(LOCAL_CRATE.as_def_id().expect_local()); record!(self.tables.visibility[LOCAL_CRATE.as_def_id()] <- tcx.visibility(LOCAL_CRATE.as_def_id())); if let Some(stability) = stability { record!(self.tables.lookup_stability[LOCAL_CRATE.as_def_id()] <- stability); @@ -1715,7 +1717,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let def_id = id.to_def_id(); self.tables.opt_def_kind.set(def_id.index, DefKind::Macro(macro_kind)); record!(self.tables.kind[def_id] <- EntryKind::ProcMacro(macro_kind)); - self.encode_attrs(def_id); + self.encode_attrs(id); record!(self.tables.def_keys[def_id] <- def_key); record!(self.tables.def_ident_span[def_id] <- span); record!(self.tables.def_span[def_id] <- span); |
