rust/tests/ui/traits/next-solver/cycles/inductive-cycle-but-ok.rs

45 lines
1.0 KiB
Rust
Raw Normal View History

2023-12-14 06:11:28 -06:00
// compile-flags: -Znext-solver
2023-08-10 05:56:53 -05:00
// check-pass
#![feature(trivial_bounds, marker_trait_attr)]
#![allow(trivial_bounds)]
// This previously triggered a bug in the provisional cache.
//
// This has the proof tree
// - `Root: Trait` proven via impl
// - `MultipleCandidates: Trait`
// - candidate: overflow-impl
// - `Root: Trait` (inductive cycle ~> OVERFLOW)
// - candidate: trivial-impl ~> YES
// - merge respones ~> YES
// - `MultipleCandidates: 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 `YES`.
struct Root;
struct MultipleCandidates;
#[marker]
trait Trait {}
impl Trait for Root
where
MultipleCandidates: Trait,
MultipleCandidates: Trait,
{}
// overflow-impl
impl Trait for MultipleCandidates
where
Root: Trait,
{}
// trivial-impl
impl Trait for MultipleCandidates {}
fn impls_trait<T: Trait>() {}
fn main() {
impls_trait::<Root>();
}