Skip to content

Commit

Permalink
Cargo clippy and undo exposing the GraphNodeID in GraphNodeRef
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Jun 14, 2024
1 parent 9501994 commit 9a2689d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[path = "generated/binding_rules.rs"]
mod binding_rules;

use metaslang_graph_builder::{ast, ParseError};
pub use metaslang_graph_builder::functions::Functions;
use metaslang_graph_builder::{ast, ParseError};
pub use metaslang_graph_builder::{ExecutionConfig, ExecutionError, NoCancellation, Variables};

use crate::cst::KindTypes;
Expand Down
2 changes: 1 addition & 1 deletion crates/metaslang/graph_builder/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ impl std::fmt::Debug for SyntaxNodeRef {

/// A reference to a graph node
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct GraphNodeRef(pub GraphNodeID);
pub struct GraphNodeRef(GraphNodeID);

impl GraphNodeRef {
/// Returns the index of the graph node that this reference refers to.
Expand Down
2 changes: 1 addition & 1 deletion crates/solidity/outputs/cargo/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ infra_utils = { workspace = true }
once_cell = { workspace = true }
regex = { workspace = true }
semver = { workspace = true }
slang_solidity = { workspace = true, features = ["__private_ariadne"] }
slang_solidity = { workspace = true, features = ["__private_ariadne", "__experimental_bindings_api"] }
solidity_language = { workspace = true }
strum_macros = { workspace = true }

Expand Down
19 changes: 10 additions & 9 deletions crates/solidity/outputs/cargo/tests/src/graph_output/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std::fmt;
use std::fs::{self, create_dir_all};

use anyhow::Result;
use infra_utils::cargo::CargoWorkspace;
use infra_utils::paths::FileWalker;
Expand All @@ -6,8 +9,6 @@ use slang_solidity::bindings::{
get_stack_graph_builder, ExecutionConfig, Functions, Graph, NoCancellation, Variables,
};
use slang_solidity::language::Language;
use std::fmt;
use std::fs::{self, create_dir_all};

#[test]
pub fn run_all() -> Result<()> {
Expand Down Expand Up @@ -51,28 +52,28 @@ fn run(file_name: &str) -> Result<()> {
Ok(())
}

fn print_graph_as_mermaid<'a>(graph: &'a Graph) -> impl fmt::Display + 'a {
fn print_graph_as_mermaid(graph: &Graph) -> impl fmt::Display + '_ {
struct DisplayGraph<'a>(&'a Graph);

impl<'a> fmt::Display for DisplayGraph<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let graph = self.0;
write!(f, "graph TD\n")?;
writeln!(f, "graph TD")?;
for node in graph.iter_nodes() {
let gn = &graph[node];
let node_label = if let Some(symbol) = gn.attributes.get("symbol") {
symbol.to_string()
} else {
format!("{}", node.0)
format!("{}", node.index())
};
let node_type = gn.attributes.get("type").and_then(|x| x.as_str().ok());
match node_type {
Some("push_symbol") => write!(f, "\tN{}[/{}\\]\n", node.0, node_label)?,
Some("pop_symbol") => write!(f, "\tN{}[\\{}/]\n", node.0, node_label)?,
_ => write!(f, "\tN{}[{}]\n", node.0, node_label)?,
Some("push_symbol") => writeln!(f, "\tN{}[/{}\\]", node.index(), node_label)?,
Some("pop_symbol") => writeln!(f, "\tN{}[\\{}/]", node.index(), node_label)?,
_ => writeln!(f, "\tN{}[{}]", node.index(), node_label)?,
}
for (sink, _edge) in gn.iter_edges() {
write!(f, "\tN{} --> N{}\n", node.0, sink.0)?;
writeln!(f, "\tN{} --> N{}", node.index(), sink.index())?;
}
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/solidity/outputs/cargo/tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(test)]

mod cst_output;
mod graph_output;
mod doc_examples;
mod graph_output;
mod trivia;

0 comments on commit 9a2689d

Please sign in to comment.