about summary refs log tree commit diff
path: root/tests/ui/traits/next-solver/cycles/inductive-cycle-but-err.rs
blob: 754fc872e457cb06f386dce1c246dedbfa9d67c3 (plain)
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
//@ compile-flags: -Znext-solver
#![feature(trivial_bounds, marker_trait_attr)]
#![allow(trivial_bounds)]
// This previously triggered a bug in the provisional cache.
//
// This has the proof tree
// - `MultipleCandidates: Trait` proven via impl-one
//   - `MultipleNested: Trait` via impl
//     - `MultipleCandidates: Trait` (inductive cycle ~> OVERFLOW)
//     - `DoesNotImpl: Trait` (ERR)
// - `MultipleCandidates: Trait` proven via impl-two
//   - `MultipleNested: Trait` (in provisional cache ~> OVERFLOW)
//
// We previously incorrectly treated the `MultipleCandidates: Trait` as
// overflow because it was in the cache and reached via an inductive cycle.
// It should be `NoSolution`.

struct MultipleCandidates;
struct MultipleNested;
struct DoesNotImpl;

#[marker]
trait Trait {}

// impl-one
impl Trait for MultipleCandidates
where
    MultipleNested: Trait
{}

// impl-two
impl Trait for MultipleCandidates
where
    MultipleNested: Trait,
{}

// We ignore the trivially true global where-bounds when checking that this
// impl is well-formed, meaning that we depend on `MultipleNested: Trait` when
// recursively proving `MultipleCandidates: Trait`.
//
// These overflow errors will disappear once we treat these cycles as either
// productive or an error.
impl Trait for MultipleNested
//~^ ERROR overflow evaluating the requirement `MultipleNested: Trait`
where
    MultipleCandidates: Trait,
    //~^ ERROR overflow evaluating the requirement `MultipleCandidates: Trait`
    DoesNotImpl: Trait,
{}

fn impls_trait<T: Trait>() {}

fn main() {
    impls_trait::<MultipleCandidates>();
    //~^ ERROR the trait bound `MultipleCandidates: Trait` is not satisfied
}