-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
casting &[u8]
to * const u8
doesn't work in const_eval
#33457
Conversation
@@ -1117,6 +1117,10 @@ fn cast_const<'tcx>(tcx: &TyCtxt<'tcx>, val: ConstVal, ty: ty::Ty) -> CastResult | |||
Float(f) => cast_const_float(tcx, f, ty), | |||
Char(c) => cast_const_int(tcx, Infer(c as u64), ty), | |||
Function(_) => Err(UnimplementedConstVal("casting fn pointers")), | |||
ByteStr(_) => match ty.sty { | |||
ty::TyRawPtr(_) => Err(ErrKind::UnimplementedConstVal("casting a bytestr to a raw ptr")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this help? Wouldn't it still error?
EDIT: I think... I see? Can't be done in const_eval
but is still constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, and the const_err
lint ignores some kinds of errors, since there's no point in informing the user that const_eval can't evaluate it unless they try to use it in an array length or pattern.
@bors r+ |
📌 Commit d818a08 has been approved by |
|
And travis complains:
|
@bors r- Until the tidy failure is fixed. |
d818a08
to
7461e45
Compare
done |
@bors r+ |
📌 Commit 7461e45 has been approved by |
fixes #33452
r? @eddyb
cc @Ms2ger