From b2332633091c02744e2f1447768f4fd82bf78902 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 27 Aug 2023 16:33:33 -0400 Subject: [PATCH] Add a specialization for encoding byte arrays in rmeta --- compiler/rustc_metadata/src/rmeta/encoder.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index be91ad4088a..5ade67c62ff 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -347,6 +347,13 @@ fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) { } } +impl<'a, 'tcx> Encodable> for [u8] { + fn encode(&self, e: &mut EncodeContext<'a, 'tcx>) { + Encoder::emit_usize(e, self.len()); + e.emit_raw_bytes(self); + } +} + impl<'a, 'tcx> TyEncoder for EncodeContext<'a, 'tcx> { const CLEAR_CROSS_CRATE: bool = true;