-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #64928 - JohnTitor:add-some-tests, r=Centril
- Loading branch information
Showing
6 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
trait Foo { | ||
fn foo([a, b]: [i32; 2]) {} | ||
//~^ ERROR: patterns aren't allowed in methods without bodies | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ?Sized>(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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::ops::Add; | ||
|
||
trait Trait<T> { | ||
fn get(self) -> T; | ||
} | ||
|
||
struct Holder<T>(T); | ||
|
||
impl<T> Trait<T> for Holder<T> { | ||
fn get(self) -> T { | ||
self.0 | ||
} | ||
} | ||
|
||
enum Either<L, R> { | ||
Left(L), | ||
Right(R), | ||
} | ||
|
||
impl<L, R> Either<L, R> { | ||
fn converge<T>(self) -> T where L: Trait<T>, R: Trait<T> { | ||
match self { | ||
Either::Left(val) => val.get(), | ||
Either::Right(val) => val.get(), | ||
} | ||
} | ||
} | ||
|
||
fn add_generic<A: Add<B>, B>(lhs: A, rhs: B) -> Either< | ||
impl Trait<<A as Add<B>>::Output>, | ||
impl Trait<<A as Add<B>>::Output> | ||
> { | ||
if true { | ||
Either::Left(Holder(lhs + rhs)) | ||
} else { | ||
Either::Right(Holder(lhs + rhs)) | ||
} | ||
} | ||
|
||
fn add_one( | ||
value: u32, | ||
) -> Either<impl Trait<<u32 as Add<u32>>::Output>, impl Trait<<u32 as Add<u32>>::Output>> { | ||
//~^ ERROR: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>` | ||
//~| ERROR: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>` | ||
add_generic(value, 1u32) | ||
} | ||
|
||
pub fn main() { | ||
add_one(3).converge(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0277]: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>` is not satisfied | ||
--> $DIR/issue-58344.rs:42:13 | ||
| | ||
LL | ) -> Either<impl Trait<<u32 as Add<u32>>::Output>, impl Trait<<u32 as Add<u32>>::Output>> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<u32>` is not implemented for `impl Trait<<u32 as std::ops::Add>::Output>` | ||
| | ||
= note: the return type of a function must have a statically known size | ||
|
||
error[E0277]: the trait bound `impl Trait<<u32 as std::ops::Add>::Output>: Trait<u32>` is not satisfied | ||
--> $DIR/issue-58344.rs:42:52 | ||
| | ||
LL | ) -> Either<impl Trait<<u32 as Add<u32>>::Output>, impl Trait<<u32 as Add<u32>>::Output>> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<u32>` is not implemented for `impl Trait<<u32 as std::ops::Add>::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`. |