Skip to content

Support constants in const eval #11772

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

Merged
merged 3 commits into from
Mar 24, 2022
Merged

Support constants in const eval #11772

merged 3 commits into from
Mar 24, 2022

Conversation

HKalbasi
Copy link
Member

This PR enables evaluating things like this:

const X: usize = 2;
const Y: usize = 3 + X; // = 5

My target was nalgebra's U5, U22, ... which are defined as type U5 = Const<{ SomeType5::SOME_ASSOC_CONST }> but I didn't find out how to find the ConstId of the implementation of the trait, not the trait itself (possibly related to #4558 ? We can find associated type alias, so maybe this is doable already) So it doesn't help for nalgebra currently, but it is useful anyway.

Copy link
Member

@flodiebold flodiebold left a comment

Choose a reason for hiding this comment

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

Looks good! We should really start having a proper test suite for this though.

I didn't find out how to find the ConstId of the implementation of the trait, not the trait itself (possibly related to #4558 ? We can find associated type alias, so maybe this is doable already)

That's exactly that issue. And yes, it's very similar to normalizing type aliases, but Chalk can't do it for functions or consts yet.

bors d+

@bors
Copy link
Contributor

bors bot commented Mar 20, 2022

✌️ HKalbasi can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@HKalbasi
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 24, 2022

@bors bors bot merged commit f3d1a53 into rust-lang:master Mar 24, 2022
@HKalbasi
Copy link
Member Author

image

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