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
16 changes: 8 additions & 8 deletions librubyfmt/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,16 +1172,16 @@ pub fn format_paren(ps: &mut ParserState, paren: ParenExpr) {
}

pub fn format_dot2(ps: &mut ParserState, dot2: Dot2) {
format_dot2_or_3(ps, "..".to_string(), dot2.1, dot2.2);
format_dot2_or_3(ps, "..", dot2.1, dot2.2);
}

pub fn format_dot3(ps: &mut ParserState, dot3: Dot3) {
format_dot2_or_3(ps, "...".to_string(), dot3.1, dot3.2);
format_dot2_or_3(ps, "...", dot3.1, dot3.2);
}

pub fn format_dot2_or_3(
ps: &mut ParserState,
dots: String,
dots: &'static str,
left: Option<Box<Expression>>,
right: Option<Box<Expression>>,
) {
Expand All @@ -1206,12 +1206,12 @@ pub fn format_dot2_or_3(
}
}

pub fn percent_symbol_for(tag: String) -> String {
pub fn percent_symbol_for(tag: String) -> &'static str {
match tag.as_ref() {
"qsymbols" => "%i".to_string(),
"qwords" => "%w".to_string(),
"symbols" => "%I".to_string(),
"words" => "%W".to_string(),
"qsymbols" => "%i",
"qwords" => "%w",
"symbols" => "%I",
"words" => "%W",
_ => panic!("got invalid percent symbol"),
}
}
Expand Down
4 changes: 2 additions & 2 deletions librubyfmt/src/format_prism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ fn format_call_chain_segments<'src>(
// Attr_write values are formatted after the breakable so they break independently
if let Some(value) = trailing_attr_write_value {
ps.emit_space();
ps.emit_op("=".to_string());
ps.emit_op("=");
ps.emit_space();
ps.with_start_of_line(false, |ps| format_node(ps, value));
}
Expand Down Expand Up @@ -2728,7 +2728,7 @@ fn format_array_node<'src>(ps: &mut ParserState<'src>, array_node: prism::ArrayN
let orig_delim = opening.and_then(|s| s.chars().nth(2)).unwrap_or('[');

if is_word_array {
ps.emit_ident(opening.unwrap().split_at(2).0.to_string());
ps.emit_ident(opening.unwrap().split_at(2).0);
}

if array_node.elements().is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion librubyfmt/src/string_escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn single_to_double_quoted(content: &str, start_delim: &str, end_delim: &str
.replace_all(content, |captures: &fancy_regex::Captures| {
// first capture is the entire match
let val = captures.get(0).unwrap();
let val_str = val.as_str().to_string();
let val_str = val.as_str();
if val_str.ends_with("\"") {
// Ends with a quote, which we transform to `\"`
format!("{}\\\"", &val_str[0..(val_str.len() - 1)])
Expand Down