File tree 3 files changed +34
-0
lines changed
crates/proc_macro_srv/src
3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ macro_rules! with_api {
112
112
Literal {
113
113
fn drop( $self: $S:: Literal ) ;
114
114
fn clone( $self: & $S:: Literal ) -> $S:: Literal ;
115
+ fn from_str( s: & str ) -> Result <$S:: Literal , ( ) >;
115
116
fn debug_kind( $self: & $S:: Literal ) -> String ;
116
117
fn symbol( $self: & $S:: Literal ) -> String ;
117
118
fn suffix( $self: & $S:: Literal ) -> Option <String >;
@@ -318,6 +319,19 @@ impl<T: Unmark> Unmark for Option<T> {
318
319
}
319
320
}
320
321
322
+ impl < T : Mark , E : Mark > Mark for Result < T , E > {
323
+ type Unmarked = Result < T :: Unmarked , E :: Unmarked > ;
324
+ fn mark ( unmarked : Self :: Unmarked ) -> Self {
325
+ unmarked. map ( T :: mark) . map_err ( E :: mark)
326
+ }
327
+ }
328
+ impl < T : Unmark , E : Unmark > Unmark for Result < T , E > {
329
+ type Unmarked = Result < T :: Unmarked , E :: Unmarked > ;
330
+ fn unmark ( self ) -> Self :: Unmarked {
331
+ self . map ( T :: unmark) . map_err ( E :: unmark)
332
+ }
333
+ }
334
+
321
335
macro_rules! mark_noop {
322
336
( $( $ty: ty) ,* $( , ) ?) => {
323
337
$(
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ pub struct LexError {
37
37
_inner : ( ) ,
38
38
}
39
39
40
+ impl LexError {
41
+ fn new ( ) -> Self {
42
+ LexError { _inner : ( ) }
43
+ }
44
+ }
45
+
40
46
impl TokenStream {
41
47
/// Returns an empty `TokenStream` containing no token trees.
42
48
pub fn new ( ) -> TokenStream {
@@ -925,6 +931,17 @@ impl fmt::Debug for Literal {
925
931
}
926
932
}
927
933
934
+ impl FromStr for Literal {
935
+ type Err = LexError ;
936
+
937
+ fn from_str ( src : & str ) -> Result < Self , LexError > {
938
+ match bridge:: client:: Literal :: from_str ( src) {
939
+ Ok ( literal) => Ok ( Literal ( literal) ) ,
940
+ Err ( ( ) ) => Err ( LexError :: new ( ) ) ,
941
+ }
942
+ }
943
+ }
944
+
928
945
pub mod tracked_env {
929
946
use std:: env:: { self , VarError } ;
930
947
use std:: ffi:: OsStr ;
Original file line number Diff line number Diff line change @@ -521,6 +521,9 @@ impl server::Ident for Rustc {
521
521
}
522
522
523
523
impl server:: Literal for Rustc {
524
+ fn from_str ( & mut self , s : & str ) -> Result < Self :: Literal , ( ) > {
525
+ unimplemented ! ( )
526
+ }
524
527
fn debug_kind ( & mut self , _literal : & Self :: Literal ) -> String {
525
528
// r-a: debug_kind and suffix are unsupported; corresponding client code has been changed to not call these.
526
529
// They must still be present to be ABI-compatible and work with upstream proc_macro.
You can’t perform that action at this time.
0 commit comments