-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce that dyn* casts are actually pointer-sized
- Loading branch information
1 parent
6d651a2
commit 84b06d5
Showing
10 changed files
with
132 additions
and
8 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
15 changes: 15 additions & 0 deletions
15
src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs
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,15 @@ | ||
#![feature(dyn_star)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn dyn_debug(_: (dyn* Debug + '_)) { | ||
|
||
} | ||
|
||
fn polymorphic<T: Debug + ?Sized>(t: &T) { | ||
dyn_debug(t); | ||
//~^ ERROR `&T` needs to be a pointer-sized type | ||
} | ||
|
||
fn main() {} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.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,15 @@ | ||
error[E0277]: `&T` needs to be a pointer-sized type | ||
--> $DIR/check-size-at-cast-polymorphic-bad.rs:11:15 | ||
| | ||
LL | dyn_debug(t); | ||
| ^ `&T` needs to be a pointer-sized type | ||
| | ||
= help: the trait `PointerSized` is not implemented for `&T` | ||
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | ||
| | ||
LL | fn polymorphic<T: Debug + ?Sized>(t: &T) where &T: PointerSized { | ||
| ++++++++++++++++++++++ | ||
|
||
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,16 @@ | ||
// check-pass | ||
|
||
#![feature(dyn_star)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn dyn_debug(_: (dyn* Debug + '_)) { | ||
|
||
} | ||
|
||
fn polymorphic<T: Debug>(t: &T) { | ||
dyn_debug(t); | ||
} | ||
|
||
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,10 @@ | ||
#![feature(dyn_star)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::fmt::Debug; | ||
|
||
fn main() { | ||
let i = [1, 2, 3, 4] as dyn* Debug; | ||
//~^ ERROR `[i32; 4]` needs to be a pointer-sized type | ||
dbg!(i); | ||
} |
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,11 @@ | ||
error[E0277]: `[i32; 4]` needs to be a pointer-sized type | ||
--> $DIR/check-size-at-cast.rs:7:13 | ||
| | ||
LL | let i = [1, 2, 3, 4] as dyn* Debug; | ||
| ^^^^^^^^^^^^ `[i32; 4]` needs to be a pointer-sized type | ||
| | ||
= help: the trait `PointerSized` is not implemented for `[i32; 4]` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |