Skip to content

Commit 7df2daa

Browse files
Fix Result and Option not getting a jump to def link generated
1 parent 717f5df commit 7df2daa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/librustdoc/html/highlight.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ enum Class {
333333
/// `Ident` isn't rendered in the HTML but we still need it for the `Span` it contains.
334334
Ident(Span),
335335
Lifetime,
336-
PreludeTy,
336+
PreludeTy(Span),
337337
PreludeVal,
338338
QuestionMark,
339339
Decoration(&'static str),
@@ -381,7 +381,7 @@ impl Class {
381381
Class::Bool => "bool-val",
382382
Class::Ident(_) => "",
383383
Class::Lifetime => "lifetime",
384-
Class::PreludeTy => "prelude-ty",
384+
Class::PreludeTy(_) => "prelude-ty",
385385
Class::PreludeVal => "prelude-val",
386386
Class::QuestionMark => "question-mark",
387387
Class::Decoration(kind) => kind,
@@ -392,7 +392,7 @@ impl Class {
392392
/// a "span" (a tuple representing `(lo, hi)` equivalent of `Span`).
393393
fn get_span(self) -> Option<Span> {
394394
match self {
395-
Self::Ident(sp) | Self::Self_(sp) | Self::Macro(sp) => Some(sp),
395+
Self::Ident(sp) | Self::Self_(sp) | Self::Macro(sp) | Self::PreludeTy(sp) => Some(sp),
396396
Self::Comment
397397
| Self::DocComment
398398
| Self::Attribute
@@ -403,7 +403,6 @@ impl Class {
403403
| Self::Number
404404
| Self::Bool
405405
| Self::Lifetime
406-
| Self::PreludeTy
407406
| Self::PreludeVal
408407
| Self::QuestionMark
409408
| Self::Decoration(_) => None,
@@ -847,7 +846,7 @@ impl<'src> Classifier<'src> {
847846
}
848847
TokenKind::Ident => match get_real_ident_class(text, false) {
849848
None => match text {
850-
"Option" | "Result" => Class::PreludeTy,
849+
"Option" | "Result" => Class::PreludeTy(self.new_span(before, text)),
851850
"Some" | "None" | "Ok" | "Err" => Class::PreludeVal,
852851
// "union" is a weak keyword and is only considered as a keyword when declaring
853852
// a union type.

0 commit comments

Comments
 (0)