File: jump-to-def-pats.rs

package info (click to toggle)
rustc 1.87.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 925,564 kB
  • sloc: xml: 158,127; python: 36,039; javascript: 19,761; sh: 19,737; cpp: 18,981; ansic: 13,133; asm: 4,376; makefile: 710; perl: 29; lisp: 28; ruby: 19; sql: 11
file content (52 lines) | stat: -rw-r--r-- 1,426 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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",
        }
    }
}