forked from rust-lang/chalk
-
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.
- Loading branch information
1 parent
82cf22a
commit 7469656
Showing
5 changed files
with
181 additions
and
24 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
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
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
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,133 @@ | ||
use super::*; | ||
|
||
#[test] | ||
fn issue_727_1() { | ||
test!( | ||
program { | ||
#[upstream] #[non_enumerable] #[lang(sized)] | ||
trait Sized {} | ||
|
||
#[non_enumerable] #[object_safe] | ||
trait Database {} | ||
|
||
#[non_enumerable] | ||
trait QueryGroup | ||
where | ||
Self: Sized, | ||
{ | ||
type DynDb: Database + HasQueryGroup<Self>; | ||
} | ||
|
||
#[non_enumerable] #[object_safe] | ||
trait HasQueryGroup<G> | ||
where | ||
Self: Database, | ||
G: QueryGroup, | ||
G: Sized, | ||
{ } | ||
|
||
#[non_enumerable] #[object_safe] | ||
trait HelloWorld | ||
where | ||
Self: HasQueryGroup<HelloWorldStorage>, | ||
{ } | ||
|
||
struct HelloWorldStorage {} | ||
|
||
impl QueryGroup for HelloWorldStorage { | ||
type DynDb = dyn HelloWorld + 'static; | ||
} | ||
impl<DB> HelloWorld for DB | ||
where | ||
DB: Database, | ||
DB: HasQueryGroup<HelloWorldStorage>, | ||
DB: Sized, | ||
{ } | ||
} | ||
|
||
goal { | ||
forall<T> { | ||
if (FromEnv(T: Database); FromEnv(T: HasQueryGroup<HelloWorldStorage>); FromEnv(T: Sized)) { | ||
T: HelloWorld | ||
} | ||
} | ||
} yields[SolverChoice::slg_default()] { // ok | ||
expect![["Unique"]] | ||
} yields[SolverChoice::recursive_default()] { // fails: "Ambiguous; no inference guidance" | ||
expect![["Unique"]] | ||
} | ||
); | ||
} | ||
|
||
#[test] | ||
fn issue_727_2() { | ||
test!( | ||
program { | ||
#[non_enumerable] #[object_safe] | ||
trait Database {} | ||
|
||
#[non_enumerable] | ||
trait QueryGroup | ||
{ | ||
type DynDb: Database + HasQueryGroup<Self>; | ||
} | ||
|
||
#[non_enumerable] #[object_safe] | ||
trait HasQueryGroup<G> | ||
where | ||
Self: Database, | ||
G: QueryGroup, | ||
{ } | ||
|
||
struct HelloWorldStorage {} | ||
|
||
impl QueryGroup for HelloWorldStorage { | ||
type DynDb = dyn HasQueryGroup<HelloWorldStorage> + 'static; | ||
} | ||
} | ||
|
||
goal { | ||
forall<T> { | ||
if (FromEnv(T: HasQueryGroup<HelloWorldStorage>)) { | ||
T: Database | ||
} | ||
} | ||
} yields[SolverChoice::slg_default()] { | ||
expect![["Unique"]] | ||
} yields[SolverChoice::recursive_default()] { | ||
expect![["Unique"]] | ||
} | ||
); | ||
} | ||
|
||
#[test] | ||
fn issue_727_3() { | ||
test!( | ||
program { | ||
#[non_enumerable] | ||
trait Database {} | ||
|
||
#[non_enumerable] | ||
trait HasQueryGroup<G> | ||
where | ||
Self: Database, | ||
{ } | ||
|
||
struct HelloWorldStorage {} | ||
|
||
impl Database for HelloWorldStorage { } | ||
} | ||
|
||
goal { | ||
forall<T, S> { | ||
if (FromEnv(HelloWorldStorage: HasQueryGroup<T>); FromEnv(HelloWorldStorage: HasQueryGroup<S>)) { | ||
HelloWorldStorage: Database | ||
} | ||
} | ||
} yields[SolverChoice::slg_default()] { | ||
expect![["Unique"]] | ||
} yields[SolverChoice::recursive_default()] { | ||
expect![["Unique"]] | ||
} | ||
); | ||
} |
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