Skip to content

todo! macro does not satisfy type-checker when impl Trait is in the return position #132674

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
duncpro opened this issue Nov 6, 2024 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@duncpro
Copy link
Contributor

duncpro commented Nov 6, 2024

The todo! macro does not satisfy the type-checker when impl Trait is in the return position.

This behavior contradicts the official documentation.

[todo!] can be useful if you are prototyping and just want a placeholder to let your code pass type analysis.

- doc for std::todo macro

Example

// src/main.rs
struct T;

fn make_iter() -> impl Iterator<Item = T> {
    todo!()
}

fn main() {
    make_iter();
}
cargo run

Playground

Expected Behavior

The code to compile normally and panic during execution.

Actual Behavior

The code fails to compile because it does not pass typecheck.
Image

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: aarch64-apple-darwin
release: 1.82.0
LLVM version: 19.1.1
@duncpro duncpro added the C-bug Category: This is a bug. label Nov 6, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 6, 2024
@theemathas
Copy link
Contributor

Duplicate of #113875

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 6, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Nov 6, 2024

Indeed. Thanks for the report anyway!

@jieyouxu jieyouxu closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
@duncpro
Copy link
Contributor Author

duncpro commented Nov 9, 2024

Perhaps a note can be added to the docs for todo! so this doesn't get reported again?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants