Skip to content

Bogus associated type HKT syntax somehow compiles with no errors #23543

Closed

Description

@theemathas

Code:

pub trait A : Copy {}

struct Foo;

pub trait D {
    fn f<T>(self)
        where T<Bogus = Foo>: A;
}

fn main() {}

playpen

This isn't supposed to compile at all.

Probably a variant of #23544

Activity

  1. added
    I-ICE
    on Mar 22, 2015
  2. bombless commented on Apr 1, 2015

    @bombless
    Contributor
    use std::marker::PhantomFn;
    
    trait Trait<T>: PhantomFn<Self, T> {}
    
    impl<T> Trait<T> for () where Trait<T>: Eq {}
    
    fn main() {}

    This seems similar (illegal bounds at where clause)

  3. theemathas commented on Apr 1, 2015

    @theemathas
    ContributorAuthor

    This is incorrectly labelled. This should be I-wrong, not I-ICE

  4. added and removed
    I-ICE
    on Apr 1, 2015
  5. huonw commented on Apr 1, 2015

    @huonw
    Contributor

    @bombless I'm not sure that is illegal, since Trait<T> is a valid type (its is a DST): that impl is just conditional on whether the Trait<T> type implements Eq, e.g.

    use std::marker::PhantomFn;
    
    trait Trait<T>: PhantomFn<Self, T> {}
    
    impl<T> Trait<T> for () where Trait<T>: Eq {}
    
    
    fn foo<T, U: Trait<T>>() {}
    
    
    impl PartialEq for Trait<u16> {
        fn eq(&self, _: &Trait<u16>) -> bool { false }
    }
    impl Eq for Trait<u16> {}
    
    
    fn main() {
        foo::<u16, ()>();
    
        // foo::<u8, ()>();
        // error: the trait `core::cmp::Eq` is not implemented for the type `Trait<u8>`
    }
  6. Stebalien commented on Sep 16, 2015

    @Stebalien
    Contributor

    Triage: can't reproduce.

    tmp.rs:7:17: 7:28 error: associated type bindings are not allowed here [E0229]
    tmp.rs:7         where T<Bogus = Foo>: A;
                             ^~~~~~~~~~~
    error: aborting due to previous error
    
  7. added
    E-needs-test
    on Sep 16, 2015
  8. added a commit that references this issue on Sep 17, 2015
    a06812f
  9. added a commit that references this issue on Nov 16, 2026
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

    E-needs-test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions