Skip to content

Commit 920cf4b

Browse files
committed
Auto merge of #27596 - tsion:fix-27450, r=arielb1
Fixes #27450. r? @steveklabnik
2 parents e5d90d9 + f351e76 commit 920cf4b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/librustc_typeck/check/cast.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ enum CastError {
100100
DifferingKinds,
101101
IllegalCast,
102102
NeedViaPtr,
103+
NeedViaThinPtr,
103104
NeedViaInt,
104105
NeedViaUsize,
105106
NonScalar,
@@ -120,6 +121,7 @@ impl<'tcx> CastCheck<'tcx> {
120121
e: CastError) {
121122
match e {
122123
CastError::NeedViaPtr |
124+
CastError::NeedViaThinPtr |
123125
CastError::NeedViaInt |
124126
CastError::NeedViaUsize => {
125127
fcx.type_error_message(self.span, |actual| {
@@ -130,6 +132,7 @@ impl<'tcx> CastCheck<'tcx> {
130132
fcx.ccx.tcx.sess.fileline_help(self.span,
131133
&format!("cast through {} first", match e {
132134
CastError::NeedViaPtr => "a raw pointer",
135+
CastError::NeedViaThinPtr => "a thin pointer",
133136
CastError::NeedViaInt => "an integer",
134137
CastError::NeedViaUsize => "a usize",
135138
_ => unreachable!()
@@ -324,7 +327,7 @@ impl<'tcx> CastCheck<'tcx> {
324327
if fcx.type_is_known_to_be_sized(m_expr.ty, self.span) {
325328
Ok(CastKind::PtrAddrCast)
326329
} else {
327-
Err(CastError::NeedViaPtr)
330+
Err(CastError::NeedViaThinPtr)
328331
}
329332
}
330333

src/test/compile-fail/cast-rfc0401.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn main()
9696
let _ = &f as *const f64; //~ ERROR casting
9797
let _ = fat_v as usize;
9898
//~^ ERROR casting
99-
//~^^ HELP through a raw pointer first
99+
//~^^ HELP through a thin pointer first
100100

101101
let a : *const str = "hello";
102102
let _ = a as *const Foo;

src/test/compile-fail/fat-ptr-cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
b as usize; //~ ERROR non-scalar cast
2222
p as usize;
2323
//~^ ERROR casting
24-
//~^^ HELP cast through a raw pointer
24+
//~^^ HELP cast through a thin pointer
2525

2626
// #22955
2727
q as *const [i32]; //~ ERROR casting

0 commit comments

Comments
 (0)