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 c15fa41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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
14 changes: 7 additions & 7 deletions crates/solidity/outputs/cargo/tests/src/graph_output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,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

0 comments on commit c15fa41

Please sign in to comment.