about summary refs log tree commit diff
path: root/tests/ui/traits/const-traits/unconstrained-var-specialization.rs
blob: 43a3311445012bb58334dc4a3abbc81b8f85ea5c (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
//@ check-pass
//@ compile-flags: --crate-type=lib
#![no_std]
#![allow(internal_features)]
#![feature(rustc_attrs, min_specialization, const_trait_impl)]

// In the default impl below, `A` is constrained by the projection predicate, and if the host effect
// predicate for `const Foo` doesn't resolve vars, then specialization will fail.

#[const_trait]
trait Foo {}

pub trait Iterator {
    type Item;
}

#[rustc_unsafe_specialization_marker]
pub trait MoreSpecificThanIterator: Iterator {}

pub trait Tr {
    fn foo();
}

impl<A: const Foo, Iter> Tr for Iter
    where
        Iter: Iterator<Item = A>,
{
    default fn foo() {}
}

impl<A: const Foo, Iter> Tr for Iter
    where
        Iter: MoreSpecificThanIterator<Item = A>,
{
    fn foo() {}
}