Add tests.

This commit is contained in:
Camille GILLOT 2022-05-09 18:43:16 +02:00
parent 3a08bd7873
commit 0fa27efad7
5 changed files with 189 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// check-pass
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
pub trait First {
const CONST: usize;
}
pub trait Second {}
impl<'a> First for dyn Second
where
&'a Self: First,
{
const CONST: usize = <&Self>::CONST;
}
trait Third: First
where
[u8; Self::CONST]:
{
const VAL: [u8; Self::CONST] = [0; Self::CONST];
}
fn main() {}

View File

@ -1,4 +1,6 @@
// build-pass
// compiler-opts: -Zmir-opt-level=2
#![allow(dead_code)]
trait Foo {
fn foo(&self);

View File

@ -0,0 +1,46 @@
warning: trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:20:29
|
LL | for<'any> &'any mut (): Clone,
| ^^^^^
|
= note: `#[warn(trivial_bounds)]` on by default
warning: trait bound i32: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:28:21
|
LL | struct S where i32: Foo;
| ^^^
warning: trait bound i32: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:31:28
|
LL | impl Foo for () where i32: Foo {
| ^^^
warning: trait bound i32: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:40:19
|
LL | fn f() where i32: Foo {
| ^^^
warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:48:28
|
LL | fn g() where &'static str: Foo {
| ^^^
warning: trait bound String: Neg does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:57:13
|
LL | String: ::std::ops::Neg<Output = String>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: trait bound i32: Iterator does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:65:10
|
LL | i32: Iterator,
| ^^^^^^^^
warning: 7 warnings emitted

View File

@ -0,0 +1,46 @@
warning: trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:20:29
|
LL | for<'any> &'any mut (): Clone,
| ^^^^^
|
= note: `#[warn(trivial_bounds)]` on by default
warning: trait bound i32: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:28:21
|
LL | struct S where i32: Foo;
| ^^^
warning: trait bound i32: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:31:28
|
LL | impl Foo for () where i32: Foo {
| ^^^
warning: trait bound i32: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:40:19
|
LL | fn f() where i32: Foo {
| ^^^
warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:48:28
|
LL | fn g() where &'static str: Foo {
| ^^^
warning: trait bound String: Neg does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:57:13
|
LL | String: ::std::ops::Neg<Output = String>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: trait bound i32: Iterator does not depend on any type or lifetime parameters
--> $DIR/issue-73021-impossible-inline.rs:65:10
|
LL | i32: Iterator,
| ^^^^^^^^
warning: 7 warnings emitted

View File

@ -0,0 +1,71 @@
// build-pass
// revisions: no-opt inline
// [inline]compile-flags: -Zmir-opt-level=3 --emit=mir
#![feature(trivial_bounds)]
#![allow(unused)]
trait Foo {
fn test(&self);
}
fn foo<'a>(s: &'a mut ())
where
&'a mut (): Foo,
{
s.test();
}
fn clone(it: &mut ()) -> &mut ()
where
for<'any> &'any mut (): Clone,
//~^ WARN trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters
{
it.clone()
}
fn generic_function<X: Foo>(x: X) {}
struct S where i32: Foo;
//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
impl Foo for () where i32: Foo {
//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
fn test(&self) {
3i32.test();
Foo::test(&4i32);
generic_function(5i32);
}
}
fn f() where i32: Foo {
//~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
let s = S;
3i32.test();
Foo::test(&4i32);
generic_function(5i32);
}
fn g() where &'static str: Foo {
//~^ WARN trait bound &'static str: Foo does not depend on any type or lifetime parameters
"Foo".test();
Foo::test(&"Foo");
generic_function("Foo");
}
fn use_op(s: String) -> String
where
String: ::std::ops::Neg<Output = String>,
//~^ WARN trait bound String: Neg does not depend on any type or lifetime parameters
{
-s
}
fn use_for()
where
i32: Iterator,
//~^ WARN trait bound i32: Iterator does not depend on any type or lifetime parameters
{
for _ in 2i32 {}
}
fn main() {}