File: not-on-struct.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, 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 (38 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download | duplicates (14)
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
// We don't need those errors. Ideally we would silence them, but to do so we need to move the
// lint from being an early-lint during parsing to a late-lint, because it needs to be aware of
// the types involved.
#![allow(bare_trait_objects)]

struct Foo;

fn foo(_x: Box<Foo + Send>) { } //~ ERROR expected trait, found struct `Foo`

type TypeAlias<T> = Box<dyn Vec<T>>; //~ ERROR expected trait, found struct `Vec`

struct A;
fn a() -> A + 'static { //~ ERROR expected trait, found
    A
}
fn b<'a,T,E>(iter: Iterator<Item=Result<T,E> + 'a>) { //~ ERROR expected trait, found
    panic!()
}
fn c() -> 'static + A { //~ ERROR expected trait, found
    A
}
fn d<'a,T,E>(iter: Iterator<Item='a + Result<T,E>>) { //~ ERROR expected trait, found
    panic!()
}
fn e() -> 'static + A + 'static { //~ ERROR expected trait, found
//~^ ERROR only a single explicit lifetime bound is permitted
    A
}
fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) { //~ ERROR expected trait, found
//~^ ERROR only a single explicit lifetime bound is permitted
    panic!()
}
struct Traitor;
trait Trait {}
fn g() -> Traitor + 'static { //~ ERROR expected trait, found struct `Traitor`
    A
}
fn main() {}