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

Missing warning for an unused const in async fn #108296

Closed
stepantubanov opened this issue Feb 21, 2023 · 3 comments · Fixed by #108315
Closed

Missing warning for an unused const in async fn #108296

stepantubanov opened this issue Feb 21, 2023 · 3 comments · Fixed by #108315
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@stepantubanov
Copy link

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.

@stepantubanov stepantubanov added the C-bug Category: This is a bug. label Feb 21, 2023
@clubby789
Copy link
Contributor

clubby789 commented Feb 21, 2023

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

@clubby789
Copy link
Contributor

clubby789 commented Feb 21, 2023

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.

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 21, 2023
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 21, 2023
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 21, 2023
@bors bors closed this as completed in 783617b Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants