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