-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Remove support for dynamic allocas #142911
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
Open
mejrs
wants to merge
3
commits into
rust-lang:master
Choose a base branch
from
mejrs:unsized
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+161
−94
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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,27 @@ | ||
//! `#![feature(unsized_fn_params)]` lets you use unsized function parameters. In particular this | ||
//! is load bearing for `Box<dyn FnOnce()>: FnOnce()`. To do that, borrowck relaxes the requirement | ||
//! that certain places must be `Sized`. But in #142911 we removed alloca support, so these | ||
//! arguments can't move (or ICE at codegen) That means when `unsized_fn_params` is enabled, we must | ||
//! explicitly check that unsized function arguments are place expressions. | ||
//! | ||
//! Also see tests/ui/unsized_locals/unsized-exprs-rpass.rs | ||
|
||
#![feature(unsized_fn_params)] | ||
|
||
fn foo() -> Box<[u8]> { | ||
Box::new(*b"foo") | ||
} | ||
|
||
fn udrop<T: ?Sized>(_x: T) {} | ||
|
||
fn main(){ | ||
// NB The ordering of the following operations matters, otherwise errors get swallowed somehow. | ||
|
||
udrop::<[u8]>(if true { *foo() } else { *foo() }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time | ||
udrop::<[u8]>({ *foo() }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time | ||
udrop(match foo() { x => *x }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time | ||
udrop::<[u8]>({ loop { break *foo(); } }); //~ERROR the size for values of type `[u8]` cannot be known at compilation time | ||
|
||
{ *foo() }; //~ERROR the size for values of type `[u8]` cannot be known at compilation time | ||
{ loop { break *foo(); } }; //~ERROR the size for values of type `[u8]` cannot be known at compilation time | ||
} |
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,81 @@ | ||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/unsized-non-place-exprs.rs:20:19 | ||
| | ||
LL | udrop::<[u8]>(if true { *foo() } else { *foo() }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u8]` | ||
note: unsized values must be place expressions and cannot be moved from | ||
--> $DIR/unsized-non-place-exprs.rs:20:19 | ||
| | ||
LL | udrop::<[u8]>(if true { *foo() } else { *foo() }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/unsized-non-place-exprs.rs:21:19 | ||
| | ||
LL | udrop::<[u8]>({ *foo() }); | ||
| ^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u8]` | ||
note: unsized values must be place expressions and cannot be moved from | ||
--> $DIR/unsized-non-place-exprs.rs:21:19 | ||
| | ||
LL | udrop::<[u8]>({ *foo() }); | ||
| ^^^^^^^^^^ | ||
|
||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/unsized-non-place-exprs.rs:22:11 | ||
| | ||
LL | udrop(match foo() { x => *x }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u8]` | ||
note: unsized values must be place expressions and cannot be moved from | ||
--> $DIR/unsized-non-place-exprs.rs:22:11 | ||
| | ||
LL | udrop(match foo() { x => *x }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/unsized-non-place-exprs.rs:23:19 | ||
| | ||
LL | udrop::<[u8]>({ loop { break *foo(); } }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u8]` | ||
note: unsized values must be place expressions and cannot be moved from | ||
--> $DIR/unsized-non-place-exprs.rs:23:19 | ||
| | ||
LL | udrop::<[u8]>({ loop { break *foo(); } }); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/unsized-non-place-exprs.rs:25:5 | ||
| | ||
LL | { *foo() }; | ||
| ^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u8]` | ||
note: unsized values must be place expressions and cannot be moved from | ||
--> $DIR/unsized-non-place-exprs.rs:25:5 | ||
| | ||
LL | { *foo() }; | ||
| ^^^^^^^^^^ | ||
|
||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/unsized-non-place-exprs.rs:26:5 | ||
| | ||
LL | { loop { break *foo(); } }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u8]` | ||
note: unsized values must be place expressions and cannot be moved from | ||
--> $DIR/unsized-non-place-exprs.rs:26:5 | ||
| | ||
LL | { loop { break *foo(); } }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be made a direct place in the future? If so maybe add a FIXME?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know anything about codegen, so I don't know about that. There are quite a few occasions of
UnsizedPlace(_) => bug!()
though, so it does look like something that could be refactored.