-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Check that a box expression's type is Sized #88087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,31 +1,21 @@ | ||
error[E0161]: cannot move a value of type str: the size of str cannot be statically determined | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/dst-rvalue.rs:6:28 | ||
| | ||
LL | let _x: Box<str> = box *"hello world"; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error[E0161]: cannot move a value of type [isize]: the size of [isize] cannot be statically determined | ||
--> $DIR/dst-rvalue.rs:11:32 | ||
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
LL | let _x: Box<[isize]> = box *array; | ||
| ^^^^^^ | ||
= help: the trait `Sized` is not implemented for `str` | ||
= note: the type of a box expression must have a statically known size | ||
|
||
error[E0507]: cannot move out of a shared reference | ||
--> $DIR/dst-rvalue.rs:6:28 | ||
| | ||
LL | let _x: Box<str> = box *"hello world"; | ||
| ^^^^^^^^^^^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait | ||
|
||
error[E0508]: cannot move out of type `[isize]`, a non-copy slice | ||
--> $DIR/dst-rvalue.rs:11:32 | ||
error[E0277]: the size for values of type `[isize]` cannot be known at compilation time | ||
--> $DIR/dst-rvalue.rs:10:32 | ||
| | ||
LL | let _x: Box<[isize]> = box *array; | ||
| ^^^^^^ | ||
| | | ||
| cannot move out of here | ||
| move occurs because `*array` has type `[isize]`, which does not implement the `Copy` trait | ||
| ^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[isize]` | ||
= note: the type of a box expression must have a statically known size | ||
|
||
error: aborting due to 4 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0161, E0507, E0508. | ||
For more information about an error, try `rustc --explain E0161`. | ||
For more information about this error, try `rustc --explain E0277`. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
#![feature(box_syntax)] | ||
// Box expression needs to be movable, and hence has to be of a Sized type. | ||
fn main() { | ||
let _x: Box<[u32]> = box { loop {} }; | ||
//~^ ERROR: the size for values of type `[u32]` cannot be known at compilation time | ||
|
||
// Check that a deduced size does not cause issues. | ||
let _y: Box<[u32]> = box []; | ||
let _z: Box<[u32; 0]> = box { loop {} }; | ||
} |
This file contains hidden or 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 @@ | ||
error[E0277]: the size for values of type `[u32]` cannot be known at compilation time | ||
--> $DIR/issue-87935-unsized-box-expr.rs:4:30 | ||
| | ||
LL | let _x: Box<[u32]> = box { loop {} }; | ||
| ^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u32]` | ||
= note: the type of a box expression must have a statically known size | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.