Auto merge of #118257 - mu001999:dead_code/trait, r=cjgillot
Make traits / trait methods detected by the dead code lint Fixes #118139 and #41883
This commit is contained in:
commit
d4f6f9ee6a
@ -4,6 +4,7 @@
|
||||
// is dead.
|
||||
|
||||
use hir::def_id::{LocalDefIdMap, LocalDefIdSet};
|
||||
use hir::ItemKind;
|
||||
use rustc_data_structures::unord::UnordSet;
|
||||
use rustc_errors::MultiSpan;
|
||||
use rustc_hir as hir;
|
||||
@ -14,7 +15,7 @@ use rustc_hir::{Node, PatKind, TyKind};
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::privacy::Level;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::ty::{self, TyCtxt, Visibility};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::lint::builtin::DEAD_CODE;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
@ -381,9 +382,46 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
|
||||
intravisit::walk_item(self, item)
|
||||
}
|
||||
hir::ItemKind::ForeignMod { .. } => {}
|
||||
hir::ItemKind::Trait(..) => {
|
||||
for impl_def_id in self.tcx.all_impls(item.owner_id.to_def_id()) {
|
||||
if let Some(local_def_id) = impl_def_id.as_local()
|
||||
&& let ItemKind::Impl(impl_ref) =
|
||||
self.tcx.hir().expect_item(local_def_id).kind
|
||||
{
|
||||
// skip items
|
||||
// mark dependent traits live
|
||||
intravisit::walk_generics(self, impl_ref.generics);
|
||||
// mark dependent parameters live
|
||||
intravisit::walk_path(self, impl_ref.of_trait.unwrap().path);
|
||||
}
|
||||
}
|
||||
|
||||
intravisit::walk_item(self, item)
|
||||
}
|
||||
_ => intravisit::walk_item(self, item),
|
||||
},
|
||||
Node::TraitItem(trait_item) => {
|
||||
// mark corresponing ImplTerm live
|
||||
let trait_item_id = trait_item.owner_id.to_def_id();
|
||||
if let Some(trait_id) = self.tcx.trait_of_item(trait_item_id) {
|
||||
// mark the trait live
|
||||
self.check_def_id(trait_id);
|
||||
|
||||
for impl_id in self.tcx.all_impls(trait_id) {
|
||||
if let Some(local_impl_id) = impl_id.as_local()
|
||||
&& let ItemKind::Impl(impl_ref) =
|
||||
self.tcx.hir().expect_item(local_impl_id).kind
|
||||
{
|
||||
// mark self_ty live
|
||||
intravisit::walk_ty(self, impl_ref.self_ty);
|
||||
if let Some(&impl_item_id) =
|
||||
self.tcx.impl_item_implementor_ids(impl_id).get(&trait_item_id)
|
||||
{
|
||||
self.check_def_id(impl_item_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
Node::ImplItem(impl_item) => {
|
||||
@ -636,10 +674,6 @@ fn check_item<'tcx>(
|
||||
}
|
||||
}
|
||||
DefKind::Impl { of_trait } => {
|
||||
if of_trait {
|
||||
worklist.push((id.owner_id.def_id, ComesFromAllowExpect::No));
|
||||
}
|
||||
|
||||
// get DefIds from another query
|
||||
let local_def_ids = tcx
|
||||
.associated_item_def_ids(id.owner_id)
|
||||
@ -648,7 +682,11 @@ fn check_item<'tcx>(
|
||||
|
||||
// And we access the Map here to get HirId from LocalDefId
|
||||
for id in local_def_ids {
|
||||
if of_trait {
|
||||
// for impl trait blocks, mark associate functions live if the trait is public
|
||||
if of_trait
|
||||
&& (!matches!(tcx.def_kind(id), DefKind::AssocFn)
|
||||
|| tcx.local_visibility(id) == Visibility::Public)
|
||||
{
|
||||
worklist.push((id, ComesFromAllowExpect::No));
|
||||
} else if let Some(comes_from_allow) = has_allow_dead_code_or_lang_attr(tcx, id) {
|
||||
worklist.push((id, comes_from_allow));
|
||||
@ -679,7 +717,7 @@ fn check_trait_item(
|
||||
use hir::TraitItemKind::{Const, Fn};
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::AssocConst | DefKind::AssocFn) {
|
||||
let trait_item = tcx.hir().trait_item(id);
|
||||
if matches!(trait_item.kind, Const(_, Some(_)) | Fn(_, hir::TraitFn::Provided(_)))
|
||||
if matches!(trait_item.kind, Const(_, Some(_)) | Fn(..))
|
||||
&& let Some(comes_from_allow) =
|
||||
has_allow_dead_code_or_lang_attr(tcx, trait_item.owner_id.def_id)
|
||||
{
|
||||
@ -948,7 +986,8 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
| DefKind::TyAlias
|
||||
| DefKind::Enum
|
||||
| DefKind::Union
|
||||
| DefKind::ForeignTy => self.warn_dead_code(def_id, "used"),
|
||||
| DefKind::ForeignTy
|
||||
| DefKind::Trait => self.warn_dead_code(def_id, "used"),
|
||||
DefKind::Struct => self.warn_dead_code(def_id, "constructed"),
|
||||
DefKind::Variant | DefKind::Field => bug!("should be handled specially"),
|
||||
_ => {}
|
||||
@ -973,18 +1012,33 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
|
||||
let module_items = tcx.hir_module_items(module);
|
||||
|
||||
for item in module_items.items() {
|
||||
if let hir::ItemKind::Impl(impl_item) = tcx.hir().item(item).kind {
|
||||
let mut dead_items = Vec::new();
|
||||
for item in impl_item.items {
|
||||
let def_id = item.id.owner_id.def_id;
|
||||
if !visitor.is_live_code(def_id) {
|
||||
let name = tcx.item_name(def_id.to_def_id());
|
||||
let level = visitor.def_lint_level(def_id);
|
||||
let def_kind = tcx.def_kind(item.owner_id);
|
||||
|
||||
dead_items.push(DeadItem { def_id, name, level })
|
||||
let mut dead_codes = Vec::new();
|
||||
// if we have diagnosed the trait, do not diagnose unused methods
|
||||
if matches!(def_kind, DefKind::Impl { .. })
|
||||
|| (def_kind == DefKind::Trait && live_symbols.contains(&item.owner_id.def_id))
|
||||
{
|
||||
for &def_id in tcx.associated_item_def_ids(item.owner_id.def_id) {
|
||||
// We have diagnosed unused methods in traits
|
||||
if matches!(def_kind, DefKind::Impl { of_trait: true })
|
||||
&& tcx.def_kind(def_id) == DefKind::AssocFn
|
||||
|| def_kind == DefKind::Trait && tcx.def_kind(def_id) != DefKind::AssocFn
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(local_def_id) = def_id.as_local()
|
||||
&& !visitor.is_live_code(local_def_id)
|
||||
{
|
||||
let name = tcx.item_name(def_id);
|
||||
let level = visitor.def_lint_level(local_def_id);
|
||||
dead_codes.push(DeadItem { def_id: local_def_id, name, level });
|
||||
}
|
||||
}
|
||||
visitor.warn_multiple(item.owner_id.def_id, "used", dead_items, ReportOn::NamedField);
|
||||
}
|
||||
if !dead_codes.is_empty() {
|
||||
visitor.warn_multiple(item.owner_id.def_id, "used", dead_codes, ReportOn::NamedField);
|
||||
}
|
||||
|
||||
if !live_symbols.contains(&item.owner_id.def_id) {
|
||||
@ -997,7 +1051,6 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let def_kind = tcx.def_kind(item.owner_id);
|
||||
if let DefKind::Struct | DefKind::Union | DefKind::Enum = def_kind {
|
||||
let adt = tcx.adt_def(item.owner_id);
|
||||
let mut dead_variants = Vec::new();
|
||||
@ -1044,8 +1097,6 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
|
||||
for foreign_item in module_items.foreign_items() {
|
||||
visitor.check_definition(foreign_item.owner_id.def_id);
|
||||
}
|
||||
|
||||
// We do not warn trait items.
|
||||
}
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
use super::*;
|
||||
|
||||
use rustc_data_structures::sync::FreezeLock;
|
||||
|
||||
fn init_source_map() -> SourceMap {
|
||||
let sm = SourceMap::new(FilePathMapping::empty());
|
||||
sm.new_source_file(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string());
|
||||
@ -263,53 +265,6 @@ fn t10() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns the span corresponding to the `n`th occurrence of `substring` in `source_text`.
|
||||
trait SourceMapExtension {
|
||||
fn span_substr(
|
||||
&self,
|
||||
file: &Lrc<SourceFile>,
|
||||
source_text: &str,
|
||||
substring: &str,
|
||||
n: usize,
|
||||
) -> Span;
|
||||
}
|
||||
|
||||
impl SourceMapExtension for SourceMap {
|
||||
fn span_substr(
|
||||
&self,
|
||||
file: &Lrc<SourceFile>,
|
||||
source_text: &str,
|
||||
substring: &str,
|
||||
n: usize,
|
||||
) -> Span {
|
||||
eprintln!(
|
||||
"span_substr(file={:?}/{:?}, substring={:?}, n={})",
|
||||
file.name, file.start_pos, substring, n
|
||||
);
|
||||
let mut i = 0;
|
||||
let mut hi = 0;
|
||||
loop {
|
||||
let offset = source_text[hi..].find(substring).unwrap_or_else(|| {
|
||||
panic!(
|
||||
"source_text `{}` does not have {} occurrences of `{}`, only {}",
|
||||
source_text, n, substring, i
|
||||
);
|
||||
});
|
||||
let lo = hi + offset;
|
||||
hi = lo + substring.len();
|
||||
if i == n {
|
||||
let span = Span::with_root_ctxt(
|
||||
BytePos(lo as u32 + file.start_pos.0),
|
||||
BytePos(hi as u32 + file.start_pos.0),
|
||||
);
|
||||
assert_eq!(&self.span_to_snippet(span).unwrap()[..], substring);
|
||||
return span;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Takes a unix-style path and returns a platform specific path.
|
||||
fn path(p: &str) -> PathBuf {
|
||||
path_str(p).into()
|
||||
|
@ -1,3 +1,4 @@
|
||||
#[allow(dead_code)]
|
||||
trait Trait {
|
||||
fn blah(&self);
|
||||
}
|
||||
|
@ -59,12 +59,14 @@ cfg_if::cfg_if! {
|
||||
|
||||
/// A trait for viewing representations from std types
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code)] // not used on all platforms
|
||||
pub trait AsInner<Inner: ?Sized> {
|
||||
fn as_inner(&self) -> &Inner;
|
||||
}
|
||||
|
||||
/// A trait for viewing representations from std types
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code)] // not used on all platforms
|
||||
pub trait AsInnerMut<Inner: ?Sized> {
|
||||
fn as_inner_mut(&mut self) -> &mut Inner;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
trait T1 {
|
||||
#[allow(dead_code)]
|
||||
fn method1(self: Box<Self>);
|
||||
}
|
||||
trait T2 {
|
||||
|
@ -2,30 +2,36 @@
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
|
||||
#[allow(dead_code)]
|
||||
fn a(&self) -> i32 {
|
||||
10
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn z(&self) -> i32 {
|
||||
11
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn y(&self) -> i32 {
|
||||
12
|
||||
}
|
||||
}
|
||||
|
||||
trait Bar: Foo {
|
||||
#[allow(dead_code)]
|
||||
fn b(&self) -> i32 {
|
||||
20
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn w(&self) -> i32 {
|
||||
21
|
||||
}
|
||||
}
|
||||
|
||||
trait Baz: Bar {
|
||||
#[allow(dead_code)]
|
||||
fn c(&self) -> i32 {
|
||||
30
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ trait Foo<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Bar {
|
||||
fn bar(&self) {
|
||||
println!("Bar!");
|
||||
|
@ -383,14 +383,17 @@ fn struct_() {
|
||||
|
||||
fn replace_vptr() {
|
||||
trait A {
|
||||
#[allow(dead_code)]
|
||||
fn foo_a(&self);
|
||||
}
|
||||
|
||||
trait B {
|
||||
#[allow(dead_code)]
|
||||
fn foo_b(&self);
|
||||
}
|
||||
|
||||
trait C: A + B {
|
||||
#[allow(dead_code)]
|
||||
fn foo_c(&self);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ use std::sync::atomic::Ordering::*;
|
||||
use std::sync::atomic::{fence, AtomicUsize};
|
||||
use std::thread::spawn;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Copy, Clone)]
|
||||
struct EvilSend<T>(pub T);
|
||||
|
||||
|
@ -13,8 +13,9 @@ use std::path::{Path, PathBuf};
|
||||
// desirable, because large numbers of files are unwieldy in general. See issue
|
||||
// #73494.
|
||||
const ENTRY_LIMIT: usize = 900;
|
||||
const ISSUES_ENTRY_LIMIT: usize = 1807;
|
||||
const ROOT_ENTRY_LIMIT: usize = 868;
|
||||
// FIXME: The following limits should be reduced eventually.
|
||||
const ISSUES_ENTRY_LIMIT: usize = 1819;
|
||||
const ROOT_ENTRY_LIMIT: usize = 870;
|
||||
|
||||
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
|
||||
"rs", // test source files
|
||||
|
@ -26,7 +26,9 @@ fn start(_: isize, _: *const *const u8) -> isize {
|
||||
//~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u32>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]
|
||||
//~ MONO_ITEM fn <Struct<u32> as Trait>::foo
|
||||
//~ MONO_ITEM fn <Struct<u32> as Trait>::bar
|
||||
let _ = &s1 as &Trait;
|
||||
let r1 = &s1 as &Trait;
|
||||
r1.foo();
|
||||
r1.bar();
|
||||
|
||||
let s1 = Struct { _a: 0u64 };
|
||||
//~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u64>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]
|
||||
|
@ -57,5 +57,8 @@ fn start(_: isize, _: *const *const u8) -> isize {
|
||||
//~ MONO_ITEM fn <u32 as SomeGenericTrait<i16>>::bar::<()>
|
||||
0u32.bar(0i16, ());
|
||||
|
||||
0i8.foo();
|
||||
0i32.foo();
|
||||
|
||||
0
|
||||
}
|
||||
|
@ -75,5 +75,7 @@ fn start(_: isize, _: *const *const u8) -> isize {
|
||||
//~ MONO_ITEM fn <u32 as Trait>::foo
|
||||
let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
|
||||
|
||||
false.foo();
|
||||
|
||||
0
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
// edition:2015
|
||||
// run-rustfix
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait T {
|
||||
fn foo(_: i32); //~ WARNING anonymous parameters are deprecated
|
||||
//~| WARNING this is accepted in the current edition
|
||||
|
@ -5,6 +5,7 @@
|
||||
// edition:2015
|
||||
// run-rustfix
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait T {
|
||||
fn foo(i32); //~ WARNING anonymous parameters are deprecated
|
||||
//~| WARNING this is accepted in the current edition
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: anonymous parameters are deprecated and will be removed in the next edition
|
||||
--> $DIR/anon-params-deprecated.rs:9:12
|
||||
--> $DIR/anon-params-deprecated.rs:10:12
|
||||
|
|
||||
LL | fn foo(i32);
|
||||
| ^^^ help: try naming the parameter or explicitly ignoring it: `_: i32`
|
||||
@ -13,7 +13,7 @@ LL | #![warn(anonymous_parameters)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: anonymous parameters are deprecated and will be removed in the next edition
|
||||
--> $DIR/anon-params-deprecated.rs:12:30
|
||||
--> $DIR/anon-params-deprecated.rs:13:30
|
||||
|
|
||||
LL | fn bar_with_default_impl(String, String) {}
|
||||
| ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`
|
||||
@ -22,7 +22,7 @@ LL | fn bar_with_default_impl(String, String) {}
|
||||
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
|
||||
|
||||
warning: anonymous parameters are deprecated and will be removed in the next edition
|
||||
--> $DIR/anon-params-deprecated.rs:12:38
|
||||
--> $DIR/anon-params-deprecated.rs:13:38
|
||||
|
|
||||
LL | fn bar_with_default_impl(String, String) {}
|
||||
| ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`
|
||||
|
@ -1,4 +1,5 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
|
||||
trait Lattice {
|
||||
const BOTTOM: Self;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ fn sub<A: Foo, B: Foo>() -> i32 {
|
||||
A::X - B::X
|
||||
}
|
||||
|
||||
trait Bar: Foo {
|
||||
trait Bar: Foo { //~ WARN trait `Bar` is never used
|
||||
const Y: i32 = Self::X;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
warning: trait `Bar` is never used
|
||||
--> $DIR/associated-const-type-parameters.rs:30:7
|
||||
|
|
||||
LL | trait Bar: Foo {
|
||||
| ^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -5,7 +5,7 @@
|
||||
use std::ops::Add;
|
||||
|
||||
trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
|
||||
trait Tr2<'a> { fn tr2(self) -> &'a Self; }
|
||||
trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
|
||||
|
||||
fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
|
||||
fn assert_static<T: 'static>(_: T) {}
|
||||
|
12
tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr
Normal file
12
tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
warning: method `tr2` is never used
|
||||
--> $DIR/dyn-impl-trait-type.rs:8:20
|
||||
|
|
||||
LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
|
||||
| --- ^^^
|
||||
| |
|
||||
| method in this trait
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -7,7 +7,7 @@
|
||||
use std::ops::Add;
|
||||
|
||||
trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
|
||||
trait Tr2<'a> { fn tr2(self) -> &'a Self; }
|
||||
trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
|
||||
|
||||
fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
|
||||
fn assert_static<T: 'static>(_: T) {}
|
||||
|
12
tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr
Normal file
12
tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
warning: method `tr2` is never used
|
||||
--> $DIR/dyn-rpit-and-let.rs:10:20
|
||||
|
|
||||
LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
|
||||
| --- ^^^
|
||||
| |
|
||||
| method in this trait
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -5,7 +5,7 @@
|
||||
use std::ops::Add;
|
||||
|
||||
trait Tr1 { type As1; fn mk(self) -> Self::As1; }
|
||||
trait Tr2<'a> { fn tr2(self) -> &'a Self; }
|
||||
trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
|
||||
|
||||
fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
|
||||
fn assert_static<T: 'static>(_: T) {}
|
||||
|
12
tests/ui/associated-type-bounds/rpit.stderr
Normal file
12
tests/ui/associated-type-bounds/rpit.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
warning: method `tr2` is never used
|
||||
--> $DIR/rpit.rs:8:20
|
||||
|
|
||||
LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
|
||||
| --- ^^^
|
||||
| |
|
||||
| method in this trait
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -1,4 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
trait O {
|
||||
type M;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
trait O {
|
||||
type M;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:12:21
|
||||
--> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:13:21
|
||||
|
|
||||
LL | const N: C::M = 4u8;
|
||||
| ^^^ expected associated type, found `u8`
|
||||
|
@ -1,5 +1,6 @@
|
||||
// run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![feature(associated_type_bounds)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
trait Get {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
trait Get {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0277]: the trait bound `Self: Get` is not satisfied
|
||||
--> $DIR/associated-types-for-unimpl-trait.rs:10:40
|
||||
--> $DIR/associated-types-for-unimpl-trait.rs:11:40
|
||||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// Test the case where we resolve `C::Result` and the trait bound
|
||||
// itself includes a `Self::Item` shorthand.
|
||||
//
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use std::vec;
|
||||
|
||||
trait IntoIteratorX {
|
||||
trait IntoIteratorX { //~ WARN trait `IntoIteratorX` is never used
|
||||
type Item;
|
||||
type IntoIter: Iterator<Item=Self::Item>;
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
warning: trait `IntoIteratorX` is never used
|
||||
--> $DIR/associated-types-issue-20220.rs:7:7
|
||||
|
|
||||
LL | trait IntoIteratorX {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// Test that we are able to have an impl that defines an associated type
|
||||
// before the actual trait.
|
||||
|
||||
|
@ -13,7 +13,7 @@ impl<'a> Bound for &'a i32 {}
|
||||
trait IntoIterator {
|
||||
type Iter: Iterator;
|
||||
|
||||
fn into_iter(self) -> Self::Iter;
|
||||
fn into_iter(self) -> Self::Iter; //~ WARN method `into_iter` is never used
|
||||
}
|
||||
|
||||
impl<'a, T> IntoIterator for &'a [T; 3] {
|
||||
|
@ -0,0 +1,13 @@
|
||||
warning: method `into_iter` is never used
|
||||
--> $DIR/associated-types-nested-projections.rs:16:8
|
||||
|
|
||||
LL | trait IntoIterator {
|
||||
| ------------ method in this trait
|
||||
...
|
||||
LL | fn into_iter(self) -> Self::Iter;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
#![allow(unused_variables)]
|
||||
// Test that we normalize associated types that appear in bounds; if
|
||||
// we didn't, the call to `self.split2()` fails to type check.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
#![allow(unused_variables)]
|
||||
// Test that we normalize associated types that appear in bounds; if
|
||||
// we didn't, the call to `self.split2()` fails to type check.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
#![allow(unused_variables)]
|
||||
// Test that we correctly handle projection bounds appearing in the
|
||||
// supertrait list (and in conjunction with overloaded operators). In
|
||||
|
@ -6,7 +6,7 @@ trait Int
|
||||
{
|
||||
type T;
|
||||
|
||||
fn dummy(&self) { }
|
||||
fn dummy(&self) { } //~ WARN method `dummy` is never used
|
||||
}
|
||||
|
||||
trait NonZero
|
||||
|
@ -0,0 +1,13 @@
|
||||
warning: method `dummy` is never used
|
||||
--> $DIR/associated-types-projection-from-known-type-in-impl.rs:9:8
|
||||
|
|
||||
LL | trait Int
|
||||
| --- method in this trait
|
||||
...
|
||||
LL | fn dummy(&self) { }
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Check that we get an error when you use `<Self as Get>::Value` in
|
||||
// the trait definition even if there is no default method.
|
||||
|
||||
#![allow(dead_code)]
|
||||
trait Get {
|
||||
type Value;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Check that we get an error when you use `<Self as Get>::Value` in
|
||||
// the trait definition even if there is no default method.
|
||||
|
||||
#![allow(dead_code)]
|
||||
trait Get {
|
||||
type Value;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0277]: the trait bound `Self: Get` is not satisfied
|
||||
--> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:10:40
|
||||
--> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:11:40
|
||||
|
|
||||
LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// Check that we do not get an error when you use `<Self as Get>::Value` in
|
||||
// the trait definition if there is no default method and for every impl,
|
||||
// `Self` does implement `Get`.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
trait Foo<T> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
trait Get<T> {
|
||||
|
@ -1,9 +1,11 @@
|
||||
// run-rustfix
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Baz {}
|
||||
impl Baz for () {}
|
||||
impl<T> Baz for (T,) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Fiz {}
|
||||
impl Fiz for bool {}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
// run-rustfix
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Baz {}
|
||||
impl Baz for () {}
|
||||
impl<T> Baz for (T,) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Fiz {}
|
||||
impl Fiz for bool {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
|
||||
--> $DIR/impl-wf-cycle-5.rs:20:1
|
||||
--> $DIR/impl-wf-cycle-5.rs:22:1
|
||||
|
|
||||
LL | / impl<T> Grault for (T,)
|
||||
LL | |
|
||||
@ -12,7 +12,7 @@ LL | type A = ();
|
||||
| ------ associated type `<(T,) as Grault>::A` is specified here
|
||||
|
|
||||
note: required for `(T,)` to implement `Grault`
|
||||
--> $DIR/impl-wf-cycle-5.rs:20:9
|
||||
--> $DIR/impl-wf-cycle-5.rs:22:9
|
||||
|
|
||||
LL | impl<T> Grault for (T,)
|
||||
| ^^^^^^ ^^^^
|
||||
|
@ -1,9 +1,11 @@
|
||||
// run-rustfix
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Baz {}
|
||||
impl Baz for () {}
|
||||
impl<T> Baz for (T,) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Fiz {}
|
||||
impl Fiz for bool {}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
// run-rustfix
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Baz {}
|
||||
impl Baz for () {}
|
||||
impl<T> Baz for (T,) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
trait Fiz {}
|
||||
impl Fiz for bool {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
|
||||
--> $DIR/impl-wf-cycle-6.rs:20:1
|
||||
--> $DIR/impl-wf-cycle-6.rs:22:1
|
||||
|
|
||||
LL | / impl<T: Grault> Grault for (T,)
|
||||
LL | |
|
||||
@ -11,7 +11,7 @@ LL | type A = ();
|
||||
| ------ associated type `<(T,) as Grault>::A` is specified here
|
||||
|
|
||||
note: required for `(T,)` to implement `Grault`
|
||||
--> $DIR/impl-wf-cycle-6.rs:20:17
|
||||
--> $DIR/impl-wf-cycle-6.rs:22:17
|
||||
|
|
||||
LL | impl<T: Grault> Grault for (T,)
|
||||
| ^^^^^^ ^^^^
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![feature(auto_traits)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
// run-rustfix
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![feature(auto_traits)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
// run-rustfix
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0567]: auto traits cannot have generic parameters
|
||||
--> $DIR/auto-trait-validation.rs:5:19
|
||||
--> $DIR/auto-trait-validation.rs:6:19
|
||||
|
|
||||
LL | auto trait Generic<T> {}
|
||||
| -------^^^ help: remove the parameters
|
||||
@ -7,7 +7,7 @@ LL | auto trait Generic<T> {}
|
||||
| auto trait cannot have generic parameters
|
||||
|
||||
error[E0568]: auto traits cannot have super traits or lifetime bounds
|
||||
--> $DIR/auto-trait-validation.rs:7:17
|
||||
--> $DIR/auto-trait-validation.rs:8:17
|
||||
|
|
||||
LL | auto trait Bound : Copy {}
|
||||
| -----^^^^^^^ help: remove the super traits or lifetime bounds
|
||||
@ -15,7 +15,7 @@ LL | auto trait Bound : Copy {}
|
||||
| auto traits cannot have super traits or lifetime bounds
|
||||
|
||||
error[E0568]: auto traits cannot have super traits or lifetime bounds
|
||||
--> $DIR/auto-trait-validation.rs:9:25
|
||||
--> $DIR/auto-trait-validation.rs:10:25
|
||||
|
|
||||
LL | auto trait LifetimeBound : 'static {}
|
||||
| -------------^^^^^^^^^^ help: remove the super traits or lifetime bounds
|
||||
@ -23,7 +23,7 @@ LL | auto trait LifetimeBound : 'static {}
|
||||
| auto traits cannot have super traits or lifetime bounds
|
||||
|
||||
error[E0380]: auto traits cannot have associated items
|
||||
--> $DIR/auto-trait-validation.rs:11:25
|
||||
--> $DIR/auto-trait-validation.rs:12:25
|
||||
|
|
||||
LL | auto trait MyTrait { fn foo() {} }
|
||||
| ------- ---^^^-----
|
||||
|
@ -19,8 +19,8 @@ fn take_auto_unsafe<T: AutoUnsafe>(_: T) {}
|
||||
|
||||
fn main() {
|
||||
// Parse inside functions.
|
||||
auto trait AutoInner {}
|
||||
unsafe auto trait AutoUnsafeInner {}
|
||||
auto trait AutoInner {} //~ WARN trait `AutoInner` is never used
|
||||
unsafe auto trait AutoUnsafeInner {} //~ WARN trait `AutoUnsafeInner` is never used
|
||||
|
||||
take_auto(0);
|
||||
take_auto(AutoBool(true));
|
||||
|
16
tests/ui/auto-traits/auto-traits.stderr
Normal file
16
tests/ui/auto-traits/auto-traits.stderr
Normal file
@ -0,0 +1,16 @@
|
||||
warning: trait `AutoInner` is never used
|
||||
--> $DIR/auto-traits.rs:22:16
|
||||
|
|
||||
LL | auto trait AutoInner {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: trait `AutoUnsafeInner` is never used
|
||||
--> $DIR/auto-traits.rs:23:23
|
||||
|
|
||||
LL | unsafe auto trait AutoUnsafeInner {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// Simple test case of implementing a trait with super-builtin-kinds.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// Tests correct implementation of traits with super-builtin-kinds
|
||||
// using a bounded type parameter.
|
||||
|
||||
|
@ -8,7 +8,7 @@ trait Foo<T> {
|
||||
fn foo(&self, _: T) -> u32 { 42 }
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
trait Bar { //~ WARN trait `Bar` is never used
|
||||
fn bar(&self) { println!("Bar!"); }
|
||||
}
|
||||
|
||||
|
10
tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
Normal file
10
tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
warning: trait `Bar` is never used
|
||||
--> $DIR/cast-rfc0401-vtable-kinds.rs:11:7
|
||||
|
|
||||
LL | trait Bar {
|
||||
| ^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -3,7 +3,7 @@
|
||||
#![feature(ptr_metadata)]
|
||||
|
||||
trait Foo {
|
||||
fn foo(&self) {}
|
||||
fn foo(&self) {} //~ WARN method `foo` is never used
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
12
tests/ui/cast/fat-ptr-cast-rpass.stderr
Normal file
12
tests/ui/cast/fat-ptr-cast-rpass.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
warning: method `foo` is never used
|
||||
--> $DIR/fat-ptr-cast-rpass.rs:6:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- method in this trait
|
||||
LL | fn foo(&self) {}
|
||||
| ^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -19,6 +19,6 @@ impl<T> Test<T> {
|
||||
fn send(&self, _: T) {}
|
||||
}
|
||||
|
||||
trait Foo { fn dummy(&self) { }}
|
||||
trait Foo { fn dummy(&self) { }} //~ WARN method `dummy` is never used
|
||||
struct Output(#[allow(dead_code)] isize);
|
||||
impl Foo for Output {}
|
||||
|
12
tests/ui/coercion/issue-14589.stderr
Normal file
12
tests/ui/coercion/issue-14589.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
warning: method `dummy` is never used
|
||||
--> $DIR/issue-14589.rs:22:16
|
||||
|
|
||||
LL | trait Foo { fn dummy(&self) { }}
|
||||
| --- ^^^^^
|
||||
| |
|
||||
| method in this trait
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
#![allow(unused_imports)]
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
trait Bar<const N: usize> {}
|
||||
|
||||
trait Foo<const N: usize> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Checks that `impl Trait<{anon_const}> for Type` evaluates successfully.
|
||||
// run-pass
|
||||
// check-pass
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(generic_const_exprs))]
|
||||
|
@ -4,7 +4,7 @@ trait Foo<const N: usize> {
|
||||
fn myfun(&self) -> usize;
|
||||
}
|
||||
trait Bar<const N: usize> : Foo<N> {}
|
||||
trait Baz: Foo<3> {}
|
||||
trait Baz: Foo<3> {} //~ WARN trait `Baz` is never used
|
||||
|
||||
struct FooType<const N: usize>;
|
||||
struct BarType<const N: usize>;
|
||||
@ -23,10 +23,10 @@ impl Foo<3> for BazType {
|
||||
impl Baz for BazType {}
|
||||
|
||||
trait Foz {}
|
||||
trait Boz: Foo<3> + Foz {}
|
||||
trait Boz: Foo<3> + Foz {} //~ WARN trait `Boz` is never used
|
||||
trait Bok<const N: usize>: Foo<N> + Foz {}
|
||||
|
||||
struct FozType;
|
||||
struct FozType; //~ WARN struct `FozType` is never constructed
|
||||
struct BozType;
|
||||
struct BokType<const N: usize>;
|
||||
|
||||
|
22
tests/ui/const-generics/dyn-supertraits.stderr
Normal file
22
tests/ui/const-generics/dyn-supertraits.stderr
Normal file
@ -0,0 +1,22 @@
|
||||
warning: trait `Baz` is never used
|
||||
--> $DIR/dyn-supertraits.rs:7:7
|
||||
|
|
||||
LL | trait Baz: Foo<3> {}
|
||||
| ^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: trait `Boz` is never used
|
||||
--> $DIR/dyn-supertraits.rs:26:7
|
||||
|
|
||||
LL | trait Boz: Foo<3> + Foz {}
|
||||
| ^^^
|
||||
|
||||
warning: struct `FozType` is never constructed
|
||||
--> $DIR/dyn-supertraits.rs:29:8
|
||||
|
|
||||
LL | struct FozType;
|
||||
| ^^^^^^^
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-pass
|
||||
trait Bar<T> {}
|
||||
trait Bar<T> {} //~ WARN trait `Bar` is never used
|
||||
impl<T> Bar<T> for [u8; 7] {}
|
||||
|
||||
struct Foo<const N: usize> {}
|
||||
|
10
tests/ui/const-generics/issues/issue-69654-run-pass.stderr
Normal file
10
tests/ui/const-generics/issues/issue-69654-run-pass.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
warning: trait `Bar` is never used
|
||||
--> $DIR/issue-69654-run-pass.rs:2:7
|
||||
|
|
||||
LL | trait Bar<T> {}
|
||||
| ^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![allow(unused_imports)]
|
||||
|
||||
mod foo {
|
||||
pub trait Value {
|
||||
pub trait Value { //~ WARN trait `Value` is never used
|
||||
fn value(&self) -> usize;
|
||||
}
|
||||
}
|
||||
|
10
tests/ui/consts/const-block-item.stderr
Normal file
10
tests/ui/consts/const-block-item.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
warning: trait `Value` is never used
|
||||
--> $DIR/const-block-item.rs:5:15
|
||||
|
|
||||
LL | pub trait Value {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
#![deny(unused)]
|
||||
|
||||
trait Trt {}
|
||||
pub trait Trt {}
|
||||
pub struct Str {}
|
||||
impl Trt for Str {}
|
||||
|
||||
macro_rules! check_impl {
|
||||
($struct:ident,$trait:ident) => {
|
||||
($struct:ident, $trait:ident) => {
|
||||
const _ : () = {
|
||||
use std::marker::PhantomData;
|
||||
struct ImplementsTrait<T: $trait>(PhantomData<T>);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
trait Foo {
|
||||
|
@ -14,14 +14,14 @@ reuse to_reuse::foo {{
|
||||
x + self
|
||||
}}
|
||||
|
||||
trait Trait {
|
||||
trait Trait { //~ WARN trait `Trait` is never used
|
||||
fn bar(&self, x: i32) -> i32 { x }
|
||||
}
|
||||
|
||||
struct F;
|
||||
struct F; //~ WARN struct `F` is never constructed
|
||||
impl Trait for F {}
|
||||
|
||||
struct S(F);
|
||||
struct S(F); //~ WARN struct `S` is never constructed
|
||||
impl Trait for S {
|
||||
reuse <F as Trait>::bar {
|
||||
#[allow(unused_imports)]
|
||||
|
@ -7,5 +7,25 @@ LL | #![feature(fn_delegation)]
|
||||
= note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
warning: trait `Trait` is never used
|
||||
--> $DIR/target-expr-pass.rs:17:7
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: struct `F` is never constructed
|
||||
--> $DIR/target-expr-pass.rs:21:8
|
||||
|
|
||||
LL | struct F;
|
||||
| ^
|
||||
|
||||
warning: struct `S` is never constructed
|
||||
--> $DIR/target-expr-pass.rs:24:8
|
||||
|
|
||||
LL | struct S(F);
|
||||
| ^
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// run-pass
|
||||
// check-pass
|
||||
#[derive(Copy, Clone)]
|
||||
struct Test;
|
||||
|
||||
|
@ -12,7 +12,7 @@ struct Cat {
|
||||
}
|
||||
|
||||
trait Dummy {
|
||||
fn get(&self) -> usize;
|
||||
fn get(&self) -> usize; //~ WARN method `get` is never used
|
||||
}
|
||||
|
||||
impl Dummy for Cat {
|
||||
|
12
tests/ui/drop/drop-struct-as-object.stderr
Normal file
12
tests/ui/drop/drop-struct-as-object.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
warning: method `get` is never used
|
||||
--> $DIR/drop-struct-as-object.rs:15:8
|
||||
|
|
||||
LL | trait Dummy {
|
||||
| ----- method in this trait
|
||||
LL | fn get(&self) -> usize;
|
||||
| ^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -5,7 +5,7 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
struct S;
|
||||
trait T { fn dummy(&self) { } }
|
||||
trait T { fn dummy(&self) { } } //~ WARN method `dummy` is never used
|
||||
impl T for S {}
|
||||
|
||||
pub fn main() {
|
||||
|
12
tests/ui/dynamically-sized-types/dst-coercions.stderr
Normal file
12
tests/ui/dynamically-sized-types/dst-coercions.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
warning: method `dummy` is never used
|
||||
--> $DIR/dst-coercions.rs:8:14
|
||||
|
|
||||
LL | trait T { fn dummy(&self) { } }
|
||||
| - ^^^^^
|
||||
| |
|
||||
| method in this trait
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -3,7 +3,7 @@
|
||||
// no type parameters at all
|
||||
|
||||
struct S<>;
|
||||
trait T<> {}
|
||||
trait T<> {} //~ WARN trait `T` is never used
|
||||
enum E<> { V }
|
||||
impl<> T<> for S<> {}
|
||||
impl T for E {}
|
||||
|
10
tests/ui/empty-type-parameter-list.stderr
Normal file
10
tests/ui/empty-type-parameter-list.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
warning: trait `T` is never used
|
||||
--> $DIR/empty-type-parameter-list.rs:6:7
|
||||
|
|
||||
LL | trait T<> {}
|
||||
| ^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -1,5 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dropping_references)]
|
||||
|
||||
struct Foo {
|
||||
|
@ -1,5 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dropping_references)]
|
||||
|
||||
struct Foo {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0040]: explicit use of destructor method
|
||||
--> $DIR/explicit-call-to-supertrait-dtor.rs:22:14
|
||||
--> $DIR/explicit-call-to-supertrait-dtor.rs:23:14
|
||||
|
|
||||
LL | self.drop();
|
||||
| ^^^^ explicit destructor calls not allowed
|
||||
|
2
tests/ui/extern/no-mangle-associated-fn.rs
vendored
2
tests/ui/extern/no-mangle-associated-fn.rs
vendored
@ -12,7 +12,7 @@ impl Foo {
|
||||
}
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
trait Bar { //~ WARN trait `Bar` is never used
|
||||
fn qux() -> u8;
|
||||
}
|
||||
|
||||
|
10
tests/ui/extern/no-mangle-associated-fn.stderr
vendored
Normal file
10
tests/ui/extern/no-mangle-associated-fn.stderr
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
warning: trait `Bar` is never used
|
||||
--> $DIR/no-mangle-associated-fn.rs:15:7
|
||||
|
|
||||
LL | trait Bar {
|
||||
| ^^^
|
||||
|
|
||||
= note: `#[warn(dead_code)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -1,4 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
|
||||
trait GatTrait {
|
||||
type Gat<'a> where Self: 'a;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(dead_code)]
|
||||
|
||||
trait GatTrait {
|
||||
type Gat<'a> where Self: 'a;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-88360.rs:15:9
|
||||
--> $DIR/issue-88360.rs:16:9
|
||||
|
|
||||
LL | trait SuperTrait<T>
|
||||
| - found this type parameter
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![deny(no_mangle_generic_items)]
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![deny(no_mangle_generic_items)]
|
||||
|
||||
#[no_mangle]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user