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};
17
18macro_rules! with_api {
39 ($S:ident, $m:ident) => {
40 $m! {
41 fn injected_env_var(var: &str) -> Option<String>;
42 fn track_env_var(var: &str, value: Option<&str>);
43 fn track_path(path: &str);
44 fn literal_from_str(s: &str) -> Result<Literal<$S::Span, $S::Symbol>, ()>;
45 fn emit_diagnostic(diagnostic: Diagnostic<$S::Span>);
46
47 fn ts_drop(stream: $S::TokenStream);
48 fn ts_clone(stream: &$S::TokenStream) -> $S::TokenStream;
49 fn ts_is_empty(stream: &$S::TokenStream) -> bool;
50 fn ts_expand_expr(stream: &$S::TokenStream) -> Result<$S::TokenStream, ()>;
51 fn ts_from_str(src: &str) -> $S::TokenStream;
52 fn ts_to_string(stream: &$S::TokenStream) -> String;
53 fn ts_from_token_tree(
54 tree: TokenTree<$S::TokenStream, $S::Span, $S::Symbol>,
55 ) -> $S::TokenStream;
56 fn ts_concat_trees(
57 base: Option<$S::TokenStream>,
58 trees: Vec<TokenTree<$S::TokenStream, $S::Span, $S::Symbol>>,
59 ) -> $S::TokenStream;
60 fn ts_concat_streams(
61 base: Option<$S::TokenStream>,
62 streams: Vec<$S::TokenStream>,
63 ) -> $S::TokenStream;
64 fn ts_into_trees(
65 stream: $S::TokenStream
66 ) -> Vec<TokenTree<$S::TokenStream, $S::Span, $S::Symbol>>;
67
68 fn span_debug(span: $S::Span) -> String;
69 fn span_parent(span: $S::Span) -> Option<$S::Span>;
70 fn span_source(span: $S::Span) -> $S::Span;
71 fn span_byte_range(span: $S::Span) -> Range<usize>;
72 fn span_start(span: $S::Span) -> $S::Span;
73 fn span_end(span: $S::Span) -> $S::Span;
74 fn span_line(span: $S::Span) -> usize;
75 fn span_column(span: $S::Span) -> usize;
76 fn span_file(span: $S::Span) -> String;
77 fn span_local_file(span: $S::Span) -> Option<String>;
78 fn span_join(span: $S::Span, other: $S::Span) -> Option<$S::Span>;
79 fn span_subspan(span: $S::Span, start: Bound<usize>, end: Bound<usize>) -> Option<$S::Span>;
80 fn span_resolved_at(span: $S::Span, at: $S::Span) -> $S::Span;
81 fn span_source_text(span: $S::Span) -> Option<String>;
82 fn span_save_span(span: $S::Span) -> usize;
83 fn span_recover_proc_macro_span(id: usize) -> $S::Span;
84
85 fn symbol_normalize_and_validate_ident(string: &str) -> Result<$S::Symbol, ()>;
86 }
87 };
88}
89
90pub(crate) struct Methods;
91
92#[allow(unsafe_code)]
93mod arena;
94#[allow(unsafe_code)]
95mod buffer;
96#[deny(unsafe_code)]
97pub mod client;
98#[allow(unsafe_code)]
99mod closure;
100#[forbid(unsafe_code)]
101mod fxhash;
102#[forbid(unsafe_code)]
103mod handle;
104#[macro_use]
105#[forbid(unsafe_code)]
106mod rpc;
107#[allow(unsafe_code)]
108mod selfless_reify;
109#[forbid(unsafe_code)]
110pub mod server;
111#[allow(unsafe_code)]
112mod symbol;
113
114use buffer::Buffer;
115pub use rpc::PanicMessage;
116use rpc::{Decode, Encode};
117
118#[repr(C)]
124pub struct BridgeConfig<'a> {
125 input: Buffer,
127
128 dispatch: closure::Closure<'a, Buffer, Buffer>,
130
131 force_show_panics: bool,
133}
134
135impl !Send for BridgeConfig<'_> {}
136impl !Sync for BridgeConfig<'_> {}
137
138macro_rules! declare_tags {
139 (
140 $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)*;)*
141 ) => {
142 #[allow(non_camel_case_types)]
143 pub(super) enum ApiTags {
144 $($method),*
145 }
146 rpc_encode_decode!(enum ApiTags { $($method),* });
147 }
148}
149#[allow(non_camel_case_types)]
pub(super) enum ApiTags {
injected_env_var,
track_env_var,
track_path,
literal_from_str,
emit_diagnostic,
ts_drop,
ts_clone,
ts_is_empty,
ts_expand_expr,
ts_from_str,
ts_to_string,
ts_from_token_tree,
ts_concat_trees,
ts_concat_streams,
ts_into_trees,
span_debug,
span_parent,
span_source,
span_byte_range,
span_start,
span_end,
span_line,
span_column,
span_file,
span_local_file,
span_join,
span_subspan,
span_resolved_at,
span_source_text,
span_save_span,
span_recover_proc_macro_span,
symbol_normalize_and_validate_ident,
}
impl<S> Encode<S> for ApiTags {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[repr(u8)]
enum Tag {
injected_env_var,
track_env_var,
track_path,
literal_from_str,
emit_diagnostic,
ts_drop,
ts_clone,
ts_is_empty,
ts_expand_expr,
ts_from_str,
ts_to_string,
ts_from_token_tree,
ts_concat_trees,
ts_concat_streams,
ts_into_trees,
span_debug,
span_parent,
span_source,
span_byte_range,
span_start,
span_end,
span_line,
span_column,
span_file,
span_local_file,
span_join,
span_subspan,
span_resolved_at,
span_source_text,
span_save_span,
span_recover_proc_macro_span,
symbol_normalize_and_validate_ident,
}
match self {
ApiTags::injected_env_var => {
(Tag::injected_env_var as u8).encode(w, s);
}
ApiTags::track_env_var => {
(Tag::track_env_var as u8).encode(w, s);
}
ApiTags::track_path => { (Tag::track_path as u8).encode(w, s); }
ApiTags::literal_from_str => {
(Tag::literal_from_str as u8).encode(w, s);
}
ApiTags::emit_diagnostic => {
(Tag::emit_diagnostic as u8).encode(w, s);
}
ApiTags::ts_drop => { (Tag::ts_drop as u8).encode(w, s); }
ApiTags::ts_clone => { (Tag::ts_clone as u8).encode(w, s); }
ApiTags::ts_is_empty => { (Tag::ts_is_empty as u8).encode(w, s); }
ApiTags::ts_expand_expr => {
(Tag::ts_expand_expr as u8).encode(w, s);
}
ApiTags::ts_from_str => { (Tag::ts_from_str as u8).encode(w, s); }
ApiTags::ts_to_string => {
(Tag::ts_to_string as u8).encode(w, s);
}
ApiTags::ts_from_token_tree => {
(Tag::ts_from_token_tree as u8).encode(w, s);
}
ApiTags::ts_concat_trees => {
(Tag::ts_concat_trees as u8).encode(w, s);
}
ApiTags::ts_concat_streams => {
(Tag::ts_concat_streams as u8).encode(w, s);
}
ApiTags::ts_into_trees => {
(Tag::ts_into_trees as u8).encode(w, s);
}
ApiTags::span_debug => { (Tag::span_debug as u8).encode(w, s); }
ApiTags::span_parent => { (Tag::span_parent as u8).encode(w, s); }
ApiTags::span_source => { (Tag::span_source as u8).encode(w, s); }
ApiTags::span_byte_range => {
(Tag::span_byte_range as u8).encode(w, s);
}
ApiTags::span_start => { (Tag::span_start as u8).encode(w, s); }
ApiTags::span_end => { (Tag::span_end as u8).encode(w, s); }
ApiTags::span_line => { (Tag::span_line as u8).encode(w, s); }
ApiTags::span_column => { (Tag::span_column as u8).encode(w, s); }
ApiTags::span_file => { (Tag::span_file as u8).encode(w, s); }
ApiTags::span_local_file => {
(Tag::span_local_file as u8).encode(w, s);
}
ApiTags::span_join => { (Tag::span_join as u8).encode(w, s); }
ApiTags::span_subspan => {
(Tag::span_subspan as u8).encode(w, s);
}
ApiTags::span_resolved_at => {
(Tag::span_resolved_at as u8).encode(w, s);
}
ApiTags::span_source_text => {
(Tag::span_source_text as u8).encode(w, s);
}
ApiTags::span_save_span => {
(Tag::span_save_span as u8).encode(w, s);
}
ApiTags::span_recover_proc_macro_span => {
(Tag::span_recover_proc_macro_span as u8).encode(w, s);
}
ApiTags::symbol_normalize_and_validate_ident => {
(Tag::symbol_normalize_and_validate_ident as u8).encode(w, s);
}
}
}
}
impl<'a, S> Decode<'a, '_, S> for ApiTags {
fn decode(r: &mut &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
mod tag {
#[repr(u8)]
enum Tag {
injected_env_var,
track_env_var,
track_path,
literal_from_str,
emit_diagnostic,
ts_drop,
ts_clone,
ts_is_empty,
ts_expand_expr,
ts_from_str,
ts_to_string,
ts_from_token_tree,
ts_concat_trees,
ts_concat_streams,
ts_into_trees,
span_debug,
span_parent,
span_source,
span_byte_range,
span_start,
span_end,
span_line,
span_column,
span_file,
span_local_file,
span_join,
span_subspan,
span_resolved_at,
span_source_text,
span_save_span,
span_recover_proc_macro_span,
symbol_normalize_and_validate_ident,
}
pub(crate) const injected_env_var: u8 =
Tag::injected_env_var as u8;
pub(crate) const track_env_var: u8 = Tag::track_env_var as u8;
pub(crate) const track_path: u8 = Tag::track_path as u8;
pub(crate) const literal_from_str: u8 =
Tag::literal_from_str as u8;
pub(crate) const emit_diagnostic: u8 = Tag::emit_diagnostic as u8;
pub(crate) const ts_drop: u8 = Tag::ts_drop as u8;
pub(crate) const ts_clone: u8 = Tag::ts_clone as u8;
pub(crate) const ts_is_empty: u8 = Tag::ts_is_empty as u8;
pub(crate) const ts_expand_expr: u8 = Tag::ts_expand_expr as u8;
pub(crate) const ts_from_str: u8 = Tag::ts_from_str as u8;
pub(crate) const ts_to_string: u8 = Tag::ts_to_string as u8;
pub(crate) const ts_from_token_tree: u8 =
Tag::ts_from_token_tree as u8;
pub(crate) const ts_concat_trees: u8 = Tag::ts_concat_trees as u8;
pub(crate) const ts_concat_streams: u8 =
Tag::ts_concat_streams as u8;
pub(crate) const ts_into_trees: u8 = Tag::ts_into_trees as u8;
pub(crate) const span_debug: u8 = Tag::span_debug as u8;
pub(crate) const span_parent: u8 = Tag::span_parent as u8;
pub(crate) const span_source: u8 = Tag::span_source as u8;
pub(crate) const span_byte_range: u8 = Tag::span_byte_range as u8;
pub(crate) const span_start: u8 = Tag::span_start as u8;
pub(crate) const span_end: u8 = Tag::span_end as u8;
pub(crate) const span_line: u8 = Tag::span_line as u8;
pub(crate) const span_column: u8 = Tag::span_column as u8;
pub(crate) const span_file: u8 = Tag::span_file as u8;
pub(crate) const span_local_file: u8 = Tag::span_local_file as u8;
pub(crate) const span_join: u8 = Tag::span_join as u8;
pub(crate) const span_subspan: u8 = Tag::span_subspan as u8;
pub(crate) const span_resolved_at: u8 =
Tag::span_resolved_at as u8;
pub(crate) const span_source_text: u8 =
Tag::span_source_text as u8;
pub(crate) const span_save_span: u8 = Tag::span_save_span as u8;
pub(crate) const span_recover_proc_macro_span: u8 =
Tag::span_recover_proc_macro_span as u8;
pub(crate) const symbol_normalize_and_validate_ident: u8 =
Tag::symbol_normalize_and_validate_ident as u8;
}
match u8::decode(r, s) {
tag::injected_env_var => { ApiTags::injected_env_var }
tag::track_env_var => { ApiTags::track_env_var }
tag::track_path => { ApiTags::track_path }
tag::literal_from_str => { ApiTags::literal_from_str }
tag::emit_diagnostic => { ApiTags::emit_diagnostic }
tag::ts_drop => { ApiTags::ts_drop }
tag::ts_clone => { ApiTags::ts_clone }
tag::ts_is_empty => { ApiTags::ts_is_empty }
tag::ts_expand_expr => { ApiTags::ts_expand_expr }
tag::ts_from_str => { ApiTags::ts_from_str }
tag::ts_to_string => { ApiTags::ts_to_string }
tag::ts_from_token_tree => { ApiTags::ts_from_token_tree }
tag::ts_concat_trees => { ApiTags::ts_concat_trees }
tag::ts_concat_streams => { ApiTags::ts_concat_streams }
tag::ts_into_trees => { ApiTags::ts_into_trees }
tag::span_debug => { ApiTags::span_debug }
tag::span_parent => { ApiTags::span_parent }
tag::span_source => { ApiTags::span_source }
tag::span_byte_range => { ApiTags::span_byte_range }
tag::span_start => { ApiTags::span_start }
tag::span_end => { ApiTags::span_end }
tag::span_line => { ApiTags::span_line }
tag::span_column => { ApiTags::span_column }
tag::span_file => { ApiTags::span_file }
tag::span_local_file => { ApiTags::span_local_file }
tag::span_join => { ApiTags::span_join }
tag::span_subspan => { ApiTags::span_subspan }
tag::span_resolved_at => { ApiTags::span_resolved_at }
tag::span_source_text => { ApiTags::span_source_text }
tag::span_save_span => { ApiTags::span_save_span }
tag::span_recover_proc_macro_span => {
ApiTags::span_recover_proc_macro_span
}
tag::symbol_normalize_and_validate_ident => {
ApiTags::symbol_normalize_and_validate_ident
}
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
}with_api!(self, declare_tags);
150
151trait Mark {
156 type Unmarked;
157 fn mark(unmarked: Self::Unmarked) -> Self;
158 fn unmark(self) -> Self::Unmarked;
159}
160
161#[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)]
162struct Marked<T, M> {
163 value: T,
164 _marker: marker::PhantomData<M>,
165}
166
167impl<T, M> Mark for Marked<T, M> {
168 type Unmarked = T;
169 fn mark(unmarked: Self::Unmarked) -> Self {
170 Marked { value: unmarked, _marker: marker::PhantomData }
171 }
172 fn unmark(self) -> Self::Unmarked {
173 self.value
174 }
175}
176impl<'a, T, M> Mark for &'a Marked<T, M> {
177 type Unmarked = &'a T;
178 fn mark(_: Self::Unmarked) -> Self {
179 ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
180 }
181 fn unmark(self) -> Self::Unmarked {
182 &self.value
183 }
184}
185
186impl<T: Mark> Mark for Vec<T> {
187 type Unmarked = Vec<T::Unmarked>;
188 fn mark(unmarked: Self::Unmarked) -> Self {
189 unmarked.into_iter().map(T::mark).collect()
191 }
192 fn unmark(self) -> Self::Unmarked {
193 self.into_iter().map(T::unmark).collect()
195 }
196}
197
198macro_rules! mark_noop {
199 ($($ty:ty),* $(,)?) => {
200 $(
201 impl Mark for $ty {
202 type Unmarked = Self;
203 fn mark(unmarked: Self::Unmarked) -> Self {
204 unmarked
205 }
206 fn unmark(self) -> Self::Unmarked {
207 self
208 }
209 }
210 )*
211 }
212}
213impl Mark for Level {
type Unmarked = Self;
fn mark(unmarked: Self::Unmarked) -> Self { unmarked }
fn unmark(self) -> Self::Unmarked { self }
}mark_noop! {
214 (),
215 bool,
216 &'_ str,
217 String,
218 u8,
219 usize,
220 Delimiter,
221 LitKind,
222 Level,
223}
224
225impl<S> Encode<S> for Delimiter {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[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 &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
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!(
226 enum Delimiter {
227 Parenthesis,
228 Brace,
229 Bracket,
230 None,
231 }
232);
233impl<S> Encode<S> for Level {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[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 &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
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!(
234 enum Level {
235 Error,
236 Warning,
237 Note,
238 Help,
239 }
240);
241
242#[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)]
243pub enum LitKind {
244 Byte,
245 Char,
246 Integer,
247 Float,
248 Str,
249 StrRaw(u8),
250 ByteStr,
251 ByteStrRaw(u8),
252 CStr,
253 CStrRaw(u8),
254 ErrWithGuar,
259}
260
261impl<S> Encode<S> for LitKind {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[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 &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
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!(
262 enum LitKind {
263 Byte,
264 Char,
265 Integer,
266 Float,
267 Str,
268 StrRaw(n),
269 ByteStr,
270 ByteStrRaw(n),
271 CStr,
272 CStrRaw(n),
273 ErrWithGuar,
274 }
275);
276
277macro_rules! mark_compound {
278 (struct $name:ident <$($T:ident),+> { $($field:ident),* $(,)? }) => {
279 impl<$($T: Mark),+> Mark for $name <$($T),+> {
280 type Unmarked = $name <$($T::Unmarked),+>;
281 fn mark(unmarked: Self::Unmarked) -> Self {
282 $name {
283 $($field: Mark::mark(unmarked.$field)),*
284 }
285 }
286 fn unmark(self) -> Self::Unmarked {
287 $name {
288 $($field: Mark::unmark(self.$field)),*
289 }
290 }
291 }
292 };
293 (enum $name:ident <$($T:ident),+> { $($variant:ident $(($field:ident))?),* $(,)? }) => {
294 impl<$($T: Mark),+> Mark for $name <$($T),+> {
295 type Unmarked = $name <$($T::Unmarked),+>;
296 fn mark(unmarked: Self::Unmarked) -> Self {
297 match unmarked {
298 $($name::$variant $(($field))? => {
299 $name::$variant $((Mark::mark($field)))?
300 })*
301 }
302 }
303 fn unmark(self) -> Self::Unmarked {
304 match self {
305 $($name::$variant $(($field))? => {
306 $name::$variant $((Mark::unmark($field)))?
307 })*
308 }
309 }
310 }
311 }
312}
313
314macro_rules! compound_traits {
315 ($($t:tt)*) => {
316 rpc_encode_decode!($($t)*);
317 mark_compound!($($t)*);
318 };
319}
320
321impl<S, T: Encode<S>> Encode<S> for Bound<T> {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[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 &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
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 }
}
}
fn unmark(self) -> Self::Unmarked {
match self {
Bound::Included(x) => { Bound::Included(Mark::unmark(x)) }
Bound::Excluded(x) => { Bound::Excluded(Mark::unmark(x)) }
Bound::Unbounded => { Bound::Unbounded }
}
}
}compound_traits!(
322 enum Bound<T> {
323 Included(x),
324 Excluded(x),
325 Unbounded,
326 }
327);
328
329impl<S, T: Encode<S>> Encode<S> for Option<T> {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[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 &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
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 }
}
}
fn unmark(self) -> Self::Unmarked {
match self {
Option::Some(t) => { Option::Some(Mark::unmark(t)) }
Option::None => { Option::None }
}
}
}compound_traits!(
330 enum Option<T> {
331 Some(t),
332 None,
333 }
334);
335
336impl<S, T: Encode<S>, E: Encode<S>> Encode<S> for Result<T, E> {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[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 &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
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)) }
}
}
fn unmark(self) -> Self::Unmarked {
match self {
Result::Ok(t) => { Result::Ok(Mark::unmark(t)) }
Result::Err(e) => { Result::Err(Mark::unmark(e)) }
}
}
}compound_traits!(
337 enum Result<T, E> {
338 Ok(t),
339 Err(e),
340 }
341);
342
343#[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)]
344pub struct DelimSpan<Span> {
345 pub open: Span,
346 pub close: Span,
347 pub entire: Span,
348}
349
350impl<Span: Copy> DelimSpan<Span> {
351 pub fn from_single(span: Span) -> Self {
352 DelimSpan { open: span, close: span, entire: span }
353 }
354}
355
356impl<S, Span: Encode<S>> Encode<S> for DelimSpan<Span> {
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
DelimSpan {
open: Mark::unmark(self.open),
close: Mark::unmark(self.close),
entire: Mark::unmark(self.entire),
}
}
}compound_traits!(struct DelimSpan<Span> { open, close, entire });
357
358#[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)]
359pub struct Group<TokenStream, Span> {
360 pub delimiter: Delimiter,
361 pub stream: Option<TokenStream>,
362 pub span: DelimSpan<Span>,
363}
364
365impl<S, TokenStream: Encode<S>, Span: Encode<S>> Encode<S> for
Group<TokenStream, Span> {
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
Group {
delimiter: Mark::unmark(self.delimiter),
stream: Mark::unmark(self.stream),
span: Mark::unmark(self.span),
}
}
}compound_traits!(struct Group<TokenStream, Span> { delimiter, stream, span });
366
367#[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)]
368pub struct Punct<Span> {
369 pub ch: u8,
370 pub joint: bool,
371 pub span: Span,
372}
373
374impl<S, Span: Encode<S>> Encode<S> for Punct<Span> {
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
Punct {
ch: Mark::unmark(self.ch),
joint: Mark::unmark(self.joint),
span: Mark::unmark(self.span),
}
}
}compound_traits!(struct Punct<Span> { ch, joint, span });
375
376#[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)]
377pub struct Ident<Span, Symbol> {
378 pub sym: Symbol,
379 pub is_raw: bool,
380 pub span: Span,
381}
382
383impl<S, Span: Encode<S>, Symbol: Encode<S>> Encode<S> for Ident<Span, Symbol>
{
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
Ident {
sym: Mark::unmark(self.sym),
is_raw: Mark::unmark(self.is_raw),
span: Mark::unmark(self.span),
}
}
}compound_traits!(struct Ident<Span, Symbol> { sym, is_raw, span });
384
385#[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)]
386pub struct Literal<Span, Symbol> {
387 pub kind: LitKind,
388 pub symbol: Symbol,
389 pub suffix: Option<Symbol>,
390 pub span: Span,
391}
392
393impl<S, Sp: Encode<S>, Sy: Encode<S>> Encode<S> for Literal<Sp, Sy> {
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
Literal {
kind: Mark::unmark(self.kind),
symbol: Mark::unmark(self.symbol),
suffix: Mark::unmark(self.suffix),
span: Mark::unmark(self.span),
}
}
}compound_traits!(struct Literal<Sp, Sy> { kind, symbol, suffix, span });
394
395#[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)]
396pub enum TokenTree<TokenStream, Span, Symbol> {
397 Group(Group<TokenStream, Span>),
398 Punct(Punct<Span>),
399 Ident(Ident<Span, Symbol>),
400 Literal(Literal<Span, Symbol>),
401}
402
403impl<S, TokenStream: Encode<S>, Span: Encode<S>, Symbol: Encode<S>> Encode<S>
for TokenTree<TokenStream, Span, Symbol> {
fn encode(self, w: &mut Buffer, s: &mut S) {
#[allow(non_camel_case_types)]
#[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 &'a [u8], s: &mut S) -> Self {
#[allow(non_upper_case_globals, non_camel_case_types)]
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)) }
}
}
fn unmark(self) -> Self::Unmarked {
match self {
TokenTree::Group(tt) => { TokenTree::Group(Mark::unmark(tt)) }
TokenTree::Punct(tt) => { TokenTree::Punct(Mark::unmark(tt)) }
TokenTree::Ident(tt) => { TokenTree::Ident(Mark::unmark(tt)) }
TokenTree::Literal(tt) => { TokenTree::Literal(Mark::unmark(tt)) }
}
}
}compound_traits!(
404 enum TokenTree<TokenStream, Span, Symbol> {
405 Group(tt),
406 Punct(tt),
407 Ident(tt),
408 Literal(tt),
409 }
410);
411
412#[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)]
413pub struct Diagnostic<Span> {
414 pub level: Level,
415 pub message: String,
416 pub spans: Vec<Span>,
417 pub children: Vec<Diagnostic<Span>>,
418}
419
420impl<S, Span: Encode<S>> Encode<S> for Diagnostic<Span> {
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
Diagnostic {
level: Mark::unmark(self.level),
message: Mark::unmark(self.message),
spans: Mark::unmark(self.spans),
children: Mark::unmark(self.children),
}
}
}compound_traits!(
421 struct Diagnostic<Span> { level, message, spans, children }
422);
423
424#[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)]
427pub struct ExpnGlobals<Span> {
428 pub def_site: Span,
429 pub call_site: Span,
430 pub mixed_site: Span,
431}
432
433impl<S, Span: Encode<S>> Encode<S> for ExpnGlobals<Span> {
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
ExpnGlobals {
def_site: Mark::unmark(self.def_site),
call_site: Mark::unmark(self.call_site),
mixed_site: Mark::unmark(self.mixed_site),
}
}
}compound_traits!(
434 struct ExpnGlobals<Span> { def_site, call_site, mixed_site }
435);
436
437impl<S, T: Encode<S>> Encode<S> for Range<T> {
fn encode(self, w: &mut Buffer, 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 &'a [u8], 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),
}
}
fn unmark(self) -> Self::Unmarked {
Range { start: Mark::unmark(self.start), end: Mark::unmark(self.end) }
}
}compound_traits!(
438 struct Range<T> { start, end }
439);