Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Compiler doesn't think that an associate type implements const trait #101982

Closed
fee1-dead opened this issue Sep 18, 2022 · 0 comments · Fixed by #101989
Closed

Compiler doesn't think that an associate type implements const trait #101982

fee1-dead opened this issue Sep 18, 2022 · 0 comments · Fixed by #101989
Assignees
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]`

Comments

@fee1-dead
Copy link
Member

I tried this code: play

#![feature(const_trait_impl)]

#[const_trait]
trait Foo {
    type Assoc: ~const Foo;
    fn foo() {}
}

const fn foo<T: ~const Foo>() {
    <T as Foo>::Assoc::foo();
}

I expected to see this happen: Compiles

Instead, this happened: errors

error[E0277]: the trait bound `<T as Foo>::Assoc: ~const Foo` is not satisfied
  --> src/lib.rs:10:5
   |
10 |     <T as Foo>::Assoc::foo();
   |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `~const Foo` is not implemented for `<T as Foo>::Assoc`
   |
note: the trait `Foo` is implemented for `<T as Foo>::Assoc`, but that implementation is not `const`
  --> src/lib.rs:10:5
   |
10 |     <T as Foo>::Assoc::foo();
   |     ^^^^^^^^^^^^^^^^^^^^^^
help: consider further restricting the associated type
   |
9  | const fn foo<T: ~const Foo>() where <T as Foo>::Assoc: ~const Foo {
   |                               +++++++++++++++++++++++++++++++++++

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` due to previous error
@fee1-dead fee1-dead added C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` labels Sep 18, 2022
@fee1-dead fee1-dead self-assigned this Sep 18, 2022
@bors bors closed this as completed in cd8cc91 Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant