Skip to content

Commit

Permalink
Fix Result and Option not getting a jump to def link generated
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 25, 2024
1 parent 717f5df commit 7df2daa
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ enum Class {
/// `Ident` isn't rendered in the HTML but we still need it for the `Span` it contains.
Ident(Span),
Lifetime,
PreludeTy,
PreludeTy(Span),
PreludeVal,
QuestionMark,
Decoration(&'static str),
Expand Down Expand Up @@ -381,7 +381,7 @@ impl Class {
Class::Bool => "bool-val",
Class::Ident(_) => "",
Class::Lifetime => "lifetime",
Class::PreludeTy => "prelude-ty",
Class::PreludeTy(_) => "prelude-ty",
Class::PreludeVal => "prelude-val",
Class::QuestionMark => "question-mark",
Class::Decoration(kind) => kind,
Expand All @@ -392,7 +392,7 @@ impl Class {
/// a "span" (a tuple representing `(lo, hi)` equivalent of `Span`).
fn get_span(self) -> Option<Span> {
match self {
Self::Ident(sp) | Self::Self_(sp) | Self::Macro(sp) => Some(sp),
Self::Ident(sp) | Self::Self_(sp) | Self::Macro(sp) | Self::PreludeTy(sp) => Some(sp),
Self::Comment
| Self::DocComment
| Self::Attribute
Expand All @@ -403,7 +403,6 @@ impl Class {
| Self::Number
| Self::Bool
| Self::Lifetime
| Self::PreludeTy
| Self::PreludeVal
| Self::QuestionMark
| Self::Decoration(_) => None,
Expand Down Expand Up @@ -847,7 +846,7 @@ impl<'src> Classifier<'src> {
}
TokenKind::Ident => match get_real_ident_class(text, false) {
None => match text {
"Option" | "Result" => Class::PreludeTy,
"Option" | "Result" => Class::PreludeTy(self.new_span(before, text)),
"Some" | "None" | "Ok" | "Err" => Class::PreludeVal,
// "union" is a weak keyword and is only considered as a keyword when declaring
// a union type.
Expand Down

0 comments on commit 7df2daa

Please sign in to comment.