forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#130847 - matthiaskrgr:rollup-f0n80bw, r=matth…
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#130735 (Simple validation for unsize coercion in MIR validation) - rust-lang#130781 (Fix up setting strip = true in Cargo.toml makes build scripts fail in…) - rust-lang#130811 (add link from random() helper fn to extensive DefaultRandomSource docs) - rust-lang#130819 (Add `must_use` attribute to `len_utf8` and `len_utf16`.) - rust-lang#130832 (fix some cfg logic around optimize_for_size and 16-bit targets) - rust-lang#130842 (Add tracking issue for io_error_inprogress) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
13 changed files
with
145 additions
and
48 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
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
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 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,33 @@ | ||
//@ compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+Inline,+GVN -Zvalidate-mir | ||
|
||
#![feature(unsize)] | ||
|
||
use std::marker::Unsize; | ||
|
||
pub trait CastTo<U: ?Sized>: Unsize<U> {} | ||
|
||
// Not well-formed! | ||
impl<T: ?Sized, U: ?Sized> CastTo<U> for T {} | ||
//~^ ERROR the trait bound `T: Unsize<U>` is not satisfied | ||
|
||
pub trait Cast { | ||
fn cast<U: ?Sized>(&self) | ||
where | ||
Self: CastTo<U>; | ||
} | ||
impl<T: ?Sized> Cast for T { | ||
#[inline(always)] | ||
fn cast<U: ?Sized>(&self) | ||
where | ||
Self: CastTo<U>, | ||
{ | ||
let x: &U = self; | ||
} | ||
} | ||
|
||
fn main() { | ||
// When we inline this call, then we run GVN, then | ||
// GVN tries to evaluate the `() -> [i32]` unsize. | ||
// That's invalid! | ||
().cast::<[i32]>(); | ||
} |
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 @@ | ||
error[E0277]: the trait bound `T: Unsize<U>` is not satisfied | ||
--> $DIR/validate-unsize-cast.rs:10:42 | ||
| | ||
LL | impl<T: ?Sized, U: ?Sized> CastTo<U> for T {} | ||
| ^ the trait `Unsize<U>` is not implemented for `T` | ||
| | ||
= note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information | ||
note: required by a bound in `CastTo` | ||
--> $DIR/validate-unsize-cast.rs:7:30 | ||
| | ||
LL | pub trait CastTo<U: ?Sized>: Unsize<U> {} | ||
| ^^^^^^^^^ required by this bound in `CastTo` | ||
help: consider further restricting this bound | ||
| | ||
LL | impl<T: ?Sized + std::marker::Unsize<U>, U: ?Sized> CastTo<U> for T {} | ||
| ++++++++++++++++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |