-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require defining uses to use generic parameters for all parameters of…
… a generic existential type
- Loading branch information
Showing
10 changed files
with
98 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
error: non-defining existential type use in defining scope | ||
--> $DIR/bound_reduction2.rs:16:1 | ||
error: defining existential type use does not fully define existential type | ||
--> $DIR/bound_reduction2.rs:17:1 | ||
| | ||
LL | / fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { //~ ERROR non-defining | ||
LL | / fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { //~ ERROR does not fully define | ||
LL | | () | ||
LL | | } | ||
| |_^ | ||
| | ||
note: used non-generic type <T as TraitWithAssoc>::Assoc for generic parameter | ||
--> $DIR/bound_reduction2.rs:10:22 | ||
|
||
error: could not find defining uses | ||
--> $DIR/bound_reduction2.rs:10:1 | ||
| | ||
LL | existential type Foo<V>: Trait<V>; | ||
| ^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
12 changes: 12 additions & 0 deletions
12
src/test/ui/existential_types/generic_duplicate_param_use10.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,12 @@ | ||
// compile-pass | ||
#![feature(existential_type)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn main() {} | ||
|
||
existential type Two<T, U>: Debug; | ||
|
||
fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> { | ||
(t, 4u32) | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/ui/existential_types/generic_duplicate_param_use9.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,20 @@ | ||
#![feature(existential_type)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn main() {} | ||
|
||
existential type Two<A, B>: Debug; | ||
|
||
trait Foo { | ||
type Bar: Debug; | ||
const BAR: Self::Bar; | ||
} | ||
|
||
fn two<T: Debug + Foo, U: Debug>(t: T, u: U) -> Two<T, U> { | ||
(t, u, T::BAR) | ||
} | ||
|
||
fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> { | ||
(t, u, 42) //~^ ERROR concrete type differs from previous | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/existential_types/generic_duplicate_param_use9.stderr
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 @@ | ||
error: concrete type differs from previous defining existential type use | ||
--> $DIR/generic_duplicate_param_use9.rs:18:1 | ||
| | ||
LL | / fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> { | ||
LL | | (t, u, 42) //~^ ERROR concrete type differs from previous | ||
LL | | } | ||
| |_^ expected `(A, B, <A as Foo>::Bar)`, got `(A, B, i32)` | ||
| | ||
note: previous use here | ||
--> $DIR/generic_duplicate_param_use9.rs:14:1 | ||
| | ||
LL | / fn two<T: Debug + Foo, U: Debug>(t: T, u: U) -> Two<T, U> { | ||
LL | | (t, u, T::BAR) | ||
LL | | } | ||
| |_^ | ||
|
||
error: aborting due to previous error | ||
|
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
16 changes: 8 additions & 8 deletions
16
src/test/ui/existential_types/generic_nondefining_use.stderr
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
error: non-defining existential type use in defining scope | ||
--> $DIR/generic_nondefining_use.rs:8:1 | ||
error: defining existential type use does not fully define existential type | ||
--> $DIR/generic_nondefining_use.rs:9:1 | ||
| | ||
LL | / fn cmp() -> Cmp<u32> { //~ ERROR non-defining existential type use in defining scope | ||
LL | / fn cmp() -> Cmp<u32> { //~ ERROR defining existential type use does not fully define | ||
LL | | 5u32 | ||
LL | | } | ||
| |_^ | ||
| | ||
note: used non-generic type u32 for generic parameter | ||
--> $DIR/generic_nondefining_use.rs:5:22 | ||
|
||
error: could not find defining uses | ||
--> $DIR/generic_nondefining_use.rs:5:1 | ||
| | ||
LL | existential type Cmp<T>: 'static; | ||
| ^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
error: defining existential type use does not fully define existential type | ||
--> $DIR/not_a_defining_use.rs:9:1 | ||
| | ||
LL | / fn two<T: Debug>(t: T) -> Two<T, u32> { | ||
LL | | //~^ ERROR defining existential type use does not fully define existential type | ||
LL | | (t, 4i8) | ||
LL | | } | ||
| |_^ | ||
|
||
error: concrete type differs from previous defining existential type use | ||
--> $DIR/not_a_defining_use.rs:29:1 | ||
--> $DIR/not_a_defining_use.rs:30:1 | ||
| | ||
LL | / fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { //~ concrete type differs from previous | ||
LL | | (t, <U as Bar>::FOO) | ||
LL | | } | ||
| |_^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)` | ||
| | ||
note: previous use here | ||
--> $DIR/not_a_defining_use.rs:9:1 | ||
--> $DIR/not_a_defining_use.rs:14:1 | ||
| | ||
LL | / fn two<T: Debug>(t: T) -> Two<T, u32> { | ||
LL | | (t, 4i8) | ||
LL | / fn three<T: Debug, U>(t: T) -> Two<T, U> { | ||
LL | | (t, 5i8) | ||
LL | | } | ||
| |_^ | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|