File: multiple-markers.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie, trixie-backports, trixie-proposed-updates
  • 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 (47 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download | duplicates (4)
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
// Regression test for <https://github.com/rust-lang/rust/issues/113840>
//
// This test makes sure that multiple marker (method-less) traits can reuse the
// same pointer for upcasting.
//
//@ build-fail
#![crate_type = "lib"]
#![feature(rustc_attrs)]

// Markers
trait M0 {}
trait M1 {}
trait M2 {}

// Just a trait with a method
trait T {
    fn method(&self) {}
}

#[rustc_dump_vtable]
trait A: M0 + M1 + M2 + T {} //~ error: vtable entries for `<S as A>`:

#[rustc_dump_vtable]
trait B: M0 + M1 + T + M2 {} //~ error: vtable entries for `<S as B>`:

#[rustc_dump_vtable]
trait C: M0 + T + M1 + M2 {} //~ error: vtable entries for `<S as C>`:

#[rustc_dump_vtable]
trait D: T + M0 + M1 + M2 {} //~ error: vtable entries for `<S as D>`:

struct S;

impl M0 for S {}
impl M1 for S {}
impl M2 for S {}
impl T for S {}
impl A for S {}
impl B for S {}
impl C for S {}
impl D for S {}

pub fn require_vtables() {
    fn require_vtables(_: &dyn A, _: &dyn B, _: &dyn C, _: &dyn D) {}

    require_vtables(&S, &S, &S, &S)
}