Skip to content

Commit e482d0b

Browse files
committed
Add and bless tests
1 parent 73b0eb4 commit e482d0b

34 files changed

+118
-77
lines changed

tests/ui/associated-type-bounds/union-bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
trait Tr1: Copy { type As1: Copy; }
66
trait Tr2: Copy { type As2: Copy; }
7-
trait Tr3: Copy { type As3: Copy; }
7+
trait Tr3: Copy { #[allow(dead_code)] type As3: Copy; }
88
trait Tr4<'a>: Copy { type As4: Copy; }
99
trait Tr5: Copy { type As5: Copy; }
1010

tests/ui/associated-types/impl-wf-cycle-5.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Fiz for bool {}
1111

1212
trait Grault {
1313
type A;
14+
#[allow(dead_code)]
1415
type B;
1516
}
1617

tests/ui/associated-types/impl-wf-cycle-5.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Fiz for bool {}
1111

1212
trait Grault {
1313
type A;
14+
#[allow(dead_code)]
1415
type B;
1516
}
1617

tests/ui/associated-types/impl-wf-cycle-5.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
2-
--> $DIR/impl-wf-cycle-5.rs:22:1
2+
--> $DIR/impl-wf-cycle-5.rs:23:1
33
|
44
LL | / impl<T> Grault for (T,)
55
LL | |
@@ -12,7 +12,7 @@ LL | type A = ();
1212
| ------ associated type `<(T,) as Grault>::A` is specified here
1313
|
1414
note: required for `(T,)` to implement `Grault`
15-
--> $DIR/impl-wf-cycle-5.rs:22:9
15+
--> $DIR/impl-wf-cycle-5.rs:23:9
1616
|
1717
LL | impl<T> Grault for (T,)
1818
| ^^^^^^ ^^^^

tests/ui/associated-types/impl-wf-cycle-6.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Fiz for bool {}
1111

1212
trait Grault {
1313
type A;
14+
#[allow(dead_code)]
1415
type B;
1516
}
1617

tests/ui/associated-types/impl-wf-cycle-6.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Fiz for bool {}
1111

1212
trait Grault {
1313
type A;
14+
#[allow(dead_code)]
1415
type B;
1516
}
1617

tests/ui/associated-types/impl-wf-cycle-6.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
2-
--> $DIR/impl-wf-cycle-6.rs:22:1
2+
--> $DIR/impl-wf-cycle-6.rs:23:1
33
|
44
LL | / impl<T: Grault> Grault for (T,)
55
LL | |
@@ -11,7 +11,7 @@ LL | type A = ();
1111
| ------ associated type `<(T,) as Grault>::A` is specified here
1212
|
1313
note: required for `(T,)` to implement `Grault`
14-
--> $DIR/impl-wf-cycle-6.rs:22:17
14+
--> $DIR/impl-wf-cycle-6.rs:23:17
1515
|
1616
LL | impl<T: Grault> Grault for (T,)
1717
| ^^^^^^ ^^^^

tests/ui/const-generics/cross_crate_complex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async fn foo() {
1111
async_in_foo(async_out_foo::<4>().await).await;
1212
}
1313

14-
struct Faz<const N: usize>;
14+
struct Faz<const N: usize>; //~ WARN struct `Faz` is never constructed
1515

1616
impl<const N: usize> Foo<N> for Faz<N> {}
1717
impl<const N: usize> Bar<N> for Faz<N> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: struct `Faz` is never constructed
2+
--> $DIR/cross_crate_complex.rs:14:8
3+
|
4+
LL | struct Faz<const N: usize>;
5+
| ^^^
6+
|
7+
= note: `#[warn(dead_code)]` on by default
8+
9+
warning: 1 warning emitted
10+

tests/ui/const-generics/issues/issue-86535-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub trait Foo {
99
[(); Self::ASSOC_C]:;
1010
}
1111

12-
struct Bar<const N: &'static ()>;
12+
struct Bar<const N: &'static ()>; //~ WARN struct `Bar` is never constructed
1313
impl<const N: &'static ()> Foo for Bar<N> {
1414
const ASSOC_C: usize = 3;
1515

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: struct `Bar` is never constructed
2+
--> $DIR/issue-86535-2.rs:12:8
3+
|
4+
LL | struct Bar<const N: &'static ()>;
5+
| ^^^
6+
|
7+
= note: `#[warn(dead_code)]` on by default
8+
9+
warning: 1 warning emitted
10+

tests/ui/const-generics/issues/issue-86535.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
33
#![allow(incomplete_features, unused_variables)]
44

5-
struct F<const S: &'static str>;
5+
struct F<const S: &'static str>; //~ WARN struct `F` is never constructed
66
impl<const S: &'static str> X for F<{ S }> {
77
const W: usize = 3;
88

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: struct `F` is never constructed
2+
--> $DIR/issue-86535.rs:5:8
3+
|
4+
LL | struct F<const S: &'static str>;
5+
| ^
6+
|
7+
= note: `#[warn(dead_code)]` on by default
8+
9+
warning: 1 warning emitted
10+

tests/ui/deriving/deriving-in-macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ macro_rules! define_vec {
55
() => (
66
mod foo {
77
#[derive(PartialEq)]
8-
pub struct bar;
8+
pub struct bar; //~ WARN struct `bar` is never constructed
99
}
1010
)
1111
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: struct `bar` is never constructed
2+
--> $DIR/deriving-in-macro.rs:8:24
3+
|
4+
LL | pub struct bar;
5+
| ^^^
6+
...
7+
LL | define_vec![];
8+
| ------------- in this macro invocation
9+
|
10+
= note: `#[warn(dead_code)]` on by default
11+
= note: this warning originates in the macro `define_vec` (in Nightly builds, run with -Z macro-backtrace for more info)
12+
13+
warning: 1 warning emitted
14+

tests/ui/generic-associated-types/collections.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ trait Collection<T> {
1010
type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter, Self: 'iter;
1111
type Family: CollectionFamily;
1212
// Test associated type defaults with parameters
13+
#[allow(dead_code)]
1314
type Sibling<U>: Collection<U> =
1415
<<Self as Collection<T>>::Family as CollectionFamily>::Member<U>;
1516

tests/ui/generic-associated-types/missing-bounds.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ run-rustfix
22

3+
#![allow(dead_code)]
4+
35
use std::ops::Add;
46

57
struct A<B>(B);

tests/ui/generic-associated-types/missing-bounds.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ run-rustfix
22

3+
#![allow(dead_code)]
4+
35
use std::ops::Add;
46

57
struct A<B>(B);

tests/ui/generic-associated-types/missing-bounds.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: equality constraints are not yet supported in `where` clauses
2-
--> $DIR/missing-bounds.rs:37:33
2+
--> $DIR/missing-bounds.rs:39:33
33
|
44
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
55
| ^^^^^^^^^^^^^^^^^^^^^^ not supported
@@ -12,7 +12,7 @@ LL + impl<B: Add> Add for E<B> where B: Add<Output = B> {
1212
|
1313

1414
error[E0308]: mismatched types
15-
--> $DIR/missing-bounds.rs:11:11
15+
--> $DIR/missing-bounds.rs:13:11
1616
|
1717
LL | impl<B> Add for A<B> where B: Add {
1818
| - expected this type parameter
@@ -25,14 +25,14 @@ LL | A(self.0 + rhs.0)
2525
= note: expected type parameter `B`
2626
found associated type `<B as Add>::Output`
2727
help: the type constructed contains `<B as Add>::Output` due to the type of the argument passed
28-
--> $DIR/missing-bounds.rs:11:9
28+
--> $DIR/missing-bounds.rs:13:9
2929
|
3030
LL | A(self.0 + rhs.0)
3131
| ^^--------------^
3232
| |
3333
| this argument influences the type of `A`
3434
note: tuple struct defined here
35-
--> $DIR/missing-bounds.rs:5:8
35+
--> $DIR/missing-bounds.rs:7:8
3636
|
3737
LL | struct A<B>(B);
3838
| ^
@@ -42,7 +42,7 @@ LL | impl<B> Add for A<B> where B: Add<Output = B> {
4242
| ++++++++++++
4343

4444
error[E0308]: mismatched types
45-
--> $DIR/missing-bounds.rs:21:14
45+
--> $DIR/missing-bounds.rs:23:14
4646
|
4747
LL | impl<B: Add> Add for C<B> {
4848
| - expected this type parameter
@@ -55,7 +55,7 @@ LL | Self(self.0 + rhs.0)
5555
= note: expected type parameter `B`
5656
found associated type `<B as Add>::Output`
5757
note: tuple struct defined here
58-
--> $DIR/missing-bounds.rs:15:8
58+
--> $DIR/missing-bounds.rs:17:8
5959
|
6060
LL | struct C<B>(B);
6161
| ^
@@ -65,7 +65,7 @@ LL | impl<B: Add<Output = B>> Add for C<B> {
6565
| ++++++++++++
6666

6767
error[E0369]: cannot add `B` to `B`
68-
--> $DIR/missing-bounds.rs:31:21
68+
--> $DIR/missing-bounds.rs:33:21
6969
|
7070
LL | Self(self.0 + rhs.0)
7171
| ------ ^ ----- B
@@ -78,7 +78,7 @@ LL | impl<B: std::ops::Add<Output = B>> Add for D<B> {
7878
| +++++++++++++++++++++++++++
7979

8080
error[E0308]: mismatched types
81-
--> $DIR/missing-bounds.rs:42:14
81+
--> $DIR/missing-bounds.rs:44:14
8282
|
8383
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
8484
| - expected this type parameter
@@ -91,7 +91,7 @@ LL | Self(self.0 + rhs.0)
9191
= note: expected type parameter `B`
9292
found associated type `<B as Add>::Output`
9393
note: tuple struct defined here
94-
--> $DIR/missing-bounds.rs:35:8
94+
--> $DIR/missing-bounds.rs:37:8
9595
|
9696
LL | struct E<B>(B);
9797
| ^

tests/ui/impl-trait/extra-impl-in-trait-impl.fixed

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ run-rustfix
22

3+
#![allow(dead_code)]
4+
35
struct S<T>(T);
46
struct S2;
57

tests/ui/impl-trait/extra-impl-in-trait-impl.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ run-rustfix
22

3+
#![allow(dead_code)]
4+
35
struct S<T>(T);
46
struct S2;
57

tests/ui/impl-trait/extra-impl-in-trait-impl.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: unexpected `impl` keyword
2-
--> $DIR/extra-impl-in-trait-impl.rs:6:18
2+
--> $DIR/extra-impl-in-trait-impl.rs:8:18
33
|
44
LL | impl<T: Default> impl Default for S<T> {
55
| ^^^^^ help: remove the extra `impl`
66
|
77
note: this is parsed as an `impl Trait` type, but a trait is expected at this position
8-
--> $DIR/extra-impl-in-trait-impl.rs:6:18
8+
--> $DIR/extra-impl-in-trait-impl.rs:8:18
99
|
1010
LL | impl<T: Default> impl Default for S<T> {
1111
| ^^^^^^^^^^^^
1212

1313
error: unexpected `impl` keyword
14-
--> $DIR/extra-impl-in-trait-impl.rs:12:6
14+
--> $DIR/extra-impl-in-trait-impl.rs:14:6
1515
|
1616
LL | impl impl Default for S2 {
1717
| ^^^^^ help: remove the extra `impl`
1818
|
1919
note: this is parsed as an `impl Trait` type, but a trait is expected at this position
20-
--> $DIR/extra-impl-in-trait-impl.rs:12:6
20+
--> $DIR/extra-impl-in-trait-impl.rs:14:6
2121
|
2222
LL | impl impl Default for S2 {
2323
| ^^^^^^^^^^^^

tests/ui/lint/dead-code/issue-59003.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#![deny(dead_code)]
66

7+
#[allow(dead_code)]
78
struct Foo {
8-
#[allow(dead_code)]
99
inner: u32,
1010
}
1111

tests/ui/lint/dead-code/unused-assoc-ty.rs

-25
This file was deleted.

tests/ui/lint/dead-code/unused-assoc-ty.stderr

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![deny(dead_code)]
2+
3+
struct T1; //~ ERROR struct `T1` is never constructed
4+
5+
trait Foo { type Unused; } //~ ERROR trait `Foo` is never used
6+
impl Foo for T1 { type Unused = Self; }
7+
8+
pub trait Bar { type Used; }
9+
impl Bar for T1 { type Used = Self; }
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: struct `T1` is never constructed
2+
--> $DIR/unused-trait-with-assoc-ty.rs:3:8
3+
|
4+
LL | struct T1;
5+
| ^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/unused-trait-with-assoc-ty.rs:1:9
9+
|
10+
LL | #![deny(dead_code)]
11+
| ^^^^^^^^^
12+
13+
error: trait `Foo` is never used
14+
--> $DIR/unused-trait-with-assoc-ty.rs:5:7
15+
|
16+
LL | trait Foo { type Unused; }
17+
| ^^^
18+
19+
error: aborting due to 2 previous errors
20+

tests/ui/parser/issues/issue-105366.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ run-rustfix
22

3+
#[allow(dead_code)]
34
struct Foo;
45

56
impl From<i32> for Foo {

0 commit comments

Comments
 (0)