@@ -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 = ( ) ;
@@ -807,19 +807,19 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
807
807
fn print_dyn_existential (
808
808
self ,
809
809
_predicates : & ' tcx ty:: List < ty:: ExistentialPredicate < ' tcx > > ,
810
- ) -> Result < Self :: DynExistential , Self :: Error > {
810
+ ) -> Result < Self :: DynExistential , Self :: Error > {
811
811
Ok ( ( ) )
812
812
}
813
813
814
814
fn path_crate ( self , cnum : CrateNum ) -> Result < Self :: Path , Self :: Error > {
815
- Ok ( vec ! [ self . tcx. original_crate_name( cnum) . as_str ( ) ] )
815
+ Ok ( vec ! [ self . tcx. original_crate_name( cnum) ] )
816
816
}
817
817
818
818
fn path_qualified (
819
819
self ,
820
820
self_ty : Ty < ' tcx > ,
821
821
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
822
- ) -> Result < Self :: Path , Self :: Error > {
822
+ ) -> Result < Self :: Path , Self :: Error > {
823
823
if trait_ref. is_none ( ) {
824
824
if let ty:: Adt ( def, substs) = self_ty. sty {
825
825
return self . print_def_path ( def. did , substs) ;
@@ -828,8 +828,8 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
828
828
829
829
// This shouldn't ever be needed, but just in case:
830
830
Ok ( vec ! [ match trait_ref {
831
- Some ( trait_ref) => Symbol :: intern( & format!( "{:?}" , trait_ref) ) . as_str ( ) ,
832
- None => Symbol :: intern( & format!( "<{}>" , self_ty) ) . as_str ( ) ,
831
+ Some ( trait_ref) => Symbol :: intern( & format!( "{:?}" , trait_ref) ) ,
832
+ None => Symbol :: intern( & format!( "<{}>" , self_ty) ) ,
833
833
} ] )
834
834
}
835
835
@@ -839,15 +839,15 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
839
839
_disambiguated_data : & DisambiguatedDefPathData ,
840
840
self_ty : Ty < ' tcx > ,
841
841
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
842
- ) -> Result < Self :: Path , Self :: Error > {
842
+ ) -> Result < Self :: Path , Self :: Error > {
843
843
let mut path = print_prefix ( self ) ?;
844
844
845
845
// This shouldn't ever be needed, but just in case:
846
846
path. push ( match trait_ref {
847
847
Some ( trait_ref) => {
848
- Symbol :: intern ( & format ! ( "<impl {} for {}>" , trait_ref, self_ty) ) . as_str ( )
848
+ Symbol :: intern ( & format ! ( "<impl {} for {}>" , trait_ref, self_ty) )
849
849
} ,
850
- None => Symbol :: intern ( & format ! ( "<impl {}>" , self_ty) ) . as_str ( ) ,
850
+ None => Symbol :: intern ( & format ! ( "<impl {}>" , self_ty) ) ,
851
851
} ) ;
852
852
853
853
Ok ( path)
@@ -857,7 +857,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
857
857
self ,
858
858
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
859
859
disambiguated_data : & DisambiguatedDefPathData ,
860
- ) -> Result < Self :: Path , Self :: Error > {
860
+ ) -> Result < Self :: Path , Self :: Error > {
861
861
let mut path = print_prefix ( self ) ?;
862
862
863
863
// Skip `::{{constructor}}` on tuple/unit structs.
@@ -866,15 +866,15 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
866
866
_ => { }
867
867
}
868
868
869
- path. push ( disambiguated_data. data . as_interned_str ( ) . as_str ( ) ) ;
869
+ path. push ( disambiguated_data. data . as_interned_str ( ) . as_symbol ( ) ) ;
870
870
Ok ( path)
871
871
}
872
872
873
873
fn path_generic_args (
874
874
self ,
875
875
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
876
876
_args : & [ Kind < ' tcx > ] ,
877
- ) -> Result < Self :: Path , Self :: Error > {
877
+ ) -> Result < Self :: Path , Self :: Error > {
878
878
print_prefix ( self )
879
879
}
880
880
}
0 commit comments