@@ -759,35 +759,35 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
759
759
/// # Examples
760
760
///
761
761
/// ```rust,ignore (no context or def id available)
762
- /// if cx.match_def_path(def_id, &[" core", " option", " Option" ]) {
762
+ /// if cx.match_def_path(def_id, &[sym:: core, sym:: option, sym:: Option]) {
763
763
/// // The given `def_id` is that of an `Option` type
764
764
/// }
765
765
/// ```
766
- pub fn match_def_path ( & self , def_id : DefId , path : & [ & str ] ) -> bool {
766
+ pub fn match_def_path ( & self , def_id : DefId , path : & [ Symbol ] ) -> bool {
767
767
let names = self . get_def_path ( def_id) ;
768
768
769
- names. len ( ) == path. len ( ) && names. into_iter ( ) . zip ( path. iter ( ) ) . all ( |( a, & b) | * a == * b)
769
+ names. len ( ) == path. len ( ) && names. into_iter ( ) . zip ( path. iter ( ) ) . all ( |( a, & b) | a == b)
770
770
}
771
771
772
- /// Gets the absolute path of `def_id` as a vector of `&str `.
772
+ /// Gets the absolute path of `def_id` as a vector of `Symbol `.
773
773
///
774
774
/// # Examples
775
775
///
776
776
/// ```rust,ignore (no context or def id available)
777
777
/// let def_path = cx.get_def_path(def_id);
778
- /// if let &[" core", " option", " Option" ] = &def_path[..] {
778
+ /// if let &[sym:: core, sym:: option, sym:: Option] = &def_path[..] {
779
779
/// // The given `def_id` is that of an `Option` type
780
780
/// }
781
781
/// ```
782
- pub fn get_def_path ( & self , def_id : DefId ) -> Vec < LocalInternedString > {
782
+ pub fn get_def_path ( & self , def_id : DefId ) -> Vec < Symbol > {
783
783
pub struct AbsolutePathPrinter < ' a , ' tcx > {
784
784
pub tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
785
785
}
786
786
787
787
impl < ' tcx > Printer < ' tcx , ' tcx > for AbsolutePathPrinter < ' _ , ' tcx > {
788
788
type Error = !;
789
789
790
- type Path = Vec < LocalInternedString > ;
790
+ type Path = Vec < Symbol > ;
791
791
type Region = ( ) ;
792
792
type Type = ( ) ;
793
793
type DynExistential = ( ) ;
@@ -820,14 +820,14 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
820
820
}
821
821
822
822
fn path_crate ( self , cnum : CrateNum ) -> Result < Self :: Path , Self :: Error > {
823
- Ok ( vec ! [ self . tcx. original_crate_name( cnum) . as_str ( ) ] )
823
+ Ok ( vec ! [ self . tcx. original_crate_name( cnum) ] )
824
824
}
825
825
826
826
fn path_qualified (
827
827
self ,
828
828
self_ty : Ty < ' tcx > ,
829
829
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
830
- ) -> Result < Self :: Path , Self :: Error > {
830
+ ) -> Result < Self :: Path , Self :: Error > {
831
831
if trait_ref. is_none ( ) {
832
832
if let ty:: Adt ( def, substs) = self_ty. sty {
833
833
return self . print_def_path ( def. did , substs) ;
@@ -836,8 +836,8 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
836
836
837
837
// This shouldn't ever be needed, but just in case:
838
838
Ok ( vec ! [ match trait_ref {
839
- Some ( trait_ref) => LocalInternedString :: intern( & format!( "{:?}" , trait_ref) ) ,
840
- None => LocalInternedString :: intern( & format!( "<{}>" , self_ty) ) ,
839
+ Some ( trait_ref) => Symbol :: intern( & format!( "{:?}" , trait_ref) ) ,
840
+ None => Symbol :: intern( & format!( "<{}>" , self_ty) ) ,
841
841
} ] )
842
842
}
843
843
@@ -847,16 +847,16 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
847
847
_disambiguated_data : & DisambiguatedDefPathData ,
848
848
self_ty : Ty < ' tcx > ,
849
849
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
850
- ) -> Result < Self :: Path , Self :: Error > {
850
+ ) -> Result < Self :: Path , Self :: Error > {
851
851
let mut path = print_prefix ( self ) ?;
852
852
853
853
// This shouldn't ever be needed, but just in case:
854
854
path. push ( match trait_ref {
855
855
Some ( trait_ref) => {
856
- LocalInternedString :: intern ( & format ! ( "<impl {} for {}>" , trait_ref,
856
+ Symbol :: intern ( & format ! ( "<impl {} for {}>" , trait_ref,
857
857
self_ty) )
858
858
} ,
859
- None => LocalInternedString :: intern ( & format ! ( "<impl {}>" , self_ty) ) ,
859
+ None => Symbol :: intern ( & format ! ( "<impl {}>" , self_ty) ) ,
860
860
} ) ;
861
861
862
862
Ok ( path)
@@ -866,7 +866,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
866
866
self ,
867
867
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
868
868
disambiguated_data : & DisambiguatedDefPathData ,
869
- ) -> Result < Self :: Path , Self :: Error > {
869
+ ) -> Result < Self :: Path , Self :: Error > {
870
870
let mut path = print_prefix ( self ) ?;
871
871
872
872
// Skip `::{{constructor}}` on tuple/unit structs.
@@ -875,15 +875,15 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
875
875
_ => { }
876
876
}
877
877
878
- path. push ( disambiguated_data. data . as_interned_str ( ) . as_str ( ) ) ;
878
+ path. push ( disambiguated_data. data . as_interned_str ( ) . as_symbol ( ) ) ;
879
879
Ok ( path)
880
880
}
881
881
882
882
fn path_generic_args (
883
883
self ,
884
884
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
885
885
_args : & [ Kind < ' tcx > ] ,
886
- ) -> Result < Self :: Path , Self :: Error > {
886
+ ) -> Result < Self :: Path , Self :: Error > {
887
887
print_prefix ( self )
888
888
}
889
889
}
0 commit comments