forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#73646 - JohnTitor:add-tests, r=Dylan-DPC
Add some regression tests Closes rust-lang#44861 Closes rust-lang#51506 Closes rust-lang#59435 Closes rust-lang#69840
- Loading branch information
Showing
7 changed files
with
152 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,16 @@ | ||
// check-pass | ||
|
||
#![feature(impl_trait_in_bindings)] | ||
#![allow(incomplete_features)] | ||
|
||
struct A<'a>(&'a ()); | ||
|
||
trait Trait<T> {} | ||
|
||
impl<T> Trait<T> for () {} | ||
|
||
pub fn foo<'a>() { | ||
let _x: impl Trait<A<'a>> = (); | ||
} | ||
|
||
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,41 @@ | ||
#![feature(never_type, specialization)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::iter::{self, Empty}; | ||
|
||
trait Trait { | ||
type Out: Iterator<Item = u32>; | ||
|
||
fn f(&self) -> Option<Self::Out>; | ||
} | ||
|
||
impl<T> Trait for T { | ||
default type Out = !; //~ ERROR: `!` is not an iterator | ||
|
||
default fn f(&self) -> Option<Self::Out> { | ||
None | ||
} | ||
} | ||
|
||
struct X; | ||
|
||
impl Trait for X { | ||
type Out = Empty<u32>; | ||
|
||
fn f(&self) -> Option<Self::Out> { | ||
Some(iter::empty()) | ||
} | ||
} | ||
|
||
fn f<T: Trait>(a: T) { | ||
if let Some(iter) = a.f() { | ||
println!("Some"); | ||
for x in iter { | ||
println!("x = {}", x); | ||
} | ||
} | ||
} | ||
|
||
pub fn main() { | ||
f(10); | ||
} |
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,14 @@ | ||
error[E0277]: `!` is not an iterator | ||
--> $DIR/issue-51506.rs:13:5 | ||
| | ||
LL | type Out: Iterator<Item = u32>; | ||
| ------------------------------- required by `Trait::Out` | ||
... | ||
LL | default type Out = !; | ||
| ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator | ||
| | ||
= help: the trait `std::iter::Iterator` is not implemented for `!` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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,40 @@ | ||
#![crate_type = "lib"] | ||
#![feature(specialization)] | ||
#![feature(unsize, coerce_unsized)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::ops::CoerceUnsized; | ||
|
||
pub struct SmartassPtr<A: Smartass+?Sized>(A::Data); | ||
|
||
pub trait Smartass { | ||
type Data; | ||
type Data2: CoerceUnsized<*const [u8]>; | ||
} | ||
|
||
pub trait MaybeObjectSafe {} | ||
|
||
impl MaybeObjectSafe for () {} | ||
|
||
impl<T> Smartass for T { | ||
type Data = <Self as Smartass>::Data2; | ||
default type Data2 = (); | ||
//~^ ERROR: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied | ||
} | ||
|
||
impl Smartass for () { | ||
type Data2 = *const [u8; 1]; | ||
} | ||
|
||
impl Smartass for dyn MaybeObjectSafe { | ||
type Data = *const [u8]; | ||
type Data2 = *const [u8; 0]; | ||
} | ||
|
||
impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U> | ||
where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data> | ||
{} | ||
|
||
pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<dyn MaybeObjectSafe> { | ||
s | ||
} |
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,12 @@ | ||
error[E0277]: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied | ||
--> $DIR/issue-44861.rs:21:5 | ||
| | ||
LL | type Data2: CoerceUnsized<*const [u8]>; | ||
| --------------------------------------- required by `Smartass::Data2` | ||
... | ||
LL | default type Data2 = (); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::CoerceUnsized<*const [u8]>` is not implemented for `()` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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,17 @@ | ||
#![feature(specialization)] | ||
#![allow(incomplete_features)] | ||
|
||
struct MyStruct {} | ||
|
||
trait MyTrait { | ||
type MyType: Default; | ||
} | ||
|
||
impl MyTrait for i32 { | ||
default type MyType = MyStruct; | ||
//~^ ERROR: the trait bound `MyStruct: std::default::Default` is not satisfied | ||
} | ||
|
||
fn main() { | ||
let _x: <i32 as MyTrait>::MyType = <i32 as MyTrait>::MyType::default(); | ||
} |
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,12 @@ | ||
error[E0277]: the trait bound `MyStruct: std::default::Default` is not satisfied | ||
--> $DIR/issue-59435.rs:11:5 | ||
| | ||
LL | type MyType: Default; | ||
| --------------------- required by `MyTrait::MyType` | ||
... | ||
LL | default type MyType = MyStruct; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `MyStruct` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |