@@ -181,6 +181,9 @@ impl<'a, 'tcx, F: Write> TokenHandler<'a, 'tcx, F> {
181
181
// current parent tag is not the same as our pending content.
182
182
let close_tag = if self . pending_elems . len ( ) > 1
183
183
&& let Some ( current_class) = current_class
184
+ // `PreludeTy` can never include more than an ident so it should not generate
185
+ // a wrapping `span`.
186
+ && !matches ! ( current_class, Class :: PreludeTy ( _) )
184
187
{
185
188
Some ( enter_span ( self . out , current_class, & self . href_context ) )
186
189
} else {
@@ -333,7 +336,7 @@ enum Class {
333
336
/// `Ident` isn't rendered in the HTML but we still need it for the `Span` it contains.
334
337
Ident ( Span ) ,
335
338
Lifetime ,
336
- PreludeTy ,
339
+ PreludeTy ( Span ) ,
337
340
PreludeVal ,
338
341
QuestionMark ,
339
342
Decoration ( & ' static str ) ,
@@ -381,7 +384,7 @@ impl Class {
381
384
Class :: Bool => "bool-val" ,
382
385
Class :: Ident ( _) => "" ,
383
386
Class :: Lifetime => "lifetime" ,
384
- Class :: PreludeTy => "prelude-ty" ,
387
+ Class :: PreludeTy ( _ ) => "prelude-ty" ,
385
388
Class :: PreludeVal => "prelude-val" ,
386
389
Class :: QuestionMark => "question-mark" ,
387
390
Class :: Decoration ( kind) => kind,
@@ -392,7 +395,7 @@ impl Class {
392
395
/// a "span" (a tuple representing `(lo, hi)` equivalent of `Span`).
393
396
fn get_span ( self ) -> Option < Span > {
394
397
match self {
395
- Self :: Ident ( sp) | Self :: Self_ ( sp) | Self :: Macro ( sp) => Some ( sp) ,
398
+ Self :: Ident ( sp) | Self :: Self_ ( sp) | Self :: Macro ( sp) | Self :: PreludeTy ( sp ) => Some ( sp) ,
396
399
Self :: Comment
397
400
| Self :: DocComment
398
401
| Self :: Attribute
@@ -403,14 +406,14 @@ impl Class {
403
406
| Self :: Number
404
407
| Self :: Bool
405
408
| Self :: Lifetime
406
- | Self :: PreludeTy
407
409
| Self :: PreludeVal
408
410
| Self :: QuestionMark
409
411
| Self :: Decoration ( _) => None ,
410
412
}
411
413
}
412
414
}
413
415
416
+ #[ derive( Debug ) ]
414
417
enum Highlight < ' a > {
415
418
Token { text : & ' a str , class : Option < Class > } ,
416
419
EnterSpan { class : Class } ,
@@ -847,7 +850,7 @@ impl<'src> Classifier<'src> {
847
850
}
848
851
TokenKind :: Ident => match get_real_ident_class ( text, false ) {
849
852
None => match text {
850
- "Option" | "Result" => Class :: PreludeTy ,
853
+ "Option" | "Result" => Class :: PreludeTy ( self . new_span ( before , text ) ) ,
851
854
"Some" | "None" | "Ok" | "Err" => Class :: PreludeVal ,
852
855
// "union" is a weak keyword and is only considered as a keyword when declaring
853
856
// a union type.
0 commit comments