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

FP unused_import when the import is only used in rustdoc links #92493

Closed
jendrikw opened this issue Jan 2, 2022 · 1 comment
Closed

FP unused_import when the import is only used in rustdoc links #92493

jendrikw opened this issue Jan 2, 2022 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@jendrikw
Copy link
Contributor

jendrikw commented Jan 2, 2022

I tried this code:

//! This is a link: [`Add::add`].
use std::ops::Add;

I expected to see this happen: No warning

Instead, this happened:

warning: unused import: `std::ops::Add

This is especially annoying when you deny some lints:

cargo build errors, but cargo doc is fine:

#![deny(unused_imports)]
#![deny(rustdoc::broken_intra_doc_links)]
//! This is a link: [`Add::add`].
use std::ops::Add;

When you comment out the use statement, cargo build is fine, but cargo doc errors.

#![deny(unused_imports)]
#![deny(rustdoc::broken_intra_doc_links)]
//! This is a link: [`Add::add`].
//use std::ops::Add;

I know I can use the links syntax with an explicit target, but I prefer the short form for less noise when reading the code.

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0
@jendrikw jendrikw added the C-bug Category: This is a bug. label Jan 2, 2022
@jendrikw
Copy link
Contributor Author

jendrikw commented Jan 2, 2022

Oops, dupe of #79542.

@jendrikw jendrikw closed this as completed Jan 2, 2022
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.
Projects
None yet
Development

No branches or pull requests

1 participant