Skip to content

Commit

Permalink
Add and bless tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mu001999 committed Nov 3, 2024
1 parent fe36604 commit 1996651
Show file tree
Hide file tree
Showing 34 changed files with 118 additions and 77 deletions.
2 changes: 1 addition & 1 deletion tests/ui/associated-type-bounds/union-bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

trait Tr1: Copy { type As1: Copy; }
trait Tr2: Copy { type As2: Copy; }
trait Tr3: Copy { type As3: Copy; }
trait Tr3: Copy { #[allow(dead_code)] type As3: Copy; }
trait Tr4<'a>: Copy { type As4: Copy; }
trait Tr5: Copy { type As5: Copy; }

Expand Down
1 change: 1 addition & 0 deletions tests/ui/associated-types/impl-wf-cycle-5.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impl Fiz for bool {}

trait Grault {
type A;
#[allow(dead_code)]
type B;
}

Expand Down
1 change: 1 addition & 0 deletions tests/ui/associated-types/impl-wf-cycle-5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impl Fiz for bool {}

trait Grault {
type A;
#[allow(dead_code)]
type B;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/associated-types/impl-wf-cycle-5.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
--> $DIR/impl-wf-cycle-5.rs:22:1
--> $DIR/impl-wf-cycle-5.rs:23:1
|
LL | / impl<T> Grault for (T,)
LL | |
Expand All @@ -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:22:9
--> $DIR/impl-wf-cycle-5.rs:23:9
|
LL | impl<T> Grault for (T,)
| ^^^^^^ ^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/associated-types/impl-wf-cycle-6.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impl Fiz for bool {}

trait Grault {
type A;
#[allow(dead_code)]
type B;
}

Expand Down
1 change: 1 addition & 0 deletions tests/ui/associated-types/impl-wf-cycle-6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impl Fiz for bool {}

trait Grault {
type A;
#[allow(dead_code)]
type B;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/associated-types/impl-wf-cycle-6.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
--> $DIR/impl-wf-cycle-6.rs:22:1
--> $DIR/impl-wf-cycle-6.rs:23:1
|
LL | / impl<T: Grault> Grault for (T,)
LL | |
Expand All @@ -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:22:17
--> $DIR/impl-wf-cycle-6.rs:23:17
|
LL | impl<T: Grault> Grault for (T,)
| ^^^^^^ ^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/const-generics/cross_crate_complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async fn foo() {
async_in_foo(async_out_foo::<4>().await).await;
}

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

impl<const N: usize> Foo<N> for Faz<N> {}
impl<const N: usize> Bar<N> for Faz<N> {
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/const-generics/cross_crate_complex.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: struct `Faz` is never constructed
--> $DIR/cross_crate_complex.rs:14:8
|
LL | struct Faz<const N: usize>;
| ^^^
|
= note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion tests/ui/const-generics/issues/issue-86535-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub trait Foo {
[(); Self::ASSOC_C]:;
}

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

Expand Down
10 changes: 10 additions & 0 deletions tests/ui/const-generics/issues/issue-86535-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: struct `Bar` is never constructed
--> $DIR/issue-86535-2.rs:12:8
|
LL | struct Bar<const N: &'static ()>;
| ^^^
|
= note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion tests/ui/const-generics/issues/issue-86535.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
#![allow(incomplete_features, unused_variables)]

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

Expand Down
10 changes: 10 additions & 0 deletions tests/ui/const-generics/issues/issue-86535.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: struct `F` is never constructed
--> $DIR/issue-86535.rs:5:8
|
LL | struct F<const S: &'static str>;
| ^
|
= note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion tests/ui/deriving/deriving-in-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ macro_rules! define_vec {
() => (
mod foo {
#[derive(PartialEq)]
pub struct bar;
pub struct bar; //~ WARN struct `bar` is never constructed
}
)
}
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/deriving/deriving-in-macro.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
warning: struct `bar` is never constructed
--> $DIR/deriving-in-macro.rs:9:24
|
LL | pub struct bar;
| ^^^
...
LL | define_vec![];
| ------------- in this macro invocation
|
= note: `#[warn(dead_code)]` on by default
= note: this warning originates in the macro `define_vec` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 1 warning emitted

1 change: 1 addition & 0 deletions tests/ui/generic-associated-types/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ trait Collection<T> {
type Iter<'iter>: Iterator<Item=&'iter T> where T: 'iter, Self: 'iter;
type Family: CollectionFamily;
// Test associated type defaults with parameters
#[allow(dead_code)]
type Sibling<U>: Collection<U> =
<<Self as Collection<T>>::Family as CollectionFamily>::Member<U>;

Expand Down
2 changes: 2 additions & 0 deletions tests/ui/generic-associated-types/missing-bounds.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ run-rustfix

#![allow(dead_code)]

use std::ops::Add;

struct A<B>(B);
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/generic-associated-types/missing-bounds.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ run-rustfix

#![allow(dead_code)]

use std::ops::Add;

struct A<B>(B);
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/generic-associated-types/missing-bounds.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: equality constraints are not yet supported in `where` clauses
--> $DIR/missing-bounds.rs:37:33
--> $DIR/missing-bounds.rs:39:33
|
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
| ^^^^^^^^^^^^^^^^^^^^^^ not supported
Expand All @@ -11,7 +11,7 @@ LL | impl<B: Add> Add for E<B> where B: Add<Output = B> {
| ~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:11:11
--> $DIR/missing-bounds.rs:13:11
|
LL | impl<B> Add for A<B> where B: Add {
| - expected this type parameter
Expand All @@ -24,14 +24,14 @@ LL | A(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
help: the type constructed contains `<B as Add>::Output` due to the type of the argument passed
--> $DIR/missing-bounds.rs:11:9
--> $DIR/missing-bounds.rs:13:9
|
LL | A(self.0 + rhs.0)
| ^^--------------^
| |
| this argument influences the type of `A`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:5:8
--> $DIR/missing-bounds.rs:7:8
|
LL | struct A<B>(B);
| ^
Expand All @@ -41,7 +41,7 @@ LL | impl<B> Add for A<B> where B: Add<Output = B> {
| ++++++++++++

error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:21:14
--> $DIR/missing-bounds.rs:23:14
|
LL | impl<B: Add> Add for C<B> {
| - expected this type parameter
Expand All @@ -54,7 +54,7 @@ LL | Self(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:15:8
--> $DIR/missing-bounds.rs:17:8
|
LL | struct C<B>(B);
| ^
Expand All @@ -64,7 +64,7 @@ LL | impl<B: Add<Output = B>> Add for C<B> {
| ++++++++++++

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

error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:42:14
--> $DIR/missing-bounds.rs:44:14
|
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
| - expected this type parameter
Expand All @@ -90,7 +90,7 @@ LL | Self(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:35:8
--> $DIR/missing-bounds.rs:37:8
|
LL | struct E<B>(B);
| ^
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/impl-trait/extra-impl-in-trait-impl.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ run-rustfix

#![allow(dead_code)]

struct S<T>(T);
struct S2;

Expand Down
2 changes: 2 additions & 0 deletions tests/ui/impl-trait/extra-impl-in-trait-impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ run-rustfix

#![allow(dead_code)]

struct S<T>(T);
struct S2;

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/impl-trait/extra-impl-in-trait-impl.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: unexpected `impl` keyword
--> $DIR/extra-impl-in-trait-impl.rs:6:18
--> $DIR/extra-impl-in-trait-impl.rs:8:18
|
LL | impl<T: Default> impl Default for S<T> {
| ^^^^^ help: remove the extra `impl`
|
note: this is parsed as an `impl Trait` type, but a trait is expected at this position
--> $DIR/extra-impl-in-trait-impl.rs:6:18
--> $DIR/extra-impl-in-trait-impl.rs:8:18
|
LL | impl<T: Default> impl Default for S<T> {
| ^^^^^^^^^^^^

error: unexpected `impl` keyword
--> $DIR/extra-impl-in-trait-impl.rs:12:6
--> $DIR/extra-impl-in-trait-impl.rs:14:6
|
LL | impl impl Default for S2 {
| ^^^^^ help: remove the extra `impl`
|
note: this is parsed as an `impl Trait` type, but a trait is expected at this position
--> $DIR/extra-impl-in-trait-impl.rs:12:6
--> $DIR/extra-impl-in-trait-impl.rs:14:6
|
LL | impl impl Default for S2 {
| ^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/dead-code/issue-59003.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#![deny(dead_code)]

#[allow(dead_code)]
struct Foo {
#[allow(dead_code)]
inner: u32,
}

Expand Down
25 changes: 0 additions & 25 deletions tests/ui/lint/dead-code/unused-assoc-ty.rs

This file was deleted.

16 changes: 0 additions & 16 deletions tests/ui/lint/dead-code/unused-assoc-ty.stderr

This file was deleted.

11 changes: 11 additions & 0 deletions tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![deny(dead_code)]

struct T1; //~ ERROR struct `T1` is never constructed

trait Foo { type Unused; } //~ ERROR trait `Foo` is never used
impl Foo for T1 { type Unused = Self; }

pub trait Bar { type Used; }
impl Bar for T1 { type Used = Self; }

fn main() {}
20 changes: 20 additions & 0 deletions tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error: struct `T1` is never constructed
--> $DIR/unused-trait-with-assoc-ty.rs:3:8
|
LL | struct T1;
| ^^
|
note: the lint level is defined here
--> $DIR/unused-trait-with-assoc-ty.rs:1:9
|
LL | #![deny(dead_code)]
| ^^^^^^^^^

error: trait `Foo` is never used
--> $DIR/unused-trait-with-assoc-ty.rs:5:7
|
LL | trait Foo { type Unused; }
| ^^^

error: aborting due to 2 previous errors

1 change: 1 addition & 0 deletions tests/ui/parser/issues/issue-105366.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@ run-rustfix

#[allow(dead_code)]
struct Foo;

impl From<i32> for Foo {
Expand Down
Loading

0 comments on commit 1996651

Please sign in to comment.