use std::sync::Arc;
use mir_codebase::StubSlice;
use mir_issues::Issue;
#[salsa::input]
pub struct SourceFile {
pub path: Arc<str>,
pub text: Arc<str>,
}
#[derive(Clone, Debug)]
pub struct FileDefinitions {
pub slice: Arc<StubSlice>,
pub issues: Arc<Vec<Issue>>,
}
impl PartialEq for FileDefinitions {
fn eq(&self, other: &Self) -> bool {
if Arc::ptr_eq(&self.slice, &other.slice) {
return true;
}
*self.slice == *other.slice
}
}
unsafe impl salsa::Update for FileDefinitions {
unsafe fn maybe_update(old_ptr: *mut Self, new_val: Self) -> bool {
let old = unsafe { &mut *old_ptr };
if *old == new_val {
return false; }
*old = new_val;
true
}
}
#[derive(Clone, Debug, Default)]
pub struct Ancestors(pub Vec<Arc<str>>);
impl PartialEq for Ancestors {
fn eq(&self, other: &Self) -> bool {
self.0.len() == other.0.len()
&& self
.0
.iter()
.zip(&other.0)
.all(|(a, b)| a.as_ref() == b.as_ref())
}
}
unsafe impl salsa::Update for Ancestors {
unsafe fn maybe_update(old_ptr: *mut Self, new_val: Self) -> bool {
let old = unsafe { &mut *old_ptr };
if *old == new_val {
return false;
}
*old = new_val;
true
}
}