From 3a023e7e589c469c2c761c73eeab9c238818e94b Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Fri, 10 Jun 2022 12:14:24 +0900 Subject: [PATCH] collapse dead code warnings into a single diagnostic add comments in `store_dead_field_or_variant` support multiple log level add a item ident label fix ui tests fix a ui test fix a rustdoc ui test use let chain refactor: remove `store_dead_field_or_variant` fix a tiny bug --- Cargo.lock | 1 + compiler/rustc_passes/Cargo.toml | 1 + compiler/rustc_passes/src/dead.rs | 251 +++++++++++++----- src/test/rustdoc-ui/display-output.stdout | 2 +- .../associated-const-dead-code.rs | 2 +- .../associated-const-dead-code.stderr | 2 +- .../2229_closure_analysis/issue-87987.rs | 11 +- .../2229_closure_analysis/issue-87987.stderr | 14 +- .../match/issue-87097.rs | 2 +- .../match/issue-87097.stderr | 5 +- src/test/ui/derive-uninhabited-enum-38885.rs | 2 +- .../ui/derive-uninhabited-enum-38885.stderr | 5 +- ...lone-debug-dead-code-in-the-same-struct.rs | 8 +- ...-debug-dead-code-in-the-same-struct.stderr | 31 +-- src/test/ui/derives/clone-debug-dead-code.rs | 10 +- .../ui/derives/clone-debug-dead-code.stderr | 30 ++- src/test/ui/issues/issue-37515.rs | 2 +- src/test/ui/issues/issue-37515.stderr | 2 +- src/test/ui/lint/dead-code/basic.rs | 2 +- src/test/ui/lint/dead-code/basic.stderr | 2 +- src/test/ui/lint/dead-code/const-and-self.rs | 4 +- .../ui/lint/dead-code/const-and-self.stderr | 15 +- .../ui/lint/dead-code/empty-unused-enum.rs | 2 +- .../lint/dead-code/empty-unused-enum.stderr | 2 +- src/test/ui/lint/dead-code/impl-trait.rs | 2 +- src/test/ui/lint/dead-code/impl-trait.stderr | 2 +- src/test/ui/lint/dead-code/issue-85255.rs | 24 +- src/test/ui/lint/dead-code/issue-85255.stderr | 42 ++- .../ui/lint/dead-code/lint-dead-code-1.rs | 20 +- .../ui/lint/dead-code/lint-dead-code-1.stderr | 23 +- .../ui/lint/dead-code/lint-dead-code-2.rs | 6 +- .../ui/lint/dead-code/lint-dead-code-2.stderr | 6 +- .../ui/lint/dead-code/lint-dead-code-3.rs | 10 +- .../ui/lint/dead-code/lint-dead-code-3.stderr | 10 +- .../ui/lint/dead-code/lint-dead-code-4.rs | 20 +- .../ui/lint/dead-code/lint-dead-code-4.stderr | 54 ++-- .../ui/lint/dead-code/lint-dead-code-5.rs | 8 +- .../ui/lint/dead-code/lint-dead-code-5.stderr | 18 +- .../ui/lint/dead-code/lint-dead-code-6.rs | 8 +- .../ui/lint/dead-code/lint-dead-code-6.stderr | 8 +- .../multiple-dead-codes-in-the-same-struct.rs | 29 ++ ...tiple-dead-codes-in-the-same-struct.stderr | 55 ++++ src/test/ui/lint/dead-code/newline-span.rs | 6 +- .../ui/lint/dead-code/newline-span.stderr | 6 +- src/test/ui/lint/dead-code/type-alias.rs | 2 +- src/test/ui/lint/dead-code/type-alias.stderr | 2 +- src/test/ui/lint/dead-code/unused-enum.rs | 7 +- src/test/ui/lint/dead-code/unused-enum.stderr | 6 +- .../lint/dead-code/unused-struct-variant.rs | 2 +- .../dead-code/unused-struct-variant.stderr | 5 +- src/test/ui/lint/dead-code/unused-variant.rs | 2 +- .../ui/lint/dead-code/unused-variant.stderr | 4 +- src/test/ui/lint/dead-code/with-core-crate.rs | 2 +- .../ui/lint/dead-code/with-core-crate.stderr | 2 +- src/test/ui/lint/force-warn/allow-warnings.rs | 2 +- .../ui/lint/force-warn/allow-warnings.stderr | 2 +- .../allowed-warn-by-default-lint.rs | 2 +- .../allowed-warn-by-default-lint.stderr | 2 +- .../warn-by-default-lint-two-modules.rs | 4 +- .../warn-by-default-lint-two-modules.stderr | 4 +- src/test/ui/lint/issue-17718-const-naming.rs | 2 +- .../ui/lint/issue-17718-const-naming.stderr | 2 +- src/test/ui/span/macro-span-replacement.rs | 2 +- .../ui/span/macro-span-replacement.stderr | 2 +- .../unused-warning-point-at-identifier.rs | 8 +- .../unused-warning-point-at-identifier.stderr | 8 +- .../ui/test-attrs/test-warns-dead-code.rs | 2 +- .../ui/test-attrs/test-warns-dead-code.stderr | 2 +- .../union/union-fields-1.mirunsafeck.stderr | 20 +- src/test/ui/union/union-fields-1.rs | 8 +- .../union/union-fields-1.thirunsafeck.stderr | 20 +- .../union-lint-dead-code.mirunsafeck.stderr | 5 +- src/test/ui/union/union-lint-dead-code.rs | 2 +- .../union-lint-dead-code.thirunsafeck.stderr | 5 +- 74 files changed, 565 insertions(+), 338 deletions(-) create mode 100644 src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs create mode 100644 src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr diff --git a/Cargo.lock b/Cargo.lock index 671f85ca3b6..5a0c94d3b68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4286,6 +4286,7 @@ dependencies = [ name = "rustc_passes" version = "0.0.0" dependencies = [ + "itertools", "rustc_ast", "rustc_ast_pretty", "rustc_attr", diff --git a/compiler/rustc_passes/Cargo.toml b/compiler/rustc_passes/Cargo.toml index 787d37277c6..676812db59a 100644 --- a/compiler/rustc_passes/Cargo.toml +++ b/compiler/rustc_passes/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" [dependencies] tracing = "0.1" +itertools = "0.10.1" rustc_middle = { path = "../rustc_middle" } rustc_attr = { path = "../rustc_attr" } rustc_data_structures = { path = "../rustc_data_structures" } diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 421c67fb6b7..01d93f6ff0c 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -2,8 +2,9 @@ // closely. The idea is that all reachable symbols are live, codes called // from live codes are live, and everything else is dead. +use itertools::Itertools; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_errors::pluralize; +use rustc_errors::{pluralize, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -164,9 +165,10 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { if let (Res::Local(id_l), Res::Local(id_r)) = ( typeck_results.qpath_res(qpath_l, lhs.hir_id), typeck_results.qpath_res(qpath_r, rhs.hir_id), - ) && id_l == id_r - { - return true; + ) { + if id_l == id_r { + return true; + } } return false; } @@ -269,13 +271,10 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } fn visit_node(&mut self, node: Node<'tcx>) { - match node { - Node::ImplItem(hir::ImplItem { def_id, .. }) - if self.should_ignore_item(def_id.to_def_id()) => - { - return; - } - _ => (), + if let Node::ImplItem(hir::ImplItem { def_id, .. }) = node + && self.should_ignore_item(def_id.to_def_id()) + { + return; } let had_repr_c = self.repr_has_repr_c; @@ -624,11 +623,17 @@ fn live_symbols_and_ignored_derived_traits<'tcx>( (symbol_visitor.live_symbols, symbol_visitor.ignored_derived_traits) } +struct DeadVariant { + hir_id: hir::HirId, + span: Span, + name: Symbol, + level: lint::Level, +} + struct DeadVisitor<'tcx> { tcx: TyCtxt<'tcx>, live_symbols: &'tcx FxHashSet, ignored_derived_traits: &'tcx FxHashMap>, - ignored_struct_def: FxHashSet, } impl<'tcx> DeadVisitor<'tcx> { @@ -686,6 +691,111 @@ impl<'tcx> DeadVisitor<'tcx> { false } + fn warn_multiple_dead_codes( + &self, + dead_codes: &[(hir::HirId, Span, Symbol)], + participle: &str, + parent_hir_id: Option, + ) { + if let Some((id, _, name)) = dead_codes.first() + && !name.as_str().starts_with('_') + { + self.tcx.struct_span_lint_hir( + lint::builtin::DEAD_CODE, + *id, + MultiSpan::from_spans( + dead_codes.iter().map(|(_, span, _)| *span).collect(), + ), + |lint| { + let def_id = self.tcx.hir().local_def_id(*id); + let descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id()); + let span_len = dead_codes.len(); + let names = match &dead_codes.iter().map(|(_, _, n)| n.to_string()).collect::>()[..] + { + _ if span_len > 6 => String::new(), + [name] => format!("`{name}` "), + [names @ .., last] => { + format!("{} and `{last}` ", names.iter().map(|name| format!("`{name}`")).join(", ")) + } + [] => unreachable!(), + }; + let mut err = lint.build(&format!( + "{these}{descr}{s} {names}{are} never {participle}", + these = if span_len > 6 { "multiple " } else { "" }, + s = pluralize!(span_len), + are = pluralize!("is", span_len), + )); + let hir = self.tcx.hir(); + if let Some(parent_hir_id) = parent_hir_id + && let Some(parent_node) = hir.find(parent_hir_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( + item.ident.span, + format!( + "{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 Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) + { + let traits_str = ign_traits + .iter() + .map(|(trait_id, _)| format!("`{}`", self.tcx.item_name(*trait_id))) + .collect::>() + .join(" and "); + let plural_s = pluralize!(ign_traits.len()); + let article = if ign_traits.len() > 1 { "" } else { "a " }; + let is_are = if ign_traits.len() > 1 { "these are" } else { "this is" }; + let msg = format!( + "`{}` has {}derived impl{} for the trait{} {}, but {} \ + intentionally ignored during dead code analysis", + self.tcx.item_name(encl_def_id.to_def_id()), + article, + plural_s, + plural_s, + traits_str, + is_are + ); + err.note(&msg); + } + err.emit(); + }, + ); + } + } + + fn warn_dead_fields_and_variants( + &self, + hir_id: hir::HirId, + participle: &str, + dead_codes: Vec, + ) { + let mut dead_codes = dead_codes + .iter() + .filter(|v| !v.name.as_str().starts_with('_')) + .map(|v| v) + .collect::>(); + if dead_codes.is_empty() { + return; + } + dead_codes.sort_by_key(|v| v.level); + for (_, group) in &dead_codes.into_iter().group_by(|v| v.level) { + self.warn_multiple_dead_codes( + &group + .map(|v| (v.hir_id, v.span, v.name)) + .collect::>(), + participle, + Some(hir_id), + ); + } + } + fn warn_dead_code( &mut self, id: hir::HirId, @@ -693,50 +803,7 @@ impl<'tcx> DeadVisitor<'tcx> { name: Symbol, participle: &str, ) { - if !name.as_str().starts_with('_') { - self.tcx.struct_span_lint_hir(lint::builtin::DEAD_CODE, id, span, |lint| { - let def_id = self.tcx.hir().local_def_id(id); - let descr = self.tcx.def_kind(def_id).descr(def_id.to_def_id()); - let mut err = lint.build(&format!("{descr} is never {participle}: `{name}`")); - let hir = self.tcx.hir(); - let is_field_in_same_struct = - if let Some(parent_hir_id) = self.tcx.hir().find_parent_node(id) - && let Some(parent_node) = self.tcx.hir().find(parent_hir_id) - && let Node::Item(hir::Item{kind: hir::ItemKind::Struct(..), ..}) = parent_node - && let Some(did) = self.tcx.hir().opt_local_def_id(parent_hir_id) - { - !self.ignored_struct_def.insert(did) - } else { - false - }; - if !is_field_in_same_struct - && let Some(encl_scope) = hir.get_enclosing_scope(id) - && let Some(encl_def_id) = hir.opt_local_def_id(encl_scope) - && let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) - { - let traits_str = ign_traits - .iter() - .map(|(trait_id, _)| format!("`{}`", self.tcx.item_name(*trait_id))) - .collect::>() - .join(" and "); - let plural_s = pluralize!(ign_traits.len()); - let article = if ign_traits.len() > 1 { "" } else { "a " }; - let is_are = if ign_traits.len() > 1 { "these are" } else { "this is" }; - let msg = format!( - "`{}` has {}derived impl{} for the trait{} {}, but {} \ - intentionally ignored during dead code analysis", - self.tcx.item_name(encl_def_id.to_def_id()), - article, - plural_s, - plural_s, - traits_str, - is_are - ); - err.note(&msg); - } - err.emit(); - }); - } + self.warn_multiple_dead_codes(&[(id, span, name)], participle, None); } } @@ -790,15 +857,40 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> { // This visitor should only visit a single module at a time. fn visit_mod(&mut self, _: &'tcx hir::Mod<'tcx>, _: Span, _: hir::HirId) {} + fn visit_enum_def( + &mut self, + enum_definition: &'tcx hir::EnumDef<'tcx>, + generics: &'tcx hir::Generics<'tcx>, + item_id: hir::HirId, + _: Span, + ) { + intravisit::walk_enum_def(self, enum_definition, generics, item_id); + let dead_variants = enum_definition + .variants + .iter() + .filter_map(|variant| { + if self.should_warn_about_variant(&variant) { + Some(DeadVariant { + hir_id: variant.id, + span: variant.span, + name: variant.ident.name, + level: self.tcx.lint_level_at_node(lint::builtin::DEAD_CODE, variant.id).0, + }) + } else { + None + } + }) + .collect(); + self.warn_dead_fields_and_variants(item_id, "constructed", dead_variants) + } + fn visit_variant( &mut self, variant: &'tcx hir::Variant<'tcx>, g: &'tcx hir::Generics<'tcx>, id: hir::HirId, ) { - if self.should_warn_about_variant(&variant) { - self.warn_dead_code(variant.id, variant.span, variant.ident.name, "constructed"); - } else { + if !self.should_warn_about_variant(&variant) { intravisit::walk_variant(self, variant, g, id); } } @@ -810,11 +902,35 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> { intravisit::walk_foreign_item(self, fi); } - fn visit_field_def(&mut self, field: &'tcx hir::FieldDef<'tcx>) { - if self.should_warn_about_field(&field) { - self.warn_dead_code(field.hir_id, field.span, field.ident.name, "read"); - } - intravisit::walk_field_def(self, field); + fn visit_variant_data( + &mut self, + def: &'tcx hir::VariantData<'tcx>, + _: Symbol, + _: &hir::Generics<'_>, + id: hir::HirId, + _: rustc_span::Span, + ) { + intravisit::walk_struct_def(self, def); + let dead_fields = def + .fields() + .iter() + .filter_map(|field| { + if self.should_warn_about_field(&field) { + Some(DeadVariant { + hir_id: field.hir_id, + span: field.span, + name: field.ident.name, + level: self + .tcx + .lint_level_at_node(lint::builtin::DEAD_CODE, field.hir_id) + .0, + }) + } else { + None + } + }) + .collect(); + self.warn_dead_fields_and_variants(id, "read", dead_fields) } fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) { @@ -867,12 +983,7 @@ impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> { fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) { let (live_symbols, ignored_derived_traits) = tcx.live_symbols_and_ignored_derived_traits(()); - let mut visitor = DeadVisitor { - tcx, - live_symbols, - ignored_derived_traits, - ignored_struct_def: FxHashSet::default(), - }; + let mut visitor = DeadVisitor { tcx, live_symbols, ignored_derived_traits }; let (module, _, module_id) = tcx.hir().get_module(module); // Do not use an ItemLikeVisitor since we may want to skip visiting some items // when a surrounding one is warned against or `_`. diff --git a/src/test/rustdoc-ui/display-output.stdout b/src/test/rustdoc-ui/display-output.stdout index 51d638b31a8..ad25d1ce541 100644 --- a/src/test/rustdoc-ui/display-output.stdout +++ b/src/test/rustdoc-ui/display-output.stdout @@ -24,7 +24,7 @@ warning: unused variable: `x` LL | fn foo(x: &dyn std::fmt::Display) {} | ^ help: if this is intentional, prefix it with an underscore: `_x` -warning: function is never used: `foo` +warning: function `foo` is never used --> $DIR/display-output.rs:13:4 | LL | fn foo(x: &dyn std::fmt::Display) {} diff --git a/src/test/ui/associated-consts/associated-const-dead-code.rs b/src/test/ui/associated-consts/associated-const-dead-code.rs index e659bdb83f9..f7b676418ff 100644 --- a/src/test/ui/associated-consts/associated-const-dead-code.rs +++ b/src/test/ui/associated-consts/associated-const-dead-code.rs @@ -4,7 +4,7 @@ struct MyFoo; impl MyFoo { const BAR: u32 = 1; - //~^ ERROR associated constant is never used: `BAR` + //~^ ERROR associated constant `BAR` is never used } fn main() { diff --git a/src/test/ui/associated-consts/associated-const-dead-code.stderr b/src/test/ui/associated-consts/associated-const-dead-code.stderr index 9b6bbb68a71..7a4dbfe087b 100644 --- a/src/test/ui/associated-consts/associated-const-dead-code.stderr +++ b/src/test/ui/associated-consts/associated-const-dead-code.stderr @@ -1,4 +1,4 @@ -error: associated constant is never used: `BAR` +error: associated constant `BAR` is never used --> $DIR/associated-const-dead-code.rs:6:5 | LL | const BAR: u32 = 1; diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87987.rs b/src/test/ui/closures/2229_closure_analysis/issue-87987.rs index d4f243ee347..d26343c33cf 100644 --- a/src/test/ui/closures/2229_closure_analysis/issue-87987.rs +++ b/src/test/ui/closures/2229_closure_analysis/issue-87987.rs @@ -2,16 +2,13 @@ // edition:2021 struct Props { - field_1: u32, //~ WARNING: field is never read: `field_1` - field_2: u32, //~ WARNING: field is never read: `field_2` + field_1: u32, //~ WARNING: fields `field_1` and `field_2` are never read + field_2: u32, } fn main() { // Test 1 - let props_2 = Props { - field_1: 1, - field_2: 1, - }; + let props_2 = Props { field_1: 1, field_2: 1 }; let _ = || { let _: Props = props_2; @@ -23,7 +20,7 @@ fn main() { let mref = &mut arr; let _c = || match arr { - [_, _, _, _] => println!("A") + [_, _, _, _] => println!("A"), }; println!("{:#?}", mref); diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87987.stderr b/src/test/ui/closures/2229_closure_analysis/issue-87987.stderr index 5828295fae3..57b8f7ae609 100644 --- a/src/test/ui/closures/2229_closure_analysis/issue-87987.stderr +++ b/src/test/ui/closures/2229_closure_analysis/issue-87987.stderr @@ -1,16 +1,14 @@ -warning: field is never read: `field_1` +warning: fields `field_1` and `field_2` are never read --> $DIR/issue-87987.rs:5:5 | +LL | struct Props { + | ----- fields in this struct LL | field_1: u32, | ^^^^^^^^^^^^ +LL | field_2: u32, + | ^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default -warning: field is never read: `field_2` - --> $DIR/issue-87987.rs:6:5 - | -LL | field_2: u32, - | ^^^^^^^^^^^^ - -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.rs b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.rs index 241ddcb83e1..815fc0a719c 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.rs +++ b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.rs @@ -3,7 +3,7 @@ enum Variant { A, - B, //~ WARNING: variant is never constructed: `B` + B, //~ WARNING: variant `B` is never constructed } struct A { diff --git a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr index 38f2929a05f..2a49ed4b5ff 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr @@ -1,6 +1,9 @@ -warning: variant is never constructed: `B` +warning: variant `B` is never constructed --> $DIR/issue-87097.rs:6:5 | +LL | enum Variant { + | ------- variant in this enum +LL | A, LL | B, | ^ | diff --git a/src/test/ui/derive-uninhabited-enum-38885.rs b/src/test/ui/derive-uninhabited-enum-38885.rs index 35c3065ea81..0089453ef0f 100644 --- a/src/test/ui/derive-uninhabited-enum-38885.rs +++ b/src/test/ui/derive-uninhabited-enum-38885.rs @@ -10,7 +10,7 @@ enum Void {} #[derive(Debug)] enum Foo { Bar(u8), - Void(Void), //~ WARN never constructed + Void(Void), //~ WARN variant `Void` is never constructed } fn main() { diff --git a/src/test/ui/derive-uninhabited-enum-38885.stderr b/src/test/ui/derive-uninhabited-enum-38885.stderr index 58aaf978dc7..4feaf3ac961 100644 --- a/src/test/ui/derive-uninhabited-enum-38885.stderr +++ b/src/test/ui/derive-uninhabited-enum-38885.stderr @@ -1,6 +1,9 @@ -warning: variant is never constructed: `Void` +warning: variant `Void` is never constructed --> $DIR/derive-uninhabited-enum-38885.rs:13:5 | +LL | enum Foo { + | --- variant in this enum +LL | Bar(u8), LL | Void(Void), | ^^^^^^^^^^ | diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs index f5cff8ae9e5..15d06817577 100644 --- a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs +++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs @@ -3,10 +3,10 @@ #[derive(Debug)] pub struct Whatever { pub field0: (), - field1: (), //~ERROR field is never read: `field1 - field2: (), //~ERROR field is never read: `field2 - field3: (), //~ERROR field is never read: `field3 - field4: (), //~ERROR field is never read: `field4 + field1: (), //~ ERROR fields `field1`, `field2`, `field3` and `field4` are never read + field2: (), + field3: (), + field4: (), } fn main() {} diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr index 2190a0307bf..383e0b4b725 100644 --- a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr +++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr @@ -1,8 +1,17 @@ -error: field is never read: `field1` +error: fields `field1`, `field2`, `field3` and `field4` are never read --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:6:5 | +LL | pub struct Whatever { + | -------- fields in this struct +LL | pub field0: (), LL | field1: (), | ^^^^^^^^^^ +LL | field2: (), + | ^^^^^^^^^^ +LL | field3: (), + | ^^^^^^^^^^ +LL | field4: (), + | ^^^^^^^^^^ | note: the lint level is defined here --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:1:11 @@ -11,23 +20,5 @@ LL | #![forbid(dead_code)] | ^^^^^^^^^ = note: `Whatever` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis -error: field is never read: `field2` - --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:7:5 - | -LL | field2: (), - | ^^^^^^^^^^ - -error: field is never read: `field3` - --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:8:5 - | -LL | field3: (), - | ^^^^^^^^^^ - -error: field is never read: `field4` - --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:9:5 - | -LL | field4: (), - | ^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to previous error diff --git a/src/test/ui/derives/clone-debug-dead-code.rs b/src/test/ui/derives/clone-debug-dead-code.rs index 80e91320939..ab49260c01b 100644 --- a/src/test/ui/derives/clone-debug-dead-code.rs +++ b/src/test/ui/derives/clone-debug-dead-code.rs @@ -4,22 +4,22 @@ #![forbid(dead_code)] struct A { f: () } -//~^ ERROR: field is never read: `f` +//~^ ERROR: field `f` is never read #[derive(Clone)] struct B { f: () } -//~^ ERROR: field is never read: `f` +//~^ ERROR: field `f` is never read #[derive(Debug)] struct C { f: () } -//~^ ERROR: field is never read: `f` +//~^ ERROR: field `f` is never read #[derive(Debug,Clone)] struct D { f: () } -//~^ ERROR: field is never read: `f` +//~^ ERROR: field `f` is never read struct E { f: () } -//~^ ERROR: field is never read: `f` +//~^ ERROR: field `f` is never read // Custom impl, still doesn't read f impl Clone for E { fn clone(&self) -> Self { diff --git a/src/test/ui/derives/clone-debug-dead-code.stderr b/src/test/ui/derives/clone-debug-dead-code.stderr index 031b8ce713e..73a00251188 100644 --- a/src/test/ui/derives/clone-debug-dead-code.stderr +++ b/src/test/ui/derives/clone-debug-dead-code.stderr @@ -1,8 +1,10 @@ -error: field is never read: `f` +error: field `f` is never read --> $DIR/clone-debug-dead-code.rs:6:12 | LL | struct A { f: () } - | ^^^^^ + | - ^^^^^ + | | + | field in this struct | note: the lint level is defined here --> $DIR/clone-debug-dead-code.rs:4:11 @@ -10,35 +12,43 @@ note: the lint level is defined here LL | #![forbid(dead_code)] | ^^^^^^^^^ -error: field is never read: `f` +error: field `f` is never read --> $DIR/clone-debug-dead-code.rs:10:12 | LL | struct B { f: () } - | ^^^^^ + | - ^^^^^ + | | + | field in this struct | = note: `B` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis -error: field is never read: `f` +error: field `f` is never read --> $DIR/clone-debug-dead-code.rs:14:12 | LL | struct C { f: () } - | ^^^^^ + | - ^^^^^ + | | + | field in this struct | = note: `C` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis -error: field is never read: `f` +error: field `f` is never read --> $DIR/clone-debug-dead-code.rs:18:12 | LL | struct D { f: () } - | ^^^^^ + | - ^^^^^ + | | + | field in this struct | = note: `D` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis -error: field is never read: `f` +error: field `f` is never read --> $DIR/clone-debug-dead-code.rs:21:12 | LL | struct E { f: () } - | ^^^^^ + | - ^^^^^ + | | + | field in this struct error: aborting due to 5 previous errors diff --git a/src/test/ui/issues/issue-37515.rs b/src/test/ui/issues/issue-37515.rs index caff507c918..b3a870d505a 100644 --- a/src/test/ui/issues/issue-37515.rs +++ b/src/test/ui/issues/issue-37515.rs @@ -3,6 +3,6 @@ #![warn(unused)] type Z = dyn for<'x> Send; -//~^ WARN type alias is never used +//~^ WARN type alias `Z` is never used fn main() {} diff --git a/src/test/ui/issues/issue-37515.stderr b/src/test/ui/issues/issue-37515.stderr index 204a39bc8e8..c9bb4c10010 100644 --- a/src/test/ui/issues/issue-37515.stderr +++ b/src/test/ui/issues/issue-37515.stderr @@ -1,4 +1,4 @@ -warning: type alias is never used: `Z` +warning: type alias `Z` is never used --> $DIR/issue-37515.rs:5:1 | LL | type Z = dyn for<'x> Send; diff --git a/src/test/ui/lint/dead-code/basic.rs b/src/test/ui/lint/dead-code/basic.rs index 2b69985d33d..3b8ffd58cb5 100644 --- a/src/test/ui/lint/dead-code/basic.rs +++ b/src/test/ui/lint/dead-code/basic.rs @@ -1,7 +1,7 @@ #![deny(dead_code)] #![allow(unreachable_code)] -fn foo() { //~ ERROR function is never used +fn foo() { //~ ERROR function `foo` is never used // none of these should have any dead_code exposed to the user panic!(); diff --git a/src/test/ui/lint/dead-code/basic.stderr b/src/test/ui/lint/dead-code/basic.stderr index f7b9b9c613a..7d068cead44 100644 --- a/src/test/ui/lint/dead-code/basic.stderr +++ b/src/test/ui/lint/dead-code/basic.stderr @@ -1,4 +1,4 @@ -error: function is never used: `foo` +error: function `foo` is never used --> $DIR/basic.rs:4:4 | LL | fn foo() { diff --git a/src/test/ui/lint/dead-code/const-and-self.rs b/src/test/ui/lint/dead-code/const-and-self.rs index 0bcdd6edf0d..5c96e4d0ecb 100644 --- a/src/test/ui/lint/dead-code/const-and-self.rs +++ b/src/test/ui/lint/dead-code/const-and-self.rs @@ -30,8 +30,8 @@ impl Foo for X { enum E { A, - B, //~ WARN variant is never constructed: `B` - C, //~ WARN variant is never constructed: `C` + B, //~ WARN variants `B` and `C` are never constructed + C, } type F = E; diff --git a/src/test/ui/lint/dead-code/const-and-self.stderr b/src/test/ui/lint/dead-code/const-and-self.stderr index c0e406189e8..9d1d7d6ecde 100644 --- a/src/test/ui/lint/dead-code/const-and-self.stderr +++ b/src/test/ui/lint/dead-code/const-and-self.stderr @@ -1,8 +1,13 @@ -warning: variant is never constructed: `B` +warning: variants `B` and `C` are never constructed --> $DIR/const-and-self.rs:33:5 | +LL | enum E { + | - variants in this enum +LL | A, LL | B, | ^ +LL | C, + | ^ | note: the lint level is defined here --> $DIR/const-and-self.rs:3:9 @@ -10,11 +15,5 @@ note: the lint level is defined here LL | #![warn(dead_code)] | ^^^^^^^^^ -warning: variant is never constructed: `C` - --> $DIR/const-and-self.rs:34:5 - | -LL | C, - | ^ - -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/src/test/ui/lint/dead-code/empty-unused-enum.rs b/src/test/ui/lint/dead-code/empty-unused-enum.rs index 834681d77e6..864501e9495 100644 --- a/src/test/ui/lint/dead-code/empty-unused-enum.rs +++ b/src/test/ui/lint/dead-code/empty-unused-enum.rs @@ -1,5 +1,5 @@ #![deny(unused)] -enum E {} //~ ERROR enum is never used +enum E {} //~ ERROR enum `E` is never used fn main() {} diff --git a/src/test/ui/lint/dead-code/empty-unused-enum.stderr b/src/test/ui/lint/dead-code/empty-unused-enum.stderr index ed9a7ccd14b..6391f0941c8 100644 --- a/src/test/ui/lint/dead-code/empty-unused-enum.stderr +++ b/src/test/ui/lint/dead-code/empty-unused-enum.stderr @@ -1,4 +1,4 @@ -error: enum is never used: `E` +error: enum `E` is never used --> $DIR/empty-unused-enum.rs:3:6 | LL | enum E {} diff --git a/src/test/ui/lint/dead-code/impl-trait.rs b/src/test/ui/lint/dead-code/impl-trait.rs index a2736d97308..757b8f83ef0 100644 --- a/src/test/ui/lint/dead-code/impl-trait.rs +++ b/src/test/ui/lint/dead-code/impl-trait.rs @@ -9,7 +9,7 @@ impl Trait for () { } type Used = (); -type Unused = (); //~ ERROR type alias is never used +type Unused = (); //~ ERROR type alias `Unused` is never used fn foo() -> impl Trait {} diff --git a/src/test/ui/lint/dead-code/impl-trait.stderr b/src/test/ui/lint/dead-code/impl-trait.stderr index 09b6d08eb8f..9c47c1b5355 100644 --- a/src/test/ui/lint/dead-code/impl-trait.stderr +++ b/src/test/ui/lint/dead-code/impl-trait.stderr @@ -1,4 +1,4 @@ -error: type alias is never used: `Unused` +error: type alias `Unused` is never used --> $DIR/impl-trait.rs:12:1 | LL | type Unused = (); diff --git a/src/test/ui/lint/dead-code/issue-85255.rs b/src/test/ui/lint/dead-code/issue-85255.rs index 871dde91a3e..043f68137b8 100644 --- a/src/test/ui/lint/dead-code/issue-85255.rs +++ b/src/test/ui/lint/dead-code/issue-85255.rs @@ -4,39 +4,39 @@ #![warn(dead_code)] struct Foo { - a: i32, //~ WARNING: field is never read - pub b: i32, //~ WARNING: field is never read + a: i32, //~ WARNING: fields `a` and `b` are never read + pub b: i32, } struct Bar; impl Bar { - fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used - pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used + fn a(&self) -> i32 { 5 } //~ WARNING: associated function `a` is never used + pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function `b` is never used } pub(crate) struct Foo1 { - a: i32, //~ WARNING: field is never read - pub b: i32, //~ WARNING: field is never read + a: i32, //~ WARNING: fields `a` and `b` are never read + pub b: i32, } pub(crate) struct Bar1; impl Bar1 { - fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used - pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used + fn a(&self) -> i32 { 5 } //~ WARNING: associated function `a` is never used + pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function `b` is never used } pub(crate) struct Foo2 { - a: i32, //~ WARNING: field is never read - pub b: i32, //~ WARNING: field is never read + a: i32, //~ WARNING: fields `a` and `b` are never read + pub b: i32, } pub(crate) struct Bar2; impl Bar2 { - fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used - pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used + fn a(&self) -> i32 { 5 } //~ WARNING: associated function `a` is never used + pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function `b` is never used } diff --git a/src/test/ui/lint/dead-code/issue-85255.stderr b/src/test/ui/lint/dead-code/issue-85255.stderr index 5f786d5a2a8..7ebbebb1aba 100644 --- a/src/test/ui/lint/dead-code/issue-85255.stderr +++ b/src/test/ui/lint/dead-code/issue-85255.stderr @@ -1,8 +1,12 @@ -warning: field is never read: `a` +warning: fields `a` and `b` are never read --> $DIR/issue-85255.rs:7:5 | +LL | struct Foo { + | --- fields in this struct LL | a: i32, | ^^^^^^ +LL | pub b: i32, + | ^^^^^^^^^^ | note: the lint level is defined here --> $DIR/issue-85255.rs:4:9 @@ -10,71 +14,61 @@ note: the lint level is defined here LL | #![warn(dead_code)] | ^^^^^^^^^ -warning: field is never read: `b` - --> $DIR/issue-85255.rs:8:5 - | -LL | pub b: i32, - | ^^^^^^^^^^ - -warning: associated function is never used: `a` +warning: associated function `a` is never used --> $DIR/issue-85255.rs:14:8 | LL | fn a(&self) -> i32 { 5 } | ^ -warning: associated function is never used: `b` +warning: associated function `b` is never used --> $DIR/issue-85255.rs:15:12 | LL | pub fn b(&self) -> i32 { 6 } | ^ -warning: field is never read: `a` +warning: fields `a` and `b` are never read --> $DIR/issue-85255.rs:19:5 | +LL | pub(crate) struct Foo1 { + | ---- fields in this struct LL | a: i32, | ^^^^^^ - -warning: field is never read: `b` - --> $DIR/issue-85255.rs:20:5 - | LL | pub b: i32, | ^^^^^^^^^^ -warning: associated function is never used: `a` +warning: associated function `a` is never used --> $DIR/issue-85255.rs:26:8 | LL | fn a(&self) -> i32 { 5 } | ^ -warning: associated function is never used: `b` +warning: associated function `b` is never used --> $DIR/issue-85255.rs:27:12 | LL | pub fn b(&self) -> i32 { 6 } | ^ -warning: field is never read: `a` +warning: fields `a` and `b` are never read --> $DIR/issue-85255.rs:31:5 | +LL | pub(crate) struct Foo2 { + | ---- fields in this struct LL | a: i32, | ^^^^^^ - -warning: field is never read: `b` - --> $DIR/issue-85255.rs:32:5 - | LL | pub b: i32, | ^^^^^^^^^^ -warning: associated function is never used: `a` +warning: associated function `a` is never used --> $DIR/issue-85255.rs:38:8 | LL | fn a(&self) -> i32 { 5 } | ^ -warning: associated function is never used: `b` +warning: associated function `b` is never used --> $DIR/issue-85255.rs:39:12 | LL | pub fn b(&self) -> i32 { 6 } | ^ -warning: 12 warnings emitted +warning: 9 warnings emitted diff --git a/src/test/ui/lint/dead-code/lint-dead-code-1.rs b/src/test/ui/lint/dead-code/lint-dead-code-1.rs index 896147fcc77..8f5a4c41ef2 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-1.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-1.rs @@ -9,7 +9,7 @@ pub use foo2::Bar2; mod foo { - pub struct Bar; //~ ERROR: struct is never constructed + pub struct Bar; //~ ERROR: struct `Bar` is never constructed } mod foo2 { @@ -17,14 +17,14 @@ mod foo2 { } pub static pub_static: isize = 0; -static priv_static: isize = 0; //~ ERROR: static is never used +static priv_static: isize = 0; //~ ERROR: static `priv_static` is never used const used_static: isize = 0; pub static used_static2: isize = used_static; const USED_STATIC: isize = 0; const STATIC_USED_IN_ENUM_DISCRIMINANT: isize = 10; pub const pub_const: isize = 0; -const priv_const: isize = 0; //~ ERROR: constant is never used +const priv_const: isize = 0; //~ ERROR: constant `priv_const` is never used const used_const: isize = 0; pub const used_const2: isize = used_const; const USED_CONST: isize = 1; @@ -32,7 +32,7 @@ const CONST_USED_IN_ENUM_DISCRIMINANT: isize = 11; pub type typ = *const UsedStruct4; pub struct PubStruct; -struct PrivStruct; //~ ERROR: struct is never constructed +struct PrivStruct; //~ ERROR: struct `PrivStruct` is never constructed struct UsedStruct1 { #[allow(dead_code)] x: isize @@ -61,10 +61,10 @@ pub enum pub_enum3 { Bar = CONST_USED_IN_ENUM_DISCRIMINANT, } -enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used +enum priv_enum { foo2, bar2 } //~ ERROR: enum `priv_enum` is never used enum used_enum { foo3, - bar3 //~ ERROR variant is never constructed + bar3 //~ ERROR variant `bar3` is never constructed } fn f() {} @@ -85,21 +85,21 @@ pub fn pub_fn() { } f::(); } -fn priv_fn() { //~ ERROR: function is never used +fn priv_fn() { //~ ERROR: function `priv_fn` is never used let unused_struct = PrivStruct; } fn used_fn() {} -fn foo() { //~ ERROR: function is never used +fn foo() { //~ ERROR: function `foo` is never used bar(); let unused_enum = priv_enum::foo2; } -fn bar() { //~ ERROR: function is never used +fn bar() { //~ ERROR: function `bar` is never used foo(); } -fn baz() -> impl Copy { //~ ERROR: function is never used +fn baz() -> impl Copy { //~ ERROR: function `baz` is never used "I'm unused, too" } diff --git a/src/test/ui/lint/dead-code/lint-dead-code-1.stderr b/src/test/ui/lint/dead-code/lint-dead-code-1.stderr index 72e28e7940e..2eddc4ce21c 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-1.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-1.stderr @@ -1,4 +1,4 @@ -error: static is never used: `priv_static` +error: static `priv_static` is never used --> $DIR/lint-dead-code-1.rs:20:1 | LL | static priv_static: isize = 0; @@ -10,55 +10,58 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: constant is never used: `priv_const` +error: constant `priv_const` is never used --> $DIR/lint-dead-code-1.rs:27:1 | LL | const priv_const: isize = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: struct is never constructed: `PrivStruct` +error: struct `PrivStruct` is never constructed --> $DIR/lint-dead-code-1.rs:35:8 | LL | struct PrivStruct; | ^^^^^^^^^^ -error: enum is never used: `priv_enum` +error: enum `priv_enum` is never used --> $DIR/lint-dead-code-1.rs:64:6 | LL | enum priv_enum { foo2, bar2 } | ^^^^^^^^^ -error: variant is never constructed: `bar3` +error: variant `bar3` is never constructed --> $DIR/lint-dead-code-1.rs:67:5 | +LL | enum used_enum { + | --------- variant in this enum +LL | foo3, LL | bar3 | ^^^^ -error: function is never used: `priv_fn` +error: function `priv_fn` is never used --> $DIR/lint-dead-code-1.rs:88:4 | LL | fn priv_fn() { | ^^^^^^^ -error: function is never used: `foo` +error: function `foo` is never used --> $DIR/lint-dead-code-1.rs:93:4 | LL | fn foo() { | ^^^ -error: function is never used: `bar` +error: function `bar` is never used --> $DIR/lint-dead-code-1.rs:98:4 | LL | fn bar() { | ^^^ -error: function is never used: `baz` +error: function `baz` is never used --> $DIR/lint-dead-code-1.rs:102:4 | LL | fn baz() -> impl Copy { | ^^^ -error: struct is never constructed: `Bar` +error: struct `Bar` is never constructed --> $DIR/lint-dead-code-1.rs:12:16 | LL | pub struct Bar; diff --git a/src/test/ui/lint/dead-code/lint-dead-code-2.rs b/src/test/ui/lint/dead-code/lint-dead-code-2.rs index 2cfe6e539db..6bfa4d96f71 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-2.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-2.rs @@ -19,10 +19,10 @@ impl Bar for Foo { fn live_fn() {} -fn dead_fn() {} //~ ERROR: function is never used +fn dead_fn() {} //~ ERROR: function `dead_fn` is never used #[rustc_main] -fn dead_fn2() {} //~ ERROR: function is never used +fn dead_fn2() {} //~ ERROR: function `dead_fn2` is never used fn used_fn() {} @@ -35,7 +35,7 @@ fn start(_: isize, _: *const *const u8) -> isize { } // this is not main -fn main() { //~ ERROR: function is never used +fn main() { //~ ERROR: function `main` is never used dead_fn(); dead_fn2(); } diff --git a/src/test/ui/lint/dead-code/lint-dead-code-2.stderr b/src/test/ui/lint/dead-code/lint-dead-code-2.stderr index b01ba57f985..85af553c986 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-2.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-2.stderr @@ -1,4 +1,4 @@ -error: function is never used: `dead_fn` +error: function `dead_fn` is never used --> $DIR/lint-dead-code-2.rs:22:4 | LL | fn dead_fn() {} @@ -10,13 +10,13 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: function is never used: `dead_fn2` +error: function `dead_fn2` is never used --> $DIR/lint-dead-code-2.rs:25:4 | LL | fn dead_fn2() {} | ^^^^^^^^ -error: function is never used: `main` +error: function `main` is never used --> $DIR/lint-dead-code-2.rs:38:4 | LL | fn main() { diff --git a/src/test/ui/lint/dead-code/lint-dead-code-3.rs b/src/test/ui/lint/dead-code/lint-dead-code-3.rs index 7f39f7965f2..c3e56063dc3 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-3.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-3.rs @@ -11,14 +11,14 @@ extern "C" { pub fn extern_foo(); } -struct Foo; //~ ERROR: struct is never constructed +struct Foo; //~ ERROR: struct `Foo` is never constructed impl Foo { - fn foo(&self) { //~ ERROR: associated function is never used + fn foo(&self) { //~ ERROR: associated function `foo` is never used bar() } } -fn bar() { //~ ERROR: function is never used +fn bar() { //~ ERROR: function `bar` is never used fn baz() {} Foo.foo(); @@ -57,9 +57,9 @@ mod blah { } } -enum c_void {} //~ ERROR: enum is never used +enum c_void {} //~ ERROR: enum `c_void` is never used extern "C" { - fn free(p: *const c_void); //~ ERROR: function is never used + fn free(p: *const c_void); //~ ERROR: function `free` is never used } // Check provided method diff --git a/src/test/ui/lint/dead-code/lint-dead-code-3.stderr b/src/test/ui/lint/dead-code/lint-dead-code-3.stderr index cf8f01ea19f..af59c6fec1f 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-3.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-3.stderr @@ -1,4 +1,4 @@ -error: struct is never constructed: `Foo` +error: struct `Foo` is never constructed --> $DIR/lint-dead-code-3.rs:14:8 | LL | struct Foo; @@ -10,25 +10,25 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: associated function is never used: `foo` +error: associated function `foo` is never used --> $DIR/lint-dead-code-3.rs:16:8 | LL | fn foo(&self) { | ^^^ -error: function is never used: `bar` +error: function `bar` is never used --> $DIR/lint-dead-code-3.rs:21:4 | LL | fn bar() { | ^^^ -error: enum is never used: `c_void` +error: enum `c_void` is never used --> $DIR/lint-dead-code-3.rs:60:6 | LL | enum c_void {} | ^^^^^^ -error: function is never used: `free` +error: function `free` is never used --> $DIR/lint-dead-code-3.rs:62:5 | LL | fn free(p: *const c_void); diff --git a/src/test/ui/lint/dead-code/lint-dead-code-4.rs b/src/test/ui/lint/dead-code/lint-dead-code-4.rs index 8bcb1e5ba8c..0fc6c6156fd 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-4.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-4.rs @@ -4,7 +4,7 @@ struct Foo { x: usize, - b: bool, //~ ERROR: field is never read + b: bool, //~ ERROR: field `b` is never read } fn field_read(f: Foo) -> usize { @@ -12,8 +12,8 @@ fn field_read(f: Foo) -> usize { } enum XYZ { - X, //~ ERROR variant is never constructed - Y { //~ ERROR variant is never constructed + X, //~ ERROR variants `X` and `Y` are never constructed + Y { a: String, b: i32, c: i32, @@ -21,7 +21,7 @@ enum XYZ { Z } -enum ABC { //~ ERROR enum is never used +enum ABC { //~ ERROR enum `ABC` is never used A, B { a: String, @@ -33,13 +33,13 @@ enum ABC { //~ ERROR enum is never used // ensure struct variants get warning for their fields enum IJK { - I, //~ ERROR variant is never constructed + I, //~ ERROR variants `I` and `K` are never constructed J { a: String, - b: i32, //~ ERROR field is never read - c: i32, //~ ERROR field is never read + b: i32, //~ ERROR fields `b` and `c` are never read + c: i32, }, - K //~ ERROR variant is never constructed + K } @@ -58,9 +58,9 @@ fn field_match_in_patterns(b: XYZ) -> String { } struct Bar { - x: usize, //~ ERROR: field is never read + x: usize, //~ ERROR: fields `x` and `c` are never read b: bool, - c: bool, //~ ERROR: field is never read + c: bool, _guard: () } diff --git a/src/test/ui/lint/dead-code/lint-dead-code-4.stderr b/src/test/ui/lint/dead-code/lint-dead-code-4.stderr index 3905d1a06bd..dcd810b3e48 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-4.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-4.stderr @@ -1,6 +1,9 @@ -error: field is never read: `b` +error: field `b` is never read --> $DIR/lint-dead-code-4.rs:7:5 | +LL | struct Foo { + | --- field in this struct +LL | x: usize, LL | b: bool, | ^^^^^^^ | @@ -10,15 +13,13 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: variant is never constructed: `X` +error: variants `X` and `Y` are never constructed --> $DIR/lint-dead-code-4.rs:15:5 | -LL | X, - | ^ - -error: variant is never constructed: `Y` - --> $DIR/lint-dead-code-4.rs:16:5 - | +LL | enum XYZ { + | --- variants in this enum +LL | X, + | ^ LL | / Y { LL | | a: String, LL | | b: i32, @@ -26,47 +27,44 @@ LL | | c: i32, LL | | }, | |_____^ -error: enum is never used: `ABC` +error: enum `ABC` is never used --> $DIR/lint-dead-code-4.rs:24:6 | LL | enum ABC { | ^^^ -error: variant is never constructed: `I` - --> $DIR/lint-dead-code-4.rs:36:5 - | -LL | I, - | ^ - -error: field is never read: `b` +error: fields `b` and `c` are never read --> $DIR/lint-dead-code-4.rs:39:9 | +LL | enum IJK { + | --- fields in this enum +... LL | b: i32, | ^^^^^^ - -error: field is never read: `c` - --> $DIR/lint-dead-code-4.rs:40:9 - | LL | c: i32, | ^^^^^^ -error: variant is never constructed: `K` - --> $DIR/lint-dead-code-4.rs:42:5 +error: variants `I` and `K` are never constructed + --> $DIR/lint-dead-code-4.rs:36:5 | +LL | enum IJK { + | --- variants in this enum +LL | I, + | ^ +... LL | K | ^ -error: field is never read: `x` +error: fields `x` and `c` are never read --> $DIR/lint-dead-code-4.rs:61:5 | +LL | struct Bar { + | --- fields in this struct LL | x: usize, | ^^^^^^^^ - -error: field is never read: `c` - --> $DIR/lint-dead-code-4.rs:63:5 - | +LL | b: bool, LL | c: bool, | ^^^^^^^ -error: aborting due to 10 previous errors +error: aborting due to 6 previous errors diff --git a/src/test/ui/lint/dead-code/lint-dead-code-5.rs b/src/test/ui/lint/dead-code/lint-dead-code-5.rs index b477c97c545..ed90fb46429 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-5.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-5.rs @@ -3,15 +3,15 @@ enum Enum1 { Variant1(isize), - Variant2 //~ ERROR: variant is never constructed + Variant2 //~ ERROR: variant `Variant2` is never constructed } enum Enum2 { Variant3(bool), #[allow(dead_code)] Variant4(isize), - Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5` - Variant6(isize), //~ ERROR: variant is never constructed: `Variant6` + Variant5 { _x: isize }, //~ ERROR: variants `Variant5` and `Variant6` are never constructed + Variant6(isize), _Variant7, Variant8 { _field: bool }, Variant9, @@ -32,7 +32,7 @@ impl Enum2 { } } -enum Enum3 { //~ ERROR: enum is never used +enum Enum3 { //~ ERROR: enum `Enum3` is never used Variant8, Variant9 } diff --git a/src/test/ui/lint/dead-code/lint-dead-code-5.stderr b/src/test/ui/lint/dead-code/lint-dead-code-5.stderr index 519add82627..037a9be22ad 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-5.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-5.stderr @@ -1,6 +1,9 @@ -error: variant is never constructed: `Variant2` +error: variant `Variant2` is never constructed --> $DIR/lint-dead-code-5.rs:6:5 | +LL | enum Enum1 { + | ----- variant in this enum +LL | Variant1(isize), LL | Variant2 | ^^^^^^^^ | @@ -10,23 +13,22 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: variant is never constructed: `Variant5` +error: variants `Variant5` and `Variant6` are never constructed --> $DIR/lint-dead-code-5.rs:13:5 | +LL | enum Enum2 { + | ----- variants in this enum +... LL | Variant5 { _x: isize }, | ^^^^^^^^^^^^^^^^^^^^^^ - -error: variant is never constructed: `Variant6` - --> $DIR/lint-dead-code-5.rs:14:5 - | LL | Variant6(isize), | ^^^^^^^^^^^^^^^ -error: enum is never used: `Enum3` +error: enum `Enum3` is never used --> $DIR/lint-dead-code-5.rs:35:6 | LL | enum Enum3 { | ^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/src/test/ui/lint/dead-code/lint-dead-code-6.rs b/src/test/ui/lint/dead-code/lint-dead-code-6.rs index 0a543d5c622..e3074acf129 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-6.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-6.rs @@ -1,16 +1,16 @@ #![deny(dead_code)] -struct UnusedStruct; //~ ERROR struct is never constructed: `UnusedStruct` +struct UnusedStruct; //~ ERROR struct `UnusedStruct` is never constructed impl UnusedStruct { - fn unused_impl_fn_1() { //~ ERROR associated function is never used: `unused_impl_fn_1` + fn unused_impl_fn_1() { //~ ERROR associated function `unused_impl_fn_1` is never used println!("blah"); } - fn unused_impl_fn_2(var: i32) { //~ ERROR associated function is never used: `unused_impl_fn_2` + fn unused_impl_fn_2(var: i32) { //~ ERROR associated function `unused_impl_fn_2` is never used println!("foo {}", var); } - fn unused_impl_fn_3( //~ ERROR associated function is never used: `unused_impl_fn_3` + fn unused_impl_fn_3( //~ ERROR associated function `unused_impl_fn_3` is never used var: i32, ) { println!("bar {}", var); diff --git a/src/test/ui/lint/dead-code/lint-dead-code-6.stderr b/src/test/ui/lint/dead-code/lint-dead-code-6.stderr index 7dc60730d6a..f9d83308a3d 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-6.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-6.stderr @@ -1,4 +1,4 @@ -error: struct is never constructed: `UnusedStruct` +error: struct `UnusedStruct` is never constructed --> $DIR/lint-dead-code-6.rs:3:8 | LL | struct UnusedStruct; @@ -10,19 +10,19 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: associated function is never used: `unused_impl_fn_1` +error: associated function `unused_impl_fn_1` is never used --> $DIR/lint-dead-code-6.rs:5:8 | LL | fn unused_impl_fn_1() { | ^^^^^^^^^^^^^^^^ -error: associated function is never used: `unused_impl_fn_2` +error: associated function `unused_impl_fn_2` is never used --> $DIR/lint-dead-code-6.rs:9:8 | LL | fn unused_impl_fn_2(var: i32) { | ^^^^^^^^^^^^^^^^ -error: associated function is never used: `unused_impl_fn_3` +error: associated function `unused_impl_fn_3` is never used --> $DIR/lint-dead-code-6.rs:13:8 | LL | fn unused_impl_fn_3( diff --git a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs new file mode 100644 index 00000000000..e3935cf9149 --- /dev/null +++ b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs @@ -0,0 +1,29 @@ +#![warn(dead_code)] + +struct Bar { + #[allow(dead_code)] + a: usize, + #[forbid(dead_code)] + b: usize, //~ ERROR field `b` is never read + #[deny(dead_code)] + c: usize, //~ ERROR fields `c` and `e` are never read + d: usize, //~ WARN fields `d`, `f` and `g` are never read + #[deny(dead_code)] + e: usize, + f: usize, + g: usize, + _h: usize, +} + +fn main() { + Bar { + a: 1, + b: 1, + c: 1, + d: 1, + e: 1, + f: 1, + g: 1, + _h: 1, + }; +} diff --git a/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr new file mode 100644 index 00000000000..5cc8e06c09d --- /dev/null +++ b/src/test/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr @@ -0,0 +1,55 @@ +warning: fields `d`, `f` and `g` are never read + --> $DIR/multiple-dead-codes-in-the-same-struct.rs:10:5 + | +LL | struct Bar { + | --- fields in this struct +... +LL | d: usize, + | ^^^^^^^^ +... +LL | f: usize, + | ^^^^^^^^ +LL | g: usize, + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/multiple-dead-codes-in-the-same-struct.rs:1:9 + | +LL | #![warn(dead_code)] + | ^^^^^^^^^ + +error: fields `c` and `e` are never read + --> $DIR/multiple-dead-codes-in-the-same-struct.rs:9:5 + | +LL | struct Bar { + | --- fields in this struct +... +LL | c: usize, + | ^^^^^^^^ +... +LL | e: usize, + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/multiple-dead-codes-in-the-same-struct.rs:8:12 + | +LL | #[deny(dead_code)] + | ^^^^^^^^^ + +error: field `b` is never read + --> $DIR/multiple-dead-codes-in-the-same-struct.rs:7:5 + | +LL | struct Bar { + | --- field in this struct +... +LL | b: usize, + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/multiple-dead-codes-in-the-same-struct.rs:6:14 + | +LL | #[forbid(dead_code)] + | ^^^^^^^^^ + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/src/test/ui/lint/dead-code/newline-span.rs b/src/test/ui/lint/dead-code/newline-span.rs index a4342056419..209c3cd937f 100644 --- a/src/test/ui/lint/dead-code/newline-span.rs +++ b/src/test/ui/lint/dead-code/newline-span.rs @@ -1,14 +1,14 @@ #![deny(dead_code)] -fn unused() { //~ error: function is never used: +fn unused() { //~ error: function `unused` is never used println!("blah"); } -fn unused2(var: i32) { //~ error: function is never used: +fn unused2(var: i32) { //~ error: function `unused2` is never used println!("foo {}", var); } -fn unused3( //~ error: function is never used: +fn unused3( //~ error: function `unused3` is never used var: i32, ) { println!("bar {}", var); diff --git a/src/test/ui/lint/dead-code/newline-span.stderr b/src/test/ui/lint/dead-code/newline-span.stderr index fd74405f2b6..4eeadccc823 100644 --- a/src/test/ui/lint/dead-code/newline-span.stderr +++ b/src/test/ui/lint/dead-code/newline-span.stderr @@ -1,4 +1,4 @@ -error: function is never used: `unused` +error: function `unused` is never used --> $DIR/newline-span.rs:3:4 | LL | fn unused() { @@ -10,13 +10,13 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: function is never used: `unused2` +error: function `unused2` is never used --> $DIR/newline-span.rs:7:4 | LL | fn unused2(var: i32) { | ^^^^^^^ -error: function is never used: `unused3` +error: function `unused3` is never used --> $DIR/newline-span.rs:11:4 | LL | fn unused3( diff --git a/src/test/ui/lint/dead-code/type-alias.rs b/src/test/ui/lint/dead-code/type-alias.rs index 86daf3ea04d..35a7f125dda 100644 --- a/src/test/ui/lint/dead-code/type-alias.rs +++ b/src/test/ui/lint/dead-code/type-alias.rs @@ -1,7 +1,7 @@ #![deny(dead_code)] type Used = u8; -type Unused = u8; //~ ERROR type alias is never used +type Unused = u8; //~ ERROR type alias `Unused` is never used fn id(x: Used) -> Used { x } diff --git a/src/test/ui/lint/dead-code/type-alias.stderr b/src/test/ui/lint/dead-code/type-alias.stderr index b2acd5d4213..80c6ba962b8 100644 --- a/src/test/ui/lint/dead-code/type-alias.stderr +++ b/src/test/ui/lint/dead-code/type-alias.stderr @@ -1,4 +1,4 @@ -error: type alias is never used: `Unused` +error: type alias `Unused` is never used --> $DIR/type-alias.rs:4:1 | LL | type Unused = u8; diff --git a/src/test/ui/lint/dead-code/unused-enum.rs b/src/test/ui/lint/dead-code/unused-enum.rs index e57fac259c5..20df3e1de6f 100644 --- a/src/test/ui/lint/dead-code/unused-enum.rs +++ b/src/test/ui/lint/dead-code/unused-enum.rs @@ -1,9 +1,10 @@ #![deny(unused)] -struct F; //~ ERROR struct is never constructed -struct B; //~ ERROR struct is never constructed +struct F; //~ ERROR struct `F` is never constructed +struct B; //~ ERROR struct `B` is never constructed -enum E { //~ ERROR enum is never used +enum E { + //~^ ERROR enum `E` is never used Foo(F), Bar(B), } diff --git a/src/test/ui/lint/dead-code/unused-enum.stderr b/src/test/ui/lint/dead-code/unused-enum.stderr index 9f368fdd2f8..d2602dbb344 100644 --- a/src/test/ui/lint/dead-code/unused-enum.stderr +++ b/src/test/ui/lint/dead-code/unused-enum.stderr @@ -1,4 +1,4 @@ -error: struct is never constructed: `F` +error: struct `F` is never constructed --> $DIR/unused-enum.rs:3:8 | LL | struct F; @@ -11,13 +11,13 @@ LL | #![deny(unused)] | ^^^^^^ = note: `#[deny(dead_code)]` implied by `#[deny(unused)]` -error: struct is never constructed: `B` +error: struct `B` is never constructed --> $DIR/unused-enum.rs:4:8 | LL | struct B; | ^ -error: enum is never used: `E` +error: enum `E` is never used --> $DIR/unused-enum.rs:6:6 | LL | enum E { diff --git a/src/test/ui/lint/dead-code/unused-struct-variant.rs b/src/test/ui/lint/dead-code/unused-struct-variant.rs index 69ab29042e5..a914e0c3301 100644 --- a/src/test/ui/lint/dead-code/unused-struct-variant.rs +++ b/src/test/ui/lint/dead-code/unused-struct-variant.rs @@ -5,7 +5,7 @@ struct B; enum E { Foo(F), - Bar(B), //~ ERROR variant is never constructed + Bar(B), //~ ERROR variant `Bar` is never constructed } fn main() { diff --git a/src/test/ui/lint/dead-code/unused-struct-variant.stderr b/src/test/ui/lint/dead-code/unused-struct-variant.stderr index b93d6d4ac18..b08402b671b 100644 --- a/src/test/ui/lint/dead-code/unused-struct-variant.stderr +++ b/src/test/ui/lint/dead-code/unused-struct-variant.stderr @@ -1,6 +1,9 @@ -error: variant is never constructed: `Bar` +error: variant `Bar` is never constructed --> $DIR/unused-struct-variant.rs:8:5 | +LL | enum E { + | - variant in this enum +LL | Foo(F), LL | Bar(B), | ^^^^^^ | diff --git a/src/test/ui/lint/dead-code/unused-variant.rs b/src/test/ui/lint/dead-code/unused-variant.rs index 295ed16d4cf..82108fa9c13 100644 --- a/src/test/ui/lint/dead-code/unused-variant.rs +++ b/src/test/ui/lint/dead-code/unused-variant.rs @@ -2,7 +2,7 @@ #[derive(Clone)] enum Enum { - Variant1, //~ ERROR: variant is never constructed + Variant1, //~ ERROR: variant `Variant1` is never constructed Variant2, } diff --git a/src/test/ui/lint/dead-code/unused-variant.stderr b/src/test/ui/lint/dead-code/unused-variant.stderr index 57f8ca74f83..a68f64775ad 100644 --- a/src/test/ui/lint/dead-code/unused-variant.stderr +++ b/src/test/ui/lint/dead-code/unused-variant.stderr @@ -1,6 +1,8 @@ -error: variant is never constructed: `Variant1` +error: variant `Variant1` is never constructed --> $DIR/unused-variant.rs:5:5 | +LL | enum Enum { + | ---- variant in this enum LL | Variant1, | ^^^^^^^^ | diff --git a/src/test/ui/lint/dead-code/with-core-crate.rs b/src/test/ui/lint/dead-code/with-core-crate.rs index bc74e807783..0a94b528f33 100644 --- a/src/test/ui/lint/dead-code/with-core-crate.rs +++ b/src/test/ui/lint/dead-code/with-core-crate.rs @@ -4,7 +4,7 @@ #[macro_use] extern crate core; -fn foo() { //~ ERROR function is never used +fn foo() { //~ ERROR function `foo` is never used // none of these should have any dead_code exposed to the user panic!(); diff --git a/src/test/ui/lint/dead-code/with-core-crate.stderr b/src/test/ui/lint/dead-code/with-core-crate.stderr index 2c63e60d676..7adcf884886 100644 --- a/src/test/ui/lint/dead-code/with-core-crate.stderr +++ b/src/test/ui/lint/dead-code/with-core-crate.stderr @@ -1,4 +1,4 @@ -error: function is never used: `foo` +error: function `foo` is never used --> $DIR/with-core-crate.rs:7:4 | LL | fn foo() { diff --git a/src/test/ui/lint/force-warn/allow-warnings.rs b/src/test/ui/lint/force-warn/allow-warnings.rs index adcefc7ec78..0199381fcbb 100644 --- a/src/test/ui/lint/force-warn/allow-warnings.rs +++ b/src/test/ui/lint/force-warn/allow-warnings.rs @@ -6,6 +6,6 @@ #![allow(warnings)] fn dead_function() {} -//~^ WARN function is never used +//~^ WARN function `dead_function` is never used fn main() {} diff --git a/src/test/ui/lint/force-warn/allow-warnings.stderr b/src/test/ui/lint/force-warn/allow-warnings.stderr index cac2b4e9189..4de68a079e5 100644 --- a/src/test/ui/lint/force-warn/allow-warnings.stderr +++ b/src/test/ui/lint/force-warn/allow-warnings.stderr @@ -1,4 +1,4 @@ -warning: function is never used: `dead_function` +warning: function `dead_function` is never used --> $DIR/allow-warnings.rs:8:4 | LL | fn dead_function() {} diff --git a/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.rs b/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.rs index 4ac29ff7d99..06b37286776 100644 --- a/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.rs +++ b/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.rs @@ -6,6 +6,6 @@ #![allow(dead_code)] fn dead_function() {} -//~^ WARN function is never used +//~^ WARN function `dead_function` is never used fn main() {} diff --git a/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.stderr b/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.stderr index c46d7403fd0..a6634e212bd 100644 --- a/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.stderr +++ b/src/test/ui/lint/force-warn/allowed-warn-by-default-lint.stderr @@ -1,4 +1,4 @@ -warning: function is never used: `dead_function` +warning: function `dead_function` is never used --> $DIR/allowed-warn-by-default-lint.rs:8:4 | LL | fn dead_function() {} diff --git a/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs b/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs index 267e7b45f0c..47a480ad708 100644 --- a/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs +++ b/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs @@ -7,12 +7,12 @@ mod one { #![allow(dead_code)] fn dead_function() {} - //~^ WARN function is never used + //~^ WARN function `dead_function` is never used } mod two { fn dead_function() {} - //~^ WARN function is never used + //~^ WARN function `dead_function` is never used } fn main() {} diff --git a/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.stderr b/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.stderr index 2a3cf85a1e3..824bcccc05f 100644 --- a/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.stderr +++ b/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.stderr @@ -1,4 +1,4 @@ -warning: function is never used: `dead_function` +warning: function `dead_function` is never used --> $DIR/warn-by-default-lint-two-modules.rs:9:8 | LL | fn dead_function() {} @@ -6,7 +6,7 @@ LL | fn dead_function() {} | = note: requested on the command line with `--force-warn dead-code` -warning: function is never used: `dead_function` +warning: function `dead_function` is never used --> $DIR/warn-by-default-lint-two-modules.rs:14:8 | LL | fn dead_function() {} diff --git a/src/test/ui/lint/issue-17718-const-naming.rs b/src/test/ui/lint/issue-17718-const-naming.rs index 7386478f9f0..d7f0e72769b 100644 --- a/src/test/ui/lint/issue-17718-const-naming.rs +++ b/src/test/ui/lint/issue-17718-const-naming.rs @@ -3,6 +3,6 @@ const foo: isize = 3; //~^ ERROR: should have an upper case name -//~^^ ERROR: constant is never used +//~^^ ERROR: constant `foo` is never used fn main() {} diff --git a/src/test/ui/lint/issue-17718-const-naming.stderr b/src/test/ui/lint/issue-17718-const-naming.stderr index a1fc99c9a3d..4c97f6d63d4 100644 --- a/src/test/ui/lint/issue-17718-const-naming.stderr +++ b/src/test/ui/lint/issue-17718-const-naming.stderr @@ -1,4 +1,4 @@ -error: constant is never used: `foo` +error: constant `foo` is never used --> $DIR/issue-17718-const-naming.rs:4:1 | LL | const foo: isize = 3; diff --git a/src/test/ui/span/macro-span-replacement.rs b/src/test/ui/span/macro-span-replacement.rs index 25df4a2aa38..66973c58d35 100644 --- a/src/test/ui/span/macro-span-replacement.rs +++ b/src/test/ui/span/macro-span-replacement.rs @@ -4,7 +4,7 @@ macro_rules! m { ($a:tt $b:tt) => { - $b $a; //~ WARN struct is never constructed + $b $a; //~ WARN struct `S` is never constructed } } diff --git a/src/test/ui/span/macro-span-replacement.stderr b/src/test/ui/span/macro-span-replacement.stderr index d08b24e9562..433d02dcbe7 100644 --- a/src/test/ui/span/macro-span-replacement.stderr +++ b/src/test/ui/span/macro-span-replacement.stderr @@ -1,4 +1,4 @@ -warning: struct is never constructed: `S` +warning: struct `S` is never constructed --> $DIR/macro-span-replacement.rs:7:14 | LL | $b $a; diff --git a/src/test/ui/span/unused-warning-point-at-identifier.rs b/src/test/ui/span/unused-warning-point-at-identifier.rs index d4d5bc1cbc8..af4834503cd 100644 --- a/src/test/ui/span/unused-warning-point-at-identifier.rs +++ b/src/test/ui/span/unused-warning-point-at-identifier.rs @@ -2,26 +2,26 @@ #![warn(unused)] -enum Enum { //~ WARN enum is never used +enum Enum { //~ WARN enum `Enum` is never used A, B, C, D, } -struct Struct { //~ WARN struct is never constructed +struct Struct { //~ WARN struct `Struct` is never constructed a: usize, b: usize, c: usize, d: usize, } -fn func() -> usize { //~ WARN function is never used +fn func() -> usize { //~ WARN function `func` is never used 3 } fn -func_complete_span() //~ WARN function is never used +func_complete_span() //~ WARN function `func_complete_span` is never used -> usize { 3 diff --git a/src/test/ui/span/unused-warning-point-at-identifier.stderr b/src/test/ui/span/unused-warning-point-at-identifier.stderr index 6ef877da122..c2cb5623194 100644 --- a/src/test/ui/span/unused-warning-point-at-identifier.stderr +++ b/src/test/ui/span/unused-warning-point-at-identifier.stderr @@ -1,4 +1,4 @@ -warning: enum is never used: `Enum` +warning: enum `Enum` is never used --> $DIR/unused-warning-point-at-identifier.rs:5:6 | LL | enum Enum { @@ -11,19 +11,19 @@ LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(dead_code)]` implied by `#[warn(unused)]` -warning: struct is never constructed: `Struct` +warning: struct `Struct` is never constructed --> $DIR/unused-warning-point-at-identifier.rs:12:8 | LL | struct Struct { | ^^^^^^ -warning: function is never used: `func` +warning: function `func` is never used --> $DIR/unused-warning-point-at-identifier.rs:19:4 | LL | fn func() -> usize { | ^^^^ -warning: function is never used: `func_complete_span` +warning: function `func_complete_span` is never used --> $DIR/unused-warning-point-at-identifier.rs:24:1 | LL | func_complete_span() diff --git a/src/test/ui/test-attrs/test-warns-dead-code.rs b/src/test/ui/test-attrs/test-warns-dead-code.rs index 936461f162d..4190885b6b2 100644 --- a/src/test/ui/test-attrs/test-warns-dead-code.rs +++ b/src/test/ui/test-attrs/test-warns-dead-code.rs @@ -2,6 +2,6 @@ #![deny(dead_code)] -fn dead() {} //~ error: function is never used: `dead` +fn dead() {} //~ error: function `dead` is never used fn main() {} diff --git a/src/test/ui/test-attrs/test-warns-dead-code.stderr b/src/test/ui/test-attrs/test-warns-dead-code.stderr index d3bcea29513..6c0f2884128 100644 --- a/src/test/ui/test-attrs/test-warns-dead-code.stderr +++ b/src/test/ui/test-attrs/test-warns-dead-code.stderr @@ -1,4 +1,4 @@ -error: function is never used: `dead` +error: function `dead` is never used --> $DIR/test-warns-dead-code.rs:5:4 | LL | fn dead() {} diff --git a/src/test/ui/union/union-fields-1.mirunsafeck.stderr b/src/test/ui/union/union-fields-1.mirunsafeck.stderr index 9f1e2947c86..5b932b9626c 100644 --- a/src/test/ui/union/union-fields-1.mirunsafeck.stderr +++ b/src/test/ui/union/union-fields-1.mirunsafeck.stderr @@ -1,6 +1,9 @@ -error: field is never read: `c` +error: field `c` is never read --> $DIR/union-fields-1.rs:9:5 | +LL | union U1 { + | -- field in this union +... LL | c: u8, | ^^^^^ | @@ -10,21 +13,28 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: field is never read: `a` +error: field `a` is never read --> $DIR/union-fields-1.rs:12:5 | +LL | union U2 { + | -- field in this union LL | a: u8, | ^^^^^ -error: field is never read: `a` +error: field `a` is never read --> $DIR/union-fields-1.rs:16:20 | LL | union NoDropLike { a: u8 } - | ^^^^^ + | ---------- ^^^^^ + | | + | field in this union -error: field is never read: `c` +error: field `c` is never read --> $DIR/union-fields-1.rs:21:5 | +LL | union U { + | - field in this union +... LL | c: u8, | ^^^^^ diff --git a/src/test/ui/union/union-fields-1.rs b/src/test/ui/union/union-fields-1.rs index 3d3e2355a26..cf2ef4c03d6 100644 --- a/src/test/ui/union/union-fields-1.rs +++ b/src/test/ui/union/union-fields-1.rs @@ -6,19 +6,19 @@ union U1 { a: u8, // should not be reported b: u8, // should not be reported - c: u8, //~ ERROR field is never read + c: u8, //~ ERROR field `c` is never read } union U2 { - a: u8, //~ ERROR field is never read + a: u8, //~ ERROR field `a` is never read b: u8, // should not be reported c: u8, // should not be reported } -union NoDropLike { a: u8 } //~ ERROR field is never read +union NoDropLike { a: u8 } //~ ERROR field `a` is never read union U { a: u8, // should not be reported b: u8, // should not be reported - c: u8, //~ ERROR field is never read + c: u8, //~ ERROR field `c` is never read } type A = U; diff --git a/src/test/ui/union/union-fields-1.thirunsafeck.stderr b/src/test/ui/union/union-fields-1.thirunsafeck.stderr index 9f1e2947c86..5b932b9626c 100644 --- a/src/test/ui/union/union-fields-1.thirunsafeck.stderr +++ b/src/test/ui/union/union-fields-1.thirunsafeck.stderr @@ -1,6 +1,9 @@ -error: field is never read: `c` +error: field `c` is never read --> $DIR/union-fields-1.rs:9:5 | +LL | union U1 { + | -- field in this union +... LL | c: u8, | ^^^^^ | @@ -10,21 +13,28 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: field is never read: `a` +error: field `a` is never read --> $DIR/union-fields-1.rs:12:5 | +LL | union U2 { + | -- field in this union LL | a: u8, | ^^^^^ -error: field is never read: `a` +error: field `a` is never read --> $DIR/union-fields-1.rs:16:20 | LL | union NoDropLike { a: u8 } - | ^^^^^ + | ---------- ^^^^^ + | | + | field in this union -error: field is never read: `c` +error: field `c` is never read --> $DIR/union-fields-1.rs:21:5 | +LL | union U { + | - field in this union +... LL | c: u8, | ^^^^^ diff --git a/src/test/ui/union/union-lint-dead-code.mirunsafeck.stderr b/src/test/ui/union/union-lint-dead-code.mirunsafeck.stderr index 22d4428c902..f6e515f8400 100644 --- a/src/test/ui/union/union-lint-dead-code.mirunsafeck.stderr +++ b/src/test/ui/union/union-lint-dead-code.mirunsafeck.stderr @@ -1,6 +1,9 @@ -error: field is never read: `b` +error: field `b` is never read --> $DIR/union-lint-dead-code.rs:8:5 | +LL | union Foo { + | --- field in this union +LL | x: usize, LL | b: bool, | ^^^^^^^ | diff --git a/src/test/ui/union/union-lint-dead-code.rs b/src/test/ui/union/union-lint-dead-code.rs index 64c28d72e9e..65aaf0a1d35 100644 --- a/src/test/ui/union/union-lint-dead-code.rs +++ b/src/test/ui/union/union-lint-dead-code.rs @@ -5,7 +5,7 @@ union Foo { x: usize, - b: bool, //~ ERROR: field is never read + b: bool, //~ ERROR: field `b` is never read _unused: u16, } diff --git a/src/test/ui/union/union-lint-dead-code.thirunsafeck.stderr b/src/test/ui/union/union-lint-dead-code.thirunsafeck.stderr index 22d4428c902..f6e515f8400 100644 --- a/src/test/ui/union/union-lint-dead-code.thirunsafeck.stderr +++ b/src/test/ui/union/union-lint-dead-code.thirunsafeck.stderr @@ -1,6 +1,9 @@ -error: field is never read: `b` +error: field `b` is never read --> $DIR/union-lint-dead-code.rs:8:5 | +LL | union Foo { + | --- field in this union +LL | x: usize, LL | b: bool, | ^^^^^^^ |