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.
Do not ICE when trying to get layout of an infer type
or other types whose layout cannot be computed such as bound, coroutine witness etc.
- Loading branch information
Showing
4 changed files
with
43 additions
and
12 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 was deleted.
Oops, something went wrong.
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 @@ | ||
// Regression test for #126942 | ||
|
||
// Tests that we do not ICE when an attempt | ||
// is made to compute the layout of a type | ||
// that normalizes to an infer type | ||
|
||
struct Thing; | ||
|
||
pub trait Every { | ||
type Assoc; | ||
} | ||
impl<T: ?Sized> Every for Thing { | ||
//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates | ||
type Assoc = T; | ||
} | ||
|
||
// The type of this static normalizes to `Infer` | ||
// thanks to the `?Sized` constraint in the impl above | ||
static I: <Thing as Every>::Assoc = 3; | ||
//~^ ERROR type annotations needed | ||
|
||
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,19 @@ | ||
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | ||
--> $DIR/ice-layout-of-invalid-type-126942.rs:12:6 | ||
| | ||
LL | impl<T: ?Sized> Every for Thing { | ||
| ^ unconstrained type parameter | ||
|
||
error[E0283]: type annotations needed | ||
--> $DIR/ice-layout-of-invalid-type-126942.rs:19:11 | ||
| | ||
LL | static I: <Thing as Every>::Assoc = 3; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` | ||
| | ||
= note: cannot satisfy `_: Sync` | ||
= note: shared static variables must have a type that implements `Sync` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0207, E0283. | ||
For more information about an error, try `rustc --explain E0207`. |