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

Cannot compile todo!() in functions returning impl Trait with associated types #117293

Closed
nicklimmm opened this issue Oct 27, 2023 · 1 comment
Closed
Labels
C-bug Category: This is a bug.

Comments

@nicklimmm
Copy link
Contributor

nicklimmm commented Oct 27, 2023

I tried this code:

trait Trait {
    type Type;
}

fn foo() -> impl Trait<Type = ()> {
    todo!()
}

Expected:

  • Compile without errors, similar to when returning other types such as i32, etc.

Instead, this happened:

error[E0277]: the trait bound `(): Trait` is not satisfied
 --> src/main.rs:5:13
  |
5 | fn foo() -> impl Trait<Type = ()> {
  |             ^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `()`
  |

Question:

  • Could this be caused by the behavior of having the ! type in the function body?

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (aa1a71e9e 2023-10-26)
binary: rustc
commit-hash: aa1a71e9e90f6eb3aed8cf79fc80bea304c17ecb
commit-date: 2023-10-26
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.3
Backtrace
@nicklimmm nicklimmm added the C-bug Category: This is a bug. label Oct 27, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 27, 2023
@fmease
Copy link
Member

fmease commented Oct 27, 2023

Closing as duplicate of #113875.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 28, 2023
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.
Projects
None yet
Development

No branches or pull requests

3 participants