-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Replace NullOp::SizeOf and NullOp::AlignOf by lang items. #147793
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -414,8 +414,6 @@ fn report_eval_error<'tcx>( | |
| let (error, backtrace) = error.into_parts(); | ||
| backtrace.print_backtrace(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one here should stay -- it's part of how |
||
|
|
||
| let instance = with_no_trimmed_paths!(cid.instance.to_string()); | ||
|
|
||
| super::report( | ||
| ecx, | ||
| error, | ||
|
|
@@ -430,7 +428,7 @@ fn report_eval_error<'tcx>( | |
| diag.subdiagnostic(frame); | ||
| } | ||
| // Add after the frame rendering above, as it adds its own `instance` args. | ||
| diag.arg("instance", instance); | ||
| diag.arg("instance", with_no_trimmed_paths!(cid.instance.to_string())); | ||
| diag.arg("num_frames", num_frames); | ||
| }, | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,6 +156,24 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { | |
| let b_ty = self.read_type_id(&args[1])?; | ||
| self.write_scalar(Scalar::from_bool(a_ty == b_ty), dest)?; | ||
| } | ||
| sym::size_of => { | ||
| let tp_ty = instance.args.type_at(0); | ||
| let layout = self.layout_of(tp_ty)?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need a monomorphic enough check here to avoid the cycle error from #149081
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you say more oli? I could try to look at it, but I'm not sure what you mean here. Delay it until later? Skip evaluating it if there's a generic in here still? Use something like the transmute logic that can sometimes give sizes for generic things?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I should have expanded more -- I guess it's just another |
||
| if !layout.is_sized() { | ||
| span_bug!(self.cur_span(), "unsized type for `size_of`"); | ||
| } | ||
| let val = layout.size.bytes(); | ||
| self.write_scalar(Scalar::from_target_usize(val, self), dest)?; | ||
| } | ||
| sym::align_of => { | ||
| let tp_ty = instance.args.type_at(0); | ||
| let layout = self.layout_of(tp_ty)?; | ||
| if !layout.is_sized() { | ||
| span_bug!(self.cur_span(), "unsized type for `align_of`"); | ||
| } | ||
| let val = layout.align.bytes(); | ||
| self.write_scalar(Scalar::from_target_usize(val, self), dest)?; | ||
| } | ||
| sym::variant_count => { | ||
| let tp_ty = instance.args.type_at(0); | ||
| let ty = match tp_ty.kind() { | ||
|
|
||
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.
(No action) I do like that this means the different backends don't need this any more, which is nice since it all needs to match what CTFE did anyway 👍