Unnamed repository; edit this file 'description' to name the repository.
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use super::*;

// test trait_item
// trait T { fn new() -> Self; }
pub(super) fn trait_(p: &mut Parser<'_>, m: Marker) {
    p.bump(T![trait]);
    name_r(p, ITEM_RECOVERY_SET);

    // test trait_item_generic_params
    // trait X<U: Debug + Display> {}
    generic_params::opt_generic_param_list(p);

    if p.eat(T![=]) {
        // test trait_alias
        // trait Z<U> = T<U>;
        generic_params::bounds_without_colon(p);

        // test trait_alias_where_clause
        // trait Z<U> = T<U> where U: Copy;
        // trait Z<U> = where Self: T<U>;
        generic_params::opt_where_clause(p);
        p.expect(T![;]);
        m.complete(p, TRAIT);
        return;
    }

    if p.at(T![:]) {
        // test trait_item_bounds
        // trait T: Hash + Clone {}
        generic_params::bounds(p);
    }

    // test trait_item_where_clause
    // trait T where Self: Copy {}
    generic_params::opt_where_clause(p);

    if p.at(T!['{']) {
        assoc_item_list(p);
    } else {
        p.error("expected `{`");
    }
    m.complete(p, TRAIT);
}

// test impl_item
// impl S {}
pub(super) fn impl_(p: &mut Parser<'_>, m: Marker) {
    p.bump(T![impl]);
    if p.at(T![<]) && not_a_qualified_path(p) {
        generic_params::opt_generic_param_list(p);
    }

    // test impl_item_const
    // impl const Send for S {}
    p.eat(T![const]);

    // test impl_item_never_type
    // impl ! {}
    if p.at(T![!]) && !p.nth_at(1, T!['{']) {
        // test impl_item_neg
        // impl !Send for S {}
        p.eat(T![!]);
    }
    impl_type(p);
    if p.eat(T![for]) {
        impl_type(p);
    }
    generic_params::opt_where_clause(p);
    if p.at(T!['{']) {
        assoc_item_list(p);
    } else {
        p.error("expected `{`");
    }
    m.complete(p, IMPL);
}

// test assoc_item_list
// impl F {
//     type A = i32;
//     const B: i32 = 92;
//     fn foo() {}
//     fn bar(&self) {}
// }
pub(crate) fn assoc_item_list(p: &mut Parser<'_>) {
    assert!(p.at(T!['{']));

    let m = p.start();
    p.bump(T!['{']);
    // test assoc_item_list_inner_attrs
    // impl S { #![attr] }
    attributes::inner_attrs(p);

    while !p.at(EOF) && !p.at(T!['}']) {
        if p.at(T!['{']) {
            error_block(p, "expected an item");
            continue;
        }
        item_or_macro(p, true, false);
    }
    p.expect(T!['}']);
    m.complete(p, ASSOC_ITEM_LIST);
}

// test impl_type_params
// impl<const N: u32> Bar<N> {}
fn not_a_qualified_path(p: &Parser<'_>) -> bool {
    // There's an ambiguity between generic parameters and qualified paths in impls.
    // If we see `<` it may start both, so we have to inspect some following tokens.
    // The following combinations can only start generics,
    // but not qualified paths (with one exception):
    //     `<` `>` - empty generic parameters
    //     `<` `#` - generic parameters with attributes
    //     `<` `const` - const generic parameters
    //     `<` (LIFETIME_IDENT|IDENT) `>` - single generic parameter
    //     `<` (LIFETIME_IDENT|IDENT) `,` - first generic parameter in a list
    //     `<` (LIFETIME_IDENT|IDENT) `:` - generic parameter with bounds
    //     `<` (LIFETIME_IDENT|IDENT) `=` - generic parameter with a default
    // The only truly ambiguous case is
    //     `<` IDENT `>` `::` IDENT ...
    // we disambiguate it in favor of generics (`impl<T> ::absolute::Path<T> { ... }`)
    // because this is what almost always expected in practice, qualified paths in impls
    // (`impl <Type>::AssocTy { ... }`) aren't even allowed by type checker at the moment.
    if [T![#], T![>], T![const]].contains(&p.nth(1)) {
        return true;
    }
    ([LIFETIME_IDENT, IDENT].contains(&p.nth(1)))
        && ([T![>], T![,], T![:], T![=]].contains(&p.nth(2)))
}

// test_err impl_type
// impl Type {}
// impl Trait1 for T {}
// impl impl NotType {}
// impl Trait2 for impl NotType {}
pub(crate) fn impl_type(p: &mut Parser<'_>) {
    if p.at(T![impl]) {
        p.error("expected trait or type");
        return;
    }
    types::type_(p);
}
e
-rw-r--r--
6056
README
-rw-r--r--
2362
cache.c
-rw-r--r--
10183
cache.h
-rw-r--r--
1069
cgit-doc.css
-rw-r--r--
42
cgit.c
-rw-r--r--
24897
cgit.css
-rw-r--r--
11229
cgit.h
-rw-r--r--
6942
cgit.png
-rw-r--r--
1488
cgitrc.5.txt
-rw-r--r--
21791
cmd.c
-rw-r--r--
3716
cmd.h
-rw-r--r--
301
configfile.c
-rw-r--r--
1426
configfile.h
-rw-r--r--
220
filters
d---------
gen-version.sh
-rwxr-xr-x
392
git @ 7ed863a
m---------
html.c
-rw-r--r--
6959
html.h
-rw-r--r--
1070
parsing.c
-rw-r--r--
4945
scan-tree.c
-rw-r--r--
5555
scan-tree.h
-rw-r--r--
150
shared.c
-rw-r--r--
12430
tests
d---------
ui-atom.c
-rw-r--r--
3167
ui-atom.h
-rw-r--r--
112
ui-blob.c
-rw-r--r--
2635
ui-blob.h
-rw-r--r--
195
ui-clone.c
-rw-r--r--
2414
ui-clone.h
-rw-r--r--
211
ui-commit.c
-rw-r--r--
4117
ui-commit.h
-rw-r--r--
129
ui-diff.c
-rw-r--r--
10922
ui-diff.h
-rw-r--r--
517
ui-log.c
-rw-r--r--
10825
ui-log.h
-rw-r--r--
261
ui-patch.c
-rw-r--r--
3382
ui-patch.h
-rw-r--r--
125
ui-plain.c
-rw-r--r--
3945
ui-plain.h
-rw-r--r--
120
ui-refs.c
-rw-r--r--
5916
ui-refs.h
-rw-r--r--
182
ui-repolist.c
-rw-r--r--
6867
ui-repolist.h
-rw-r--r--
146
ui-shared.c
-rw-r--r--
24249
ui-shared.h
-rw-r--r--
3145
ui-snapshot.c
-rw-r--r--
4833
ui-snapshot.h
-rw-r--r--
191
ui-ssdiff.c
-rw-r--r--
9334
ui-ssdiff.h
-rw-r--r--
479
ui-stats.c
-rw-r--r--
9785
ui-stats.h
-rw-r--r--
638
ui-summary.c
-rw-r--r--
3087
ui-summary.h
-rw-r--r--
152
ui-tag.c
-rw-r--r--
2425
ui-tag.h
-rw-r--r--
101
ui-tree.c
-rw-r--r--
6708
ui-tree.h
-rw-r--r--
119
vector.c
-rw-r--r--
762
vector.h
-rw-r--r--
292
README.md