1#![deny(unsafe_code)]
10
11use std::hash::Hash;
12use std::ops::{Bound, Range};
13use std::sync::Once;
14use std::{fmt, marker, mem, panic, thread};
15
16use crate::{Delimiter, Level, Spacing};
17
18macro_rules! with_api {
49 ($S:ident, $self:ident, $m:ident) => {
50 $m! {
51 FreeFunctions {
52 fn drop($self: $S::FreeFunctions);
53 fn injected_env_var(var: &str) -> Option<String>;
54 fn track_env_var(var: &str, value: Option<&str>);
55 fn track_path(path: &str);
56 fn literal_from_str(s: &str) -> Result<Literal<$S::Span, $S::Symbol>, ()>;
57 fn emit_diagnostic(diagnostic: Diagnostic<$S::Span>);
58 },
59 TokenStream {
60 fn drop($self: $S::TokenStream);
61 fn clone($self: &$S::TokenStream) -> $S::TokenStream;
62 fn is_empty($self: &$S::TokenStream) -> bool;
63 fn expand_expr($self: &$S::TokenStream) -> Result<$S::TokenStream, ()>;
64 fn from_str(src: &str) -> $S::TokenStream;
65 fn to_string($self: &$S::TokenStream) -> String;
66 fn from_token_tree(
67 tree: TokenTree<$S::TokenStream, $S::Span, $S::Symbol>,
68 ) -> $S::TokenStream;
69 fn concat_trees(
70 base: Option<$S::TokenStream>,
71 trees: Vec<TokenTree<$S::TokenStream, $S::Span, $S::Symbol>>,
72 ) -> $S::TokenStream;
73 fn concat_streams(
74 base: Option<$S::TokenStream>,
75 streams: Vec<$S::TokenStream>,
76 ) -> $S::TokenStream;
77 fn into_trees(
78 $self: $S::TokenStream
79 ) -> Vec<TokenTree<$S::TokenStream, $S::Span, $S::Symbol>>;
80 },
81 Span {
82 fn debug($self: $S::Span) -> String;
83 fn parent($self: $S::Span) -> Option<$S::Span>;
84 fn source($self: $S::Span) -> $S::Span;
85 fn byte_range($self: $S::Span) -> Range<usize>;
86 fn start($self: $S::Span) -> $S::Span;
87 fn end($self: $S::Span) -> $S::Span;
88 fn line($self: $S::Span) -> usize;
89 fn column($self: $S::Span) -> usize;
90 fn file($self: $S::Span) -> String;
91 fn local_file($self: $S::Span) -> Option<String>;
92 fn join($self: $S::Span, other: $S::Span) -> Option<$S::Span>;
93 fn subspan($self: $S::Span, start: Bound<usize>, end: Bound<usize>) -> Option<$S::Span>;
94 fn resolved_at($self: $S::Span, at: $S::Span) -> $S::Span;
95 fn source_text($self: $S::Span) -> Option<String>;
96 fn save_span($self: $S::Span) -> usize;
97 fn recover_proc_macro_span(id: usize) -> $S::Span;
98 },
99 Symbol {
100 fn normalize_and_validate_ident(string: &str) -> Result<$S::Symbol, ()>;
101 },
102 }
103 };
104}
105
106macro_rules! with_api_handle_types {
109 ($m:ident) => {
110 $m! {
111 'owned:
112 FreeFunctions,
113 TokenStream,
114
115 'interned:
116 Span,
117 }
119 };
120}
121
122#[allow(unsafe_code)]
123mod arena;
124#[allow(unsafe_code)]
125mod buffer;
126#[deny(unsafe_code)]
127pub mod client;
128#[allow(unsafe_code)]
129mod closure;
130#[forbid(unsafe_code)]
131mod fxhash;
132#[forbid(unsafe_code)]
133mod handle;
134#[macro_use]
135#[forbid(unsafe_code)]
136mod rpc;
137#[allow(unsafe_code)]
138mod selfless_reify;
139#[forbid(unsafe_code)]
140pub mod server;
141#[allow(unsafe_code)]
142mod symbol;
143
144use buffer::Buffer;
145pub use rpc::PanicMessage;
146use rpc::{Decode, Encode, Reader, Writer};
147
148#[repr(C)]
154pub struct BridgeConfig<'a> {
155 input: Buffer,
157
158 dispatch: closure::Closure<'a, Buffer, Buffer>,
160
161 force_show_panics: bool,
163}
164
165impl !Send for BridgeConfig<'_> {}
166impl !Sync for BridgeConfig<'_> {}
167
168#[forbid(unsafe_code)]
169#[allow(non_camel_case_types)]
170mod api_tags {
171 use super::rpc::{Decode, Encode, Reader, Writer};
172
173 macro_rules! declare_tags {
174 ($($name:ident {
175 $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)*;)*
176 }),* $(,)?) => {
177 $(
178 pub(super) enum $name {
179 $($method),*
180 }
181 rpc_encode_decode!(enum $name { $($method),* });
182 )*
183
184 pub(super) enum Method {
185 $($name($name)),*
186 }
187 rpc_encode_decode!(enum Method { $($name(m)),* });
188 }
189 }
190 pub(super) enum Symbol { normalize_and_validate_ident, }
impl<S> Encode<S> for Symbol {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { normalize_and_validate_ident, }
match self {
Symbol::normalize_and_validate_ident => {
(Tag::normalize_and_validate_ident as u8).encode(w, s);
}
}
}
}
impl<'a, S> Decode<'a, '_, S> for Symbol {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { normalize_and_validate_ident, }
pub(crate) const normalize_and_validate_ident: u8 =
Tag::normalize_and_validate_ident as u8;
}
match u8::decode(r, s) {
tag::normalize_and_validate_ident => {
Symbol::normalize_and_validate_ident
}
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}
pub(super) enum Method {
FreeFunctions(FreeFunctions),
TokenStream(TokenStream),
Span(Span),
Symbol(Symbol),
}
impl<S> Encode<S> for Method {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { FreeFunctions, TokenStream, Span, Symbol, }
match self {
Method::FreeFunctions(m) => {
(Tag::FreeFunctions as u8).encode(w, s);
m.encode(w, s);
}
Method::TokenStream(m) => {
(Tag::TokenStream as u8).encode(w, s);
m.encode(w, s);
}
Method::Span(m) => {
(Tag::Span as u8).encode(w, s);
m.encode(w, s);
}
Method::Symbol(m) => {
(Tag::Symbol as u8).encode(w, s);
m.encode(w, s);
}
}
}
}
impl<'a, S> Decode<'a, '_, S> for Method {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { FreeFunctions, TokenStream, Span, Symbol, }
pub(crate) const FreeFunctions: u8 = Tag::FreeFunctions as u8;
pub(crate) const TokenStream: u8 = Tag::TokenStream as u8;
pub(crate) const Span: u8 = Tag::Span as u8;
pub(crate) const Symbol: u8 = Tag::Symbol as u8;
}
match u8::decode(r, s) {
tag::FreeFunctions => {
let m = Decode::decode(r, s);
Method::FreeFunctions(m)
}
tag::TokenStream => {
let m = Decode::decode(r, s);
Method::TokenStream(m)
}
tag::Span => { let m = Decode::decode(r, s); Method::Span(m) }
tag::Symbol => { let m = Decode::decode(r, s); Method::Symbol(m) }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}with_api!(self, self, declare_tags);
191}
192
193trait Mark {
198 type Unmarked;
199 fn mark(unmarked: Self::Unmarked) -> Self;
200}
201
202trait Unmark {
204 type Unmarked;
205 fn unmark(self) -> Self::Unmarked;
206}
207
208#[derive(#[automatically_derived]
impl<T: ::core::marker::Copy, M: ::core::marker::Copy> ::core::marker::Copy
for Marked<T, M> {
}Copy, #[automatically_derived]
impl<T: ::core::clone::Clone, M: ::core::clone::Clone> ::core::clone::Clone
for Marked<T, M> {
#[inline]
fn clone(&self) -> Marked<T, M> {
Marked {
value: ::core::clone::Clone::clone(&self.value),
_marker: ::core::clone::Clone::clone(&self._marker),
}
}
}Clone, #[automatically_derived]
impl<T: ::core::cmp::PartialEq, M: ::core::cmp::PartialEq>
::core::cmp::PartialEq for Marked<T, M> {
#[inline]
fn eq(&self, other: &Marked<T, M>) -> bool {
self.value == other.value && self._marker == other._marker
}
}PartialEq, #[automatically_derived]
impl<T: ::core::cmp::Eq, M: ::core::cmp::Eq> ::core::cmp::Eq for Marked<T, M>
{
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<T>;
let _: ::core::cmp::AssertParamIsEq<marker::PhantomData<M>>;
}
}Eq, #[automatically_derived]
impl<T: ::core::hash::Hash, M: ::core::hash::Hash> ::core::hash::Hash for
Marked<T, M> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
::core::hash::Hash::hash(&self.value, state);
::core::hash::Hash::hash(&self._marker, state)
}
}Hash)]
209struct Marked<T, M> {
210 value: T,
211 _marker: marker::PhantomData<M>,
212}
213
214impl<T, M> Mark for Marked<T, M> {
215 type Unmarked = T;
216 fn mark(unmarked: Self::Unmarked) -> Self {
217 Marked { value: unmarked, _marker: marker::PhantomData }
218 }
219}
220impl<T, M> Unmark for Marked<T, M> {
221 type Unmarked = T;
222 fn unmark(self) -> Self::Unmarked {
223 self.value
224 }
225}
226impl<'a, T, M> Unmark for &'a Marked<T, M> {
227 type Unmarked = &'a T;
228 fn unmark(self) -> Self::Unmarked {
229 &self.value
230 }
231}
232impl<'a, T, M> Unmark for &'a mut Marked<T, M> {
233 type Unmarked = &'a mut T;
234 fn unmark(self) -> Self::Unmarked {
235 &mut self.value
236 }
237}
238
239impl<T: Mark> Mark for Vec<T> {
240 type Unmarked = Vec<T::Unmarked>;
241 fn mark(unmarked: Self::Unmarked) -> Self {
242 unmarked.into_iter().map(T::mark).collect()
244 }
245}
246impl<T: Unmark> Unmark for Vec<T> {
247 type Unmarked = Vec<T::Unmarked>;
248 fn unmark(self) -> Self::Unmarked {
249 self.into_iter().map(T::unmark).collect()
251 }
252}
253
254macro_rules! mark_noop {
255 ($($ty:ty),* $(,)?) => {
256 $(
257 impl Mark for $ty {
258 type Unmarked = Self;
259 fn mark(unmarked: Self::Unmarked) -> Self {
260 unmarked
261 }
262 }
263 impl Unmark for $ty {
264 type Unmarked = Self;
265 fn unmark(self) -> Self::Unmarked {
266 self
267 }
268 }
269 )*
270 }
271}
272impl Mark for Spacing {
type Unmarked = Self;
fn mark(unmarked: Self::Unmarked) -> Self { unmarked }
}
impl Unmark for Spacing {
type Unmarked = Self;
fn unmark(self) -> Self::Unmarked { self }
}mark_noop! {
273 (),
274 bool,
275 char,
276 &'_ [u8],
277 &'_ str,
278 String,
279 u8,
280 usize,
281 Delimiter,
282 LitKind,
283 Level,
284 Spacing,
285}
286
287impl<S> Encode<S> for Delimiter {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { Parenthesis, Brace, Bracket, None, }
match self {
Delimiter::Parenthesis => {
(Tag::Parenthesis as u8).encode(w, s);
}
Delimiter::Brace => { (Tag::Brace as u8).encode(w, s); }
Delimiter::Bracket => { (Tag::Bracket as u8).encode(w, s); }
Delimiter::None => { (Tag::None as u8).encode(w, s); }
}
}
}
impl<'a, S> Decode<'a, '_, S> for Delimiter {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { Parenthesis, Brace, Bracket, None, }
pub(crate) const Parenthesis: u8 = Tag::Parenthesis as u8;
pub(crate) const Brace: u8 = Tag::Brace as u8;
pub(crate) const Bracket: u8 = Tag::Bracket as u8;
pub(crate) const None: u8 = Tag::None as u8;
}
match u8::decode(r, s) {
tag::Parenthesis => { Delimiter::Parenthesis }
tag::Brace => { Delimiter::Brace }
tag::Bracket => { Delimiter::Bracket }
tag::None => { Delimiter::None }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}rpc_encode_decode!(
288 enum Delimiter {
289 Parenthesis,
290 Brace,
291 Bracket,
292 None,
293 }
294);
295impl<S> Encode<S> for Level {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { Error, Warning, Note, Help, }
match self {
Level::Error => { (Tag::Error as u8).encode(w, s); }
Level::Warning => { (Tag::Warning as u8).encode(w, s); }
Level::Note => { (Tag::Note as u8).encode(w, s); }
Level::Help => { (Tag::Help as u8).encode(w, s); }
}
}
}
impl<'a, S> Decode<'a, '_, S> for Level {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { Error, Warning, Note, Help, }
pub(crate) const Error: u8 = Tag::Error as u8;
pub(crate) const Warning: u8 = Tag::Warning as u8;
pub(crate) const Note: u8 = Tag::Note as u8;
pub(crate) const Help: u8 = Tag::Help as u8;
}
match u8::decode(r, s) {
tag::Error => { Level::Error }
tag::Warning => { Level::Warning }
tag::Note => { Level::Note }
tag::Help => { Level::Help }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}rpc_encode_decode!(
296 enum Level {
297 Error,
298 Warning,
299 Note,
300 Help,
301 }
302);
303impl<S> Encode<S> for Spacing {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { Alone, Joint, }
match self {
Spacing::Alone => { (Tag::Alone as u8).encode(w, s); }
Spacing::Joint => { (Tag::Joint as u8).encode(w, s); }
}
}
}
impl<'a, S> Decode<'a, '_, S> for Spacing {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { Alone, Joint, }
pub(crate) const Alone: u8 = Tag::Alone as u8;
pub(crate) const Joint: u8 = Tag::Joint as u8;
}
match u8::decode(r, s) {
tag::Alone => { Spacing::Alone }
tag::Joint => { Spacing::Joint }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}rpc_encode_decode!(
304 enum Spacing {
305 Alone,
306 Joint,
307 }
308);
309
310#[derive(#[automatically_derived]
impl ::core::marker::Copy for LitKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LitKind {
#[inline]
fn clone(&self) -> LitKind {
let _: ::core::clone::AssertParamIsClone<u8>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::Eq for LitKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<u8>;
}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for LitKind {
#[inline]
fn eq(&self, other: &LitKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(LitKind::StrRaw(__self_0), LitKind::StrRaw(__arg1_0)) =>
__self_0 == __arg1_0,
(LitKind::ByteStrRaw(__self_0), LitKind::ByteStrRaw(__arg1_0))
=> __self_0 == __arg1_0,
(LitKind::CStrRaw(__self_0), LitKind::CStrRaw(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for LitKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
LitKind::Byte => ::core::fmt::Formatter::write_str(f, "Byte"),
LitKind::Char => ::core::fmt::Formatter::write_str(f, "Char"),
LitKind::Integer =>
::core::fmt::Formatter::write_str(f, "Integer"),
LitKind::Float => ::core::fmt::Formatter::write_str(f, "Float"),
LitKind::Str => ::core::fmt::Formatter::write_str(f, "Str"),
LitKind::StrRaw(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "StrRaw",
&__self_0),
LitKind::ByteStr =>
::core::fmt::Formatter::write_str(f, "ByteStr"),
LitKind::ByteStrRaw(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ByteStrRaw", &__self_0),
LitKind::CStr => ::core::fmt::Formatter::write_str(f, "CStr"),
LitKind::CStrRaw(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"CStrRaw", &__self_0),
LitKind::ErrWithGuar =>
::core::fmt::Formatter::write_str(f, "ErrWithGuar"),
}
}
}Debug)]
311pub enum LitKind {
312 Byte,
313 Char,
314 Integer,
315 Float,
316 Str,
317 StrRaw(u8),
318 ByteStr,
319 ByteStrRaw(u8),
320 CStr,
321 CStrRaw(u8),
322 ErrWithGuar,
327}
328
329impl<S> Encode<S> for LitKind {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag {
Byte,
Char,
Integer,
Float,
Str,
StrRaw,
ByteStr,
ByteStrRaw,
CStr,
CStrRaw,
ErrWithGuar,
}
match self {
LitKind::Byte => { (Tag::Byte as u8).encode(w, s); }
LitKind::Char => { (Tag::Char as u8).encode(w, s); }
LitKind::Integer => { (Tag::Integer as u8).encode(w, s); }
LitKind::Float => { (Tag::Float as u8).encode(w, s); }
LitKind::Str => { (Tag::Str as u8).encode(w, s); }
LitKind::StrRaw(n) => {
(Tag::StrRaw as u8).encode(w, s);
n.encode(w, s);
}
LitKind::ByteStr => { (Tag::ByteStr as u8).encode(w, s); }
LitKind::ByteStrRaw(n) => {
(Tag::ByteStrRaw as u8).encode(w, s);
n.encode(w, s);
}
LitKind::CStr => { (Tag::CStr as u8).encode(w, s); }
LitKind::CStrRaw(n) => {
(Tag::CStrRaw as u8).encode(w, s);
n.encode(w, s);
}
LitKind::ErrWithGuar => { (Tag::ErrWithGuar as u8).encode(w, s); }
}
}
}
impl<'a, S> Decode<'a, '_, S> for LitKind {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag {
Byte,
Char,
Integer,
Float,
Str,
StrRaw,
ByteStr,
ByteStrRaw,
CStr,
CStrRaw,
ErrWithGuar,
}
pub(crate) const Byte: u8 = Tag::Byte as u8;
pub(crate) const Char: u8 = Tag::Char as u8;
pub(crate) const Integer: u8 = Tag::Integer as u8;
pub(crate) const Float: u8 = Tag::Float as u8;
pub(crate) const Str: u8 = Tag::Str as u8;
pub(crate) const StrRaw: u8 = Tag::StrRaw as u8;
pub(crate) const ByteStr: u8 = Tag::ByteStr as u8;
pub(crate) const ByteStrRaw: u8 = Tag::ByteStrRaw as u8;
pub(crate) const CStr: u8 = Tag::CStr as u8;
pub(crate) const CStrRaw: u8 = Tag::CStrRaw as u8;
pub(crate) const ErrWithGuar: u8 = Tag::ErrWithGuar as u8;
}
match u8::decode(r, s) {
tag::Byte => { LitKind::Byte }
tag::Char => { LitKind::Char }
tag::Integer => { LitKind::Integer }
tag::Float => { LitKind::Float }
tag::Str => { LitKind::Str }
tag::StrRaw => {
let n = Decode::decode(r, s);
LitKind::StrRaw(n)
}
tag::ByteStr => { LitKind::ByteStr }
tag::ByteStrRaw => {
let n = Decode::decode(r, s);
LitKind::ByteStrRaw(n)
}
tag::CStr => { LitKind::CStr }
tag::CStrRaw => {
let n = Decode::decode(r, s);
LitKind::CStrRaw(n)
}
tag::ErrWithGuar => { LitKind::ErrWithGuar }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}rpc_encode_decode!(
330 enum LitKind {
331 Byte,
332 Char,
333 Integer,
334 Float,
335 Str,
336 StrRaw(n),
337 ByteStr,
338 ByteStrRaw(n),
339 CStr,
340 CStrRaw(n),
341 ErrWithGuar,
342 }
343);
344
345macro_rules! mark_compound {
346 (struct $name:ident <$($T:ident),+> { $($field:ident),* $(,)? }) => {
347 impl<$($T: Mark),+> Mark for $name <$($T),+> {
348 type Unmarked = $name <$($T::Unmarked),+>;
349 fn mark(unmarked: Self::Unmarked) -> Self {
350 $name {
351 $($field: Mark::mark(unmarked.$field)),*
352 }
353 }
354 }
355
356 impl<$($T: Unmark),+> Unmark for $name <$($T),+> {
357 type Unmarked = $name <$($T::Unmarked),+>;
358 fn unmark(self) -> Self::Unmarked {
359 $name {
360 $($field: Unmark::unmark(self.$field)),*
361 }
362 }
363 }
364 };
365 (enum $name:ident <$($T:ident),+> { $($variant:ident $(($field:ident))?),* $(,)? }) => {
366 impl<$($T: Mark),+> Mark for $name <$($T),+> {
367 type Unmarked = $name <$($T::Unmarked),+>;
368 fn mark(unmarked: Self::Unmarked) -> Self {
369 match unmarked {
370 $($name::$variant $(($field))? => {
371 $name::$variant $((Mark::mark($field)))?
372 })*
373 }
374 }
375 }
376
377 impl<$($T: Unmark),+> Unmark for $name <$($T),+> {
378 type Unmarked = $name <$($T::Unmarked),+>;
379 fn unmark(self) -> Self::Unmarked {
380 match self {
381 $($name::$variant $(($field))? => {
382 $name::$variant $((Unmark::unmark($field)))?
383 })*
384 }
385 }
386 }
387 }
388}
389
390macro_rules! compound_traits {
391 ($($t:tt)*) => {
392 rpc_encode_decode!($($t)*);
393 mark_compound!($($t)*);
394 };
395}
396
397impl<S, T: Encode<S>> Encode<S> for Bound<T> {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { Included, Excluded, Unbounded, }
match self {
Bound::Included(x) => {
(Tag::Included as u8).encode(w, s);
x.encode(w, s);
}
Bound::Excluded(x) => {
(Tag::Excluded as u8).encode(w, s);
x.encode(w, s);
}
Bound::Unbounded => { (Tag::Unbounded as u8).encode(w, s); }
}
}
}
impl<'a, S, T: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for Bound<T> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { Included, Excluded, Unbounded, }
pub(crate) const Included: u8 = Tag::Included as u8;
pub(crate) const Excluded: u8 = Tag::Excluded as u8;
pub(crate) const Unbounded: u8 = Tag::Unbounded as u8;
}
match u8::decode(r, s) {
tag::Included => {
let x = Decode::decode(r, s);
Bound::Included(x)
}
tag::Excluded => {
let x = Decode::decode(r, s);
Bound::Excluded(x)
}
tag::Unbounded => { Bound::Unbounded }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}
impl<T: Mark> Mark for Bound<T> {
type Unmarked = Bound<T::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
match unmarked {
Bound::Included(x) => { Bound::Included(Mark::mark(x)) }
Bound::Excluded(x) => { Bound::Excluded(Mark::mark(x)) }
Bound::Unbounded => { Bound::Unbounded }
}
}
}
impl<T: Unmark> Unmark for Bound<T> {
type Unmarked = Bound<T::Unmarked>;
fn unmark(self) -> Self::Unmarked {
match self {
Bound::Included(x) => { Bound::Included(Unmark::unmark(x)) }
Bound::Excluded(x) => { Bound::Excluded(Unmark::unmark(x)) }
Bound::Unbounded => { Bound::Unbounded }
}
}
}compound_traits!(
398 enum Bound<T> {
399 Included(x),
400 Excluded(x),
401 Unbounded,
402 }
403);
404
405impl<S, T: Encode<S>> Encode<S> for Option<T> {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { Some, None, }
match self {
Option::Some(t) => {
(Tag::Some as u8).encode(w, s);
t.encode(w, s);
}
Option::None => { (Tag::None as u8).encode(w, s); }
}
}
}
impl<'a, S, T: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for Option<T> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { Some, None, }
pub(crate) const Some: u8 = Tag::Some as u8;
pub(crate) const None: u8 = Tag::None as u8;
}
match u8::decode(r, s) {
tag::Some => { let t = Decode::decode(r, s); Option::Some(t) }
tag::None => { Option::None }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}
impl<T: Mark> Mark for Option<T> {
type Unmarked = Option<T::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
match unmarked {
Option::Some(t) => { Option::Some(Mark::mark(t)) }
Option::None => { Option::None }
}
}
}
impl<T: Unmark> Unmark for Option<T> {
type Unmarked = Option<T::Unmarked>;
fn unmark(self) -> Self::Unmarked {
match self {
Option::Some(t) => { Option::Some(Unmark::unmark(t)) }
Option::None => { Option::None }
}
}
}compound_traits!(
406 enum Option<T> {
407 Some(t),
408 None,
409 }
410);
411
412impl<S, T: Encode<S>, E: Encode<S>> Encode<S> for Result<T, E> {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { Ok, Err, }
match self {
Result::Ok(t) => { (Tag::Ok as u8).encode(w, s); t.encode(w, s); }
Result::Err(e) => {
(Tag::Err as u8).encode(w, s);
e.encode(w, s);
}
}
}
}
impl<'a, S, T: for<'s> Decode<'a, 's, S>, E: for<'s> Decode<'a, 's, S>>
Decode<'a, '_, S> for Result<T, E> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { Ok, Err, }
pub(crate) const Ok: u8 = Tag::Ok as u8;
pub(crate) const Err: u8 = Tag::Err as u8;
}
match u8::decode(r, s) {
tag::Ok => { let t = Decode::decode(r, s); Result::Ok(t) }
tag::Err => { let e = Decode::decode(r, s); Result::Err(e) }
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}
impl<T: Mark, E: Mark> Mark for Result<T, E> {
type Unmarked = Result<T::Unmarked, E::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
match unmarked {
Result::Ok(t) => { Result::Ok(Mark::mark(t)) }
Result::Err(e) => { Result::Err(Mark::mark(e)) }
}
}
}
impl<T: Unmark, E: Unmark> Unmark for Result<T, E> {
type Unmarked = Result<T::Unmarked, E::Unmarked>;
fn unmark(self) -> Self::Unmarked {
match self {
Result::Ok(t) => { Result::Ok(Unmark::unmark(t)) }
Result::Err(e) => { Result::Err(Unmark::unmark(e)) }
}
}
}compound_traits!(
413 enum Result<T, E> {
414 Ok(t),
415 Err(e),
416 }
417);
418
419#[derive(#[automatically_derived]
impl<Span: ::core::marker::Copy> ::core::marker::Copy for DelimSpan<Span> { }Copy, #[automatically_derived]
impl<Span: ::core::clone::Clone> ::core::clone::Clone for DelimSpan<Span> {
#[inline]
fn clone(&self) -> DelimSpan<Span> {
DelimSpan {
open: ::core::clone::Clone::clone(&self.open),
close: ::core::clone::Clone::clone(&self.close),
entire: ::core::clone::Clone::clone(&self.entire),
}
}
}Clone)]
420pub struct DelimSpan<Span> {
421 pub open: Span,
422 pub close: Span,
423 pub entire: Span,
424}
425
426impl<Span: Copy> DelimSpan<Span> {
427 pub fn from_single(span: Span) -> Self {
428 DelimSpan { open: span, close: span, entire: span }
429 }
430}
431
432impl<S, Span: Encode<S>> Encode<S> for DelimSpan<Span> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.open.encode(w, s);
self.close.encode(w, s);
self.entire.encode(w, s);
}
}
impl<'a, S, Span: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for
DelimSpan<Span> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
DelimSpan {
open: Decode::decode(r, s),
close: Decode::decode(r, s),
entire: Decode::decode(r, s),
}
}
}
impl<Span: Mark> Mark for DelimSpan<Span> {
type Unmarked = DelimSpan<Span::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
DelimSpan {
open: Mark::mark(unmarked.open),
close: Mark::mark(unmarked.close),
entire: Mark::mark(unmarked.entire),
}
}
}
impl<Span: Unmark> Unmark for DelimSpan<Span> {
type Unmarked = DelimSpan<Span::Unmarked>;
fn unmark(self) -> Self::Unmarked {
DelimSpan {
open: Unmark::unmark(self.open),
close: Unmark::unmark(self.close),
entire: Unmark::unmark(self.entire),
}
}
}compound_traits!(struct DelimSpan<Span> { open, close, entire });
433
434#[derive(#[automatically_derived]
impl<TokenStream: ::core::clone::Clone, Span: ::core::clone::Clone>
::core::clone::Clone for Group<TokenStream, Span> {
#[inline]
fn clone(&self) -> Group<TokenStream, Span> {
Group {
delimiter: ::core::clone::Clone::clone(&self.delimiter),
stream: ::core::clone::Clone::clone(&self.stream),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone)]
435pub struct Group<TokenStream, Span> {
436 pub delimiter: Delimiter,
437 pub stream: Option<TokenStream>,
438 pub span: DelimSpan<Span>,
439}
440
441impl<S, TokenStream: Encode<S>, Span: Encode<S>> Encode<S> for
Group<TokenStream, Span> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.delimiter.encode(w, s);
self.stream.encode(w, s);
self.span.encode(w, s);
}
}
impl<'a, S, TokenStream: for<'s> Decode<'a, 's, S>,
Span: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for
Group<TokenStream, Span> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
Group {
delimiter: Decode::decode(r, s),
stream: Decode::decode(r, s),
span: Decode::decode(r, s),
}
}
}
impl<TokenStream: Mark, Span: Mark> Mark for Group<TokenStream, Span> {
type Unmarked = Group<TokenStream::Unmarked, Span::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
Group {
delimiter: Mark::mark(unmarked.delimiter),
stream: Mark::mark(unmarked.stream),
span: Mark::mark(unmarked.span),
}
}
}
impl<TokenStream: Unmark, Span: Unmark> Unmark for Group<TokenStream, Span> {
type Unmarked = Group<TokenStream::Unmarked, Span::Unmarked>;
fn unmark(self) -> Self::Unmarked {
Group {
delimiter: Unmark::unmark(self.delimiter),
stream: Unmark::unmark(self.stream),
span: Unmark::unmark(self.span),
}
}
}compound_traits!(struct Group<TokenStream, Span> { delimiter, stream, span });
442
443#[derive(#[automatically_derived]
impl<Span: ::core::clone::Clone> ::core::clone::Clone for Punct<Span> {
#[inline]
fn clone(&self) -> Punct<Span> {
Punct {
ch: ::core::clone::Clone::clone(&self.ch),
joint: ::core::clone::Clone::clone(&self.joint),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone)]
444pub struct Punct<Span> {
445 pub ch: u8,
446 pub joint: bool,
447 pub span: Span,
448}
449
450impl<S, Span: Encode<S>> Encode<S> for Punct<Span> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.ch.encode(w, s);
self.joint.encode(w, s);
self.span.encode(w, s);
}
}
impl<'a, S, Span: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for Punct<Span>
{
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
Punct {
ch: Decode::decode(r, s),
joint: Decode::decode(r, s),
span: Decode::decode(r, s),
}
}
}
impl<Span: Mark> Mark for Punct<Span> {
type Unmarked = Punct<Span::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
Punct {
ch: Mark::mark(unmarked.ch),
joint: Mark::mark(unmarked.joint),
span: Mark::mark(unmarked.span),
}
}
}
impl<Span: Unmark> Unmark for Punct<Span> {
type Unmarked = Punct<Span::Unmarked>;
fn unmark(self) -> Self::Unmarked {
Punct {
ch: Unmark::unmark(self.ch),
joint: Unmark::unmark(self.joint),
span: Unmark::unmark(self.span),
}
}
}compound_traits!(struct Punct<Span> { ch, joint, span });
451
452#[derive(#[automatically_derived]
impl<Span: ::core::marker::Copy, Symbol: ::core::marker::Copy>
::core::marker::Copy for Ident<Span, Symbol> {
}Copy, #[automatically_derived]
impl<Span: ::core::clone::Clone, Symbol: ::core::clone::Clone>
::core::clone::Clone for Ident<Span, Symbol> {
#[inline]
fn clone(&self) -> Ident<Span, Symbol> {
Ident {
sym: ::core::clone::Clone::clone(&self.sym),
is_raw: ::core::clone::Clone::clone(&self.is_raw),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl<Span: ::core::cmp::Eq, Symbol: ::core::cmp::Eq> ::core::cmp::Eq for
Ident<Span, Symbol> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<Symbol>;
let _: ::core::cmp::AssertParamIsEq<bool>;
let _: ::core::cmp::AssertParamIsEq<Span>;
}
}Eq, #[automatically_derived]
impl<Span: ::core::cmp::PartialEq, Symbol: ::core::cmp::PartialEq>
::core::cmp::PartialEq for Ident<Span, Symbol> {
#[inline]
fn eq(&self, other: &Ident<Span, Symbol>) -> bool {
self.is_raw == other.is_raw && self.sym == other.sym &&
self.span == other.span
}
}PartialEq)]
453pub struct Ident<Span, Symbol> {
454 pub sym: Symbol,
455 pub is_raw: bool,
456 pub span: Span,
457}
458
459impl<S, Span: Encode<S>, Symbol: Encode<S>> Encode<S> for Ident<Span, Symbol>
{
fn encode(self, w: &mut Writer, s: &mut S) {
self.sym.encode(w, s);
self.is_raw.encode(w, s);
self.span.encode(w, s);
}
}
impl<'a, S, Span: for<'s> Decode<'a, 's, S>,
Symbol: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for
Ident<Span, Symbol> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
Ident {
sym: Decode::decode(r, s),
is_raw: Decode::decode(r, s),
span: Decode::decode(r, s),
}
}
}
impl<Span: Mark, Symbol: Mark> Mark for Ident<Span, Symbol> {
type Unmarked = Ident<Span::Unmarked, Symbol::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
Ident {
sym: Mark::mark(unmarked.sym),
is_raw: Mark::mark(unmarked.is_raw),
span: Mark::mark(unmarked.span),
}
}
}
impl<Span: Unmark, Symbol: Unmark> Unmark for Ident<Span, Symbol> {
type Unmarked = Ident<Span::Unmarked, Symbol::Unmarked>;
fn unmark(self) -> Self::Unmarked {
Ident {
sym: Unmark::unmark(self.sym),
is_raw: Unmark::unmark(self.is_raw),
span: Unmark::unmark(self.span),
}
}
}compound_traits!(struct Ident<Span, Symbol> { sym, is_raw, span });
460
461#[derive(#[automatically_derived]
impl<Span: ::core::clone::Clone, Symbol: ::core::clone::Clone>
::core::clone::Clone for Literal<Span, Symbol> {
#[inline]
fn clone(&self) -> Literal<Span, Symbol> {
Literal {
kind: ::core::clone::Clone::clone(&self.kind),
symbol: ::core::clone::Clone::clone(&self.symbol),
suffix: ::core::clone::Clone::clone(&self.suffix),
span: ::core::clone::Clone::clone(&self.span),
}
}
}Clone, #[automatically_derived]
impl<Span: ::core::cmp::Eq, Symbol: ::core::cmp::Eq> ::core::cmp::Eq for
Literal<Span, Symbol> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<LitKind>;
let _: ::core::cmp::AssertParamIsEq<Symbol>;
let _: ::core::cmp::AssertParamIsEq<Option<Symbol>>;
let _: ::core::cmp::AssertParamIsEq<Span>;
}
}Eq, #[automatically_derived]
impl<Span: ::core::cmp::PartialEq, Symbol: ::core::cmp::PartialEq>
::core::cmp::PartialEq for Literal<Span, Symbol> {
#[inline]
fn eq(&self, other: &Literal<Span, Symbol>) -> bool {
self.kind == other.kind && self.symbol == other.symbol &&
self.suffix == other.suffix && self.span == other.span
}
}PartialEq)]
462pub struct Literal<Span, Symbol> {
463 pub kind: LitKind,
464 pub symbol: Symbol,
465 pub suffix: Option<Symbol>,
466 pub span: Span,
467}
468
469impl<S, Sp: Encode<S>, Sy: Encode<S>> Encode<S> for Literal<Sp, Sy> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.kind.encode(w, s);
self.symbol.encode(w, s);
self.suffix.encode(w, s);
self.span.encode(w, s);
}
}
impl<'a, S, Sp: for<'s> Decode<'a, 's, S>, Sy: for<'s> Decode<'a, 's, S>>
Decode<'a, '_, S> for Literal<Sp, Sy> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
Literal {
kind: Decode::decode(r, s),
symbol: Decode::decode(r, s),
suffix: Decode::decode(r, s),
span: Decode::decode(r, s),
}
}
}
impl<Sp: Mark, Sy: Mark> Mark for Literal<Sp, Sy> {
type Unmarked = Literal<Sp::Unmarked, Sy::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
Literal {
kind: Mark::mark(unmarked.kind),
symbol: Mark::mark(unmarked.symbol),
suffix: Mark::mark(unmarked.suffix),
span: Mark::mark(unmarked.span),
}
}
}
impl<Sp: Unmark, Sy: Unmark> Unmark for Literal<Sp, Sy> {
type Unmarked = Literal<Sp::Unmarked, Sy::Unmarked>;
fn unmark(self) -> Self::Unmarked {
Literal {
kind: Unmark::unmark(self.kind),
symbol: Unmark::unmark(self.symbol),
suffix: Unmark::unmark(self.suffix),
span: Unmark::unmark(self.span),
}
}
}compound_traits!(struct Literal<Sp, Sy> { kind, symbol, suffix, span });
470
471#[derive(#[automatically_derived]
impl<TokenStream: ::core::clone::Clone, Span: ::core::clone::Clone,
Symbol: ::core::clone::Clone> ::core::clone::Clone for
TokenTree<TokenStream, Span, Symbol> {
#[inline]
fn clone(&self) -> TokenTree<TokenStream, Span, Symbol> {
match self {
TokenTree::Group(__self_0) =>
TokenTree::Group(::core::clone::Clone::clone(__self_0)),
TokenTree::Punct(__self_0) =>
TokenTree::Punct(::core::clone::Clone::clone(__self_0)),
TokenTree::Ident(__self_0) =>
TokenTree::Ident(::core::clone::Clone::clone(__self_0)),
TokenTree::Literal(__self_0) =>
TokenTree::Literal(::core::clone::Clone::clone(__self_0)),
}
}
}Clone)]
472pub enum TokenTree<TokenStream, Span, Symbol> {
473 Group(Group<TokenStream, Span>),
474 Punct(Punct<Span>),
475 Ident(Ident<Span, Symbol>),
476 Literal(Literal<Span, Symbol>),
477}
478
479impl<S, TokenStream: Encode<S>, Span: Encode<S>, Symbol: Encode<S>> Encode<S>
for TokenTree<TokenStream, Span, Symbol> {
fn encode(self, w: &mut Writer, s: &mut S) {
#[repr(u8)]
enum Tag { Group, Punct, Ident, Literal, }
match self {
TokenTree::Group(tt) => {
(Tag::Group as u8).encode(w, s);
tt.encode(w, s);
}
TokenTree::Punct(tt) => {
(Tag::Punct as u8).encode(w, s);
tt.encode(w, s);
}
TokenTree::Ident(tt) => {
(Tag::Ident as u8).encode(w, s);
tt.encode(w, s);
}
TokenTree::Literal(tt) => {
(Tag::Literal as u8).encode(w, s);
tt.encode(w, s);
}
}
}
}
impl<'a, S, TokenStream: for<'s> Decode<'a, 's, S>,
Span: for<'s> Decode<'a, 's, S>, Symbol: for<'s> Decode<'a, 's, S>>
Decode<'a, '_, S> for TokenTree<TokenStream, Span, Symbol> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
#[allow(non_upper_case_globals)]
mod tag {
#[repr(u8)]
enum Tag { Group, Punct, Ident, Literal, }
pub(crate) const Group: u8 = Tag::Group as u8;
pub(crate) const Punct: u8 = Tag::Punct as u8;
pub(crate) const Ident: u8 = Tag::Ident as u8;
pub(crate) const Literal: u8 = Tag::Literal as u8;
}
match u8::decode(r, s) {
tag::Group => {
let tt = Decode::decode(r, s);
TokenTree::Group(tt)
}
tag::Punct => {
let tt = Decode::decode(r, s);
TokenTree::Punct(tt)
}
tag::Ident => {
let tt = Decode::decode(r, s);
TokenTree::Ident(tt)
}
tag::Literal => {
let tt = Decode::decode(r, s);
TokenTree::Literal(tt)
}
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}
impl<TokenStream: Mark, Span: Mark, Symbol: Mark> Mark for
TokenTree<TokenStream, Span, Symbol> {
type Unmarked =
TokenTree<TokenStream::Unmarked, Span::Unmarked, Symbol::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
match unmarked {
TokenTree::Group(tt) => { TokenTree::Group(Mark::mark(tt)) }
TokenTree::Punct(tt) => { TokenTree::Punct(Mark::mark(tt)) }
TokenTree::Ident(tt) => { TokenTree::Ident(Mark::mark(tt)) }
TokenTree::Literal(tt) => { TokenTree::Literal(Mark::mark(tt)) }
}
}
}
impl<TokenStream: Unmark, Span: Unmark, Symbol: Unmark> Unmark for
TokenTree<TokenStream, Span, Symbol> {
type Unmarked =
TokenTree<TokenStream::Unmarked, Span::Unmarked, Symbol::Unmarked>;
fn unmark(self) -> Self::Unmarked {
match self {
TokenTree::Group(tt) => { TokenTree::Group(Unmark::unmark(tt)) }
TokenTree::Punct(tt) => { TokenTree::Punct(Unmark::unmark(tt)) }
TokenTree::Ident(tt) => { TokenTree::Ident(Unmark::unmark(tt)) }
TokenTree::Literal(tt) => {
TokenTree::Literal(Unmark::unmark(tt))
}
}
}
}compound_traits!(
480 enum TokenTree<TokenStream, Span, Symbol> {
481 Group(tt),
482 Punct(tt),
483 Ident(tt),
484 Literal(tt),
485 }
486);
487
488#[derive(#[automatically_derived]
impl<Span: ::core::clone::Clone> ::core::clone::Clone for Diagnostic<Span> {
#[inline]
fn clone(&self) -> Diagnostic<Span> {
Diagnostic {
level: ::core::clone::Clone::clone(&self.level),
message: ::core::clone::Clone::clone(&self.message),
spans: ::core::clone::Clone::clone(&self.spans),
children: ::core::clone::Clone::clone(&self.children),
}
}
}Clone, #[automatically_derived]
impl<Span: ::core::fmt::Debug> ::core::fmt::Debug for Diagnostic<Span> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Diagnostic",
"level", &self.level, "message", &self.message, "spans",
&self.spans, "children", &&self.children)
}
}Debug)]
489pub struct Diagnostic<Span> {
490 pub level: Level,
491 pub message: String,
492 pub spans: Vec<Span>,
493 pub children: Vec<Diagnostic<Span>>,
494}
495
496impl<S, Span: Encode<S>> Encode<S> for Diagnostic<Span> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.level.encode(w, s);
self.message.encode(w, s);
self.spans.encode(w, s);
self.children.encode(w, s);
}
}
impl<'a, S, Span: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for
Diagnostic<Span> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
Diagnostic {
level: Decode::decode(r, s),
message: Decode::decode(r, s),
spans: Decode::decode(r, s),
children: Decode::decode(r, s),
}
}
}
impl<Span: Mark> Mark for Diagnostic<Span> {
type Unmarked = Diagnostic<Span::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
Diagnostic {
level: Mark::mark(unmarked.level),
message: Mark::mark(unmarked.message),
spans: Mark::mark(unmarked.spans),
children: Mark::mark(unmarked.children),
}
}
}
impl<Span: Unmark> Unmark for Diagnostic<Span> {
type Unmarked = Diagnostic<Span::Unmarked>;
fn unmark(self) -> Self::Unmarked {
Diagnostic {
level: Unmark::unmark(self.level),
message: Unmark::unmark(self.message),
spans: Unmark::unmark(self.spans),
children: Unmark::unmark(self.children),
}
}
}compound_traits!(
497 struct Diagnostic<Span> { level, message, spans, children }
498);
499
500#[derive(#[automatically_derived]
impl<Span: ::core::clone::Clone> ::core::clone::Clone for ExpnGlobals<Span> {
#[inline]
fn clone(&self) -> ExpnGlobals<Span> {
ExpnGlobals {
def_site: ::core::clone::Clone::clone(&self.def_site),
call_site: ::core::clone::Clone::clone(&self.call_site),
mixed_site: ::core::clone::Clone::clone(&self.mixed_site),
}
}
}Clone)]
503pub struct ExpnGlobals<Span> {
504 pub def_site: Span,
505 pub call_site: Span,
506 pub mixed_site: Span,
507}
508
509impl<S, Span: Encode<S>> Encode<S> for ExpnGlobals<Span> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.def_site.encode(w, s);
self.call_site.encode(w, s);
self.mixed_site.encode(w, s);
}
}
impl<'a, S, Span: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for
ExpnGlobals<Span> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
ExpnGlobals {
def_site: Decode::decode(r, s),
call_site: Decode::decode(r, s),
mixed_site: Decode::decode(r, s),
}
}
}
impl<Span: Mark> Mark for ExpnGlobals<Span> {
type Unmarked = ExpnGlobals<Span::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
ExpnGlobals {
def_site: Mark::mark(unmarked.def_site),
call_site: Mark::mark(unmarked.call_site),
mixed_site: Mark::mark(unmarked.mixed_site),
}
}
}
impl<Span: Unmark> Unmark for ExpnGlobals<Span> {
type Unmarked = ExpnGlobals<Span::Unmarked>;
fn unmark(self) -> Self::Unmarked {
ExpnGlobals {
def_site: Unmark::unmark(self.def_site),
call_site: Unmark::unmark(self.call_site),
mixed_site: Unmark::unmark(self.mixed_site),
}
}
}compound_traits!(
510 struct ExpnGlobals<Span> { def_site, call_site, mixed_site }
511);
512
513impl<S, T: Encode<S>> Encode<S> for Range<T> {
fn encode(self, w: &mut Writer, s: &mut S) {
self.start.encode(w, s);
self.end.encode(w, s);
}
}
impl<'a, S, T: for<'s> Decode<'a, 's, S>> Decode<'a, '_, S> for Range<T> {
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
Range { start: Decode::decode(r, s), end: Decode::decode(r, s) }
}
}
impl<T: Mark> Mark for Range<T> {
type Unmarked = Range<T::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
Range {
start: Mark::mark(unmarked.start),
end: Mark::mark(unmarked.end),
}
}
}
impl<T: Unmark> Unmark for Range<T> {
type Unmarked = Range<T::Unmarked>;
fn unmark(self) -> Self::Unmarked {
Range {
start: Unmark::unmark(self.start),
end: Unmark::unmark(self.end),
}
}
}compound_traits!(
514 struct Range<T> { start, end }
515);