Skip to content

unused_qualifications shouldn't trigger on expanded code #96698

Closed
@zecakeh

Description

@zecakeh

Given the following code:

use my_macros::my_enum_macro;
use super::a::AType;

my_enum_macro! {
  "key.a_type" => super::a,
  "key.b_type" => super::c::b,
  // Other variants
}

pub fn my_fn(param: AType) {
  // ...
}

Where my_enum_macro, among other things, uses the path provided for the variant to qualify a type based on the key. It so happens that for the first variant here, the type in the expanded code resolves to super::a::AType.

The current output is:

warning: unnecessary qualification
  --> src/my_mod.rs:5:3
   |
  5|         "key.a_type" => super::a,
   |         ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: requested on the command line with `-W unused-qualifications`

Since the type is already imported at the top, the qualification is indeed unnecessary. But I would also expect to have the same behavior with my macro what other imports there are above.

That's why I believe that this warning shouldn't trigger on expanded code, or at least between regular and expanded code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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

    Issue actions