Skip to content

The todo! macro does not play well with RPIT #121449

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
sillykelvin opened this issue Feb 22, 2024 · 1 comment
Closed

The todo! macro does not play well with RPIT #121449

sillykelvin opened this issue Feb 22, 2024 · 1 comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sillykelvin
Copy link

Given the following code:

trait T {}

fn foo() -> impl T {
    todo!()
}

fn bar<U: T>() -> U {
    todo!()
}

Function foo fails to compile, while bar is ok. The compiler reports the following error:

   Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `(): T` is not satisfied
 --> src/lib.rs:3:13
  |
3 | fn foo() -> impl T {
  |             ^^^^^^ the trait `T` is not implemented for `()`
  |
help: this trait has no implementations, consider adding one
 --> src/lib.rs:1:1
  |
1 | trait T {}
  | ^^^^^^^

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (lib) due to 1 previous error

I'm using rustc 1.76.0, however, the nightly version (2024-02-21 3406ada) also produces the same error.

PS: It's the same result for returning impl Future and async functions, I think it might be the same problem (in the following code, foo fails to compile, while bar is ok):

use std::future::Future;

fn foo() -> impl Future {
    todo!()
}

async fn bar() {
    todo!()
}
@sillykelvin sillykelvin added the C-bug Category: This is a bug. label Feb 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 22, 2024
@sillykelvin sillykelvin changed the title The todo! macro does not play well with RPITIT The todo! macro does not play well with RPIT Feb 22, 2024
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 22, 2024
@fmease
Copy link
Member

fmease commented Feb 22, 2024

Closing as duplicate of #113875.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
# 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. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants