Skip to content

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

Closed
@Globidev

Description

@Globidev

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

Activity

added
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Mar 11, 2019
sanxiyn

sanxiyn commented on Mar 11, 2019

@sanxiyn
Member

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();
}
added
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
and removed on Mar 11, 2019
added a commit that references this issue on Mar 13, 2019

Rollup merge of rust-lang#59129 - sanxiyn:visit-impl-trait, r=varkor

b70a98f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sanxiyn@jonas-schievink@Globidev

        Issue actions

          Type alias used in async fn return type is wrongly reported unused · Issue #59085 · rust-lang/rust