Skip to content

Commit

Permalink
Implements #[allow(dead_code)] (FuelLabs#4170)
Browse files Browse the repository at this point in the history
## Description
Added support for new attribute #[allow(dead_code)]

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
esdrubal authored Mar 2, 2023
1 parent 829cb7c commit 50ab59e
Show file tree
Hide file tree
Showing 16 changed files with 459 additions and 75 deletions.
14 changes: 7 additions & 7 deletions sway-core/src/control_flow_analysis/analyze_return_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'cfg> ControlFlowGraph<'cfg> {
let mut last_discovered_span;
for rover in rovers {
last_discovered_span = match &self.graph[rover] {
ControlFlowGraphNode::ProgramNode(node) => Some(node.span.clone()),
ControlFlowGraphNode::ProgramNode { node, .. } => Some(node.span.clone()),
ControlFlowGraphNode::MethodDeclaration { span, .. } => Some(span.clone()),
_ => None,
};
Expand Down Expand Up @@ -137,7 +137,7 @@ fn connect_node<'eng: 'cfg, 'cfg>(
..
})
| ty::TyAstNodeContent::ImplicitReturnExpression(_) => {
let this_index = graph.add_node(node.into());
let this_index = graph.add_node(ControlFlowGraphNode::from_node(node));
for leaf_ix in leaves {
graph.add_edge(*leaf_ix, this_index, "".into());
}
Expand All @@ -150,14 +150,14 @@ fn connect_node<'eng: 'cfg, 'cfg>(
// An abridged version of the dead code analysis for a while loop
// since we don't really care about what the loop body contains when detecting
// divergent paths
let node = graph.add_node(node.into());
let node = graph.add_node(ControlFlowGraphNode::from_node(node));
for leaf in leaves {
graph.add_edge(*leaf, node, "while loop entry".into());
}
Ok(NodeConnection::NextStep(vec![node]))
}
ty::TyAstNodeContent::Expression(ty::TyExpression { .. }) => {
let entry = graph.add_node(node.into());
let entry = graph.add_node(ControlFlowGraphNode::from_node(node));
// insert organizational dominator node
// connected to all current leaves
for leaf in leaves {
Expand Down Expand Up @@ -189,15 +189,15 @@ fn connect_declaration<'eng: 'cfg, 'cfg>(
| StorageDeclaration { .. }
| GenericTypeForFunctionScope { .. } => Ok(leaves.to_vec()),
VariableDeclaration(_) | ConstantDeclaration { .. } => {
let entry_node = graph.add_node(node.into());
let entry_node = graph.add_node(ControlFlowGraphNode::from_node(node));
for leaf in leaves {
graph.add_edge(*leaf, entry_node, "".into());
}
Ok(vec![entry_node])
}
FunctionDeclaration { decl_id, .. } => {
let fn_decl = decl_engine.get_function(decl_id);
let entry_node = graph.add_node(node.into());
let entry_node = graph.add_node(ControlFlowGraphNode::from_node(node));
for leaf in leaves {
graph.add_edge(*leaf, entry_node, "".into());
}
Expand All @@ -208,7 +208,7 @@ fn connect_declaration<'eng: 'cfg, 'cfg>(
let ty::TyImplTrait {
trait_name, items, ..
} = decl_engine.get_impl_trait(decl_id);
let entry_node = graph.add_node(node.into());
let entry_node = graph.add_node(ControlFlowGraphNode::from_node(node));
for leaf in leaves {
graph.add_edge(*leaf, entry_node, "".into());
}
Expand Down
Loading

0 comments on commit 50ab59e

Please sign in to comment.