File: method-signature-matches.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (59 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download | duplicates (5)
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
//@ edition: 2021
//@ revisions: mismatch mismatch_async too_many too_few lt

#[cfg(mismatch)]
trait Uwu {
    fn owo(x: ()) -> impl Sized;
}

#[cfg(mismatch)]
impl Uwu for () {
    fn owo(_: u8) {}
    //[mismatch]~^ ERROR method `owo` has an incompatible type for trait
}

#[cfg(mismatch_async)]
trait AsyncUwu {
    async fn owo(x: ()) {}
}

#[cfg(mismatch_async)]
impl AsyncUwu for () {
    async fn owo(_: u8) {}
    //[mismatch_async]~^ ERROR method `owo` has an incompatible type for trait
}

#[cfg(too_many)]
trait TooMuch {
    fn calm_down_please() -> impl Sized;
}

#[cfg(too_many)]
impl TooMuch for () {
    fn calm_down_please(_: (), _: (), _: ()) {}
    //[too_many]~^ ERROR method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0
}

#[cfg(too_few)]
trait TooLittle {
    fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized;
}

#[cfg(too_few)]
impl TooLittle for () {
    fn come_on_a_little_more_effort() {}
    //[too_few]~^ ERROR method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3
}

#[cfg(lt)]
trait Lifetimes {
    fn early<'early, T>(x: &'early T) -> impl Sized;
}

#[cfg(lt)]
impl Lifetimes for () {
    fn early<'late, T>(_: &'late ()) {}
    //[lt]~^ ERROR method `early` has an incompatible type for trait
}

fn main() {}