]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/rfc-2632-const-trait-impl.rs
Rollup merge of #107169 - albertlarsan68:lock-in-pre-push, r=Mark-Simulacrum
[rust.git] / tests / rustdoc / rfc-2632-const-trait-impl.rs
1 // Test that we do not currently display `~const` in rustdoc
2 // as that syntax is currently provisional; `~const Destruct` has
3 // no effect on stable code so it should be hidden as well.
4 //
5 // To future blessers: make sure that `const_trait_impl` is
6 // stabilized when changing `@!has` to `@has`, and please do
7 // not remove this test.
8 #![feature(const_trait_impl)]
9 #![crate_name = "foo"]
10
11 use std::marker::Destruct;
12
13 pub struct S<T>(T);
14
15 // @!has foo/trait.Tr.html '//div[@class="item-decl"]/pre[@class="rust"]/code/a[@class="trait"]' '~const'
16 // @has - '//div[@class="item-decl"]/pre[@class="rust"]/code/a[@class="trait"]' 'Clone'
17 // @!has - '//div[@class="item-decl"]/pre[@class="rust"]/code/span[@class="where"]' '~const'
18 // @has - '//div[@class="item-decl"]/pre[@class="rust"]/code/span[@class="where"]' ': Clone'
19 #[const_trait]
20 pub trait Tr<T> {
21     // @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const'
22     // @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
23     // @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
24     // @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
25     fn a<A: ~const Clone + ~const Destruct>()
26     where
27         Option<A>: ~const Clone + ~const Destruct,
28     {
29     }
30 }
31
32 // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]' ''
33 // @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const'
34 // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Clone'
35 // @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const'
36 // @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
37 impl<T: ~const Clone + ~const Destruct> const Tr<T> for T
38 where
39     Option<T>: ~const Clone + ~const Destruct,
40 {
41     fn a<A: ~const Clone + ~const Destruct>()
42     where
43         Option<A>: ~const Clone + ~const Destruct,
44     {
45     }
46 }
47
48 // @!has foo/fn.foo.html '//div[@class="item-decl"]/pre[@class="rust"]/code/a[@class="trait"]' '~const'
49 // @has - '//div[@class="item-decl"]/pre[@class="rust"]/code/a[@class="trait"]' 'Clone'
50 // @!has - '//div[@class="item-decl"]/pre[@class="rust"]/code/span[@class="where fmt-newline"]' '~const'
51 // @has - '//div[@class="item-decl"]/pre[@class="rust"]/code/span[@class="where fmt-newline"]' ': Clone'
52 pub const fn foo<F: ~const Clone + ~const Destruct>()
53 where
54     Option<F>: ~const Clone + ~const Destruct,
55 {
56     F::a()
57 }
58
59 impl<T> S<T> {
60     // @!has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const'
61     // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
62     // @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const'
63     // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
64     pub const fn foo<B, C: ~const Clone + ~const Destruct>()
65     where
66         B: ~const Clone + ~const Destruct,
67     {
68         B::a()
69     }
70 }