-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typeck: merge opaque type inference logic
This commit merges the logic used for opaque type type inference for impl Trait and non-impl Trait cases. This fixes an ICE where existential types used in the return types of functions would be allowed to have an out-of-scope generic type parameter.
- Loading branch information
Showing
8 changed files
with
217 additions
and
139 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// ignore-tidy-linelength | ||
#![feature(existential_type)] | ||
|
||
pub trait Bar | ||
{ | ||
type E: Copy; | ||
|
||
fn foo<T>() -> Self::E; | ||
} | ||
|
||
impl<S: Default> Bar for S { | ||
existential type E: Copy; | ||
//~^ ERROR the trait bound `S: std::marker::Copy` is not satisfied in `(S, T)` [E0277] | ||
//~^^ ERROR the trait bound `T: std::marker::Copy` is not satisfied in `(S, T)` [E0277] | ||
|
||
fn foo<T: Default>() -> Self::E { | ||
//~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for existential type | ||
(S::default(), T::default()) | ||
} | ||
} | ||
|
||
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,33 @@ | ||
error[E0277]: the trait bound `S: std::marker::Copy` is not satisfied in `(S, T)` | ||
--> $DIR/issue-55872-1.rs:12:5 | ||
| | ||
LL | existential type E: Copy; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `S` | ||
| | ||
= help: consider adding a `where S: std::marker::Copy` bound | ||
= note: required because it appears within the type `(S, T)` | ||
= note: the return type of a function must have a statically known size | ||
|
||
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied in `(S, T)` | ||
--> $DIR/issue-55872-1.rs:12:5 | ||
| | ||
LL | existential type E: Copy; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `std::marker::Copy` is not implemented for `T` | ||
| | ||
= help: consider adding a `where T: std::marker::Copy` bound | ||
= note: required because it appears within the type `(S, T)` | ||
= note: the return type of a function must have a statically known size | ||
|
||
error: type parameter `T` is part of concrete type but not used in parameter list for existential type | ||
--> $DIR/issue-55872-1.rs:16:37 | ||
| | ||
LL | fn foo<T: Default>() -> Self::E { | ||
| _____________________________________^ | ||
LL | | | ||
LL | | (S::default(), T::default()) | ||
LL | | } | ||
| |_____^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
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,20 @@ | ||
// edition:2018 | ||
// ignore-tidy-linelength | ||
#![feature(async_await, existential_type)] | ||
|
||
pub trait Bar { | ||
type E: Copy; | ||
|
||
fn foo<T>() -> Self::E; | ||
} | ||
|
||
impl<S> Bar for S { | ||
existential type E: Copy; | ||
//~^ ERROR the trait bound `impl std::future::Future: std::marker::Copy` is not satisfied [E0277] | ||
fn foo<T>() -> Self::E { | ||
//~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for existential type | ||
async {} | ||
} | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.