Skip to content

Missing warning for an unused const in async fn #108296

Closed

Description

@stepantubanov

I tried this code:

pub async fn foo() {
    const A: usize = 1;
}

I expected to see the warning:

warning: constant A is never used

Instead no warning was reported by the compiler.

Observed in nightly, 1.67.
Seems like the warning was shown in 1.63 and stopped showing in 1.64.

Activity

  1. clubby789 commented on Feb 21, 2023

    @clubby789
    Contributor

    Bisected to

      commit[0] 2022-06-30UTC: Auto merge of 98377 - davidv1992:add-lifetimes-to-argument-temporaries, r=oli-obk
      commit[1] 2022-07-01UTC: Auto merge of 98706 - flip1995:clippyup, r=Dylan-DPC
      commit[2] 2022-07-01UTC: Auto merge of 98752 - matthiaskrgr:rollup-uwimznc, r=matthiaskrgr
      commit[3] 2022-07-01UTC: Auto merge of 98730 - matthiaskrgr:rollup-2c4d4x5, r=matthiaskrgr
      commit[4] 2022-07-01UTC: Auto merge of 98402 - cjgillot:undead, r=michaelwoerister
      commit[5] 2022-07-01UTC: Auto merge of 98767 - Dylan-DPC:rollup-j1gq5sr, r=Dylan-DPC
      commit[6] 2022-07-01UTC: Auto merge of 93967 - cjgillot:short-struct-span, r=petrochenkov
    

    CI has expired so I couldn't automatically bisect further, but #98402 looks like a likely candidate

  2. clubby789 commented on Feb 21, 2023

    @clubby789
    Contributor

    It looks like the issue is that dead code detection doesn't work inside closures and generators (which async functions use in their desugaring)

    #[deny(dead_code)]
    #[allow(unused_must_use)]
    pub fn foo() {
        || {
            fn a() {}
        };
    }

    This is denied by 1.63 but allowed on 1.64+.
    @rustbot label +regression-from-stable-to-stable


    if parent != module && !live_symbols.contains(&parent) {
    // We already have diagnosed something.
    continue;
    }

    Here, the parent of the closure is foo::{closure#0} so checking dead code is skipped.

  3. added
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Feb 21, 2023
  4. apiraino commented on Feb 21, 2023

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-medium

  5. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Feb 21, 2023
  6. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 21, 2023
  7. added a commit that references this issue on Feb 22, 2023
    783617b
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

    C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions