@@ -21,15 +21,15 @@ use rustc_span::{BytePos, Span, DUMMY_SP};
21
21
use super :: format:: { self , Buffer } ;
22
22
23
23
/// This type is needed in case we want to render links on items to allow to go to their definition.
24
- pub ( crate ) struct HrefContext < ' a , ' b , ' c > {
25
- pub ( crate ) context : & ' a Context < ' b > ,
24
+ pub ( crate ) struct HrefContext < ' a , ' tcx > {
25
+ pub ( crate ) context : & ' a Context < ' tcx > ,
26
26
/// This span contains the current file we're going through.
27
27
pub ( crate ) file_span : Span ,
28
28
/// This field is used to know "how far" from the top of the directory we are to link to either
29
29
/// documentation pages or other source pages.
30
- pub ( crate ) root_path : & ' c str ,
30
+ pub ( crate ) root_path : & ' a str ,
31
31
/// This field is used to calculate precise local URLs.
32
- pub ( crate ) current_href : & ' c str ,
32
+ pub ( crate ) current_href : String ,
33
33
}
34
34
35
35
/// Decorations are represented as a map from CSS class to vector of character ranges.
@@ -70,7 +70,7 @@ pub(crate) fn render_source_with_highlighting(
70
70
src : & str ,
71
71
out : & mut Buffer ,
72
72
line_numbers : Buffer ,
73
- href_context : HrefContext < ' _ , ' _ , ' _ > ,
73
+ href_context : HrefContext < ' _ , ' _ > ,
74
74
decoration_info : DecorationInfo ,
75
75
extra : Option < & str > ,
76
76
) {
@@ -137,7 +137,7 @@ fn can_merge(class1: Option<Class>, class2: Option<Class>, text: &str) -> bool {
137
137
138
138
/// This type is used as a conveniency to prevent having to pass all its fields as arguments into
139
139
/// the various functions (which became its methods).
140
- struct TokenHandler < ' a , ' b , ' c , ' d , ' e > {
140
+ struct TokenHandler < ' a , ' tcx > {
141
141
out : & ' a mut Buffer ,
142
142
/// It contains the closing tag and the associated `Class`.
143
143
closing_tags : Vec < ( & ' static str , Class ) > ,
@@ -149,11 +149,11 @@ struct TokenHandler<'a, 'b, 'c, 'd, 'e> {
149
149
current_class : Option < Class > ,
150
150
/// We need to keep the `Class` for each element because it could contain a `Span` which is
151
151
/// used to generate links.
152
- pending_elems : Vec < ( & ' b str , Option < Class > ) > ,
153
- href_context : Option < HrefContext < ' c , ' d , ' e > > ,
152
+ pending_elems : Vec < ( & ' a str , Option < Class > ) > ,
153
+ href_context : Option < HrefContext < ' a , ' tcx > > ,
154
154
}
155
155
156
- impl < ' a , ' b , ' c , ' d , ' e > TokenHandler < ' a , ' b , ' c , ' d , ' e > {
156
+ impl < ' a , ' tcx > TokenHandler < ' a , ' tcx > {
157
157
fn handle_exit_span ( & mut self ) {
158
158
// We can't get the last `closing_tags` element using `pop()` because `closing_tags` is
159
159
// being used in `write_pending_elems`.
@@ -205,7 +205,7 @@ impl<'a, 'b, 'c, 'd, 'e> TokenHandler<'a, 'b, 'c, 'd, 'e> {
205
205
}
206
206
}
207
207
208
- impl < ' a , ' b , ' c , ' d , ' e > Drop for TokenHandler < ' a , ' b , ' c , ' d , ' e > {
208
+ impl < ' a , ' tcx > Drop for TokenHandler < ' a , ' tcx > {
209
209
/// When leaving, we need to flush all pending data to not have missing content.
210
210
fn drop ( & mut self ) {
211
211
if self . pending_exit_span . is_some ( ) {
@@ -230,7 +230,7 @@ impl<'a, 'b, 'c, 'd, 'e> Drop for TokenHandler<'a, 'b, 'c, 'd, 'e> {
230
230
fn write_code (
231
231
out : & mut Buffer ,
232
232
src : & str ,
233
- href_context : Option < HrefContext < ' _ , ' _ , ' _ > > ,
233
+ href_context : Option < HrefContext < ' _ , ' _ > > ,
234
234
decoration_info : Option < DecorationInfo > ,
235
235
) {
236
236
// This replace allows to fix how the code source with DOS backline characters is displayed.
@@ -514,18 +514,18 @@ impl Decorations {
514
514
515
515
/// Processes program tokens, classifying strings of text by highlighting
516
516
/// category (`Class`).
517
- struct Classifier < ' a > {
518
- tokens : PeekIter < ' a > ,
517
+ struct Classifier < ' src > {
518
+ tokens : PeekIter < ' src > ,
519
519
in_attribute : bool ,
520
520
in_macro : bool ,
521
521
in_macro_nonterminal : bool ,
522
522
byte_pos : u32 ,
523
523
file_span : Span ,
524
- src : & ' a str ,
524
+ src : & ' src str ,
525
525
decorations : Option < Decorations > ,
526
526
}
527
527
528
- impl < ' a > Classifier < ' a > {
528
+ impl < ' src > Classifier < ' src > {
529
529
/// Takes as argument the source code to HTML-ify, the rust edition to use and the source code
530
530
/// file span which will be used later on by the `span_correspondance_map`.
531
531
fn new ( src : & str , file_span : Span , decoration_info : Option < DecorationInfo > ) -> Classifier < ' _ > {
@@ -603,7 +603,7 @@ impl<'a> Classifier<'a> {
603
603
///
604
604
/// It returns the token's kind, the token as a string and its byte position in the source
605
605
/// string.
606
- fn next ( & mut self ) -> Option < ( TokenKind , & ' a str , u32 ) > {
606
+ fn next ( & mut self ) -> Option < ( TokenKind , & ' src str , u32 ) > {
607
607
if let Some ( ( kind, text) ) = self . tokens . next ( ) {
608
608
let before = self . byte_pos ;
609
609
self . byte_pos += text. len ( ) as u32 ;
@@ -618,7 +618,7 @@ impl<'a> Classifier<'a> {
618
618
/// The general structure for this method is to iterate over each token,
619
619
/// possibly giving it an HTML span with a class specifying what flavor of
620
620
/// token is used.
621
- fn highlight ( mut self , sink : & mut dyn FnMut ( Highlight < ' a > ) ) {
621
+ fn highlight ( mut self , sink : & mut dyn FnMut ( Highlight < ' src > ) ) {
622
622
loop {
623
623
if let Some ( decs) = self . decorations . as_mut ( ) {
624
624
let byte_pos = self . byte_pos ;
@@ -666,8 +666,8 @@ impl<'a> Classifier<'a> {
666
666
fn advance (
667
667
& mut self ,
668
668
token : TokenKind ,
669
- text : & ' a str ,
670
- sink : & mut dyn FnMut ( Highlight < ' a > ) ,
669
+ text : & ' src str ,
670
+ sink : & mut dyn FnMut ( Highlight < ' src > ) ,
671
671
before : u32 ,
672
672
) {
673
673
let lookahead = self . peek ( ) ;
@@ -881,7 +881,7 @@ impl<'a> Classifier<'a> {
881
881
fn enter_span (
882
882
out : & mut Buffer ,
883
883
klass : Class ,
884
- href_context : & Option < HrefContext < ' _ , ' _ , ' _ > > ,
884
+ href_context : & Option < HrefContext < ' _ , ' _ > > ,
885
885
) -> & ' static str {
886
886
string_without_closing_tag ( out, "" , Some ( klass) , href_context, true ) . expect (
887
887
"internal error: enter_span was called with Some(klass) but did not return a \
@@ -914,7 +914,7 @@ fn string<T: Display>(
914
914
out : & mut Buffer ,
915
915
text : T ,
916
916
klass : Option < Class > ,
917
- href_context : & Option < HrefContext < ' _ , ' _ , ' _ > > ,
917
+ href_context : & Option < HrefContext < ' _ , ' _ > > ,
918
918
open_tag : bool ,
919
919
) {
920
920
if let Some ( closing_tag) = string_without_closing_tag ( out, text, klass, href_context, open_tag)
@@ -936,7 +936,7 @@ fn string_without_closing_tag<T: Display>(
936
936
out : & mut Buffer ,
937
937
text : T ,
938
938
klass : Option < Class > ,
939
- href_context : & Option < HrefContext < ' _ , ' _ , ' _ > > ,
939
+ href_context : & Option < HrefContext < ' _ , ' _ > > ,
940
940
open_tag : bool ,
941
941
) -> Option < & ' static str > {
942
942
let Some ( klass) = klass
@@ -985,7 +985,7 @@ fn string_without_closing_tag<T: Display>(
985
985
// https://github.com/rust-lang/rust/blob/60f1a2fc4b535ead9c85ce085fdce49b1b097531/src/librustdoc/html/render/context.rs#L315-L338
986
986
match href {
987
987
LinkFromSrc :: Local ( span) => {
988
- context. href_from_span_relative ( * span, href_context. current_href )
988
+ context. href_from_span_relative ( * span, & href_context. current_href )
989
989
}
990
990
LinkFromSrc :: External ( def_id) => {
991
991
format:: href_with_root_path ( * def_id, context, Some ( href_context. root_path ) )
0 commit comments