-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
The statements of test
has an arguably inconsistent behvaiour here:
#![feature(type_alias_impl_trait)]
use std::ops::Deref;
trait Trait {}
impl<A, B> Trait for (A, B, u8) where A: Deref, B: Deref<Target = A::Target>, {}
impl<A, B> Trait for (A, B, i8) {}
type TaitSized = impl Sized;
fn def_tait1() -> TaitSized {}
type TaitCopy = impl Copy;
fn def_tait2() -> TaitCopy {}
fn impl_trait<T: Trait> () {}
fn test() {
impl_trait::<(&TaitSized, &TaitCopy, _)>(); // Pass
impl_trait::<(&TaitCopy, &TaitSized, _)>(); //~ ERROR type annotation needed
impl_trait::<(&TaitCopy, &String, _)>(); // Pass
impl_trait::<(&TaitSized, &String, _)>(); //~ ERROR type annotation needed
}
Additionally, all the statements pass when TAIT's are put in a different module:
#![feature(type_alias_impl_trait)]
use std::ops::Deref;
trait Trait {}
impl<A, B> Trait for (A, B, u8) where A: Deref, B: Deref<Target = A::Target>, {}
impl<A, B> Trait for (A, B, i8) {}
mod taits {
pub type TaitSized = impl Sized;
fn def_tait1() -> TaitSized {}
pub type TaitCopy = impl Copy;
fn def_tait2() -> TaitCopy {}
}
fn impl_trait<T: Trait> () {}
fn test() {
use taits::*;
impl_trait::<(&TaitSized, &TaitCopy, _)>(); // Pass
impl_trait::<(&TaitCopy, &TaitSized, _)>(); // Pass
impl_trait::<(&TaitCopy, &String, _)>(); // Pass
impl_trait::<(&TaitSized, &String, _)>(); // Pass
}
rustc version: 1.75.0-nightly (2023-10-21 1c05d50)
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Projects
Status
Done