Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lrlex/src/lib/ctbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ where
lex_diag.file_location_msg(" parsing the `%grmtools` section", None)
));
for e in es {
out.push_str(&indent(&lex_diag.format_error(e).to_string(), " "));
out.push_str(&indent(" ", &lex_diag.format_error(e).to_string()));
out.push('\n');
}
ErrorString(out)
Expand Down Expand Up @@ -511,7 +511,7 @@ where
lex_diag.file_location_msg("", None)
));
for e in errs {
out.push_str(&indent(&lex_diag.format_error(e).to_string(), " "));
out.push_str(&indent(" ", &lex_diag.format_error(e).to_string()));
out.push('\n');
}
ErrorString(out)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ pub fn ct_token_map<StorageT: Display>(
///
/// It is plausible that we should a step 4, but currently do not:
/// 4. Replace all `\n{indent}\n` with `\n\n`
fn indent(s: &str, indent: &str) -> String {
fn indent(indent: &str, s: &str) -> String {
format!("{indent}{}\n", s.trim_end_matches('\n')).replace('\n', &format!("\n{}", indent))
}

Expand Down
10 changes: 5 additions & 5 deletions lrpar/src/lib/ctbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ where
yacc_diag.file_location_msg(" parsing the `%grmtools` section", None)
));
for e in errs {
out.push_str(&indent(&yacc_diag.format_error(e).to_string(), " "));
out.push_str(&indent(" ", &yacc_diag.format_error(e).to_string()));
}
return Err(ErrorString(out))?;
}
Expand Down Expand Up @@ -606,7 +606,7 @@ where
for e in warnings {
out.push_str(&format!(
"{}\n",
indent(&yacc_diag.format_warning(e).to_string(), " ")
indent(" ", &yacc_diag.format_warning(e).to_string())
));
}
return Err(ErrorString(out))?;
Expand All @@ -615,7 +615,7 @@ where
if !warnings.is_empty() {
for w in warnings {
let ws_loc = yacc_diag.file_location_msg("", None);
let ws = indent(&yacc_diag.format_warning(w).to_string(), " ");
let ws = indent(" ", &yacc_diag.format_warning(w).to_string());
// Assume if this variable is set we are running under cargo.
if std::env::var("OUT_DIR").is_ok() && self.show_warnings {
println!("cargo:warning={}", ws_loc);
Expand All @@ -635,7 +635,7 @@ where
yacc_diag.file_location_msg("", None)
));
for e in errs {
out.push_str(&indent(&yacc_diag.format_error(e).to_string(), " "));
out.push_str(&indent(" ", &yacc_diag.format_error(e).to_string()));
out.push('\n');
}

Expand Down Expand Up @@ -1544,7 +1544,7 @@ where
///
/// It is plausible that we should a step 4, but currently do not:
/// 4. Replace all `\n{indent}\n` with `\n\n`
fn indent(s: &str, indent: &str) -> String {
fn indent(indent: &str, s: &str) -> String {
format!("{indent}{}\n", s.trim_end_matches('\n')).replace('\n', &format!("\n{}", indent))
}

Expand Down
14 changes: 7 additions & 7 deletions nimbleparse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn read_file<P: AsRef<Path>>(path: P) -> String {
///
/// It is plausible that we should a step 4, but currently do not:
/// 4. Replace all `\n{indent}\n` with `\n\n`
fn indent(s: &str, indent: &str) -> String {
fn indent(indent: &str, s: &str) -> String {
format!("{indent}{}\n", s.trim_end_matches('\n')).replace('\n', &format!("\n{}", indent))
}

Expand Down Expand Up @@ -180,7 +180,7 @@ fn main() {
Err(errs) => {
eprintln!("{ERROR}{}", lex_diag.file_location_msg("", None));
for e in errs {
eprintln!("{}", indent(&lex_diag.format_error(e).to_string(), " "));
eprintln!("{}", indent(" ", &lex_diag.format_error(e).to_string()));
}
process::exit(1);
}
Expand All @@ -204,7 +204,7 @@ fn main() {
yacc_diag.file_location_msg(" parsing the `%grmtools` section:", None)
);
for e in errs {
eprintln!("{}", indent(&yacc_diag.format_error(e).to_string(), " "));
eprintln!("{}", indent(" ", &yacc_diag.format_error(e).to_string()));
}
std::process::exit(1);
}
Expand Down Expand Up @@ -238,7 +238,7 @@ fn main() {
};
eprintln!(
"{}",
indent(&yacc_diag.format_error(spanned_e).to_string(), " ")
indent(" ", &yacc_diag.format_error(spanned_e).to_string())
);
process::exit(1)
}
Expand All @@ -255,19 +255,19 @@ fn main() {
if !warnings.is_empty() {
eprintln!("{WARNING}{}", yacc_diag.file_location_msg("", None));
for w in warnings {
eprintln!("{}", indent(&yacc_diag.format_warning(w), " "));
eprintln!("{}", indent(" ", &yacc_diag.format_warning(w)));
}
}
x
}
Err(errs) => {
eprintln!("{ERROR}{}", yacc_diag.file_location_msg("", None));
for e in errs {
eprintln!("{}", indent(&yacc_diag.format_error(e).to_string(), " "));
eprintln!("{}", indent(" ", &yacc_diag.format_error(e).to_string()));
}
eprintln!("{WARNING}{}", yacc_diag.file_location_msg("", None));
for w in warnings {
eprintln!("{}", indent(&yacc_diag.format_warning(w), " "));
eprintln!("{}", indent(" ", &yacc_diag.format_warning(w)));
}
process::exit(1);
}
Expand Down