Skip to content

TAIT: it's possible to impl a trait for a tait by using projections #99840

Description

@lcnr
#![feature(type_alias_impl_trait)]
type Alias = impl Sized;

fn constrain() -> Alias {
    1i32
}

trait HideIt {
    type Assoc;
}

impl HideIt for () {
    type Assoc = Alias;
}

pub trait Yay {}

impl Yay for <() as HideIt>::Assoc {}
// impl Yay for i32 {} // this errors
// impl Yay for u32 {} // this also errors

As coherence checking keeps opaque types opaque this should not be unsound. Considering that a direct impl for opaque types is forbidden, this is an inconsistency we should resolve though.

cc @oli-obk

Activity

  1. added
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    on Jul 28, 2022
  2. oli-obk commented on Jul 28, 2022

    @oli-obk
    Contributor
  3. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Jul 28, 2022
  4. lcnr commented on Jul 28, 2022

    @lcnr
    ContributorAuthor

    what, is that a recent regression? :o these do error with rustc 1.63.0-nightly (5435ed691 2022-06-07)

  5. added
    I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Jul 28, 2022
  6. added
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Jul 28, 2022
  7. lqd commented on Jul 28, 2022

    @lqd
    Member

    It looks to be from last week's #99506, and out of that rollup #99345 looks likely.

  8. oli-obk commented on Jul 28, 2022

    @oli-obk
    Contributor

    Hmm... that one got reverted in #99079

    cc @compiler-errors

  9. lqd commented on Jul 28, 2022

    @lqd
    Member

    Was that a revert, or a targeted fix for closures ?

  10. oli-obk commented on Jul 28, 2022

    @oli-obk
    Contributor

    revert + actual fix of the original issue

  11. lqd commented on Jul 28, 2022

    @lqd
    Member

    The behavior is the same on master, no errors + ICEs. I'll try to manually bisect within the rollup to confirm cargo-bisect-rustc's findings.

  12. compiler-errors commented on Jul 28, 2022

    @compiler-errors
    Contributor

    Isn't this just another form of #99554?

  13. lqd commented on Jul 28, 2022

    @lqd
    Member

    (I wish we had try builds for each rolled up PR 😅) It was indeed introduced in the same rollup: by eecfdfb / #99383.

    Reverting that does indeed bring the conflicting implementation errors back, and fixes the ICE.

  14. lcnr commented on Jul 28, 2022

    @lcnr
    ContributorAuthor

    Isn't this just another form of #99554?

    no, #99554 is using projections in ways which should fail the orphan check, here we have projections which should pass the orphan check, but can be normalized to opaque types.

    These issues need two distinct fixes

    the fix for this being: add tests for auto trait stuff with opaque types but allow them in impls. As coherence doesn't use Reveal::All, having one impl trait ref with impl A<X, opaque, Y> for Z should conflict with all impl A<X, whatever, Y> for Z. Have to think more about this though

  15. oli-obk commented on Jul 28, 2022

    @oli-obk
    Contributor

    I have a proper fix locally, but we should investigate how #99383 affected this

  16. removed
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Jul 29, 2022
  17. ouz-a commented on Aug 1, 2022

    @ouz-a
    Contributor

    (I wish we had try builds for each rolled up PR 😅) It was indeed introduced in the same rollup: by eecfdfb / #99383.

    Reverting that does indeed bring the conflicting implementation errors back, and fixes the ICE.

    Although it looks suspicious this is not caused by #99383 I reverted all changes made by it and tested it, this still passes without any errors. Here https://github.com/ouz-a/rust/tree/undo_formalize

  18. moved this from Todo to In Progress in type alias impl trait stabilizationon Oct 30, 2022
  19. added 4 commits that reference this issue on Nov 22, 2022
    43eb708
    06666bb
    8c1cec9
    53eab24
  20. Repository owner moved this from In Progress to Done in type alias impl trait stabilizationon Nov 23, 2022
  21. added a commit that references this issue on Dec 1, 2022
    91d2ce3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-typesRelevant to the types team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions