Skip to content

Commit

Permalink
Rename capitalized acronym.
Browse files Browse the repository at this point in the history
Clippy now complains about the use of capitalized acronyms
like `SCC` as constructor names.  Although this seems to go against
the English grammar, we rename these constructors to capitalize the
first letter only.
  • Loading branch information
ryzhyk committed Jun 12, 2021
1 parent 581d07a commit ab0e38c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions rust/template/cmd_parser/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const HISTORY_FILE: &str = "cmd_parser_history.txt";

// We handle stdin differently depending on whether it is a user terminal or a pipe.
enum Input {
TTY(Editor<()>),
Tty(Editor<()>),
Pipe(BufReader<io::Stdin>),
}

Expand All @@ -34,14 +34,14 @@ where
let mut input = if istty {
let mut rl = Editor::<()>::new();
let _ = rl.load_history(HISTORY_FILE);
Input::TTY(rl)
Input::Tty(rl)
} else {
Input::Pipe(BufReader::new(io::stdin()))
};

loop {
let line = match &mut input {
Input::TTY(rl) => {
Input::Tty(rl) => {
let readline = rl.readline(">> ");
match readline {
Ok(mut line) => {
Expand Down
8 changes: 4 additions & 4 deletions rust/template/cmd_parser/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::borrow::Cow;

#[derive(Copy, Debug, PartialEq, Eq, Clone)]
pub enum ProfileCmd {
CPU(bool),
Cpu(bool),
Timely(bool),
}

Expand Down Expand Up @@ -59,7 +59,7 @@ named!(pub profile_cmd<&[u8], ProfileCmd>,
do_parse!(apply!(sym,"cpu") >>
enable: alt!(do_parse!(apply!(sym,"on") >> (true)) |
do_parse!(apply!(sym,"off") >> (false))) >>
(ProfileCmd::CPU(enable)))
(ProfileCmd::Cpu(enable)))
);

named!(pub profile_timely_cmd<&[u8], ProfileCmd>,
Expand Down Expand Up @@ -153,11 +153,11 @@ fn test_command() {
);
assert_eq!(
parse_command(br"profile cpu on;"),
Ok((&br""[..], Command::Profile(Some(ProfileCmd::CPU(true)))))
Ok((&br""[..], Command::Profile(Some(ProfileCmd::Cpu(true)))))
);
assert_eq!(
parse_command(br"profile cpu off;"),
Ok((&br""[..], Command::Profile(Some(ProfileCmd::CPU(false)))))
Ok((&br""[..], Command::Profile(Some(ProfileCmd::Cpu(false)))))
);
assert_eq!(
parse_command(br"profile;"),
Expand Down
10 changes: 5 additions & 5 deletions rust/template/differential_datalog/src/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub type TransformerFunc = fn() -> TransformerFuncRes;
pub enum ProgNode {
Rel { rel: Relation },
Apply { tfun: TransformerFunc },
SCC { rels: Vec<RecursiveRelation> },
Scc { rels: Vec<RecursiveRelation> },
}

/// Relation computed in a nested scope as a fixed point.
Expand Down Expand Up @@ -1150,7 +1150,7 @@ impl Program {
}
}
ProgNode::Apply { .. } => {}
ProgNode::SCC { rels: rs } => {
ProgNode::Scc { rels: rs } => {
for r in rs {
if r.rel.id == relid {
return &r.rel;
Expand Down Expand Up @@ -1178,7 +1178,7 @@ impl Program {
match n {
ProgNode::Rel { rel } => Self::rel_uses_arrangement(rel, arrid),
ProgNode::Apply { .. } => false,
ProgNode::SCC { rels } => rels
ProgNode::Scc { rels } => rels
.iter()
.any(|rel| Self::rel_uses_arrangement(&rel.rel, arrid)),
}
Expand All @@ -1205,9 +1205,9 @@ impl Program {
}
}
ProgNode::Apply { .. } => None,
ProgNode::SCC { rels: rs } => {
ProgNode::Scc { rels: rs } => {
for r in rs {
assert!(!r.rel.input, "input relation ({}) in SCC", r.rel.name);
assert!(!r.rel.input, "input relation ({}) in Scc", r.rel.name);
}

None
Expand Down
4 changes: 2 additions & 2 deletions rust/template/differential_datalog/src/program/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl<'a> DDlogWorker<'a> {
tfun()(&mut collections);
}

ProgNode::SCC { rels } => render_scc(
ProgNode::Scc { rels } => render_scc(
rels,
node_id,
outer,
Expand Down Expand Up @@ -746,7 +746,7 @@ fn render_scc<'a>(

// create a nested scope for mutually recursive relations
let new_collections = scope.scoped("recursive component", |inner| -> Result<_, String> {
// create variables for relations defined in the SCC.
// create variables for relations defined in the Scc.
let mut vars = HashMap::with_capacity_and_hasher(rels.len(), FnvBuildHasher::default());
// arrangements created inside the nested scope
let mut local_arrangements = FnvHashMap::default();
Expand Down
6 changes: 3 additions & 3 deletions rust/template/differential_datalog_test/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn test_insert_non_existent_relation() {
}

#[test]
#[should_panic(expected = "input relation (ancestor) in SCC")]
#[should_panic(expected = "input relation (ancestor) in Scc")]
fn test_input_relation_nested() {
let parent = {
Relation {
Expand Down Expand Up @@ -150,7 +150,7 @@ fn test_input_relation_nested() {
let prog: Program = Program {
nodes: vec![
ProgNode::Rel { rel: parent },
ProgNode::SCC {
ProgNode::Scc {
rels: vec![RecursiveRelation {
rel: ancestor,
distinct: true,
Expand Down Expand Up @@ -1649,7 +1649,7 @@ fn test_recursion(nthreads: usize) {
let prog: Program = Program {
nodes: vec![
ProgNode::Rel { rel: parent },
ProgNode::SCC {
ProgNode::Scc {
rels: vec![RecursiveRelation {
rel: ancestor,
distinct: true,
Expand Down
2 changes: 1 addition & 1 deletion rust/template/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn handle_cmd(
Command::Profile(None) => hddlog
.profile()
.map(|profile| println!("Profile:\n{}", profile)),
Command::Profile(Some(ProfileCmd::CPU(enable))) => hddlog.enable_cpu_profiling(enable),
Command::Profile(Some(ProfileCmd::Cpu(enable))) => hddlog.enable_cpu_profiling(enable),
Command::Profile(Some(ProfileCmd::Timely(enable))) => {
hddlog.enable_timely_profiling(enable)
}
Expand Down
4 changes: 2 additions & 2 deletions src/Language/DifferentialDatalog/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ the example below:
DDlog declaration:
extern transformer SCC(Edges: relation['E],
extern transformer Scc(Edges: relation['E],
from: function(e: 'E): 'N,
to: function(e: 'E): 'N)
-> (SCCLabels: relation [('N, 'N)])
Expand Down Expand Up @@ -2781,7 +2781,7 @@ mkNode :: (?crate_graph::CrateGraph, ?specname::String) => ProgNode -> Doc
mkNode (RelNode ProgRel{..}) =
"program::ProgNode::Rel{rel:" <+> rnameFlat prelName <> "}"
mkNode (SCCNode rels) =
"program::ProgNode::SCC{rels: vec![" <>
"program::ProgNode::Scc{rels: vec![" <>
(commaSep $ map (\RecProgRel{..} ->
"program::RecursiveRelation{rel: " <> (rnameFlat $ prelName rprelRel) <>
", distinct: " <> (if rprelDistinct then "true" else "false") <> "}") rels) <> "]}"
Expand Down

0 comments on commit ab0e38c

Please sign in to comment.