mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Return pos impl trait
This commit is contained in:
parent
6469fba44e
commit
a81e489101
31
src/test/ui/const-generics/defaults/rp_impl_trait.rs
Normal file
31
src/test/ui/const-generics/defaults/rp_impl_trait.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// run-pass
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Uwu<const N: u32 = 1, const M: u32 = N>;
|
||||
|
||||
trait Trait {}
|
||||
impl<const N: u32> Trait for Uwu<N> {}
|
||||
|
||||
fn rawr<const N: u32>() -> impl Trait {
|
||||
Uwu::<N>
|
||||
}
|
||||
|
||||
trait Traitor<const N: u8 = 1, const M: u8 = N> { }
|
||||
|
||||
impl<const N: u8> Traitor<N> for u32 {}
|
||||
impl Traitor<1, 1> for u64 {}
|
||||
|
||||
fn uwu<const N: u8>() -> impl Traitor<N> {
|
||||
1_u32
|
||||
}
|
||||
|
||||
fn owo() -> impl Traitor {
|
||||
1_u64
|
||||
}
|
||||
|
||||
fn main() {
|
||||
rawr::<3>();
|
||||
rawr::<7>();
|
||||
uwu::<{ u8::MAX }>();
|
||||
owo();
|
||||
}
|
33
src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs
Normal file
33
src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs
Normal file
@ -0,0 +1,33 @@
|
||||
#![feature(const_generics_defaults)]
|
||||
|
||||
struct Uwu<const N: u32 = 1, const M: u32 = N>;
|
||||
|
||||
trait Trait {}
|
||||
impl<const N: u32> Trait for Uwu<N> {}
|
||||
|
||||
fn rawr() -> impl Trait {
|
||||
//~^ error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
|
||||
Uwu::<10, 12>
|
||||
}
|
||||
|
||||
trait Traitor<const N: u8 = 1, const M: u8 = N> { }
|
||||
|
||||
impl<const N: u8> Traitor<N, 2> for u32 {}
|
||||
impl Traitor<1, 2> for u64 {}
|
||||
|
||||
|
||||
fn uwu<const N: u8>() -> impl Traitor<N> {
|
||||
//~^ error: the trait bound `u32: Traitor<N, N>` is not satisfied
|
||||
1_u32
|
||||
}
|
||||
|
||||
fn owo() -> impl Traitor {
|
||||
//~^ error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
|
||||
1_u64
|
||||
}
|
||||
|
||||
fn main() {
|
||||
rawr();
|
||||
uwu();
|
||||
owo();
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
|
||||
--> $DIR/rp_impl_trait_fail.rs:8:14
|
||||
|
|
||||
LL | fn rawr() -> impl Trait {
|
||||
| ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<Uwu<N> as Trait>
|
||||
|
||||
error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied
|
||||
--> $DIR/rp_impl_trait_fail.rs:19:26
|
||||
|
|
||||
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
|
||||
| ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<u32 as Traitor<N, 2_u8>>
|
||||
|
||||
error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
|
||||
--> $DIR/rp_impl_trait_fail.rs:24:13
|
||||
|
|
||||
LL | fn owo() -> impl Traitor {
|
||||
| ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<u64 as Traitor<1_u8, 2_u8>>
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Reference in New Issue
Block a user