Update tests

This commit is contained in:
r0cky 2024-02-07 10:42:01 +08:00
parent 40878ca6ea
commit c7519d42c2
276 changed files with 1049 additions and 234 deletions

View File

@ -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()

View File

@ -1,3 +1,4 @@
#[allow(dead_code)]
trait Trait {
fn blah(&self);
}

View File

@ -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;
}

View File

@ -1,4 +1,5 @@
trait T1 {
#[allow(dead_code)]
fn method1(self: Box<Self>);
}
trait T2 {

View File

@ -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
}

View File

@ -9,6 +9,7 @@ trait Foo<T> {
}
}
#[allow(dead_code)]
trait Bar {
fn bar(&self) {
println!("Bar!");

View File

@ -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);
}

View File

@ -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);

View File

@ -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

View File

@ -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]

View File

@ -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
}

View File

@ -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
}

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![feature(rustc_private)]

View File

@ -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

View File

@ -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

View File

@ -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`

View File

@ -1,4 +1,5 @@
// run-pass
// check-pass
trait Lattice {
const BOTTOM: Self;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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) {}

View 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

View File

@ -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) {}

View 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

View File

@ -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) {}

View 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

View File

@ -1,4 +1,5 @@
// run-rustfix
#![allow(dead_code)]
trait O {
type M;
}

View File

@ -1,4 +1,5 @@
// run-rustfix
#![allow(dead_code)]
trait O {
type M;
}

View File

@ -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`

View File

@ -1,5 +1,6 @@
// run-pass
#![allow(dead_code)]
#![feature(associated_type_bounds)]
#![feature(type_alias_impl_trait)]

View File

@ -1,4 +1,5 @@
// run-rustfix
#![allow(dead_code)]
#![allow(unused_variables)]
trait Get {

View File

@ -1,4 +1,5 @@
// run-rustfix
#![allow(dead_code)]
#![allow(unused_variables)]
trait Get {

View File

@ -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`

View File

@ -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.
//

View File

@ -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>;

View File

@ -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

View File

@ -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.

View File

@ -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] {

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -6,7 +6,7 @@ trait Int
{
type T;
fn dummy(&self) { }
fn dummy(&self) { } //~ WARN method `dummy` is never used
}
trait NonZero

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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`

View File

@ -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`.

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
// pretty-expanded FIXME #23616
trait Foo<T> {

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
// pretty-expanded FIXME #23616
trait Get<T> {

View File

@ -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 {}

View File

@ -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 {}

View File

@ -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,)
| ^^^^^^ ^^^^

View File

@ -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 {}

View File

@ -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 {}

View File

@ -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,)
| ^^^^^^ ^^^^

View File

@ -1,4 +1,5 @@
#![feature(auto_traits)]
#![allow(dead_code)]
// run-rustfix

View File

@ -1,4 +1,5 @@
#![feature(auto_traits)]
#![allow(dead_code)]
// run-rustfix

View File

@ -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() {} }
| ------- ---^^^-----

View File

@ -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));

View 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

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![allow(unused_imports)]

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
// Simple test case of implementing a trait with super-builtin-kinds.
// pretty-expanded FIXME #23616

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
// Tests correct implementation of traits with super-builtin-kinds
// using a bounded type parameter.

View File

@ -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!"); }
}

View 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

View File

@ -3,7 +3,7 @@
#![feature(ptr_metadata)]
trait Foo {
fn foo(&self) {}
fn foo(&self) {} //~ WARN method `foo` is never used
}
struct Bar;

View 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

View File

@ -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 {}

View 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

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![allow(unused_imports)]
// pretty-expanded FIXME #23616

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
trait Bar<const N: usize> {}
trait Foo<const N: usize> {

View File

@ -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))]

View File

@ -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>;

View 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

View File

@ -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> {}

View 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

View File

@ -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;
}
}

View 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

View File

@ -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>);

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
// pretty-expanded FIXME #23616
trait Foo {

View File

@ -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)]

View File

@ -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

View File

@ -1,4 +1,4 @@
// run-pass
// check-pass
#[derive(Copy, Clone)]
struct Test;

View File

@ -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 {

View 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

View File

@ -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() {

View 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

View File

@ -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 {}

View 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

View File

@ -1,5 +1,6 @@
// run-rustfix
#![allow(dead_code)]
#![allow(dropping_references)]
struct Foo {

View File

@ -1,5 +1,6 @@
// run-rustfix
#![allow(dead_code)]
#![allow(dropping_references)]
struct Foo {

View File

@ -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

View File

@ -12,7 +12,7 @@ impl Foo {
}
}
trait Bar {
trait Bar { //~ WARN trait `Bar` is never used
fn qux() -> u8;
}

View 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

View File

@ -1,4 +1,5 @@
// run-rustfix
#![allow(dead_code)]
trait GatTrait {
type Gat<'a> where Self: 'a;

View File

@ -1,4 +1,5 @@
// run-rustfix
#![allow(dead_code)]
trait GatTrait {
type Gat<'a> where Self: 'a;

View File

@ -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

View File

@ -1,5 +1,5 @@
// run-rustfix
#![allow(dead_code)]
#![deny(no_mangle_generic_items)]

View File

@ -1,5 +1,5 @@
// run-rustfix
#![allow(dead_code)]
#![deny(no_mangle_generic_items)]
#[no_mangle]

View File

@ -3,7 +3,7 @@
struct State;
type Error = ();
trait Bind<F> {
trait Bind<F> { //~ WARN trait `Bind` is never used
type Output;
fn bind(self, f: F) -> Self::Output;
}

Some files were not shown because too many files have changed in this diff Show More