Skip to content

Commit

Permalink
Fixes paths thing (#920)
Browse files Browse the repository at this point in the history
* fixes paths thing 
* add @nilehmann 's fix to check for empty strings!
  • Loading branch information
ranjitjhala authored Dec 4, 2024
1 parent 84dd708 commit 6aa7728
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
35 changes: 33 additions & 2 deletions crates/flux-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn is_cache_enabled() -> bool {
}

pub fn is_checked_file(file: &str) -> bool {
CONFIG.check_files.is_empty() || CONFIG.check_files.contains(file)
CONFIG.check_files.is_checked_file(file)
}

pub fn cache_path() -> PathBuf {
Expand Down Expand Up @@ -85,13 +85,44 @@ struct Config {
catch_bugs: bool,
pointer_width: PointerWidth,
check_def: String,
check_files: String,
check_files: Paths,
cache: bool,
cache_file: String,
check_overflow: bool,
scrape_quals: bool,
}

#[derive(Default)]
struct Paths {
paths: Option<Vec<PathBuf>>,
}

impl Paths {
fn is_checked_file(&self, file: &str) -> bool {
self.paths
.as_ref()
.map_or(true, |p| p.iter().any(|p| p.to_str().unwrap() == file))
}
}

impl<'de> Deserialize<'de> for Paths {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let paths: Vec<PathBuf> = String::deserialize(deserializer)?
.split(",")
.map(str::trim)
.filter(|s| !s.is_empty())
.map(PathBuf::from)
.collect();

let paths = if paths.is_empty() { None } else { Some(paths) };

Ok(Paths { paths })
}
}

#[derive(Copy, Clone, Deserialize)]
#[serde(try_from = "u8")]
pub enum PointerWidth {
Expand Down
2 changes: 1 addition & 1 deletion crates/flux-driver/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<'genv, 'tcx> CrateChecker<'genv, 'tcx> {
return config::is_checked_file(&file);
}
}
return true;
true
}

fn check_def_catching_bugs(&mut self, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> {
Expand Down

0 comments on commit 6aa7728

Please sign in to comment.