Skip to content

Commit 3405204

Browse files
committed
Explain all casts in detail
1 parent 507381e commit 3405204

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/librustc_mir/transform/qualify_min_const_fn.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,18 @@ fn check_rvalue(
163163
_ => check_operand(tcx, mir, operand, span),
164164
}
165165
}
166-
Rvalue::Cast(_, _, _) => Err((
166+
Rvalue::Cast(CastKind::UnsafeFnPointer, _, _) |
167+
Rvalue::Cast(CastKind::ReifyFnPointer, _, _) => Err((
167168
span,
168-
"only int casts are allowed in const fn".into(),
169+
"function pointer casts are not allowed in const fn".into(),
170+
)),
171+
Rvalue::Cast(CastKind::ClosureFnPointer, _, _) => Err((
172+
span,
173+
"closures are not allowed in const fn".into(),
174+
)),
175+
Rvalue::Cast(CastKind::Unsize, _, _) => Err((
176+
span,
177+
"unsizing casts are not allowed in const fn".into(),
169178
)),
170179
// binops are fine on integers
171180
Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {

0 commit comments

Comments
 (0)