Skip to content

Commit

Permalink
Formatting and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Dec 18, 2024
1 parent f832de5 commit 15888c1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crates/flowistry_pdg_construction/src/body_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub fn dump_mir_and_borrowck_facts<'tcx>(tcx: TyCtxt<'tcx>) -> (Duration, Durati
let tc_time = tc_start.elapsed();
let dump_time = Instant::now();
let path = intermediate_out_dir(tcx, INTERMEDIATE_ARTIFACT_EXT);
encode_to_file(tcx, &path, &bodies);
encode_to_file(tcx, path, &bodies);
(tc_time, dump_time.elapsed())
}

Expand All @@ -243,7 +243,7 @@ pub fn local_or_remote_paths(krate: CrateNum, tcx: TyCtxt, ext: &str) -> Vec<Pat
}

/// Try to load a [`CachedBody`] for this id.
fn load_body_and_facts<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> BodyMap<'tcx> {
fn load_body_and_facts(tcx: TyCtxt<'_>, krate: CrateNum) -> BodyMap<'_> {
let paths = local_or_remote_paths(krate, tcx, INTERMEDIATE_ARTIFACT_EXT);
for path in &paths {
if !path.exists() {
Expand Down
2 changes: 1 addition & 1 deletion crates/flowistry_pdg_construction/src/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl<'tcx> PartialGraph<'tcx> {
child_graph
.nodes
.iter()
.map(move |dest| (ctrl_src.clone(), dest.clone(), edge.clone()))
.map(move |dest| (ctrl_src, *dest, edge))
}),
);
self.nodes.extend(child_graph.nodes);
Expand Down
5 changes: 2 additions & 3 deletions crates/paralegal-flow/src/ana/inline_judge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ pub enum InlineJudgement {
impl Display for InlineJudgement {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_ref())?;
match self {
Self::AbstractViaType(reason) => write!(f, "({reason})")?,
_ => (),
if let Self::AbstractViaType(reason) = self {
write!(f, "({reason})")?;
}
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions crates/paralegal-flow/src/ana/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<'tcx> SPDGGenerator<'tcx> {

let analyzed_spans = analyzed_functions
.into_iter()
.filter_map(|f| {
.map(|f| {
let body = self.pdg_constructor.body_for_def_id(f);
let span = body_span(tcx, body.body());
let pspan = src_loc_for_span(span, tcx);
Expand All @@ -258,7 +258,7 @@ impl<'tcx> SPDGGenerator<'tcx> {
FunctionHandling::Elided
};

Some((f, (pspan, handling)))
(f, (pspan, handling))
})
.collect::<AnalyzedSpans>();

Expand Down
2 changes: 0 additions & 2 deletions crates/paralegal-flow/tests/control_flow_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#[macro_use]
extern crate lazy_static;

use std::fs::File;

use paralegal_flow::test_utils::*;

const CRATE_DIR: &str = "tests/control-flow-tests";
Expand Down
2 changes: 1 addition & 1 deletion crates/paralegal-policy/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ impl RootContext {
self.desc
.def_info
.iter()
.filter(|(did, _)| self.desc.analyzed_spans.contains_key(&did))
.filter(|(did, _)| self.desc.analyzed_spans.contains_key(did))
.map(|(_, i)| (&i.src_info, matches!(i.kind, DefKind::Type)))
})
.into_iter()
Expand Down
6 changes: 5 additions & 1 deletion crates/paralegal-policy/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ pub fn get_callsite_or_datasink_node<'a>(
.unwrap()
}

pub fn get_callsite_node<'a>(ctx: &'a RootContext, controller: Endpoint, name: &'a str) -> NodeCluster {
pub fn get_callsite_node<'a>(
ctx: &'a RootContext,
controller: Endpoint,
name: &'a str,
) -> NodeCluster {
let name = Identifier::new_intern(name);
let ctrl = &ctx.desc().controllers[&controller];
let inner = ctrl
Expand Down
2 changes: 1 addition & 1 deletion crates/paralegal-policy/tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
use anyhow::anyhow;
pub use anyhow::{ensure, Result};

use paralegal_policy::{RootContext, GraphLocation};
use paralegal_policy::{GraphLocation, RootContext};

lazy_static::lazy_static! {
static ref TOOL_BUILT: PathBuf = {
Expand Down
1 change: 1 addition & 0 deletions guide/deletion-policy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions guide/deletion-policy/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use anyhow::Result;
use paralegal_policy::{
assert_error, paralegal_spdg::traverse::EdgeSelection, Context, Marker, NodeExt,
assert_error, paralegal_spdg::traverse::EdgeSelection, Marker, NodeExt, RootContext,
};
use std::sync::Arc;

fn dummy_policy(_ctx: Arc<Context>) -> Result<()> {
fn dummy_policy(_ctx: Arc<RootContext>) -> Result<()> {
println!("Graph loaded.");
Ok(())
}
Expand All @@ -20,7 +20,7 @@ fn main() -> Result<()> {
}

#[allow(dead_code)]
fn deletion_policy(ctx: Arc<Context>) -> Result<()> {
fn deletion_policy(ctx: Arc<RootContext>) -> Result<()> {
let user_data_types = ctx.marked_type(Marker::new_intern("user_data"));

let found = ctx.all_controllers().any(|(deleter_id, _ignored)| {
Expand Down

0 comments on commit 15888c1

Please sign in to comment.