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

unused_qualifications complains #4951

Closed
2 tasks done
tyranron opened this issue Jun 5, 2023 · 1 comment · Fixed by #4952
Closed
2 tasks done

unused_qualifications complains #4951

tyranron opened this issue Jun 5, 2023 · 1 comment · Fixed by #4952
Labels
C-bug Category: Updating dependencies

Comments

@tyranron
Copy link

tyranron commented Jun 5, 2023

Please complete the following tasks

Rust Version

rustc 1.70.0 (90c541806 2023-05-31)

Clap Version

4.3.1

Minimal reproducible code

#![deny(unused_qualifications)]

use clap::Args;

#[derive(Args, Clone, Copy, Debug, Default)]
#[group(skip)]
pub struct Compose<L: Args> {
    #[command(flatten)]
    pub left: L,
}

fn main() {} 

Playground

Steps to reproduce the bug with the above code

cargo check

Actual Behaviour

error: unnecessary qualification
 --> src/main.rs:8:15
  |
8 |     #[command(flatten)]
  |               ^^^^^^^
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(unused_qualifications)]
  |         ^^^^^^^^^^^^^^^^^^^^^

Expected Behaviour

Compiles OK.

Additional Context

Appears starting from 1.70 Rust. On 1.69 Rust everything is OK.

Debug Output

If we run cargo expand on Playground, we would see the expansion like this:

#[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
#[allow(clippy :: style, clippy :: complexity, clippy :: pedantic, clippy ::
restriction, clippy :: perf, clippy :: deprecated, clippy :: nursery, clippy
:: cargo, clippy :: suspicious_else_formatting, clippy :: almost_swapped,)]
impl<L: Args> clap::FromArgMatches for Compose<L> {
    // etc...
}

It seems, that starting from 1.70 Rust, the unused_qualifications became more clever and covers more code paths than it had done before. I wonder why the #[automatically_derived] attribute is not used in the macro expansions, which is used to handle most of such situations (modulo lint bugs)?

@tyranron tyranron added the C-bug Category: Updating dependencies label Jun 5, 2023
@epage
Copy link
Member

epage commented Jun 5, 2023

Never heard of #[automatically_derived] before. In Veykril/tlborm#93, I suggested it gets covered in the Little Book of Macros.

epage added a commit to epage/clap that referenced this issue Jun 5, 2023
Unsure what all it does.  I removed our `allow`s and we still get lints,
so unsure if its only some that it applies to it.

Inspired by clap-rs#4951
epage added a commit to epage/clap that referenced this issue Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants