-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I like to build functions as a series of parts, for example I might write the following skeleton, then plan to fill in the loop
fn sorter(x: Vec<Vec<isize>>, modifier: bool) -> Vec<isize> {
let mut out = vec![];
for i in x {
}
out
}
If I run a cargo check on this, just to check for typos, I get:
warning: unused variable: `i`
--> src/playgame.rs:35:9
|
35 | for i in x {}
| ^ help: consider prefixing with an underscore: `_i`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `modifier`
--> src/playgame.rs:33:31
|
33 | fn sorter(x: Vec<Vec<isize>>, modifier: bool) -> Vec<isize> {
| ^^^^^^^^ help: consider prefixing with an underscore: `_modifier`
warning: variable does not need to be mutable
--> src/playgame.rs:34:9
|
34 | let mut out = vec![];
| ----^^^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` on by default
warning: function is never used: `sorter`
--> src/playgame.rs:33:1
|
33 | fn sorter(x: Vec<Vec<isize>>, modifier: bool) -> Vec<isize> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
I feel it should be possible to encapsulate a set of warnings which represent "unused/dead", and have a way of disabling them while developing. I realise this could be abused by some people, but I find it hard to spot the important issues between these unused/dead issues while developing.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Kampfkarren commentedon Oct 16, 2019
#![allow(dead_code)]
at the root of your crate 🙂ChrisJefferson commentedon Oct 16, 2019
I tried this (should have said), but I ended up with:
And then, I also had to remember to go remove them all every so often, as I don't want these enabling forever, just while writing a new function.
Perhaps (I'll be honest, I'm maybe not positive what I want), I want a way to disable lints easily while initially making a function, then linting once I think I've got a valid piece of finished(ish) code.
Centril commentedon Oct 16, 2019
There's always
#![allow(unused)]
to disable the whole group.I don't think there's anything actionable here yet.
ChrisJefferson commentedon Oct 16, 2019
That is, I think, what I want. That's not too much work to add and remove.
I hadn't found that there was a way of grouping together lints (I had tried googling, but I obviously did hit it). I'm not sure if there is a good way of making this more visible.
[-]Add easy way to disable "unused" warnings[/-][+]Make the documentation about `#![allow(unused)]` more visible[/+]estebank commentedon Oct 16, 2019
@Centril we could rework the lint output to be
hkBst commentedon Mar 10, 2025
@estebank I think that is a very good idea! And I'm guessing this should be pretty simple to do, so
@rustbot label -A-docs E-easy
karolzwolak commentedon Mar 21, 2025
@rustbot claim
Rollup merge of rust-lang#140794 - karolzwolak:allow-unused-doc-65464…
Rollup merge of rust-lang#140794 - karolzwolak:allow-unused-doc-65464…
Rollup merge of rust-lang#140794 - karolzwolak:allow-unused-doc-65464…
Rollup merge of rust-lang#140794 - karolzwolak:allow-unused-doc-65464…
Rollup merge of rust-lang#140794 - karolzwolak:allow-unused-doc-65464…
Rollup merge of rust-lang#140794 - karolzwolak:allow-unused-doc-65464…
Unrolled build for #140794
Rollup merge of #140794 - karolzwolak:allow-unused-doc-65464, r=david…