Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove defaults table and attach defaults directly to tyvars
- Loading branch information
Showing
6 changed files
with
143 additions
and
41 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
23 changes: 23 additions & 0 deletions
23
src/test/run-pass/default_type_parameter_default_dependent_associated_type.rs
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,23 @@ | ||
use std::marker::PhantomData; | ||
|
||
trait Id { | ||
type This; | ||
} | ||
|
||
impl<A> Id for A { | ||
type This = A; | ||
} | ||
|
||
struct Foo<X: Default = usize, Y = <X as Id>::This> { | ||
data: PhantomData<(X, Y)> | ||
} | ||
|
||
impl<X: Default, Y> Foo<X, Y> { | ||
fn new() -> Foo<X, Y> { | ||
Foo { data: PhantomData } | ||
} | ||
} | ||
|
||
fn main() { | ||
let foo = Foo::new(); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/test/run-pass/default_type_parameter_dependent_defaults.rs
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,7 @@ | ||
use std::marker::PhantomData; | ||
|
||
struct Foo<T,U=T> { data: PhantomData<(T, U)> } | ||
|
||
fn main() { | ||
let foo = Foo { data: PhantomData }; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/run-pass/default_type_parameter_struct_and_type_alias.rs
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,30 @@ | ||
use std::marker::PhantomData; | ||
|
||
trait TypeEq<A> {} | ||
impl<A> TypeEq<A> for A {} | ||
|
||
struct DeterministicHasher; | ||
struct RandomHasher; | ||
|
||
|
||
struct MyHashMap<K, V, H=DeterministicHasher> { | ||
data: PhantomData<(K, V, H)> | ||
} | ||
|
||
impl<K, V, H> MyHashMap<K, V, H> { | ||
fn new() -> MyHashMap<K, V, H> { | ||
MyHashMap { data: PhantomData } | ||
} | ||
} | ||
|
||
mod mystd { | ||
use super::{MyHashMap, RandomHasher}; | ||
pub type HashMap<K, V, H=RandomHasher> = MyHashMap<K, V, H>; | ||
} | ||
|
||
fn try_me<H>(hash_map: mystd::HashMap<i32, i32, H>) {} | ||
|
||
fn main() { | ||
let hash_map = mystd::HashMap::new(); | ||
try_me(hash_map); | ||
} |