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 injected_env_var(var: &str) -> Option<String>;
37 fn track_env_var(var: &str, value: Option<&str>);
38 fn track_path(path: &str);
39 fn literal_from_str(s: &str) -> Result<Literal<$Span, $Symbol>, String>;
40 fn emit_diagnostic(diagnostic: Diagnostic<$Span>);
41
42 fn ts_drop(stream: $TokenStream);
43 fn ts_clone(stream: &$TokenStream) -> $TokenStream;
44 fn ts_is_empty(stream: &$TokenStream) -> bool;
45 fn ts_expand_expr(stream: &$TokenStream) -> Result<$TokenStream, ()>;
46 fn ts_from_str(src: &str) -> Result<$TokenStream, String>;
47 fn ts_to_string(stream: &$TokenStream) -> String;
48 fn ts_from_token_tree(
49 tree: TokenTree<$TokenStream, $Span, $Symbol>,
50 ) -> $TokenStream;
51 fn ts_concat_trees(
52 base: Option<$TokenStream>,
53 trees: Vec<TokenTree<$TokenStream, $Span, $Symbol>>,
54 ) -> $TokenStream;
55 fn ts_concat_streams(
56 base: Option<$TokenStream>,
57 streams: Vec<$TokenStream>,
58 ) -> $TokenStream;
59 fn ts_into_trees(
60 stream: $TokenStream
61 ) -> Vec<TokenTree<$TokenStream, $Span, $Symbol>>;
62
63 fn span_debug(span: $Span) -> String;
64 fn span_parent(span: $Span) -> Option<$Span>;
65 fn span_source(span: $Span) -> $Span;
66 fn span_byte_range(span: $Span) -> Range<usize>;
67 fn span_start(span: $Span) -> $Span;
68 fn span_end(span: $Span) -> $Span;
69 fn span_line(span: $Span) -> usize;
70 fn span_column(span: $Span) -> usize;
71 fn span_file(span: $Span) -> String;
72 fn span_local_file(span: $Span) -> Option<String>;
73 fn span_join(span: $Span, other: $Span) -> Option<$Span>;
74 fn span_subspan(span: $Span, start: Bound<usize>, end: Bound<usize>) -> Option<$Span>;
75 fn span_resolved_at(span: $Span, at: $Span) -> $Span;
76 fn span_source_text(span: $Span) -> Option<String>;
77 fn span_save_span(span: $Span) -> usize;
78 fn span_recover_proc_macro_span(id: usize) -> $Span;
79
80 fn symbol_normalize_and_validate_ident(string: &str) -> Result<$Symbol, ()>;
81 }
82 };
83}
84
85pub(crate) struct Methods;
86
87#[allow(unsafe_code)]
88mod arena;
89#[allow(unsafe_code)]
90mod buffer;
91#[deny(unsafe_code)]
92pub mod client;
93#[allow(unsafe_code)]
94mod closure;
95#[forbid(unsafe_code)]
96mod fxhash;
97#[forbid(unsafe_code)]
98mod handle;
99#[macro_use]
100#[forbid(unsafe_code)]
101mod rpc;
102#[forbid(unsafe_code)]
103mod panic_message;
104#[allow(unsafe_code)]
105mod selfless_reify;
106#[forbid(unsafe_code)]
107pub mod server;
108#[allow(unsafe_code)]
109mod symbol;
110
111use buffer::Buffer;
112pub use panic_message::PanicMessage;
113use rpc::{Decode, Encode};
114
115#[repr(C)]
121pub struct BridgeConfig<'a> {
122 input: Buffer,
124
125 dispatch: closure::Closure<'a>,
127
128 force_show_panics: bool,
130}
131
132impl !Send for BridgeConfig<'_> {}
133impl !Sync for BridgeConfig<'_> {}
134
135macro_rules! declare_tags {
136 (
137 $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)*
138 ) => {
139 #[allow(non_camel_case_types)]
140 pub(super) enum ApiTags {
141 $($method),*
142 }
143 rpc_encode_decode!(enum ApiTags { $($method),* });
144 }
145}
146#[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 {
#[inline]
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 {
#[inline]
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, __, __, __);
147
148trait Mark {
153 type Unmarked;
154 fn mark(unmarked: Self::Unmarked) -> Self;
155 fn unmark(self) -> Self::Unmarked;
156}
157
158#[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_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)]
159struct Marked<T, M> {
160 value: T,
161 _marker: marker::PhantomData<M>,
162}
163
164impl<T, M> Mark for Marked<T, M> {
165 type Unmarked = T;
166 #[inline]
167 fn mark(unmarked: Self::Unmarked) -> Self {
168 Marked { value: unmarked, _marker: marker::PhantomData }
169 }
170 #[inline]
171 fn unmark(self) -> Self::Unmarked {
172 self.value
173 }
174}
175impl<'a, T> Mark for &'a Marked<T, client::TokenStream> {
176 type Unmarked = &'a T;
177 fn mark(_: Self::Unmarked) -> Self {
178 ::core::panicking::panic("internal error: entered unreachable code")unreachable!()
179 }
180 #[inline]
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 #[inline]
189 fn mark(unmarked: Self::Unmarked) -> Self {
190 unmarked.into_iter().map(T::mark).collect()
192 }
193 #[inline]
194 fn unmark(self) -> Self::Unmarked {
195 self.into_iter().map(T::unmark).collect()
197 }
198}
199
200macro_rules! mark_noop {
201 ($($ty:ty),* $(,)?) => {
202 $(
203 impl Mark for $ty {
204 type Unmarked = Self;
205 #[inline]
206 fn mark(unmarked: Self::Unmarked) -> Self {
207 unmarked
208 }
209 #[inline]
210 fn unmark(self) -> Self::Unmarked {
211 self
212 }
213 }
214 )*
215 }
216}
217impl Mark for Range<usize> {
type Unmarked = Self;
#[inline]
fn mark(unmarked: Self::Unmarked) -> Self { unmarked }
#[inline]
fn unmark(self) -> Self::Unmarked { self }
}mark_noop! {
218 (),
219 bool,
220 &'_ str,
221 String,
222 u8,
223 usize,
224 Delimiter,
225 LitKind,
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]
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_fields_are_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)]
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) -> 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)]
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) -> 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)]
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) -> 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)]
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) -> 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_fields_are_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)]
387pub struct Ident<Span, Symbol> {
388 pub sym: Symbol,
389 pub is_raw: bool,
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.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> {
#[inline]
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>;
#[inline]
fn mark(unmarked: Self::Unmarked) -> Self {
Ident {
sym: Mark::mark(unmarked.sym),
is_raw: Mark::mark(unmarked.is_raw),
span: Mark::mark(unmarked.span),
}
}
#[inline]
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 });
394
395#[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_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::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)]
396pub struct Literal<Span, Symbol> {
397 pub kind: LitKind,
398 pub symbol: Symbol,
399 pub suffix: Option<Symbol>,
400 pub span: Span,
401}
402
403impl<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 });
404
405#[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)]
406pub enum TokenTree<TokenStream, Span, Symbol> {
407 Group(Group<TokenStream, Span>),
408 Punct(Punct<Span>),
409 Ident(Ident<Span, Symbol>),
410 Literal(Literal<Span, Symbol>),
411}
412
413#[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!(
414 enum TokenTree<TokenStream, Span, Symbol> {
415 Group(tt),
416 Punct(tt),
417 Ident(tt),
418 Literal(tt),
419 }
420);
421
422#[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)]
423pub struct Diagnostic<Span> {
424 pub level: Level,
425 pub message: String,
426 pub spans: Vec<Span>,
427 pub children: Vec<Diagnostic<Span>>,
428}
429
430impl<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!(
431 struct Diagnostic<Span> { level, message, spans, children }
432);
433
434#[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)]
437pub struct ExpnGlobals<Span> {
438 pub def_site: Span,
439 pub call_site: Span,
440 pub mixed_site: Span,
441}
442
443impl<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!(
444 struct ExpnGlobals<Span> { def_site, call_site, mixed_site }
445);
446
447impl<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!(
448 struct Range<T> { start, end }
449);