Skip to content

impl Trait doesn't understand that empty functions return () #36379

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
Stebalien opened this issue Sep 10, 2016 · 3 comments · Fixed by #42230
Closed

impl Trait doesn't understand that empty functions return () #36379

Stebalien opened this issue Sep 10, 2016 · 3 comments · Fixed by #42230
Labels
A-trait-system Area: Trait system A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@Stebalien
Copy link
Contributor

The following should compile because (): Default:

#![feature(conservative_impl_trait)]
fn test() -> impl Default {}

However, it fails with:

error[E0282]: unable to infer enough type information about `_`
 --> tmp.rs:2:14
  |
2 | fn test() -> impl Default {}
  |              ^^^^^^^^^^^^ cannot infer type for `_`
  |
  = note: type annotations or generic parameter binding required

(Obviously, nobody will ever run into this in practice...)

@apasel422 apasel422 added A-trait-system Area: Trait system A-type-system Area: Type system labels Dec 28, 2016
@Mark-Simulacrum
Copy link
Member

This works today; E-needstest.

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 18, 2017
@venkatagiri
Copy link
Contributor

@Mark-Simulacrum would a run-pass be fine for this?

@Mark-Simulacrum
Copy link
Member

Let's go with a compile-fail test that look something like this one; meaningful part being these two lines. Let me know if you have any more questions!

venkatagiri added a commit to venkatagiri/rust that referenced this issue May 25, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
@fmease fmease added A-type-system Area: Type system and removed A-type-system Area: Type system labels Dec 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-trait-system Area: Trait system A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants