forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#134216 - GuillaumeGomez:jump-to-def-pats, r=fmease Enable "jump to def" feature on patterns Part of rust-lang#89095. Pattern (as in "patterns in pattern matching") were not handled by the feature, it's now added. It all started when I realized that prelude values like `Some` or `Err` were not getting a link generated either (added support for it in the first commit). r? ``@fmease``
- Loading branch information
Showing
3 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// This test ensures that patterns also get a link generated. | ||
|
||
//@ compile-flags: -Zunstable-options --generate-link-to-definition | ||
|
||
#![crate_name = "foo"] | ||
|
||
//@ has 'src/foo/jump-to-def-pats.rs.html' | ||
|
||
use std::fmt; | ||
|
||
pub enum MyEnum<T, E> { | ||
Ok(T), | ||
Err(E), | ||
Some(T), | ||
None, | ||
} | ||
|
||
pub enum X { | ||
A, | ||
} | ||
|
||
pub fn foo() -> Result<(), ()> { | ||
// FIXME: would be nice to be able to check both the class and the href at the same time so | ||
// we could check the text as well... | ||
//@ has - '//a[@class="prelude-val"]/@href' '{{channel}}/core/result/enum.Result.html#variant.Ok' | ||
//@ has - '//a[@href="{{channel}}/core/result/enum.Result.html#variant.Ok"]' 'Ok' | ||
Ok(()) | ||
} | ||
|
||
impl<T, E> fmt::Display for MyEnum<T, E> { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
//@ has - '//a[@href="#12"]' 'Self::Ok' | ||
Self::Ok(_) => f.write_str("MyEnum::Ok"), | ||
//@ has - '//a[@href="#13"]' 'MyEnum::Err' | ||
MyEnum::Err(_) => f.write_str("MyEnum::Err"), | ||
//@ has - '//a[@href="#14"]' 'Self::Some' | ||
Self::Some(_) => f.write_str("MyEnum::Some"), | ||
//@ has - '//a[@href="#15"]' 'Self::None' | ||
Self::None => f.write_str("MyEnum::None"), | ||
} | ||
} | ||
} | ||
|
||
impl X { | ||
fn p(&self) -> &str { | ||
match self { | ||
//@ has - '//a[@href="#19"]' 'Self::A' | ||
Self::A => "X::A", | ||
} | ||
} | ||
} |