impl reviewer feedback
- remove unused (pun intentional) `continue` - improve wording with assoc items in general
This commit is contained in:
parent
c41dcac8e8
commit
39e23ef532
@ -700,6 +700,13 @@ fn warn_multiple_dead_codes(
|
||||
.collect();
|
||||
|
||||
let descr = tcx.def_descr(first_id.to_def_id());
|
||||
// `impl` blocks are "batched" and (unlike other batching) might
|
||||
// contain different kinds of associated items.
|
||||
let descr = if dead_codes.iter().any(|did| tcx.def_descr(did.to_def_id()) != descr) {
|
||||
"associated item"
|
||||
} else {
|
||||
descr
|
||||
};
|
||||
let num = dead_codes.len();
|
||||
let multiple = num > 6;
|
||||
let name_list = names.into();
|
||||
@ -842,16 +849,9 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
|
||||
if let hir::ItemKind::Impl(impl_item) = tcx.hir().item(item).kind {
|
||||
let mut dead_items = Vec::new();
|
||||
for item in impl_item.items {
|
||||
match item.kind {
|
||||
hir::AssocItemKind::Const | hir::AssocItemKind::Type => {
|
||||
visitor.check_definition(item.id.owner_id.def_id)
|
||||
}
|
||||
hir::AssocItemKind::Fn { .. } => {
|
||||
let did = item.id.owner_id.def_id;
|
||||
if !visitor.is_live_code(did) {
|
||||
dead_items.push(did)
|
||||
}
|
||||
}
|
||||
let did = item.id.owner_id.def_id;
|
||||
if !visitor.is_live_code(did) {
|
||||
dead_items.push(did)
|
||||
}
|
||||
}
|
||||
visitor.warn_multiple_dead_codes(
|
||||
@ -860,7 +860,6 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
|
||||
Some(item.owner_id.def_id),
|
||||
false,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if !live_symbols.contains(&item.owner_id.def_id) {
|
||||
|
@ -1,19 +1,29 @@
|
||||
#![feature(inherent_associated_types)]
|
||||
#![allow(incomplete_features)]
|
||||
#![deny(unused)]
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn one() {}
|
||||
//~^ ERROR associated functions `one`, `two`, and `three` are never used [dead_code]
|
||||
//~^ ERROR associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used [dead_code]
|
||||
|
||||
fn two(&self) {}
|
||||
|
||||
// seperation between functions
|
||||
// seperation between items
|
||||
// ...
|
||||
// ...
|
||||
|
||||
fn used() {}
|
||||
|
||||
const CONSTANT: usize = 5;
|
||||
|
||||
// more seperation
|
||||
// ...
|
||||
// ...
|
||||
|
||||
type Type = usize;
|
||||
|
||||
fn three(&self) {
|
||||
Foo::one();
|
||||
// ...
|
||||
|
@ -1,19 +1,25 @@
|
||||
error: associated functions `one`, `two`, and `three` are never used
|
||||
--> $DIR/unused-assoc-fns.rs:6:8
|
||||
error: associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used
|
||||
--> $DIR/unused-assoc-fns.rs:8:8
|
||||
|
|
||||
LL | impl Foo {
|
||||
| -------- associated functions in this implementation
|
||||
| -------- associated items in this implementation
|
||||
LL | fn one() {}
|
||||
| ^^^
|
||||
...
|
||||
LL | fn two(&self) {}
|
||||
| ^^^
|
||||
...
|
||||
LL | const CONSTANT: usize = 5;
|
||||
| ^^^^^^^^
|
||||
...
|
||||
LL | type Type = usize;
|
||||
| ^^^^
|
||||
LL |
|
||||
LL | fn three(&self) {
|
||||
| ^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unused-assoc-fns.rs:1:9
|
||||
--> $DIR/unused-assoc-fns.rs:3:9
|
||||
|
|
||||
LL | #![deny(unused)]
|
||||
| ^^^^^^
|
||||
|
Loading…
Reference in New Issue
Block a user