Uniform spans in dead code lint.
This commit is contained in:
parent
0b2837dc07
commit
a319f3c992
22 changed files with 118 additions and 166 deletions
|
@ -635,8 +635,7 @@ fn live_symbols_and_ignored_derived_traits<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DeadVariant {
|
struct DeadVariant {
|
||||||
hir_id: hir::HirId,
|
def_id: LocalDefId,
|
||||||
span: Span,
|
|
||||||
name: Symbol,
|
name: Symbol,
|
||||||
level: lint::Level,
|
level: lint::Level,
|
||||||
}
|
}
|
||||||
|
@ -687,29 +686,39 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||||
|
|
||||||
fn warn_multiple_dead_codes(
|
fn warn_multiple_dead_codes(
|
||||||
&self,
|
&self,
|
||||||
dead_codes: &[(hir::HirId, Span, Symbol)],
|
dead_codes: &[LocalDefId],
|
||||||
participle: &str,
|
participle: &str,
|
||||||
parent_hir_id: Option<hir::HirId>,
|
parent_item: Option<LocalDefId>,
|
||||||
) {
|
) {
|
||||||
if let Some((id, _, name)) = dead_codes.first()
|
if let Some(&first_id) = dead_codes.first() {
|
||||||
&& !name.as_str().starts_with('_')
|
let tcx = self.tcx;
|
||||||
{
|
let names: Vec<_> = dead_codes
|
||||||
self.tcx.struct_span_lint_hir(
|
.iter()
|
||||||
|
.map(|&def_id| tcx.item_name(def_id.to_def_id()).to_string())
|
||||||
|
.collect();
|
||||||
|
let spans = dead_codes
|
||||||
|
.iter()
|
||||||
|
.map(|&def_id| match tcx.def_ident_span(def_id) {
|
||||||
|
Some(s) => s.with_ctxt(tcx.def_span(def_id).ctxt()),
|
||||||
|
None => tcx.def_span(def_id),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
tcx.struct_span_lint_hir(
|
||||||
lint::builtin::DEAD_CODE,
|
lint::builtin::DEAD_CODE,
|
||||||
*id,
|
tcx.hir().local_def_id_to_hir_id(first_id),
|
||||||
MultiSpan::from_spans(
|
MultiSpan::from_spans(spans),
|
||||||
dead_codes.iter().map(|(_, span, _)| *span).collect(),
|
|
||||||
),
|
|
||||||
|lint| {
|
|lint| {
|
||||||
let def_id = self.tcx.hir().local_def_id(*id);
|
let descr = tcx.def_kind(first_id).descr(first_id.to_def_id());
|
||||||
let descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id());
|
|
||||||
let span_len = dead_codes.len();
|
let span_len = dead_codes.len();
|
||||||
let names = match &dead_codes.iter().map(|(_, _, n)| n.to_string()).collect::<Vec<_>>()[..]
|
let names = match &names[..] {
|
||||||
{
|
|
||||||
_ if span_len > 6 => String::new(),
|
_ if span_len > 6 => String::new(),
|
||||||
[name] => format!("`{name}` "),
|
[name] => format!("`{name}` "),
|
||||||
[names @ .., last] => {
|
[names @ .., last] => {
|
||||||
format!("{} and `{last}` ", names.iter().map(|name| format!("`{name}`")).join(", "))
|
format!(
|
||||||
|
"{} and `{last}` ",
|
||||||
|
names.iter().map(|name| format!("`{name}`")).join(", ")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
[] => unreachable!(),
|
[] => unreachable!(),
|
||||||
};
|
};
|
||||||
|
@ -719,25 +728,17 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||||
s = pluralize!(span_len),
|
s = pluralize!(span_len),
|
||||||
are = pluralize!("is", span_len),
|
are = pluralize!("is", span_len),
|
||||||
));
|
));
|
||||||
let hir = self.tcx.hir();
|
|
||||||
if let Some(parent_hir_id) = parent_hir_id
|
if let Some(parent_item) = parent_item {
|
||||||
&& let Some(parent_node) = hir.find(parent_hir_id)
|
let parent_descr = tcx.def_kind(parent_item).descr(parent_item.to_def_id());
|
||||||
&& let Node::Item(item) = parent_node
|
|
||||||
{
|
|
||||||
let def_id = self.tcx.hir().local_def_id(parent_hir_id);
|
|
||||||
let parent_descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id());
|
|
||||||
err.span_label(
|
err.span_label(
|
||||||
item.ident.span,
|
tcx.def_ident_span(parent_item).unwrap(),
|
||||||
format!(
|
format!("{descr}{s} in this {parent_descr}", s = pluralize!(span_len)),
|
||||||
"{descr}{s} in this {parent_descr}",
|
|
||||||
s = pluralize!(span_len)
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let Some(encl_scope) = hir.get_enclosing_scope(*id)
|
|
||||||
&& let Some(encl_def_id) = hir.opt_local_def_id(encl_scope)
|
let encl_def_id = parent_item.unwrap_or(first_id);
|
||||||
&& let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id)
|
if let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) {
|
||||||
{
|
|
||||||
let traits_str = ign_traits
|
let traits_str = ign_traits
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(trait_id, _)| format!("`{}`", self.tcx.item_name(*trait_id)))
|
.map(|(trait_id, _)| format!("`{}`", self.tcx.item_name(*trait_id)))
|
||||||
|
@ -758,15 +759,15 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||||
);
|
);
|
||||||
err.note(&msg);
|
err.note(&msg);
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn warn_dead_fields_and_variants(
|
fn warn_dead_fields_and_variants(
|
||||||
&self,
|
&self,
|
||||||
hir_id: hir::HirId,
|
def_id: LocalDefId,
|
||||||
participle: &str,
|
participle: &str,
|
||||||
dead_codes: Vec<DeadVariant>,
|
dead_codes: Vec<DeadVariant>,
|
||||||
) {
|
) {
|
||||||
|
@ -781,23 +782,18 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||||
dead_codes.sort_by_key(|v| v.level);
|
dead_codes.sort_by_key(|v| v.level);
|
||||||
for (_, group) in &dead_codes.into_iter().group_by(|v| v.level) {
|
for (_, group) in &dead_codes.into_iter().group_by(|v| v.level) {
|
||||||
self.warn_multiple_dead_codes(
|
self.warn_multiple_dead_codes(
|
||||||
&group
|
&group.map(|v| v.def_id).collect::<Vec<_>>(),
|
||||||
.map(|v| (v.hir_id, v.span, v.name))
|
|
||||||
.collect::<Vec<(hir::HirId, Span, Symbol)>>(),
|
|
||||||
participle,
|
participle,
|
||||||
Some(hir_id),
|
Some(def_id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn warn_dead_code(
|
fn warn_dead_code(&mut self, id: LocalDefId, participle: &str) {
|
||||||
&mut self,
|
if self.tcx.item_name(id.to_def_id()).as_str().starts_with('_') {
|
||||||
id: hir::HirId,
|
return;
|
||||||
span: rustc_span::Span,
|
}
|
||||||
name: Symbol,
|
self.warn_multiple_dead_codes(&[id], participle, None);
|
||||||
participle: &str,
|
|
||||||
) {
|
|
||||||
self.warn_multiple_dead_codes(&[(id, span, name)], participle, None);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,33 +811,11 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||||
if self.should_warn_about_item(item) {
|
if self.should_warn_about_item(item) {
|
||||||
// For most items, we want to highlight its identifier
|
// For most items, we want to highlight its identifier
|
||||||
let span = match item.kind {
|
|
||||||
hir::ItemKind::Fn(..)
|
|
||||||
| hir::ItemKind::Mod(..)
|
|
||||||
| hir::ItemKind::Enum(..)
|
|
||||||
| hir::ItemKind::Struct(..)
|
|
||||||
| hir::ItemKind::Union(..)
|
|
||||||
| hir::ItemKind::Trait(..)
|
|
||||||
| hir::ItemKind::Impl { .. } => {
|
|
||||||
// FIXME(66095): Because item.span is annotated with things
|
|
||||||
// like expansion data, and ident.span isn't, we use the
|
|
||||||
// def_span method if it's part of a macro invocation
|
|
||||||
// (and thus has a source_callee set).
|
|
||||||
// We should probably annotate ident.span with the macro
|
|
||||||
// context, but that's a larger change.
|
|
||||||
if item.span.source_callee().is_some() {
|
|
||||||
self.tcx.sess.source_map().guess_head_span(item.span)
|
|
||||||
} else {
|
|
||||||
item.ident.span
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => item.span,
|
|
||||||
};
|
|
||||||
let participle = match item.kind {
|
let participle = match item.kind {
|
||||||
hir::ItemKind::Struct(..) => "constructed", // Issue #52325
|
hir::ItemKind::Struct(..) => "constructed", // Issue #52325
|
||||||
_ => "used",
|
_ => "used",
|
||||||
};
|
};
|
||||||
self.warn_dead_code(item.hir_id(), span, item.ident.name, participle);
|
self.warn_dead_code(item.def_id, participle);
|
||||||
} else {
|
} else {
|
||||||
// Only continue if we didn't warn
|
// Only continue if we didn't warn
|
||||||
intravisit::walk_item(self, item);
|
intravisit::walk_item(self, item);
|
||||||
|
@ -865,8 +839,7 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||||
.filter_map(|variant| {
|
.filter_map(|variant| {
|
||||||
if self.should_warn_about_variant(&variant) {
|
if self.should_warn_about_variant(&variant) {
|
||||||
Some(DeadVariant {
|
Some(DeadVariant {
|
||||||
hir_id: variant.id,
|
def_id: self.tcx.hir().local_def_id(variant.id),
|
||||||
span: variant.span,
|
|
||||||
name: variant.ident.name,
|
name: variant.ident.name,
|
||||||
level: self.tcx.lint_level_at_node(lint::builtin::DEAD_CODE, variant.id).0,
|
level: self.tcx.lint_level_at_node(lint::builtin::DEAD_CODE, variant.id).0,
|
||||||
})
|
})
|
||||||
|
@ -875,7 +848,7 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
self.warn_dead_fields_and_variants(item_id, "constructed", dead_variants)
|
self.warn_dead_fields_and_variants(item_id.expect_owner(), "constructed", dead_variants)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_variant(
|
fn visit_variant(
|
||||||
|
@ -891,7 +864,7 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||||
|
|
||||||
fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem<'tcx>) {
|
fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem<'tcx>) {
|
||||||
if self.should_warn_about_foreign_item(fi) {
|
if self.should_warn_about_foreign_item(fi) {
|
||||||
self.warn_dead_code(fi.hir_id(), fi.span, fi.ident.name, "used");
|
self.warn_dead_code(fi.def_id, "used");
|
||||||
}
|
}
|
||||||
intravisit::walk_foreign_item(self, fi);
|
intravisit::walk_foreign_item(self, fi);
|
||||||
}
|
}
|
||||||
|
@ -911,8 +884,7 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||||
.filter_map(|field| {
|
.filter_map(|field| {
|
||||||
if self.should_warn_about_field(&field) {
|
if self.should_warn_about_field(&field) {
|
||||||
Some(DeadVariant {
|
Some(DeadVariant {
|
||||||
hir_id: field.hir_id,
|
def_id: self.tcx.hir().local_def_id(field.hir_id),
|
||||||
span: field.span,
|
|
||||||
name: field.ident.name,
|
name: field.ident.name,
|
||||||
level: self
|
level: self
|
||||||
.tcx
|
.tcx
|
||||||
|
@ -924,36 +896,20 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
self.warn_dead_fields_and_variants(id, "read", dead_fields)
|
self.warn_dead_fields_and_variants(self.tcx.hir().local_def_id(id), "read", dead_fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
|
||||||
match impl_item.kind {
|
match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(_, body_id) => {
|
hir::ImplItemKind::Const(_, body_id) => {
|
||||||
if !self.symbol_is_live(impl_item.def_id) {
|
if !self.symbol_is_live(impl_item.def_id) {
|
||||||
self.warn_dead_code(
|
self.warn_dead_code(impl_item.def_id, "used");
|
||||||
impl_item.hir_id(),
|
|
||||||
impl_item.span,
|
|
||||||
impl_item.ident.name,
|
|
||||||
"used",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
self.visit_nested_body(body_id)
|
self.visit_nested_body(body_id)
|
||||||
}
|
}
|
||||||
hir::ImplItemKind::Fn(_, body_id) => {
|
hir::ImplItemKind::Fn(_, body_id) => {
|
||||||
if !self.symbol_is_live(impl_item.def_id) {
|
if !self.symbol_is_live(impl_item.def_id) {
|
||||||
// FIXME(66095): Because impl_item.span is annotated with things
|
self.warn_dead_code(impl_item.def_id, "used");
|
||||||
// like expansion data, and ident.span isn't, we use the
|
|
||||||
// def_span method if it's part of a macro invocation
|
|
||||||
// (and thus has a source_callee set).
|
|
||||||
// We should probably annotate ident.span with the macro
|
|
||||||
// context, but that's a larger change.
|
|
||||||
let span = if impl_item.span.source_callee().is_some() {
|
|
||||||
self.tcx.sess.source_map().guess_head_span(impl_item.span)
|
|
||||||
} else {
|
|
||||||
impl_item.ident.span
|
|
||||||
};
|
|
||||||
self.warn_dead_code(impl_item.hir_id(), span, impl_item.ident.name, "used");
|
|
||||||
}
|
}
|
||||||
self.visit_nested_body(body_id)
|
self.visit_nested_body(body_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: associated constant `BAR` is never used
|
error: associated constant `BAR` is never used
|
||||||
--> $DIR/associated-const-dead-code.rs:6:5
|
--> $DIR/associated-const-dead-code.rs:6:11
|
||||||
|
|
|
|
||||||
LL | const BAR: u32 = 1;
|
LL | const BAR: u32 = 1;
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/associated-const-dead-code.rs:1:9
|
--> $DIR/associated-const-dead-code.rs:1:9
|
||||||
|
|
|
@ -4,9 +4,9 @@ warning: fields `field_1` and `field_2` are never read
|
||||||
LL | struct Props {
|
LL | struct Props {
|
||||||
| ----- fields in this struct
|
| ----- fields in this struct
|
||||||
LL | field_1: u32,
|
LL | field_1: u32,
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^
|
||||||
LL | field_2: u32,
|
LL | field_2: u32,
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `#[warn(dead_code)]` on by default
|
= note: `#[warn(dead_code)]` on by default
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | enum Foo {
|
||||||
| --- variant in this enum
|
| --- variant in this enum
|
||||||
LL | Bar(u8),
|
LL | Bar(u8),
|
||||||
LL | Void(Void),
|
LL | Void(Void),
|
||||||
| ^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: `-W dead-code` implied by `-W unused`
|
= note: `-W dead-code` implied by `-W unused`
|
||||||
= note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
|
= note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
|
||||||
|
|
|
@ -5,13 +5,13 @@ LL | pub struct Whatever {
|
||||||
| -------- fields in this struct
|
| -------- fields in this struct
|
||||||
LL | pub field0: (),
|
LL | pub field0: (),
|
||||||
LL | field1: (),
|
LL | field1: (),
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^
|
||||||
LL | field2: (),
|
LL | field2: (),
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^
|
||||||
LL | field3: (),
|
LL | field3: (),
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^
|
||||||
LL | field4: (),
|
LL | field4: (),
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/clone-debug-dead-code-in-the-same-struct.rs:1:11
|
--> $DIR/clone-debug-dead-code-in-the-same-struct.rs:1:11
|
||||||
|
|
|
@ -2,7 +2,7 @@ error: field `f` is never read
|
||||||
--> $DIR/clone-debug-dead-code.rs:6:12
|
--> $DIR/clone-debug-dead-code.rs:6:12
|
||||||
|
|
|
|
||||||
LL | struct A { f: () }
|
LL | struct A { f: () }
|
||||||
| - ^^^^^
|
| - ^
|
||||||
| |
|
| |
|
||||||
| field in this struct
|
| field in this struct
|
||||||
|
|
|
|
||||||
|
@ -16,7 +16,7 @@ error: field `f` is never read
|
||||||
--> $DIR/clone-debug-dead-code.rs:10:12
|
--> $DIR/clone-debug-dead-code.rs:10:12
|
||||||
|
|
|
|
||||||
LL | struct B { f: () }
|
LL | struct B { f: () }
|
||||||
| - ^^^^^
|
| - ^
|
||||||
| |
|
| |
|
||||||
| field in this struct
|
| field in this struct
|
||||||
|
|
|
|
||||||
|
@ -26,7 +26,7 @@ error: field `f` is never read
|
||||||
--> $DIR/clone-debug-dead-code.rs:14:12
|
--> $DIR/clone-debug-dead-code.rs:14:12
|
||||||
|
|
|
|
||||||
LL | struct C { f: () }
|
LL | struct C { f: () }
|
||||||
| - ^^^^^
|
| - ^
|
||||||
| |
|
| |
|
||||||
| field in this struct
|
| field in this struct
|
||||||
|
|
|
|
||||||
|
@ -36,7 +36,7 @@ error: field `f` is never read
|
||||||
--> $DIR/clone-debug-dead-code.rs:18:12
|
--> $DIR/clone-debug-dead-code.rs:18:12
|
||||||
|
|
|
|
||||||
LL | struct D { f: () }
|
LL | struct D { f: () }
|
||||||
| - ^^^^^
|
| - ^
|
||||||
| |
|
| |
|
||||||
| field in this struct
|
| field in this struct
|
||||||
|
|
|
|
||||||
|
@ -46,7 +46,7 @@ error: field `f` is never read
|
||||||
--> $DIR/clone-debug-dead-code.rs:21:12
|
--> $DIR/clone-debug-dead-code.rs:21:12
|
||||||
|
|
|
|
||||||
LL | struct E { f: () }
|
LL | struct E { f: () }
|
||||||
| - ^^^^^
|
| - ^
|
||||||
| |
|
| |
|
||||||
| field in this struct
|
| field in this struct
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
warning: type alias `Z` is never used
|
warning: type alias `Z` is never used
|
||||||
--> $DIR/issue-37515.rs:5:1
|
--> $DIR/issue-37515.rs:5:6
|
||||||
|
|
|
|
||||||
LL | type Z = dyn for<'x> Send;
|
LL | type Z = dyn for<'x> Send;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/issue-37515.rs:3:9
|
--> $DIR/issue-37515.rs:3:9
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: type alias `Unused` is never used
|
error: type alias `Unused` is never used
|
||||||
--> $DIR/impl-trait.rs:12:1
|
--> $DIR/impl-trait.rs:12:6
|
||||||
|
|
|
|
||||||
LL | type Unused = ();
|
LL | type Unused = ();
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/impl-trait.rs:1:9
|
--> $DIR/impl-trait.rs:1:9
|
||||||
|
|
|
@ -4,9 +4,9 @@ warning: fields `a` and `b` are never read
|
||||||
LL | struct Foo {
|
LL | struct Foo {
|
||||||
| --- fields in this struct
|
| --- fields in this struct
|
||||||
LL | a: i32,
|
LL | a: i32,
|
||||||
| ^^^^^^
|
| ^
|
||||||
LL | pub b: i32,
|
LL | pub b: i32,
|
||||||
| ^^^^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/issue-85255.rs:4:9
|
--> $DIR/issue-85255.rs:4:9
|
||||||
|
@ -32,9 +32,9 @@ warning: fields `a` and `b` are never read
|
||||||
LL | pub(crate) struct Foo1 {
|
LL | pub(crate) struct Foo1 {
|
||||||
| ---- fields in this struct
|
| ---- fields in this struct
|
||||||
LL | a: i32,
|
LL | a: i32,
|
||||||
| ^^^^^^
|
| ^
|
||||||
LL | pub b: i32,
|
LL | pub b: i32,
|
||||||
| ^^^^^^^^^^
|
| ^
|
||||||
|
|
||||||
warning: associated function `a` is never used
|
warning: associated function `a` is never used
|
||||||
--> $DIR/issue-85255.rs:26:8
|
--> $DIR/issue-85255.rs:26:8
|
||||||
|
@ -54,9 +54,9 @@ warning: fields `a` and `b` are never read
|
||||||
LL | pub(crate) struct Foo2 {
|
LL | pub(crate) struct Foo2 {
|
||||||
| ---- fields in this struct
|
| ---- fields in this struct
|
||||||
LL | a: i32,
|
LL | a: i32,
|
||||||
| ^^^^^^
|
| ^
|
||||||
LL | pub b: i32,
|
LL | pub b: i32,
|
||||||
| ^^^^^^^^^^
|
| ^
|
||||||
|
|
||||||
warning: associated function `a` is never used
|
warning: associated function `a` is never used
|
||||||
--> $DIR/issue-85255.rs:38:8
|
--> $DIR/issue-85255.rs:38:8
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: static `priv_static` is never used
|
error: static `priv_static` is never used
|
||||||
--> $DIR/lint-dead-code-1.rs:20:1
|
--> $DIR/lint-dead-code-1.rs:20:8
|
||||||
|
|
|
|
||||||
LL | static priv_static: isize = 0;
|
LL | static priv_static: isize = 0;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/lint-dead-code-1.rs:5:9
|
--> $DIR/lint-dead-code-1.rs:5:9
|
||||||
|
@ -11,10 +11,10 @@ LL | #![deny(dead_code)]
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: constant `priv_const` is never used
|
error: constant `priv_const` is never used
|
||||||
--> $DIR/lint-dead-code-1.rs:27:1
|
--> $DIR/lint-dead-code-1.rs:27:7
|
||||||
|
|
|
|
||||||
LL | const priv_const: isize = 0;
|
LL | const priv_const: isize = 0;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error: struct `PrivStruct` is never constructed
|
error: struct `PrivStruct` is never constructed
|
||||||
--> $DIR/lint-dead-code-1.rs:35:8
|
--> $DIR/lint-dead-code-1.rs:35:8
|
||||||
|
|
|
@ -29,10 +29,10 @@ LL | enum c_void {}
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: function `free` is never used
|
error: function `free` is never used
|
||||||
--> $DIR/lint-dead-code-3.rs:62:5
|
--> $DIR/lint-dead-code-3.rs:62:8
|
||||||
|
|
|
|
||||||
LL | fn free(p: *const c_void);
|
LL | fn free(p: *const c_void);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | struct Foo {
|
||||||
| --- field in this struct
|
| --- field in this struct
|
||||||
LL | x: usize,
|
LL | x: usize,
|
||||||
LL | b: bool,
|
LL | b: bool,
|
||||||
| ^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/lint-dead-code-4.rs:3:9
|
--> $DIR/lint-dead-code-4.rs:3:9
|
||||||
|
@ -16,16 +16,12 @@ LL | #![deny(dead_code)]
|
||||||
error: variants `X` and `Y` are never constructed
|
error: variants `X` and `Y` are never constructed
|
||||||
--> $DIR/lint-dead-code-4.rs:15:5
|
--> $DIR/lint-dead-code-4.rs:15:5
|
||||||
|
|
|
|
||||||
LL | enum XYZ {
|
LL | enum XYZ {
|
||||||
| --- variants in this enum
|
| --- variants in this enum
|
||||||
LL | X,
|
LL | X,
|
||||||
| ^
|
| ^
|
||||||
LL | / Y {
|
LL | Y {
|
||||||
LL | | a: String,
|
| ^
|
||||||
LL | | b: i32,
|
|
||||||
LL | | c: i32,
|
|
||||||
LL | | },
|
|
||||||
| |_____^
|
|
||||||
|
|
||||||
error: enum `ABC` is never used
|
error: enum `ABC` is never used
|
||||||
--> $DIR/lint-dead-code-4.rs:24:6
|
--> $DIR/lint-dead-code-4.rs:24:6
|
||||||
|
@ -40,9 +36,9 @@ LL | enum IJK {
|
||||||
| --- fields in this enum
|
| --- fields in this enum
|
||||||
...
|
...
|
||||||
LL | b: i32,
|
LL | b: i32,
|
||||||
| ^^^^^^
|
| ^
|
||||||
LL | c: i32,
|
LL | c: i32,
|
||||||
| ^^^^^^
|
| ^
|
||||||
|
|
||||||
error: variants `I` and `K` are never constructed
|
error: variants `I` and `K` are never constructed
|
||||||
--> $DIR/lint-dead-code-4.rs:36:5
|
--> $DIR/lint-dead-code-4.rs:36:5
|
||||||
|
@ -61,10 +57,10 @@ error: fields `x` and `c` are never read
|
||||||
LL | struct Bar {
|
LL | struct Bar {
|
||||||
| --- fields in this struct
|
| --- fields in this struct
|
||||||
LL | x: usize,
|
LL | x: usize,
|
||||||
| ^^^^^^^^
|
| ^
|
||||||
LL | b: bool,
|
LL | b: bool,
|
||||||
LL | c: bool,
|
LL | c: bool,
|
||||||
| ^^^^^^^
|
| ^
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,9 @@ LL | enum Enum2 {
|
||||||
| ----- variants in this enum
|
| ----- variants in this enum
|
||||||
...
|
...
|
||||||
LL | Variant5 { _x: isize },
|
LL | Variant5 { _x: isize },
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^
|
||||||
LL | Variant6(isize),
|
LL | Variant6(isize),
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: enum `Enum3` is never used
|
error: enum `Enum3` is never used
|
||||||
--> $DIR/lint-dead-code-5.rs:35:6
|
--> $DIR/lint-dead-code-5.rs:35:6
|
||||||
|
|
|
@ -5,12 +5,12 @@ LL | struct Bar {
|
||||||
| --- fields in this struct
|
| --- fields in this struct
|
||||||
...
|
...
|
||||||
LL | d: usize,
|
LL | d: usize,
|
||||||
| ^^^^^^^^
|
| ^
|
||||||
...
|
...
|
||||||
LL | f: usize,
|
LL | f: usize,
|
||||||
| ^^^^^^^^
|
| ^
|
||||||
LL | g: usize,
|
LL | g: usize,
|
||||||
| ^^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/multiple-dead-codes-in-the-same-struct.rs:1:9
|
--> $DIR/multiple-dead-codes-in-the-same-struct.rs:1:9
|
||||||
|
@ -25,10 +25,10 @@ LL | struct Bar {
|
||||||
| --- fields in this struct
|
| --- fields in this struct
|
||||||
...
|
...
|
||||||
LL | c: usize,
|
LL | c: usize,
|
||||||
| ^^^^^^^^
|
| ^
|
||||||
...
|
...
|
||||||
LL | e: usize,
|
LL | e: usize,
|
||||||
| ^^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/multiple-dead-codes-in-the-same-struct.rs:8:12
|
--> $DIR/multiple-dead-codes-in-the-same-struct.rs:8:12
|
||||||
|
@ -43,7 +43,7 @@ LL | struct Bar {
|
||||||
| --- field in this struct
|
| --- field in this struct
|
||||||
...
|
...
|
||||||
LL | b: usize,
|
LL | b: usize,
|
||||||
| ^^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/multiple-dead-codes-in-the-same-struct.rs:6:14
|
--> $DIR/multiple-dead-codes-in-the-same-struct.rs:6:14
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: type alias `Unused` is never used
|
error: type alias `Unused` is never used
|
||||||
--> $DIR/type-alias.rs:4:1
|
--> $DIR/type-alias.rs:4:6
|
||||||
|
|
|
|
||||||
LL | type Unused = u8;
|
LL | type Unused = u8;
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/type-alias.rs:1:9
|
--> $DIR/type-alias.rs:1:9
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | enum E {
|
||||||
| - variant in this enum
|
| - variant in this enum
|
||||||
LL | Foo(F),
|
LL | Foo(F),
|
||||||
LL | Bar(B),
|
LL | Bar(B),
|
||||||
| ^^^^^^
|
| ^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/unused-struct-variant.rs:1:9
|
--> $DIR/unused-struct-variant.rs:1:9
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: constant `foo` is never used
|
error: constant `foo` is never used
|
||||||
--> $DIR/issue-17718-const-naming.rs:4:1
|
--> $DIR/issue-17718-const-naming.rs:4:7
|
||||||
|
|
|
|
||||||
LL | const foo: isize = 3;
|
LL | const foo: isize = 3;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/issue-17718-const-naming.rs:2:9
|
--> $DIR/issue-17718-const-naming.rs:2:9
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
warning: struct `S` is never constructed
|
warning: struct `S` is never constructed
|
||||||
--> $DIR/macro-span-replacement.rs:7:14
|
--> $DIR/macro-span-replacement.rs:7:12
|
||||||
|
|
|
|
||||||
LL | $b $a;
|
LL | $b $a;
|
||||||
| ^
|
| ^^
|
||||||
...
|
...
|
||||||
LL | m!(S struct);
|
LL | m!(S struct);
|
||||||
| ------------ in this macro invocation
|
| ------------ in this macro invocation
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | union U1 {
|
||||||
| -- field in this union
|
| -- field in this union
|
||||||
...
|
...
|
||||||
LL | c: u8,
|
LL | c: u8,
|
||||||
| ^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/union-fields-1.rs:4:9
|
--> $DIR/union-fields-1.rs:4:9
|
||||||
|
@ -19,13 +19,13 @@ error: field `a` is never read
|
||||||
LL | union U2 {
|
LL | union U2 {
|
||||||
| -- field in this union
|
| -- field in this union
|
||||||
LL | a: u8,
|
LL | a: u8,
|
||||||
| ^^^^^
|
| ^
|
||||||
|
|
||||||
error: field `a` is never read
|
error: field `a` is never read
|
||||||
--> $DIR/union-fields-1.rs:16:20
|
--> $DIR/union-fields-1.rs:16:20
|
||||||
|
|
|
|
||||||
LL | union NoDropLike { a: u8 }
|
LL | union NoDropLike { a: u8 }
|
||||||
| ---------- ^^^^^
|
| ---------- ^
|
||||||
| |
|
| |
|
||||||
| field in this union
|
| field in this union
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ LL | union U {
|
||||||
| - field in this union
|
| - field in this union
|
||||||
...
|
...
|
||||||
LL | c: u8,
|
LL | c: u8,
|
||||||
| ^^^^^
|
| ^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | union U1 {
|
||||||
| -- field in this union
|
| -- field in this union
|
||||||
...
|
...
|
||||||
LL | c: u8,
|
LL | c: u8,
|
||||||
| ^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/union-fields-1.rs:4:9
|
--> $DIR/union-fields-1.rs:4:9
|
||||||
|
@ -19,13 +19,13 @@ error: field `a` is never read
|
||||||
LL | union U2 {
|
LL | union U2 {
|
||||||
| -- field in this union
|
| -- field in this union
|
||||||
LL | a: u8,
|
LL | a: u8,
|
||||||
| ^^^^^
|
| ^
|
||||||
|
|
||||||
error: field `a` is never read
|
error: field `a` is never read
|
||||||
--> $DIR/union-fields-1.rs:16:20
|
--> $DIR/union-fields-1.rs:16:20
|
||||||
|
|
|
|
||||||
LL | union NoDropLike { a: u8 }
|
LL | union NoDropLike { a: u8 }
|
||||||
| ---------- ^^^^^
|
| ---------- ^
|
||||||
| |
|
| |
|
||||||
| field in this union
|
| field in this union
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ LL | union U {
|
||||||
| - field in this union
|
| - field in this union
|
||||||
...
|
...
|
||||||
LL | c: u8,
|
LL | c: u8,
|
||||||
| ^^^^^
|
| ^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | union Foo {
|
||||||
| --- field in this union
|
| --- field in this union
|
||||||
LL | x: usize,
|
LL | x: usize,
|
||||||
LL | b: bool,
|
LL | b: bool,
|
||||||
| ^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/union-lint-dead-code.rs:4:9
|
--> $DIR/union-lint-dead-code.rs:4:9
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | union Foo {
|
||||||
| --- field in this union
|
| --- field in this union
|
||||||
LL | x: usize,
|
LL | x: usize,
|
||||||
LL | b: bool,
|
LL | b: bool,
|
||||||
| ^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/union-lint-dead-code.rs:4:9
|
--> $DIR/union-lint-dead-code.rs:4:9
|
||||||
|
|
Loading…
Add table
Reference in a new issue