Skip to content
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

Fix clippy warnings, and make CI pedantic #104

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets
run: cargo clippy --all-targets -- -D warnings
- name: Build docs
run: cargo doc --no-deps --all-features
env:
Expand All @@ -43,6 +43,9 @@ jobs:
uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0-rust-nightly
- name: Run miri
run: cargo miri test

Expand All @@ -65,7 +68,7 @@ jobs:
strategy:
matrix:
include:
#- rust: 1.68.0 # Update once MSRV != stable
#- rust: 1.69.0 # Update once MSRV != stable
- rust: stable
cache: true
- rust: beta
Expand Down
5 changes: 3 additions & 2 deletions src/algorithm/half_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct HalfNodeView<'a, H> {
}

impl<'a, H: HugrView> HalfNodeView<'a, H> {
#[allow(unused)]
pub(crate) fn new(h: &'a H, cfg: CfgID) -> Self {
let mut children = h.children(cfg.node());
let entry = children.next().unwrap(); // Panic if malformed
Expand Down Expand Up @@ -70,7 +71,7 @@ impl<H: HugrView> CfgView<HalfNode> for HalfNodeView<'_, H> {
assert!(self.bb_succs(self.exit).count() == 0);
HalfNode::N(self.exit)
}
fn predecessors<'a>(&'a self, h: HalfNode) -> Self::Iterator<'a> {
fn predecessors(&self, h: HalfNode) -> Self::Iterator<'_> {
let mut ps = Vec::new();
match h {
HalfNode::N(ni) => ps.extend(self.bb_preds(ni).map(|n| self.resolve_out(n))),
Expand All @@ -81,7 +82,7 @@ impl<H: HugrView> CfgView<HalfNode> for HalfNodeView<'_, H> {
}
ps.into_iter()
}
fn successors<'a>(&'a self, n: HalfNode) -> Self::Iterator<'a> {
fn successors(&self, n: HalfNode) -> Self::Iterator<'_> {
let mut succs = Vec::new();
match n {
HalfNode::N(ni) if self.is_multi_node(ni) => succs.push(HalfNode::X(ni)),
Expand Down
12 changes: 6 additions & 6 deletions src/algorithm/nest_cfgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ pub trait CfgView<T> {
where
Self: 'c;
/// Returns an iterator over the successors of the specified basic block.
fn successors<'c>(&'c self, node: T) -> Self::Iterator<'c>;
fn successors(&self, node: T) -> Self::Iterator<'_>;
/// Returns an iterator over the predecessors of the specified basic block.
fn predecessors<'c>(&'c self, node: T) -> Self::Iterator<'c>;
fn predecessors(&self, node: T) -> Self::Iterator<'_>;
}

/// Directed edges in a Cfg - i.e. along which control flows from first to second only.
Expand Down Expand Up @@ -156,11 +156,11 @@ impl<H: HugrView> CfgView<Node> for SimpleCfgView<'_, H> {
where
Self: 'c;

fn successors<'c>(&'c self, node: Node) -> Self::Iterator<'c> {
fn successors(&self, node: Node) -> Self::Iterator<'_> {
self.h.neighbours(node, Direction::Outgoing)
}

fn predecessors<'c>(&'c self, node: Node) -> Self::Iterator<'c> {
fn predecessors(&self, node: Node) -> Self::Iterator<'_> {
self.h.neighbours(node, Direction::Incoming)
}
}
Expand Down Expand Up @@ -258,7 +258,7 @@ impl<T: Copy + Clone + PartialEq + Eq + Hash> BracketList<T> {
pub fn concat(&mut self, other: BracketList<T>) {
let BracketList { mut items, size } = other;
self.items.append(&mut items);
assert!(items.len() == 0);
assert!(items.is_empty());
self.size += size;
}

Expand Down Expand Up @@ -384,7 +384,7 @@ impl<T: Copy + Clone + PartialEq + Eq + Hash> EdgeClassifier<T> {
// Now calculate edge classes
let class = bs.tag(&self.deleted_backedges);
if let Some((Bracket::Real(e), 1)) = &class {
self.edge_classes.insert(e.clone(), class.clone());
self.edge_classes.insert(*e, class.clone());
}
if let Some(parent_edge) = tree.dfs_parents.get(&n) {
self.edge_classes.insert(cfg_edge(n, *parent_edge), class);
Expand Down