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.
Rollup merge of rust-lang#56045 - qnighy:additional-sizedness, r=cram…
…ertj Check arg/ret sizedness at ExprKind::Path This PR solves three problems: - rust-lang#50940: ICE on casting unsized tuple struct constructors - Unsized tuple struct constructors were callable in presence of `unsized_locals`. - rust-lang#48055 (comment): we cannot relax `Sized` bounds on stable functions because of fn ptr casting These are caused by lack of `Sized`ness checks for arguments/retvals at **reference sites of `FnDef` items** (not call sites of the functions). Therefore we can basically add more `Sized` obligations on typeck. However, adding `Sized` obligations arbitrarily breaks type inference; to prevent that I added a new method `require_type_is_sized_deferred` which doesn't interfere usual type inference.
- Loading branch information
Showing
16 changed files
with
133 additions
and
46 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 |
---|---|---|
|
@@ -34,4 +34,5 @@ fn main() { | |
udrop::<[u8]>((*foo())); | ||
udrop::<[u8]>((*tfoo()).1); | ||
*afoo() + 42; | ||
udrop as fn([u8]); | ||
} |
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
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,22 +1,14 @@ | ||
error[E0161]: cannot move a value of type X: the size of X cannot be statically determined | ||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/issue-30355.rs:15:6 | ||
| | ||
LL | &X(*Y) | ||
| ^^^^^ | ||
|
||
error[E0161]: cannot move a value of type [u8]: the size of [u8] cannot be statically determined | ||
--> $DIR/issue-30355.rs:15:8 | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
LL | &X(*Y) | ||
| ^^ | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/issue-30355.rs:15:8 | ||
| | ||
LL | &X(*Y) | ||
| ^^ cannot move out of borrowed content | ||
= help: the trait `std::marker::Sized` is not implemented for `[u8]` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
= note: all function arguments must have a statically known size | ||
= help: unsized locals are gated as an unstable feature | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to previous error | ||
|
||
Some errors occurred: E0161, E0507. | ||
For more information about an error, try `rustc --explain E0161`. | ||
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,3 @@ | ||
#![feature(unsized_locals)] | ||
|
||
pub fn udrop<T: ?Sized>(_x: T) {} |
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,7 @@ | ||
#![feature(unsized_locals)] | ||
|
||
fn main() { | ||
struct A<X: ?Sized>(X); | ||
A as fn(str) -> A<str>; | ||
//~^ERROR the size for values of type `str` cannot be known at compilation time | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/unsized-locals/issue-50940-with-feature.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,14 @@ | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/issue-50940-with-feature.rs:5:5 | ||
| | ||
LL | A as fn(str) -> A<str>; | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: within `main::A<str>`, the trait `std::marker::Sized` is not implemented for `str` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
= note: required because it appears within the type `main::A<str>` | ||
= note: the return type of a function must have a statically known size | ||
|
||
error: aborting due to previous error | ||
|
||
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,5 @@ | ||
fn main() { | ||
struct A<X: ?Sized>(X); | ||
A as fn(str) -> A<str>; | ||
//~^ERROR the size for values of type `str` cannot be known at compilation time | ||
} |
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,14 @@ | ||
error[E0277]: the size for values of type `str` cannot be known at compilation time | ||
--> $DIR/issue-50940.rs:3:5 | ||
| | ||
LL | A as fn(str) -> A<str>; | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `std::marker::Sized` is not implemented for `str` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
= note: all function arguments must have a statically known size | ||
= help: unsized locals are gated as an unstable feature | ||
|
||
error: aborting due to previous error | ||
|
||
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
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,10 @@ | ||
// aux-build:ufuncs.rs | ||
|
||
extern crate ufuncs; | ||
|
||
use ufuncs::udrop; | ||
|
||
fn main() { | ||
udrop as fn([u8]); | ||
//~^ERROR 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,14 @@ | ||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/unsized-exprs3.rs:8:5 | ||
| | ||
LL | udrop as fn([u8]); | ||
| ^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `std::marker::Sized` is not implemented for `[u8]` | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | ||
= note: all function arguments must have a statically known size | ||
= help: unsized locals are gated as an unstable feature | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |