diff --git a/src/test/ui/issues/issue-50571.rs b/src/test/ui/issues/issue-50571.rs new file mode 100644 index 0000000000000..728c113bdc323 --- /dev/null +++ b/src/test/ui/issues/issue-50571.rs @@ -0,0 +1,6 @@ +trait Foo { + fn foo([a, b]: [i32; 2]) {} + //~^ ERROR: patterns aren't allowed in methods without bodies +} + +fn main() {} diff --git a/src/test/ui/issues/issue-50571.stderr b/src/test/ui/issues/issue-50571.stderr new file mode 100644 index 0000000000000..834635388a066 --- /dev/null +++ b/src/test/ui/issues/issue-50571.stderr @@ -0,0 +1,13 @@ +error[E0642]: patterns aren't allowed in methods without bodies + --> $DIR/issue-50571.rs:2:12 + | +LL | fn foo([a, b]: [i32; 2]) {} + | ^^^^^^ +help: give this argument a name or use an underscore to ignore it + | +LL | fn foo(_: [i32; 2]) {} + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0642`. diff --git a/src/test/ui/issues/issue-58022.rs b/src/test/ui/issues/issue-58022.rs new file mode 100644 index 0000000000000..c6dd45e6cf3e9 --- /dev/null +++ b/src/test/ui/issues/issue-58022.rs @@ -0,0 +1,18 @@ +pub trait Foo: Sized { + const SIZE: usize; + + fn new(slice: &[u8; Foo::SIZE]) -> Self; + //~^ ERROR: type annotations needed: cannot resolve `_: Foo` +} + +pub struct Bar(T); + +impl Bar<[u8]> { + const SIZE: usize = 32; + + fn new(slice: &[u8; Self::SIZE]) -> Self { + Foo(Box::new(*slice)) //~ ERROR: expected function, found trait `Foo` + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-58022.stderr b/src/test/ui/issues/issue-58022.stderr new file mode 100644 index 0000000000000..71bad7b81fa87 --- /dev/null +++ b/src/test/ui/issues/issue-58022.stderr @@ -0,0 +1,19 @@ +error[E0423]: expected function, found trait `Foo` + --> $DIR/issue-58022.rs:14:9 + | +LL | Foo(Box::new(*slice)) + | ^^^ not a function + +error[E0283]: type annotations needed: cannot resolve `_: Foo` + --> $DIR/issue-58022.rs:4:25 + | +LL | const SIZE: usize; + | ------------------ required by `Foo::SIZE` +LL | +LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0283, E0423. +For more information about an error, try `rustc --explain E0283`. diff --git a/src/test/ui/issues/issue-58344.rs b/src/test/ui/issues/issue-58344.rs new file mode 100644 index 0000000000000..99b656d74f505 --- /dev/null +++ b/src/test/ui/issues/issue-58344.rs @@ -0,0 +1,50 @@ +use std::ops::Add; + +trait Trait { + fn get(self) -> T; +} + +struct Holder(T); + +impl Trait for Holder { + fn get(self) -> T { + self.0 + } +} + +enum Either { + Left(L), + Right(R), +} + +impl Either { + fn converge(self) -> T where L: Trait, R: Trait { + match self { + Either::Left(val) => val.get(), + Either::Right(val) => val.get(), + } + } +} + +fn add_generic, B>(lhs: A, rhs: B) -> Either< + impl Trait<>::Output>, + impl Trait<>::Output> +> { + if true { + Either::Left(Holder(lhs + rhs)) + } else { + Either::Right(Holder(lhs + rhs)) + } +} + +fn add_one( + value: u32, +) -> Either>::Output>, impl Trait<>::Output>> { + //~^ ERROR: the trait bound `impl Trait<::Output>: Trait` + //~| ERROR: the trait bound `impl Trait<::Output>: Trait` + add_generic(value, 1u32) +} + +pub fn main() { + add_one(3).converge(); +} diff --git a/src/test/ui/issues/issue-58344.stderr b/src/test/ui/issues/issue-58344.stderr new file mode 100644 index 0000000000000..427d03b679d5f --- /dev/null +++ b/src/test/ui/issues/issue-58344.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `impl Trait<::Output>: Trait` is not satisfied + --> $DIR/issue-58344.rs:42:13 + | +LL | ) -> Either>::Output>, impl Trait<>::Output>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Trait<::Output>` + | + = note: the return type of a function must have a statically known size + +error[E0277]: the trait bound `impl Trait<::Output>: Trait` is not satisfied + --> $DIR/issue-58344.rs:42:52 + | +LL | ) -> Either>::Output>, impl Trait<>::Output>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Trait<::Output>` + | + = note: the return type of a function must have a statically known size + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`.