mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
Add tests.
This commit is contained in:
parent
3a08bd7873
commit
0fa27efad7
24
src/test/ui/associated-consts/issue-88599-ref-self.rs
Normal file
24
src/test/ui/associated-consts/issue-88599-ref-self.rs
Normal 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() {}
|
@ -1,4 +1,6 @@
|
||||
// build-pass
|
||||
// compiler-opts: -Zmir-opt-level=2
|
||||
|
||||
#![allow(dead_code)]
|
||||
trait Foo {
|
||||
fn foo(&self);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
71
src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs
Normal file
71
src/test/ui/trivial-bounds/issue-73021-impossible-inline.rs
Normal 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() {}
|
Loading…
Reference in New Issue
Block a user