mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00

In the standard library, the `Extend` impl for `Iterator` (specialised with `TrustedLen`) has a parameter which is constrained by a projection predicate. This projection predicate provides a value for an inference variable but host effect evaluation wasn't resolving variables first. Adding the extra resolve can the number of errors in some tests when they gain host effect predicates, but this is not unexpected as calls to `resolve_vars_if_possible` can cause more error tainting to happen. Co-authored-by: Boxy <rust@boxyuwu.dev>
37 lines
753 B
Rust
37 lines
753 B
Rust
//@ 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() {}
|
|
}
|