Skip to content

surprising behaviour when relating opaque types in winnowing #117310

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
aliemjay opened this issue Oct 28, 2023 · 0 comments · Fixed by #122949
Closed

surprising behaviour when relating opaque types in winnowing #117310

aliemjay opened this issue Oct 28, 2023 · 0 comments · Fixed by #122949
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@aliemjay
Copy link
Member

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)

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 28, 2023
@aliemjay aliemjay added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 28, 2023
ShoyuVanilla added a commit to ShoyuVanilla/rust that referenced this issue Mar 23, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 24, 2024
Add a regression test for rust-lang#117310

Closes rust-lang#117310

It seems to have been fixed in `rustc 1.79.0-nightly (1388d7a 2024-03-20)` or before, so just adding a regression test for it.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 24, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#122737 (conditionally ignore fatal diagnostic in the SilentEmitter)
 - rust-lang#122757 (Fixed the `private-dependency` bug)
 - rust-lang#122886 (add test for rust-lang#90192)
 - rust-lang#122937 (Unbox and unwrap the contents of `StatementKind::Coverage`)
 - rust-lang#122949 (Add a regression test for rust-lang#117310)
 - rust-lang#122962 (Track run-make-support lib in common inputs stamp)
 - rust-lang#122977 (Rename `Arguments::as_const_str` to `as_statically_known_str`)
 - rust-lang#122983 (Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD)
 - rust-lang#122984 (panic-in-panic-hook: formatting a message that's just a string is risk-free)
 - rust-lang#122992 (std::thread: refine available_parallelism for solaris/illumos.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 24, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#122737 (conditionally ignore fatal diagnostic in the SilentEmitter)
 - rust-lang#122757 (Fixed the `private-dependency` bug)
 - rust-lang#122886 (add test for rust-lang#90192)
 - rust-lang#122937 (Unbox and unwrap the contents of `StatementKind::Coverage`)
 - rust-lang#122949 (Add a regression test for rust-lang#117310)
 - rust-lang#122962 (Track run-make-support lib in common inputs stamp)
 - rust-lang#122977 (Rename `Arguments::as_const_str` to `as_statically_known_str`)
 - rust-lang#122983 (Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD)
 - rust-lang#122984 (panic-in-panic-hook: formatting a message that's just a string is risk-free)
 - rust-lang#122992 (std::thread: refine available_parallelism for solaris/illumos.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 96a5348 Mar 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 24, 2024
Rollup merge of rust-lang#122949 - ShoyuVanilla:issue-117310, r=lcnr

Add a regression test for rust-lang#117310

Closes rust-lang#117310

It seems to have been fixed in `rustc 1.79.0-nightly (1388d7a 2024-03-20)` or before, so just adding a regression test for it.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-types Relevant to the types team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

2 participants