File: no-define-in-wf-check.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 893,176 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; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (66 lines) | stat: -rw-r--r-- 1,482 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@[next] check-pass

// Regression test for trait-system-refactor-initiative#106. We previously
// tried to define other opaques while checking that opaques are well-formed.
//
// This resulted in undesirable ambiguity

#![feature(type_alias_impl_trait)]

mod ex0 {
    fn foo() -> (impl Sized, impl Sized) {
        ((), ())
    }
}
mod ex1 {
    type Tait1 = impl Sized;
    //[current]~^ ERROR unconstrained opaque type
    fn foo(x: Tait1) -> impl Sized {
        let () = x;
    }
}

mod ex2 {
    type Tait1 = impl Sized;
    //[current]~^ ERROR unconstrained opaque type
    type Tait2 = impl Sized;
    fn foo(x: Tait1) -> Tait2 {
        let () = x;
    }
}

mod ex3 {
    type Tait1 = impl Sized;
    //[current]~^ ERROR unconstrained opaque type
    trait Something<T> {}
    impl<T, U> Something<U> for T {}
    type Tait2 = impl Something<Tait1>;
    fn foo(x: Tait1) -> Tait2 {
        let () = x;
    }
}

mod ex4 {
    type Tait1 = impl Sized;
    //[current]~^ ERROR unconstrained opaque type
    trait Trait<U> {
        type Assoc;
    }

    impl<T, U> Trait<U> for T {
        type Assoc = T;
    }

    // ambiguity when checking that `Tait2` is wf
    //
    // ambiguity proving `(): Trait<Tait1>`.
    type Tait2 = impl Trait<(), Assoc = impl Trait<Tait1>>;
    fn foo(x: Tait1) -> Tait2 {
        let () = x;
    }
}

fn main() {}