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

Type alias used in async fn return type is wrongly reported unused #59085

Closed
Globidev opened this issue Mar 11, 2019 · 1 comment
Closed

Type alias used in async fn return type is wrongly reported unused #59085

Globidev opened this issue Mar 11, 2019 · 1 comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Globidev
Copy link

With rustc 1.35.0-nightly (26b4cb484 2019-03-09)
The following code

type Bar = ();
async fn foo() -> Bar { }

produces the following warning

warning: type alias is never used: `Bar`                                  
 --> src/main.rs:3:1
  |
3 | type Bar = ();
  | ^^^^^^^^^^^^^^
  |
  = note: #[warn(dead_code)] on by default

When Bar is clearly used here.
This seem to only trigger if the alias is used in the return type position

@jonas-schievink jonas-schievink added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-async-await Area: Async & Await labels Mar 11, 2019
@sanxiyn
Copy link
Member

sanxiyn commented Mar 11, 2019

This is unrelated to async fn as one can reproduce with just impl Trait:

trait Trait {
    type Type;
}

impl Trait for () {
    type Type = ();
}

type Bar = ();
fn foo() -> impl Trait<Type = Bar> {}

fn main() {
    foo();
}

@sanxiyn sanxiyn added A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. and removed A-async-await Area: Async & Await labels Mar 11, 2019
Centril added a commit to Centril/rust that referenced this issue Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. 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

3 participants