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

todo!() macro doesn't work in implementations of trait methods with return position impl Trait #125097

Closed
licynthiax opened this issue May 14, 2024 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@licynthiax
Copy link

Hi! When there are impl Trait return types in trait definitions, the todo!() macro doesn't work as expected in them:

trait Foo {}

trait Bar {
    fn x() -> impl Foo;
}

struct Baz;

impl Bar for Baz {
    fn x() -> impl Foo {
        todo!()
    }
}

I expect this code to compile but panic at runtime if I call x(), but instead I get this compile-time error:

error[E0277]: the trait bound `(): Foo` is not satisfied
  --> src/main.rs:10:15
   |
10 |     fn x() -> impl Foo {
   |               ^^^^^^^^ the trait `Foo` is not implemented for `()`
   |
help: this trait has no implementations, consider adding one
  --> src/main.rs:1:1
   |
1  | trait Foo {}
   | ^^^^^^^^^

Meta

rustc --version --verbose:

rustc 1.77.1 (7cf61ebde 2024-03-27)

Backtrace: n/a (output same as above)

@licynthiax licynthiax added the C-bug Category: This is a bug. label May 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 14, 2024
@fmease
Copy link
Member

fmease commented May 14, 2024

Duplicate of #113875.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 14, 2024
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