about summary refs log tree commit diff
path: root/src/tools/rustfmt/tests/target/cfg_attribute_in_where.rs
blob: 11f495b1629955591e2eb4b8977205d3338361e1 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// rustfmt-inline_attribute_width: 40

#![crate_type = "lib"]
#![feature(cfg_attribute_in_where)]
use std::marker::PhantomData;

#[cfg(a)]
trait TraitA {}

#[cfg(b)]
trait TraitB {}

trait A<T>
where
    #[cfg = a_very_long_attribute_name]
    T: TraitA,
    #[cfg = another_very_long_attribute_name]
    T: TraitB,
{
    type B<U>
    where
        #[cfg = a]
        // line comment after the attribute
        U: TraitA,
        #[cfg = b]
        /* block comment after the attribute */
        U: TraitB,
        #[cfg = a] // short
        U: TraitA,
        #[cfg = b] /* short */ U: TraitB;

    fn foo<U>(&self)
    where
        /// line doc comment before the attribute
        U: TraitA,
        /** line doc block comment before the attribute */
        U: TraitB;
}

impl<T> A<T> for T
where
    #[doc = "line doc before the attribute"]
    T: TraitA,
    /** short doc */
    T: TraitB,
{
    type B<U>
        = ()
    where
        #[doc = "short"] U: TraitA,
        #[doc = "short"]
        #[cfg = a]
        U: TraitB;

    fn foo<U>(&self)
    where
        #[cfg = a]
        #[cfg = b]
        U: TraitA,
        /// line doc
        #[cfg = c]
        U: TraitB,
    {
    }
}

struct C<T>
where
    #[cfg = a] T: TraitA,
    #[cfg = b] T: TraitB,
{
    _t: PhantomData<T>,
}

union D<T>
where
    #[cfg = a] T: TraitA,
    #[cfg = b] T: TraitB,
{
    _t: PhantomData<T>,
}

enum E<T>
where
    #[cfg = a] T: TraitA,
    #[cfg = b] T: TraitB,
{
    E(PhantomData<T>),
}

#[allow(type_alias_bounds)]
type F<T>
where
    #[cfg = a] T: TraitA,
    #[cfg = b] T: TraitB,
= T;

impl<T> C<T>
where
    #[cfg = a] T: TraitA,
    #[cfg = b] T: TraitB,
{
    fn new<U>()
    where
        #[cfg = a] U: TraitA,
        #[cfg = b] U: TraitB,
    {
    }
}

fn foo<T>()
where
    #[cfg = a] T: TraitA,
    #[cfg = b] T: TraitB,
{
}