Skip to content

1.64 - Unexpected dead_code warning from inside macro expansion. #102217

Open
@Themayu

Description

@Themayu

I am getting an unexpected dead_code warning from inside a procedural macro's output. This warning did not appear in the previous version of the Rust Compiler. This is not present in the changelog for 1.64, so I do not believe it to be an expected change.

Code

I tried this code:

#[pin_project(project = Merge2Proj)]
#[derive(Debug)]
pub struct Merge2
{
	// struct contents...
}

// impl that only makes use of Merge2Proj::project...

I expected to see this happen: I expected the code to compile without warnings, as was true for the previous compiler version.

Instead, this happened: I get a dead_code warning from inside the pin_project macro expansion, telling me that Merge2Proj::project_ref is unused. This warning is impossible for me to remove, as I have no need for project_ref and there is no way to tell pin_project to not generate it.

Version it worked on

It most recently worked on: 1.63

Version with regression

rustc --version --verbose:

rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-pc-windows-msvc
release: 1.64.0
LLVM version: 14.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.L-dead_codeLint: dead_codeP-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