rustc_middle/ty/
codec.rs

1//! This module contains some shared code for encoding and decoding various
2//! things from the `ty` module, and in particular implements support for
3//! "shorthands" which allow to have pointers back into the already encoded
4//! stream instead of re-encoding the same thing twice.
5//!
6//! The functionality in here is shared between persisting to crate metadata and
7//! persisting to incr. comp. caches.
8
9use std::hash::Hash;
10use std::intrinsics;
11use std::marker::DiscriminantKind;
12
13use rustc_abi::{FieldIdx, VariantIdx};
14use rustc_data_structures::fx::FxHashMap;
15use rustc_hir::def_id::LocalDefId;
16use rustc_serialize::{Decodable, Encodable};
17use rustc_span::source_map::Spanned;
18use rustc_span::{Span, SpanDecoder, SpanEncoder};
19
20use crate::arena::ArenaAllocatable;
21use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos};
22use crate::mir::interpret::{AllocId, ConstAllocation, CtfeProvenance};
23use crate::mir::mono::MonoItem;
24use crate::mir::{self};
25use crate::traits;
26use crate::ty::{self, AdtDef, GenericArgsRef, Ty, TyCtxt};
27
28/// The shorthand encoding uses an enum's variant index `usize`
29/// and is offset by this value so it never matches a real variant.
30/// This offset is also chosen so that the first byte is never < 0x80.
31pub const SHORTHAND_OFFSET: usize = 0x80;
32
33pub trait TyEncoder<'tcx>: SpanEncoder {
34    const CLEAR_CROSS_CRATE: bool;
35
36    fn position(&self) -> usize;
37
38    fn type_shorthands(&mut self) -> &mut FxHashMap<Ty<'tcx>, usize>;
39
40    fn predicate_shorthands(&mut self) -> &mut FxHashMap<ty::PredicateKind<'tcx>, usize>;
41
42    fn encode_alloc_id(&mut self, alloc_id: &AllocId);
43}
44
45pub trait TyDecoder<'tcx>: SpanDecoder {
46    const CLEAR_CROSS_CRATE: bool;
47
48    fn interner(&self) -> TyCtxt<'tcx>;
49
50    fn cached_ty_for_shorthand<F>(&mut self, shorthand: usize, or_insert_with: F) -> Ty<'tcx>
51    where
52        F: FnOnce(&mut Self) -> Ty<'tcx>;
53
54    fn with_position<F, R>(&mut self, pos: usize, f: F) -> R
55    where
56        F: FnOnce(&mut Self) -> R;
57
58    fn positioned_at_shorthand(&self) -> bool {
59        (self.peek_byte() & (SHORTHAND_OFFSET as u8)) != 0
60    }
61
62    fn decode_alloc_id(&mut self) -> AllocId;
63}
64
65pub trait EncodableWithShorthand<'tcx, E: TyEncoder<'tcx>>: Copy + Eq + Hash {
66    type Variant: Encodable<E>;
67    fn variant(&self) -> &Self::Variant;
68}
69
70#[allow(rustc::usage_of_ty_tykind)]
71impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for Ty<'tcx> {
72    type Variant = ty::TyKind<'tcx>;
73
74    #[inline]
75    fn variant(&self) -> &Self::Variant {
76        self.kind()
77    }
78}
79
80impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for ty::PredicateKind<'tcx> {
81    type Variant = ty::PredicateKind<'tcx>;
82
83    #[inline]
84    fn variant(&self) -> &Self::Variant {
85        self
86    }
87}
88
89/// Trait for decoding to a reference.
90///
91/// This is a separate trait from `Decodable` so that we can implement it for
92/// upstream types, such as `FxHashSet`.
93///
94/// The `TyDecodable` derive macro will use this trait for fields that are
95/// references (and don't use a type alias to hide that).
96///
97/// `Decodable` can still be implemented in cases where `Decodable` is required
98/// by a trait bound.
99pub trait RefDecodable<'tcx, D: TyDecoder<'tcx>> {
100    fn decode(d: &mut D) -> &'tcx Self;
101}
102
103/// Encode the given value or a previously cached shorthand.
104pub fn encode_with_shorthand<'tcx, E, T, M>(encoder: &mut E, value: &T, cache: M)
105where
106    E: TyEncoder<'tcx>,
107    M: for<'b> Fn(&'b mut E) -> &'b mut FxHashMap<T, usize>,
108    T: EncodableWithShorthand<'tcx, E>,
109    // The discriminant and shorthand must have the same size.
110    T::Variant: DiscriminantKind<Discriminant = isize>,
111{
112    let existing_shorthand = cache(encoder).get(value).copied();
113    if let Some(shorthand) = existing_shorthand {
114        encoder.emit_usize(shorthand);
115        return;
116    }
117
118    let variant = value.variant();
119
120    let start = encoder.position();
121    variant.encode(encoder);
122    let len = encoder.position() - start;
123
124    // The shorthand encoding uses the same usize as the
125    // discriminant, with an offset so they can't conflict.
126    let discriminant = intrinsics::discriminant_value(variant);
127    assert!(SHORTHAND_OFFSET > discriminant as usize);
128
129    let shorthand = start + SHORTHAND_OFFSET;
130
131    // Get the number of bits that leb128 could fit
132    // in the same space as the fully encoded type.
133    let leb128_bits = len * 7;
134
135    // Check that the shorthand is a not longer than the
136    // full encoding itself, i.e., it's an obvious win.
137    if leb128_bits >= 64 || (shorthand as u64) < (1 << leb128_bits) {
138        cache(encoder).insert(*value, shorthand);
139    }
140}
141
142impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Ty<'tcx> {
143    fn encode(&self, e: &mut E) {
144        encode_with_shorthand(e, self, TyEncoder::type_shorthands);
145    }
146}
147
148impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Predicate<'tcx> {
149    fn encode(&self, e: &mut E) {
150        let kind = self.kind();
151        kind.bound_vars().encode(e);
152        encode_with_shorthand(e, &kind.skip_binder(), TyEncoder::predicate_shorthands);
153    }
154}
155
156impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Clause<'tcx> {
157    fn encode(&self, e: &mut E) {
158        self.as_predicate().encode(e);
159    }
160}
161
162impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Region<'tcx> {
163    fn encode(&self, e: &mut E) {
164        self.kind().encode(e);
165    }
166}
167
168impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Const<'tcx> {
169    fn encode(&self, e: &mut E) {
170        self.0.0.encode(e);
171    }
172}
173
174impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Pattern<'tcx> {
175    fn encode(&self, e: &mut E) {
176        self.0.0.encode(e);
177    }
178}
179
180impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::ValTree<'tcx> {
181    fn encode(&self, e: &mut E) {
182        self.0.0.encode(e);
183    }
184}
185
186impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ConstAllocation<'tcx> {
187    fn encode(&self, e: &mut E) {
188        self.inner().encode(e)
189    }
190}
191
192impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for AdtDef<'tcx> {
193    fn encode(&self, e: &mut E) {
194        self.0.0.encode(e)
195    }
196}
197
198impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for AllocId {
199    fn encode(&self, e: &mut E) {
200        e.encode_alloc_id(self)
201    }
202}
203
204impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for CtfeProvenance {
205    fn encode(&self, e: &mut E) {
206        self.into_parts().encode(e);
207    }
208}
209
210impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::ParamEnv<'tcx> {
211    fn encode(&self, e: &mut E) {
212        self.caller_bounds().encode(e);
213    }
214}
215
216#[inline]
217fn decode_arena_allocable<'tcx, D: TyDecoder<'tcx>, T: ArenaAllocatable<'tcx> + Decodable<D>>(
218    decoder: &mut D,
219) -> &'tcx T
220where
221    D: TyDecoder<'tcx>,
222{
223    decoder.interner().arena.alloc(Decodable::decode(decoder))
224}
225
226#[inline]
227fn decode_arena_allocable_slice<
228    'tcx,
229    D: TyDecoder<'tcx>,
230    T: ArenaAllocatable<'tcx> + Decodable<D>,
231>(
232    decoder: &mut D,
233) -> &'tcx [T]
234where
235    D: TyDecoder<'tcx>,
236{
237    decoder.interner().arena.alloc_from_iter(<Vec<T> as Decodable<D>>::decode(decoder))
238}
239
240impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Ty<'tcx> {
241    #[allow(rustc::usage_of_ty_tykind)]
242    fn decode(decoder: &mut D) -> Ty<'tcx> {
243        // Handle shorthands first, if we have a usize > 0x80.
244        if decoder.positioned_at_shorthand() {
245            let pos = decoder.read_usize();
246            assert!(pos >= SHORTHAND_OFFSET);
247            let shorthand = pos - SHORTHAND_OFFSET;
248
249            decoder.cached_ty_for_shorthand(shorthand, |decoder| {
250                decoder.with_position(shorthand, Ty::decode)
251            })
252        } else {
253            let tcx = decoder.interner();
254            tcx.mk_ty_from_kind(ty::TyKind::decode(decoder))
255        }
256    }
257}
258
259impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Predicate<'tcx> {
260    fn decode(decoder: &mut D) -> ty::Predicate<'tcx> {
261        let bound_vars = Decodable::decode(decoder);
262        // Handle shorthands first, if we have a usize > 0x80.
263        let predicate_kind = ty::Binder::bind_with_vars(
264            if decoder.positioned_at_shorthand() {
265                let pos = decoder.read_usize();
266                assert!(pos >= SHORTHAND_OFFSET);
267                let shorthand = pos - SHORTHAND_OFFSET;
268
269                decoder.with_position(shorthand, <ty::PredicateKind<'tcx> as Decodable<D>>::decode)
270            } else {
271                <ty::PredicateKind<'tcx> as Decodable<D>>::decode(decoder)
272            },
273            bound_vars,
274        );
275        decoder.interner().mk_predicate(predicate_kind)
276    }
277}
278
279impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Clause<'tcx> {
280    fn decode(decoder: &mut D) -> ty::Clause<'tcx> {
281        let pred: ty::Predicate<'tcx> = Decodable::decode(decoder);
282        pred.expect_clause()
283    }
284}
285
286impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for GenericArgsRef<'tcx> {
287    fn decode(decoder: &mut D) -> Self {
288        let len = decoder.read_usize();
289        let tcx = decoder.interner();
290        tcx.mk_args_from_iter(
291            (0..len).map::<ty::GenericArg<'tcx>, _>(|_| Decodable::decode(decoder)),
292        )
293    }
294}
295
296impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for mir::Place<'tcx> {
297    fn decode(decoder: &mut D) -> Self {
298        let local: mir::Local = Decodable::decode(decoder);
299        let len = decoder.read_usize();
300        let projection = decoder.interner().mk_place_elems_from_iter(
301            (0..len).map::<mir::PlaceElem<'tcx>, _>(|_| Decodable::decode(decoder)),
302        );
303        mir::Place { local, projection }
304    }
305}
306
307impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Region<'tcx> {
308    fn decode(decoder: &mut D) -> Self {
309        ty::Region::new_from_kind(decoder.interner(), Decodable::decode(decoder))
310    }
311}
312
313impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for CanonicalVarInfos<'tcx> {
314    fn decode(decoder: &mut D) -> Self {
315        let len = decoder.read_usize();
316        decoder.interner().mk_canonical_var_infos_from_iter(
317            (0..len).map::<CanonicalVarInfo<'tcx>, _>(|_| Decodable::decode(decoder)),
318        )
319    }
320}
321
322impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for AllocId {
323    fn decode(decoder: &mut D) -> Self {
324        decoder.decode_alloc_id()
325    }
326}
327
328impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for CtfeProvenance {
329    fn decode(decoder: &mut D) -> Self {
330        let parts = Decodable::decode(decoder);
331        CtfeProvenance::from_parts(parts)
332    }
333}
334
335impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::SymbolName<'tcx> {
336    fn decode(decoder: &mut D) -> Self {
337        ty::SymbolName::new(decoder.interner(), decoder.read_str())
338    }
339}
340
341impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::ParamEnv<'tcx> {
342    fn decode(d: &mut D) -> Self {
343        let caller_bounds = Decodable::decode(d);
344        ty::ParamEnv::new(caller_bounds)
345    }
346}
347
348macro_rules! impl_decodable_via_ref {
349    ($($t:ty,)+) => {
350        $(impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for $t {
351            fn decode(decoder: &mut D) -> Self {
352                RefDecodable::decode(decoder)
353            }
354        })*
355    }
356}
357
358impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
359    fn decode(decoder: &mut D) -> &'tcx Self {
360        let len = decoder.read_usize();
361        decoder
362            .interner()
363            .mk_type_list_from_iter((0..len).map::<Ty<'tcx>, _>(|_| Decodable::decode(decoder)))
364    }
365}
366
367impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D>
368    for ty::List<ty::PolyExistentialPredicate<'tcx>>
369{
370    fn decode(decoder: &mut D) -> &'tcx Self {
371        let len = decoder.read_usize();
372        decoder.interner().mk_poly_existential_predicates_from_iter(
373            (0..len).map::<ty::Binder<'tcx, _>, _>(|_| Decodable::decode(decoder)),
374        )
375    }
376}
377
378impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Const<'tcx> {
379    fn decode(decoder: &mut D) -> Self {
380        let kind: ty::ConstKind<'tcx> = Decodable::decode(decoder);
381        decoder.interner().mk_ct_from_kind(kind)
382    }
383}
384
385impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Pattern<'tcx> {
386    fn decode(decoder: &mut D) -> Self {
387        decoder.interner().mk_pat(Decodable::decode(decoder))
388    }
389}
390
391impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::ValTree<'tcx> {
392    fn decode(decoder: &mut D) -> Self {
393        decoder.interner().intern_valtree(Decodable::decode(decoder))
394    }
395}
396
397impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ConstAllocation<'tcx> {
398    fn decode(decoder: &mut D) -> Self {
399        decoder.interner().mk_const_alloc(Decodable::decode(decoder))
400    }
401}
402
403impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for AdtDef<'tcx> {
404    fn decode(decoder: &mut D) -> Self {
405        decoder.interner().mk_adt_def_from_data(Decodable::decode(decoder))
406    }
407}
408
409impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [(ty::Clause<'tcx>, Span)] {
410    fn decode(decoder: &mut D) -> &'tcx Self {
411        decoder
412            .interner()
413            .arena
414            .alloc_from_iter((0..decoder.read_usize()).map(|_| Decodable::decode(decoder)))
415    }
416}
417
418impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [(ty::PolyTraitRef<'tcx>, Span)] {
419    fn decode(decoder: &mut D) -> &'tcx Self {
420        decoder
421            .interner()
422            .arena
423            .alloc_from_iter((0..decoder.read_usize()).map(|_| Decodable::decode(decoder)))
424    }
425}
426
427impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [Spanned<MonoItem<'tcx>>] {
428    fn decode(decoder: &mut D) -> &'tcx Self {
429        decoder
430            .interner()
431            .arena
432            .alloc_from_iter((0..decoder.read_usize()).map(|_| Decodable::decode(decoder)))
433    }
434}
435
436impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<ty::BoundVariableKind> {
437    fn decode(decoder: &mut D) -> &'tcx Self {
438        let len = decoder.read_usize();
439        decoder.interner().mk_bound_variable_kinds_from_iter(
440            (0..len).map::<ty::BoundVariableKind, _>(|_| Decodable::decode(decoder)),
441        )
442    }
443}
444
445impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<ty::Const<'tcx>> {
446    fn decode(decoder: &mut D) -> &'tcx Self {
447        let len = decoder.read_usize();
448        decoder.interner().mk_const_list_from_iter(
449            (0..len).map::<ty::Const<'tcx>, _>(|_| Decodable::decode(decoder)),
450        )
451    }
452}
453
454impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D>
455    for ty::ListWithCachedTypeInfo<ty::Clause<'tcx>>
456{
457    fn decode(decoder: &mut D) -> &'tcx Self {
458        let len = decoder.read_usize();
459        decoder.interner().mk_clauses_from_iter(
460            (0..len).map::<ty::Clause<'tcx>, _>(|_| Decodable::decode(decoder)),
461        )
462    }
463}
464
465impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<FieldIdx> {
466    fn decode(decoder: &mut D) -> &'tcx Self {
467        let len = decoder.read_usize();
468        decoder
469            .interner()
470            .mk_fields_from_iter((0..len).map::<FieldIdx, _>(|_| Decodable::decode(decoder)))
471    }
472}
473
474impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<LocalDefId> {
475    fn decode(decoder: &mut D) -> &'tcx Self {
476        let len = decoder.read_usize();
477        decoder.interner().mk_local_def_ids_from_iter(
478            (0..len).map::<LocalDefId, _>(|_| Decodable::decode(decoder)),
479        )
480    }
481}
482
483impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for &'tcx ty::List<LocalDefId> {
484    fn decode(d: &mut D) -> Self {
485        RefDecodable::decode(d)
486    }
487}
488
489impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<(VariantIdx, FieldIdx)> {
490    fn decode(decoder: &mut D) -> &'tcx Self {
491        let len = decoder.read_usize();
492        decoder.interner().mk_offset_of_from_iter(
493            (0..len).map::<(VariantIdx, FieldIdx), _>(|_| Decodable::decode(decoder)),
494        )
495    }
496}
497
498impl_decodable_via_ref! {
499    &'tcx ty::TypeckResults<'tcx>,
500    &'tcx ty::List<Ty<'tcx>>,
501    &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
502    &'tcx traits::ImplSource<'tcx, ()>,
503    &'tcx mir::Body<'tcx>,
504    &'tcx mir::BorrowCheckResult<'tcx>,
505    &'tcx ty::List<ty::BoundVariableKind>,
506    &'tcx ty::ListWithCachedTypeInfo<ty::Clause<'tcx>>,
507    &'tcx ty::List<FieldIdx>,
508    &'tcx ty::List<(VariantIdx, FieldIdx)>,
509}
510
511#[macro_export]
512macro_rules! __impl_decoder_methods {
513    ($($name:ident -> $ty:ty;)*) => {
514        $(
515            #[inline]
516            fn $name(&mut self) -> $ty {
517                self.opaque.$name()
518            }
519        )*
520    }
521}
522
523macro_rules! impl_arena_allocatable_decoder {
524    ([]$args:tt) => {};
525    ([decode $(, $attrs:ident)*]
526     [$name:ident: $ty:ty]) => {
527        impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for $ty {
528            #[inline]
529            fn decode(decoder: &mut D) -> &'tcx Self {
530                decode_arena_allocable(decoder)
531            }
532        }
533
534        impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [$ty] {
535            #[inline]
536            fn decode(decoder: &mut D) -> &'tcx Self {
537                decode_arena_allocable_slice(decoder)
538            }
539        }
540    };
541}
542
543macro_rules! impl_arena_allocatable_decoders {
544    ([$($a:tt $name:ident: $ty:ty,)*]) => {
545        $(
546            impl_arena_allocatable_decoder!($a [$name: $ty]);
547        )*
548    }
549}
550
551rustc_hir::arena_types!(impl_arena_allocatable_decoders);
552arena_types!(impl_arena_allocatable_decoders);
553
554macro_rules! impl_arena_copy_decoder {
555    (<$tcx:tt> $($ty:ty,)*) => {
556        $(impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for $ty {
557            #[inline]
558            fn decode(decoder: &mut D) -> &'tcx Self {
559                decoder.interner().arena.alloc(Decodable::decode(decoder))
560            }
561        }
562
563        impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [$ty] {
564            #[inline]
565            fn decode(decoder: &mut D) -> &'tcx Self {
566                decoder.interner().arena.alloc_from_iter(<Vec<_> as Decodable<D>>::decode(decoder))
567            }
568        })*
569    };
570}
571
572impl_arena_copy_decoder! {<'tcx>
573    Span,
574    rustc_span::Ident,
575    ty::Variance,
576    rustc_span::def_id::DefId,
577    rustc_span::def_id::LocalDefId,
578    (rustc_middle::middle::exported_symbols::ExportedSymbol<'tcx>, rustc_middle::middle::exported_symbols::SymbolExportInfo),
579    ty::DeducedParamAttrs,
580}
581
582#[macro_export]
583macro_rules! implement_ty_decoder {
584    ($DecoderName:ident <$($typaram:tt),*>) => {
585        mod __ty_decoder_impl {
586            use rustc_serialize::Decoder;
587
588            use super::$DecoderName;
589
590            impl<$($typaram ),*> Decoder for $DecoderName<$($typaram),*> {
591                $crate::__impl_decoder_methods! {
592                    read_usize -> usize;
593                    read_u128 -> u128;
594                    read_u64 -> u64;
595                    read_u32 -> u32;
596                    read_u16 -> u16;
597                    read_u8 -> u8;
598
599                    read_isize -> isize;
600                    read_i128 -> i128;
601                    read_i64 -> i64;
602                    read_i32 -> i32;
603                    read_i16 -> i16;
604                }
605
606                #[inline]
607                fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
608                    self.opaque.read_raw_bytes(len)
609                }
610
611                #[inline]
612                fn peek_byte(&self) -> u8 {
613                    self.opaque.peek_byte()
614                }
615
616                #[inline]
617                fn position(&self) -> usize {
618                    self.opaque.position()
619                }
620            }
621        }
622    }
623}