Skip to content

Commit

Permalink
fixing rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-sheets committed Dec 12, 2022
1 parent 0645aa4 commit b19ad28
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/internal_rep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,18 @@ pub struct FileSystemContextRule<'a> {
pub context: Context<'a>,
}

impl FileSystemContextRule<'_> {
fn get_renamed_statement(&self, renames: &BTreeMap<String, String>) -> Self {
FileSystemContextRule {
fscontext_type: self.fscontext_type.clone(),
fs_name: self.fs_name.clone(),
path: self.path.clone(),
file_type: self.file_type,
context: self.context.get_renamed_context(renames),
}
}
}

impl TryFrom<&FileSystemContextRule<'_>> for sexp::Sexp {
type Error = ErrorItem;

Expand Down Expand Up @@ -1692,7 +1704,7 @@ fn call_to_fsc_rules<'a>(
None,
)?,
];
let validated_args = validate_arguments(c, &target_args, types, class_perms, context, file)?;
let validated_args = validate_arguments(c, &target_args, types, class_perms, context, Some(file))?;
let mut args_iter = validated_args.iter();
let mut ret = Vec::new();

Expand Down Expand Up @@ -2559,6 +2571,9 @@ impl<'a> ValidatedStatement<'a> {
ValidatedStatement::FcRule(f) => {
ValidatedStatement::FcRule(f.get_renamed_statement(renames))
}
ValidatedStatement::FscRule(f) => {
ValidatedStatement::FscRule(f.get_renamed_statement(renames))
}
// DomtransRule is probably broken on derive anyways. It uses TypeInfos directly rather
// than strings. This probably means that deriving a DomTrans using "this" is broken
ValidatedStatement::DomtransRule(_) => self.clone(),
Expand Down Expand Up @@ -3615,9 +3630,16 @@ mod tests {
let mut renames = BTreeMap::new();
renames.insert("old_name".to_string(), "new_name".to_string());
let renamed_statement = statement.get_renamed_statement(&renames);
let sexp = Sexp::from(&renamed_statement);
assert!(sexp.to_string().contains("new_name"));
assert!(!sexp.to_string().contains("old_name"));
match Sexp::try_from(&renamed_statement) {
Ok(sexp) => {
assert!(sexp.to_string().contains("new_name"));
assert!(!sexp.to_string().contains("old_name"));
}
Err(_) => {
// We should never get here in testing but if we do assert false
assert!(false);
}
}
}
}
}

0 comments on commit b19ad28

Please sign in to comment.