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

fn() -> impl T { todo!() } not compiling #116003

Closed
axos88 opened this issue Sep 20, 2023 · 2 comments
Closed

fn() -> impl T { todo!() } not compiling #116003

axos88 opened this issue Sep 20, 2023 · 2 comments
Labels
C-bug Category: This is a bug. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@axos88
Copy link

axos88 commented Sep 20, 2023

I tried this code:

trait Foo {}


fn not_implemented() -> impl Foo {
    todo!()
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=55e475624b24e243aef53a2ace435156

I expected to see this happen: compiles.

Instead, this happened:

Compiling playground v0.0.1 (/playground)
error[[E0277]](https://doc.rust-lang.org/stable/error_codes/E0277.html): the trait bound `(): Foo` is not satisfied
 --> src/lib.rs:4:25
  |
4 | fn not_implemented() -> impl Foo {
  |                         ^^^^^^^^ the trait `Foo` is not implemented for `()`

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

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.73.0-nightly (180dffba1 2023-08-14)
binary: rustc
commit-hash: 180dffba142c47240ca0d93096ce90b9fd97c8d7
commit-date: 2023-08-14
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0
@axos88 axos88 added the C-bug Category: This is a bug. label Sep 20, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 20, 2023
@fmease fmease added T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 20, 2023
@fmease
Copy link
Member

fmease commented Sep 20, 2023

Thanks reporting this issue! As I've elaborated in #113875, this works as intended in my opinion and according to @compiler-errors.

@fmease
Copy link
Member

fmease commented Sep 20, 2023

Closing as duplicate of #113875.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 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. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants