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