@@ -759,35 +759,35 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
759759 /// # Examples
760760 ///
761761 /// ```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]) {
763763 /// // The given `def_id` is that of an `Option` type
764764 /// }
765765 /// ```
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 {
767767 let names = self . get_def_path ( def_id) ;
768768
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)
770770 }
771771
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 `.
773773 ///
774774 /// # Examples
775775 ///
776776 /// ```rust,ignore (no context or def id available)
777777 /// 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[..] {
779779 /// // The given `def_id` is that of an `Option` type
780780 /// }
781781 /// ```
782- pub fn get_def_path ( & self , def_id : DefId ) -> Vec < LocalInternedString > {
782+ pub fn get_def_path ( & self , def_id : DefId ) -> Vec < Symbol > {
783783 pub struct AbsolutePathPrinter < ' a , ' tcx > {
784784 pub tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
785785 }
786786
787787 impl < ' tcx > Printer < ' tcx , ' tcx > for AbsolutePathPrinter < ' _ , ' tcx > {
788788 type Error = !;
789789
790- type Path = Vec < LocalInternedString > ;
790+ type Path = Vec < Symbol > ;
791791 type Region = ( ) ;
792792 type Type = ( ) ;
793793 type DynExistential = ( ) ;
@@ -807,19 +807,19 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
807807 fn print_dyn_existential (
808808 self ,
809809 _predicates : & ' tcx ty:: List < ty:: ExistentialPredicate < ' tcx > > ,
810- ) -> Result < Self :: DynExistential , Self :: Error > {
810+ ) -> Result < Self :: DynExistential , Self :: Error > {
811811 Ok ( ( ) )
812812 }
813813
814814 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) ] )
816816 }
817817
818818 fn path_qualified (
819819 self ,
820820 self_ty : Ty < ' tcx > ,
821821 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
822- ) -> Result < Self :: Path , Self :: Error > {
822+ ) -> Result < Self :: Path , Self :: Error > {
823823 if trait_ref. is_none ( ) {
824824 if let ty:: Adt ( def, substs) = self_ty. sty {
825825 return self . print_def_path ( def. did , substs) ;
@@ -828,8 +828,8 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
828828
829829 // This shouldn't ever be needed, but just in case:
830830 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) ) ,
833833 } ] )
834834 }
835835
@@ -839,15 +839,15 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
839839 _disambiguated_data : & DisambiguatedDefPathData ,
840840 self_ty : Ty < ' tcx > ,
841841 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
842- ) -> Result < Self :: Path , Self :: Error > {
842+ ) -> Result < Self :: Path , Self :: Error > {
843843 let mut path = print_prefix ( self ) ?;
844844
845845 // This shouldn't ever be needed, but just in case:
846846 path. push ( match trait_ref {
847847 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) )
849849 } ,
850- None => Symbol :: intern ( & format ! ( "<impl {}>" , self_ty) ) . as_str ( ) ,
850+ None => Symbol :: intern ( & format ! ( "<impl {}>" , self_ty) ) ,
851851 } ) ;
852852
853853 Ok ( path)
@@ -857,7 +857,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
857857 self ,
858858 print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
859859 disambiguated_data : & DisambiguatedDefPathData ,
860- ) -> Result < Self :: Path , Self :: Error > {
860+ ) -> Result < Self :: Path , Self :: Error > {
861861 let mut path = print_prefix ( self ) ?;
862862
863863 // Skip `::{{constructor}}` on tuple/unit structs.
@@ -866,15 +866,15 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
866866 _ => { }
867867 }
868868
869- path. push ( disambiguated_data. data . as_interned_str ( ) . as_str ( ) ) ;
869+ path. push ( disambiguated_data. data . as_interned_str ( ) . as_symbol ( ) ) ;
870870 Ok ( path)
871871 }
872872
873873 fn path_generic_args (
874874 self ,
875875 print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
876876 _args : & [ Kind < ' tcx > ] ,
877- ) -> Result < Self :: Path , Self :: Error > {
877+ ) -> Result < Self :: Path , Self :: Error > {
878878 print_prefix ( self )
879879 }
880880 }
0 commit comments