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

Comments

@Globidev
Copy link

@Globidev Globidev commented Mar 11, 2019

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

@sanxiyn
Copy link
Member

@sanxiyn 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();
}
Centril added a commit to Centril/rust that referenced this issue Mar 13, 2019
Visit impl Trait for dead_code lint

Fix rust-lang#59085.
@bors bors closed this in #59129 Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants