Skip to content

Use ECX for ty consts#192

Open
ThomasMayerl wants to merge 2 commits into
Aurel300:rewrite-2023from
ThomasMayerl:use_ecx_for_ty_consts
Open

Use ECX for ty consts#192
ThomasMayerl wants to merge 2 commits into
Aurel300:rewrite-2023from
ThomasMayerl:use_ecx_for_ty_consts

Conversation

@ThomasMayerl

@ThomasMayerl ThomasMayerl commented Jul 21, 2026

Copy link
Copy Markdown

This PR combines the control flows for mir consts and ty val consts by using the ECX for the latter as well. This PR also removes the use of arbitrary values for string consts completely (instead, each const leads to one fresh function).
Because of the unavailability of span in args_ty.rs, ty consts currently use a dummy span, meaning that the fresh constant functions will always start with const_1_0

@ThomasMayerl
ThomasMayerl force-pushed the use_ecx_for_ty_consts branch from f6415f5 to c4467f1 Compare July 21, 2026 13:50
@ThomasMayerl
ThomasMayerl marked this pull request as ready for review July 21, 2026 15:13
ty::ConstKind::Value(val) => {
let val = vir::with_vcx(|vcx| vcx.tcx().valtree_to_const_val(val));
Self::encode_const_val_ty(deps, val, ty)
// TODO: Exchange DUMMY_SP here and below with an actual Span. Otherwise opaque functions will always start with const_1_0

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not great -- is it the case that when we request an encoding we should have a span? Maybe at the same place we get the context from?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The place where this gets called is args_ty.rs which doesn't have access to the span. Is there a way to get the span?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this lead to name clases (in particular due to macro expansion), or is it just a cosmetic issue? If it's the latter, then you can make the inputs be optional so the span part of the identifier is just not emitted.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @JonasAlaif knows more about this but from what I understand, the fresh function will always add a auto-incrementing ID as well? So I guess it should just be cosmetic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants