Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
jieyouxu marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Regression test for https://github.com/rust-lang/rust/issues/45730

use std::fmt;
fn main() {
let x: *const _ = 0 as _; //~ ERROR cannot cast
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error[E0641]: cannot cast to a pointer of an unknown kind
--> $DIR/issue-45730.rs:3:28
--> $DIR/ambiguous-raw-pointer-cast-errors.rs:5:28
|
LL | let x: *const _ = 0 as _;
| ^ needs more type information
|
= note: the type information given here is insufficient to check whether the pointer cast is valid

error[E0641]: cannot cast to a pointer of an unknown kind
--> $DIR/issue-45730.rs:5:28
--> $DIR/ambiguous-raw-pointer-cast-errors.rs:7:28
|
LL | let x: *const _ = 0 as *const _;
| ^^^^^^^^ needs more type information
|
= note: the type information given here is insufficient to check whether the pointer cast is valid

error[E0641]: cannot cast to a pointer of an unknown kind
--> $DIR/issue-45730.rs:8:44
--> $DIR/ambiguous-raw-pointer-cast-errors.rs:10:44
|
LL | let x = 0 as *const i32 as *const _ as *mut _;
| ^^^^^^ needs more type information
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Regression test for https://github.com/rust-lang/rust/issues/23699

//@ run-pass
#![allow(unused_variables)]
fn gimme_a_raw_pointer<T>(_: *const T) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Regression test for https://github.com/rust-lang/rust/issues/36936

//@ run-pass
// check that casts are not being treated as lexprs.

Expand Down
9 changes: 9 additions & 0 deletions tests/ui/cast/cast-ptr-to-fat-ptr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//! Regression test for https://github.com/rust-lang/rust/issues/30615
//! This test confirms that valid code casting a thin pointer to a fat pointer does not cause ICE
//! and compiles.

//@ run-pass
fn main() {
&0u8 as *const u8 as *const dyn PartialEq<u8>;
&[0u8] as *const [u8; 1] as *const [u8];
}
10 changes: 10 additions & 0 deletions tests/ui/cast/invalid-thin-to-fat-pointer-cast.rs
Comment thread
jieyouxu marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Regression test for https://github.com/rust-lang/rust/issues/31511
//! This test confirms that a helpful enough error is shown when you try
//! to incorrectly cast a thin pointer to a fat pointer.

fn cast_thin_to_fat(x: *const ()) {
x as *const [u8];
//~^ ERROR: cannot cast thin pointer `*const ()` to wide pointer `*const [u8]`
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0607]: cannot cast thin pointer `*const ()` to wide pointer `*const [u8]`
--> $DIR/issue-31511.rs:2:5
--> $DIR/invalid-thin-to-fat-pointer-cast.rs:6:5
|
LL | x as *const [u8];
| ^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Regression test for https://github.com/rust-lang/rust/issues/43291

//@ run-pass
pub fn main() {
assert_eq!(!0usize as *const (), foo(0, 1));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Regression test for https://github.com/rust-lang/rust/issues/22312

use std::ops::Index;

pub trait Array2D: Index<usize> + Sized {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0605]: non-primitive cast: `Self` as `&dyn Index<usize, Output = <Self as Index<usize>>::Output>`
--> $DIR/issue-22312.rs:11:24
--> $DIR/non-primitive-cast-self-to-dyn-index.rs:13:24
|
LL | let indexer = &(*self as &dyn Index<usize, Output = <Self as Index<usize>>::Output>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Regression test for https://github.com/rust-lang/rust/issues/17336

//@ build-pass

#![allow(unused_must_use)]
Expand Down
5 changes: 0 additions & 5 deletions tests/ui/issues/issue-30615.rs

This file was deleted.

6 changes: 0 additions & 6 deletions tests/ui/issues/issue-31511.rs

This file was deleted.

Loading