-
Notifications
You must be signed in to change notification settings - Fork 595
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
feat: cairo-lang-utils supports no_std #4759
Conversation
c1841c3
to
b8d790e
Compare
b8d790e
to
ea92a1a
Compare
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.
Reviewed 6 of 75 files at r1, all commit messages.
Reviewable status: 6 of 75 files reviewed, 2 unresolved discussions (waiting on @tdelabro)
.github/workflows/ci.yml
line 58 at r1 (raw file):
- test -p cairo-lang-utils --no-default-features --features=serde - test -p tests steps:
Suggestion:
- test -p cairo-lang-utils
- test -p cairo-lang-utils --no-default-features --features=serde - test -p tests
steps:
crates/bin/starknet-sierra-compile/Cargo.toml
line 17 at r1 (raw file):
cairo-lang-sierra = { path = "../../cairo-lang-sierra", version = "2.4.1" } cairo-lang-starknet = { path = "../../cairo-lang-starknet", version = "2.4.1" } cairo-lang-utils = { path = "../../cairo-lang-utils", version = "2.4.1" }
why can the versions be removed?
Code quote:
cairo-lang-sierra = { path = "../../cairo-lang-sierra", version = "2.4.1" }
cairo-lang-starknet = { path = "../../cairo-lang-starknet", version = "2.4.1" }
cairo-lang-utils = { path = "../../cairo-lang-utils", version = "2.4.1" }
I though it was needless redundancy but after looking at the rust doc it seems that adding the version is required to be able to publish the crate on crates.io. My bad, I will revert those. |
@orizi Sorry I don't get what you are suggesting. What will be the behavior if I put both |
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.
Reviewed 58 of 75 files at r1, 12 of 12 files at r2, all commit messages.
Reviewable status: 74 of 76 files reviewed, 3 unresolved discussions (waiting on @tdelabro)
crates/cairo-lang-lowering/src/graph_algorithms/strongly_connected_components.rs
line 31 at r2 (raw file):
function_id: ConcreteFunctionWithBodyId, ) -> Vec<ConcreteFunctionWithBodyId> { compute_scc::<_, RandomState>(&ConcreteFunctionWithBodyPostInlineNode {
why is this a must now?
crates/cairo-lang-lowering/src/lower/mod.rs
line 486 at r2 (raw file):
.concrete_struct_members(structure.concrete_struct_id) .map_err(LoweringFlowError::Failed)?; let mut required_members = UnorderedHashMap::<_, _, RandomState>::from_iter(
i don't want us to have to do this ever.
how can this be avoided?
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 - just remove the space at the end of the line.
also - answer in reviewable so we'd have threads.
Reviewable status: 74 of 76 files reviewed, 3 unresolved discussions (waiting on @tdelabro)
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.
Reviewable status: 67 of 76 files reviewed, 3 unresolved discussions (waiting on @orizi)
.github/workflows/ci.yml
line 58 at r1 (raw file):
- test -p cairo-lang-utils --no-default-features --features=serde - test -p tests steps:
Done.
crates/cairo-lang-lowering/src/lower/mod.rs
line 486 at r2 (raw file):
Previously, orizi wrote…
i don't want us to have to do this ever.
how can this be avoided?
For compute_scc
the simplest way it to not make mod graph_algos;
no_std.
It is only used on cairo-lang-lowering which we don't plan to make no_std anytime soon.
So I put it behind a feature flag and we don't have to worry about it anymore.
For UnorderedHashMap
you can just do UnorderedHashMap::<_, _>::from_iter
. By not mentioning the last generic type, its default type will be used. Which is RandomState
.
crates/cairo-lang-lowering/src/graph_algorithms/strongly_connected_components.rs
line 31 at r2 (raw file):
Previously, orizi wrote…
why is this a must now?
Done.
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.
Reviewed 4 of 9 files at r3, all commit messages.
Reviewable status: 71 of 76 files reviewed, 4 unresolved discussions (waiting on @tdelabro)
crates/cairo-lang-lowering/src/lower/mod.rs
line 486 at r2 (raw file):
Previously, tdelabro (Timothée Delabrouille) wrote…
For
compute_scc
the simplest way it to not makemod graph_algos;
no_std.
It is only used on cairo-lang-lowering which we don't plan to make no_std anytime soon.So I put it behind a feature flag and we don't have to worry about it anymore.
For
UnorderedHashMap
you can just doUnorderedHashMap::<_, _>::from_iter
. By not mentioning the last generic type, its default type will be used. Which isRandomState
.
why do i need the first 2?
crates/cairo-lang-utils/src/graph_algos/feedback_set_test.rs
line 94 at r3 (raw file):
let fset = HashSet::<usize>::from_iter(calc_feedback_set::<_>(&IntegerNode { id: 0, graph }.into()));
why do i need <_> all around?
crates/cairo-lang-utils/src/graph_algos/strongly_connected_components.rs
line 50 at r3 (raw file):
impl<Node: GraphNode> SccAlgoContext<Node> { fn new(target_node_id: Node::NodeId) -> Self {
the base impl of the type itself may be with no extra empty line.
Suggestion:
}
impl<Node: GraphNode> SccAlgoContext<Node> {
fn new(target_node_id: Node::NodeId) -> Self {
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.
Reviewed 2 of 9 files at r3.
Reviewable status: 73 of 76 files reviewed, 3 unresolved discussions (waiting on @tdelabro)
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.
Reviewable status: 73 of 76 files reviewed, 3 unresolved discussions (waiting on @orizi)
crates/cairo-lang-lowering/src/lower/mod.rs
line 486 at r2 (raw file):
Previously, orizi wrote…
why do i need the first 2?
I found this explanation helpful: https://stackoverflow.com/a/65620283/9967008
crates/cairo-lang-utils/src/graph_algos/feedback_set_test.rs
line 94 at r3 (raw file):
Previously, orizi wrote…
why do i need <_> all around?
We don't anymore after it removed the mod from no_std.
I changed it back
crates/cairo-lang-utils/src/graph_algos/strongly_connected_components.rs
line 50 at r3 (raw file):
Previously, orizi wrote…
the base impl of the type itself may be with no extra empty line.
Done.
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.
Reviewed 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @tdelabro)
crates/cairo-lang-lowering/src/lower/mod.rs
line 486 at r2 (raw file):
Previously, tdelabro (Timothée Delabrouille) wrote…
It's explained quite clearly here: https://stackoverflow.com/a/65620283/9967008
my main contention was that i didn't need it previously. but ok.
crates/cairo-lang-utils/src/graph_algos/feedback_set_test.rs
line 35 at r4 (raw file):
fn compute_scc(&self) -> Vec<Self::NodeId> { compute_scc::<_>(self) }
Suggestion:
compute_scc(self)
}
crates/cairo-lang-utils/src/graph_algos/strongly_connected_components.rs
line 64 at r4 (raw file):
let mut ctx = SccAlgoContext::<_>::new(root.get_id()); compute_scc_recursive(&mut ctx, root); ctx.result
Suggestion:
/// Computes the SCC (Strongly Connected Component) of the given node in its graph.
pub fn compute_scc<Node: GraphNode>(root: &Node) -> Vec<Node::NodeId> {
let mut ctx = SccAlgoContext::new(root.get_id());
compute_scc_recursive(&mut ctx, root);
ctx.result
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @orizi)
crates/cairo-lang-utils/src/graph_algos/feedback_set_test.rs
line 35 at r4 (raw file):
fn compute_scc(&self) -> Vec<Self::NodeId> { compute_scc::<_>(self) }
Done.
crates/cairo-lang-utils/src/graph_algos/strongly_connected_components.rs
line 64 at r4 (raw file):
let mut ctx = SccAlgoContext::<_>::new(root.get_id()); compute_scc_recursive(&mut ctx, root); ctx.result
Done.
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.
Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @tdelabro)
supersede #3297
In this PR:
ensure-no_std
to workspaceensure-no_std
in the CIIndex
andIndexMut
impl ofOrderedHashMap
is changed, arg is now a reference, to match the inner type signature and avoid unnecessaryclone
<Un>OrderedHash<Map/Set>
types have no constraint over their generics. The constraint is only enforced at theimpl
code block level, where they are requirednew()
for<Un>OrderedHash<Map/Set>
types behind astd
flag. They usesstd::collections::hash_map::RandomState
as itsHashBuilder
types like it's implicitly done instd
rust for their internal types.Once this one is merged, I will do the follow up for
cairo-lang-casm
This change is