@@ -26,7 +26,7 @@ use super::format::{self, Buffer};
2626use super :: render:: LinkFromSrc ;
2727
2828/// This type is needed in case we want to render links on items to allow to go to their definition.
29- pub ( crate ) struct ContextInfo < ' a , ' b , ' c > {
29+ pub ( crate ) struct HrefContext < ' a , ' b , ' c > {
3030 pub ( crate ) context : & ' a Context < ' b > ,
3131 /// This span contains the current file we're going through.
3232 pub ( crate ) file_span : Span ,
@@ -48,7 +48,7 @@ pub(crate) fn render_with_highlighting(
4848 tooltip : Option < ( Option < Edition > , & str ) > ,
4949 edition : Edition ,
5050 extra_content : Option < Buffer > ,
51- context_info : Option < ContextInfo < ' _ , ' _ , ' _ > > ,
51+ href_context : Option < HrefContext < ' _ , ' _ , ' _ > > ,
5252 decoration_info : Option < DecorationInfo > ,
5353) {
5454 debug ! ( "highlighting: ================\n {}\n ==============" , src) ;
@@ -66,7 +66,7 @@ pub(crate) fn render_with_highlighting(
6666 }
6767
6868 write_header ( out, class, extra_content) ;
69- write_code ( out, src, edition, context_info , decoration_info) ;
69+ write_code ( out, src, edition, href_context , decoration_info) ;
7070 write_footer ( out, playground_button) ;
7171}
7272
@@ -89,16 +89,16 @@ fn write_header(out: &mut Buffer, class: Option<&str>, extra_content: Option<Buf
8989///
9090/// Some explanations on the last arguments:
9191///
92- /// In case we are rendering a code block and not a source code file, `context_info ` will be `None`.
93- /// To put it more simply: if `context_info ` is `None`, the code won't try to generate links to an
92+ /// In case we are rendering a code block and not a source code file, `href_context ` will be `None`.
93+ /// To put it more simply: if `href_context ` is `None`, the code won't try to generate links to an
9494/// item definition.
9595///
9696/// More explanations about spans and how we use them here are provided in the
9797fn write_code (
9898 out : & mut Buffer ,
9999 src : & str ,
100100 edition : Edition ,
101- context_info : Option < ContextInfo < ' _ , ' _ , ' _ > > ,
101+ href_context : Option < HrefContext < ' _ , ' _ , ' _ > > ,
102102 decoration_info : Option < DecorationInfo > ,
103103) {
104104 // This replace allows to fix how the code source with DOS backline characters is displayed.
@@ -107,13 +107,13 @@ fn write_code(
107107 Classifier :: new (
108108 & src,
109109 edition,
110- context_info . as_ref ( ) . map ( |c| c. file_span ) . unwrap_or ( DUMMY_SP ) ,
110+ href_context . as_ref ( ) . map ( |c| c. file_span ) . unwrap_or ( DUMMY_SP ) ,
111111 decoration_info,
112112 )
113113 . highlight ( & mut |highlight| {
114114 match highlight {
115- Highlight :: Token { text, class } => string ( out, Escape ( text) , class, & context_info ) ,
116- Highlight :: EnterSpan { class } => closing_tag = enter_span ( out, class, & context_info ) ,
115+ Highlight :: Token { text, class } => string ( out, Escape ( text) , class, & href_context ) ,
116+ Highlight :: EnterSpan { class } => closing_tag = enter_span ( out, class, & href_context ) ,
117117 Highlight :: ExitSpan => exit_span ( out, & closing_tag) ,
118118 } ;
119119 } ) ;
@@ -680,9 +680,9 @@ impl<'a> Classifier<'a> {
680680fn enter_span (
681681 out : & mut Buffer ,
682682 klass : Class ,
683- context_info : & Option < ContextInfo < ' _ , ' _ , ' _ > > ,
683+ href_context : & Option < HrefContext < ' _ , ' _ , ' _ > > ,
684684) -> & ' static str {
685- string_without_closing_tag ( out, "" , Some ( klass) , context_info )
685+ string_without_closing_tag ( out, "" , Some ( klass) , href_context )
686686 . expect ( "no closing tag to close wrapper..." )
687687}
688688
@@ -711,9 +711,9 @@ fn string<T: Display>(
711711 out : & mut Buffer ,
712712 text : T ,
713713 klass : Option < Class > ,
714- context_info : & Option < ContextInfo < ' _ , ' _ , ' _ > > ,
714+ href_context : & Option < HrefContext < ' _ , ' _ , ' _ > > ,
715715) {
716- if let Some ( closing_tag) = string_without_closing_tag ( out, text, klass, context_info ) {
716+ if let Some ( closing_tag) = string_without_closing_tag ( out, text, klass, href_context ) {
717717 out. write_str ( closing_tag) ;
718718 }
719719}
@@ -722,7 +722,7 @@ fn string_without_closing_tag<T: Display>(
722722 out : & mut Buffer ,
723723 text : T ,
724724 klass : Option < Class > ,
725- context_info : & Option < ContextInfo < ' _ , ' _ , ' _ > > ,
725+ href_context : & Option < HrefContext < ' _ , ' _ , ' _ > > ,
726726) -> Option < & ' static str > {
727727 let Some ( klass) = klass
728728 else {
@@ -754,10 +754,10 @@ fn string_without_closing_tag<T: Display>(
754754 path
755755 } ) ;
756756 }
757- if let Some ( context_info ) = context_info {
757+ if let Some ( href_context ) = href_context {
758758 if let Some ( href) =
759- context_info . context . shared . span_correspondance_map . get ( & def_span) . and_then ( |href| {
760- let context = context_info . context ;
759+ href_context . context . shared . span_correspondance_map . get ( & def_span) . and_then ( |href| {
760+ let context = href_context . context ;
761761 // FIXME: later on, it'd be nice to provide two links (if possible) for all items:
762762 // one to the documentation page and one to the source definition.
763763 // FIXME: currently, external items only generate a link to their documentation,
@@ -766,15 +766,15 @@ fn string_without_closing_tag<T: Display>(
766766 match href {
767767 LinkFromSrc :: Local ( span) => context
768768 . href_from_span ( * span, true )
769- . map ( |s| format ! ( "{}{}" , context_info . root_path, s) ) ,
769+ . map ( |s| format ! ( "{}{}" , href_context . root_path, s) ) ,
770770 LinkFromSrc :: External ( def_id) => {
771- format:: href_with_root_path ( * def_id, context, Some ( context_info . root_path ) )
771+ format:: href_with_root_path ( * def_id, context, Some ( href_context . root_path ) )
772772 . map ( |( url, _, _) | url)
773773 . or_else ( |e| {
774774 if e == format:: HrefError :: NotInExternalCache
775775 && matches ! ( klass, Class :: Macro ( _) )
776776 {
777- Ok ( generate_macro_def_id_path ( context_info , * def_id) )
777+ Ok ( generate_macro_def_id_path ( href_context , * def_id) )
778778 } else {
779779 Err ( e)
780780 }
@@ -784,7 +784,7 @@ fn string_without_closing_tag<T: Display>(
784784 LinkFromSrc :: Primitive ( prim) => format:: href_with_root_path (
785785 PrimitiveType :: primitive_locations ( context. tcx ( ) ) [ prim] ,
786786 context,
787- Some ( context_info . root_path ) ,
787+ Some ( href_context . root_path ) ,
788788 )
789789 . ok ( )
790790 . map ( |( url, _, _) | url) ,
@@ -801,10 +801,10 @@ fn string_without_closing_tag<T: Display>(
801801
802802/// This function is to get the external macro path because they are not in the cache used n
803803/// `href_with_root_path`.
804- fn generate_macro_def_id_path ( context_info : & ContextInfo < ' _ , ' _ , ' _ > , def_id : DefId ) -> String {
805- let tcx = context_info . context . shared . tcx ;
804+ fn generate_macro_def_id_path ( href_context : & HrefContext < ' _ , ' _ , ' _ > , def_id : DefId ) -> String {
805+ let tcx = href_context . context . shared . tcx ;
806806 let crate_name = tcx. crate_name ( def_id. krate ) . to_string ( ) ;
807- let cache = & context_info . context . cache ( ) ;
807+ let cache = & href_context . context . cache ( ) ;
808808
809809 let relative = tcx. def_path ( def_id) . data . into_iter ( ) . filter_map ( |elem| {
810810 // extern blocks have an empty name
@@ -825,7 +825,7 @@ fn generate_macro_def_id_path(context_info: &ContextInfo<'_, '_, '_>, def_id: De
825825
826826 let url_parts = match cache. extern_locations [ & def_id. krate ] {
827827 ExternalLocation :: Remote ( ref s) => vec ! [ s. trim_end_matches( '/' ) ] ,
828- ExternalLocation :: Local => vec ! [ context_info . root_path. trim_end_matches( '/' ) , & crate_name] ,
828+ ExternalLocation :: Local => vec ! [ href_context . root_path. trim_end_matches( '/' ) , & crate_name] ,
829829 ExternalLocation :: Unknown => panic ! ( "unknown crate" ) ,
830830 } ;
831831
0 commit comments