Skip to content

Commit 7029347

Browse files
Enable "jump to def" feature on prelude variants
1 parent 5a6036a commit 7029347

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/librustdoc/html/highlight.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ enum Class {
337337
Ident(Span),
338338
Lifetime,
339339
PreludeTy(Span),
340-
PreludeVal,
340+
PreludeVal(Span),
341341
QuestionMark,
342342
Decoration(&'static str),
343343
}
@@ -385,7 +385,7 @@ impl Class {
385385
Class::Ident(_) => "",
386386
Class::Lifetime => "lifetime",
387387
Class::PreludeTy(_) => "prelude-ty",
388-
Class::PreludeVal => "prelude-val",
388+
Class::PreludeVal(_) => "prelude-val",
389389
Class::QuestionMark => "question-mark",
390390
Class::Decoration(kind) => kind,
391391
}
@@ -395,7 +395,11 @@ impl Class {
395395
/// a "span" (a tuple representing `(lo, hi)` equivalent of `Span`).
396396
fn get_span(self) -> Option<Span> {
397397
match self {
398-
Self::Ident(sp) | Self::Self_(sp) | Self::Macro(sp) | Self::PreludeTy(sp) => Some(sp),
398+
Self::Ident(sp)
399+
| Self::Self_(sp)
400+
| Self::Macro(sp)
401+
| Self::PreludeTy(sp)
402+
| Self::PreludeVal(sp) => Some(sp),
399403
Self::Comment
400404
| Self::DocComment
401405
| Self::Attribute
@@ -406,7 +410,6 @@ impl Class {
406410
| Self::Number
407411
| Self::Bool
408412
| Self::Lifetime
409-
| Self::PreludeVal
410413
| Self::QuestionMark
411414
| Self::Decoration(_) => None,
412415
}
@@ -851,7 +854,9 @@ impl<'src> Classifier<'src> {
851854
TokenKind::Ident => match get_real_ident_class(text, false) {
852855
None => match text {
853856
"Option" | "Result" => Class::PreludeTy(self.new_span(before, text)),
854-
"Some" | "None" | "Ok" | "Err" => Class::PreludeVal,
857+
"Some" | "None" | "Ok" | "Err" => {
858+
Class::PreludeVal(self.new_span(before, text))
859+
}
855860
// "union" is a weak keyword and is only considered as a keyword when declaring
856861
// a union type.
857862
"union" if self.check_if_is_union_keyword() => Class::KeyWord,

0 commit comments

Comments
 (0)