File: maybe.rs

package info (click to toggle)
rust-easy-ext 1.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 284 kB
  • sloc: makefile: 2
file content (81 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download
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
// SPDX-License-Identifier: Apache-2.0 OR MIT

// See also `maybe` test in test.rs

use easy_ext::ext;

#[ext(E1)]
impl<T: ?Sized> T // Ok
{
    fn f(&self) {}
}

#[ext(E2)]
impl<T> T
where
    T: ?Sized, // Ok
{
    fn f(&self) {}
}

#[ext(E3)]
impl<T> T
where
    Self: ?Sized,
{
    //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
    fn f(&self) {}
}

// The following is a case where #[ext] is not used. The behavior should match in both cases.

trait T1
where
    Self: ?Sized,
{
    //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
    fn f(&self);
}

trait T2 {
    fn f(&self);
}
impl<T> T2 for T
where
    Self: ?Sized,
{
    //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
    fn f(&self) {}
}

trait T3 {
    fn f(&self);
}
impl<T: ?Sized> T3 for T // Ok
{
    fn f(&self) {}
}

trait T4 {
    fn f(&self);
}
impl<T> T4 for T
where
    T: ?Sized, // Ok
{
    fn f(&self) {}
}

trait T5 {
    fn f(&self);
}
impl<T> T5 for T {
    fn f(&self)
    where
        T: ?Sized,
    {
        //~^^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
    }
}

fn main() {}