@@ -3,11 +3,11 @@ use crate::attr;
3
3
use crate :: source_map:: { dummy_spanned, respan, Spanned } ;
4
4
use crate :: ext:: base:: ExtCtxt ;
5
5
use crate :: ptr:: P ;
6
- use crate :: symbol:: { Symbol , kw } ;
6
+ use crate :: symbol:: { kw , sym , Symbol } ;
7
7
use crate :: ThinVec ;
8
8
9
9
use rustc_target:: spec:: abi:: Abi ;
10
- use syntax_pos:: { Pos , Span , DUMMY_SP } ;
10
+ use syntax_pos:: { Pos , Span } ;
11
11
12
12
pub trait AstBuilder {
13
13
// paths
@@ -49,7 +49,6 @@ pub trait AstBuilder {
49
49
ty : P < ast:: Ty > ,
50
50
mutbl : ast:: Mutability ) -> P < ast:: Ty > ;
51
51
52
- fn ty_option ( & self , ty : P < ast:: Ty > ) -> P < ast:: Ty > ;
53
52
fn ty_infer ( & self , sp : Span ) -> P < ast:: Ty > ;
54
53
55
54
fn typaram ( & self ,
@@ -425,15 +424,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
425
424
ast:: TyKind :: Ptr ( self . ty_mt ( ty, mutbl) ) )
426
425
}
427
426
428
- fn ty_option ( & self , ty : P < ast:: Ty > ) -> P < ast:: Ty > {
429
- self . ty_path (
430
- self . path_all ( DUMMY_SP ,
431
- true ,
432
- self . std_path ( & [ "option" , "Option" ] ) ,
433
- vec ! [ ast:: GenericArg :: Type ( ty) ] ,
434
- Vec :: new ( ) ) )
435
- }
436
-
437
427
fn ty_infer ( & self , span : Span ) -> P < ast:: Ty > {
438
428
self . ty ( span, ast:: TyKind :: Infer )
439
429
}
@@ -735,7 +725,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
735
725
self . expr ( sp, ast:: ExprKind :: Array ( exprs) )
736
726
}
737
727
fn expr_vec_ng ( & self , sp : Span ) -> P < ast:: Expr > {
738
- self . expr_call_global ( sp, self . std_path ( & [ " vec" , " Vec" , " new" ] ) ,
728
+ self . expr_call_global ( sp, self . std_path ( & [ sym :: vec, sym :: Vec , sym :: new] ) ,
739
729
Vec :: new ( ) )
740
730
}
741
731
fn expr_vec_slice ( & self , sp : Span , exprs : Vec < P < ast:: Expr > > ) -> P < ast:: Expr > {
@@ -751,12 +741,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
751
741
752
742
753
743
fn expr_some ( & self , sp : Span , expr : P < ast:: Expr > ) -> P < ast:: Expr > {
754
- let some = self . std_path ( & [ " option" , " Option" , " Some" ] ) ;
744
+ let some = self . std_path ( & [ sym :: option, sym :: Option , sym :: Some ] ) ;
755
745
self . expr_call_global ( sp, some, vec ! [ expr] )
756
746
}
757
747
758
748
fn expr_none ( & self , sp : Span ) -> P < ast:: Expr > {
759
- let none = self . std_path ( & [ " option" , " Option" , " None" ] ) ;
749
+ let none = self . std_path ( & [ sym :: option, sym :: Option , sym :: None ] ) ;
760
750
let none = self . path_global ( sp, none) ;
761
751
self . expr_path ( none)
762
752
}
@@ -780,7 +770,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
780
770
let expr_loc_ptr = self . expr_addr_of ( span, expr_loc_tuple) ;
781
771
self . expr_call_global (
782
772
span,
783
- self . std_path ( & [ "rt" , " begin_panic" ] ) ,
773
+ self . std_path ( & [ sym :: rt , sym :: begin_panic] ) ,
784
774
vec ! [
785
775
self . expr_str( span, msg) ,
786
776
expr_loc_ptr] )
@@ -791,19 +781,19 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
791
781
}
792
782
793
783
fn expr_ok ( & self , sp : Span , expr : P < ast:: Expr > ) -> P < ast:: Expr > {
794
- let ok = self . std_path ( & [ " result" , " Result" , "Ok" ] ) ;
784
+ let ok = self . std_path ( & [ sym :: result, sym :: Result , sym :: Ok ] ) ;
795
785
self . expr_call_global ( sp, ok, vec ! [ expr] )
796
786
}
797
787
798
788
fn expr_err ( & self , sp : Span , expr : P < ast:: Expr > ) -> P < ast:: Expr > {
799
- let err = self . std_path ( & [ " result" , " Result" , " Err" ] ) ;
789
+ let err = self . std_path ( & [ sym :: result, sym :: Result , sym :: Err ] ) ;
800
790
self . expr_call_global ( sp, err, vec ! [ expr] )
801
791
}
802
792
803
793
fn expr_try ( & self , sp : Span , head : P < ast:: Expr > ) -> P < ast:: Expr > {
804
- let ok = self . std_path ( & [ " result" , " Result" , "Ok" ] ) ;
794
+ let ok = self . std_path ( & [ sym :: result, sym :: Result , sym :: Ok ] ) ;
805
795
let ok_path = self . path_global ( sp, ok) ;
806
- let err = self . std_path ( & [ " result" , " Result" , " Err" ] ) ;
796
+ let err = self . std_path ( & [ sym :: result, sym :: Result , sym :: Err ] ) ;
807
797
let err_path = self . path_global ( sp, err) ;
808
798
809
799
let binding_variable = self . ident_of ( "__try_var" ) ;
@@ -867,25 +857,25 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
867
857
}
868
858
869
859
fn pat_some ( & self , span : Span , pat : P < ast:: Pat > ) -> P < ast:: Pat > {
870
- let some = self . std_path ( & [ " option" , " Option" , " Some" ] ) ;
860
+ let some = self . std_path ( & [ sym :: option, sym :: Option , sym :: Some ] ) ;
871
861
let path = self . path_global ( span, some) ;
872
862
self . pat_tuple_struct ( span, path, vec ! [ pat] )
873
863
}
874
864
875
865
fn pat_none ( & self , span : Span ) -> P < ast:: Pat > {
876
- let some = self . std_path ( & [ " option" , " Option" , " None" ] ) ;
866
+ let some = self . std_path ( & [ sym :: option, sym :: Option , sym :: None ] ) ;
877
867
let path = self . path_global ( span, some) ;
878
868
self . pat_path ( span, path)
879
869
}
880
870
881
871
fn pat_ok ( & self , span : Span , pat : P < ast:: Pat > ) -> P < ast:: Pat > {
882
- let some = self . std_path ( & [ " result" , " Result" , "Ok" ] ) ;
872
+ let some = self . std_path ( & [ sym :: result, sym :: Result , sym :: Ok ] ) ;
883
873
let path = self . path_global ( span, some) ;
884
874
self . pat_tuple_struct ( span, path, vec ! [ pat] )
885
875
}
886
876
887
877
fn pat_err ( & self , span : Span , pat : P < ast:: Pat > ) -> P < ast:: Pat > {
888
- let some = self . std_path ( & [ " result" , " Result" , " Err" ] ) ;
878
+ let some = self . std_path ( & [ sym :: result, sym :: Result , sym :: Err ] ) ;
889
879
let path = self . path_global ( span, some) ;
890
880
self . pat_tuple_struct ( span, path, vec ! [ pat] )
891
881
}
0 commit comments