clean up soft-keyword transform

This commit is contained in:
Jeong YunWon authored and Charlie Marsh committed 2023-02-20 15:03:39 -05:00
1 parent 382df8e714
commit fa38e9fa47
1 file changed
+14 -22
+14 -22
View File
@@ -56,17 +56,7 @@ where
// type hints.)
if matches!(tok, Tok::Match | Tok::Case) {
if !self.start_of_line {
next = Some(Ok((
*start,
Tok::Name {
name: if matches!(tok, Tok::Match) {
"match".to_string()
} else {
"case".to_string()
},
},
*end,
)));
next = Some(Ok((*start, soft_to_name(tok), *end)));
} else {
let mut par_count = 0;
let mut sqb_count = 0;
@@ -92,17 +82,7 @@ where
first = false;
}
if !seen_colon {
next = Some(Ok((
*start,
Tok::Name {
name: if matches!(tok, Tok::Match) {
"match".to_string()
} else {
"case".to_string()
},
},
*end,
)));
next = Some(Ok((*start, soft_to_name(tok), *end)));
}
}
}
@@ -124,3 +104,15 @@ where
next
}
}
#[inline]
fn soft_to_name(tok: &Tok) -> Tok {
let name = match tok {
Tok::Match => "match",
Tok::Case => "case",
_ => unreachable!("other tokens never reach here"),
};
Tok::Name {
name: name.to_owned(),
}
}