Skip to content

Commit 8fad24d

Browse files
committed
minor: Simplify
1 parent 91200e3 commit 8fad24d

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

crates/mbe/src/expander/transcriber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn expand_repeat(
192192
t.delimiter = None;
193193
push_subtree(&mut buf, t);
194194

195-
if let Some(ref sep) = separator {
195+
if let Some(sep) = separator {
196196
match sep {
197197
Separator::Ident(ident) => {
198198
has_seps = 1;

crates/mbe/src/syntax_bridge.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl TokenIdAlloc {
396396
}
397397
}
398398

399-
/// A Raw Token (straightly from lexer) convertor
399+
/// A raw token (straight from lexer) convertor
400400
struct RawConvertor<'a> {
401401
lexed: parser::LexedStr<'a>,
402402
pos: usize,
@@ -525,8 +525,7 @@ enum SynToken {
525525
impl SynToken {
526526
fn token(&self) -> &SyntaxToken {
527527
match self {
528-
SynToken::Ordinary(it) => it,
529-
SynToken::Punch(it, _) => it,
528+
SynToken::Ordinary(it) | SynToken::Punch(it, _) => it,
530529
}
531530
}
532531
}
@@ -659,7 +658,7 @@ impl<'a> TtTreeSink<'a> {
659658

660659
let mut last = self.cursor;
661660
for _ in 0..n_tokens {
662-
let tmp_str: SmolStr;
661+
let tmp: u8;
663662
if self.cursor.eof() {
664663
break;
665664
}
@@ -669,18 +668,15 @@ impl<'a> TtTreeSink<'a> {
669668
Some(tt::buffer::TokenTreeRef::Leaf(leaf, _)) => {
670669
// Mark the range if needed
671670
let (text, id) = match leaf {
672-
tt::Leaf::Ident(ident) => (&ident.text, ident.id),
671+
tt::Leaf::Ident(ident) => (ident.text.as_str(), ident.id),
673672
tt::Leaf::Punct(punct) => {
674673
assert!(punct.char.is_ascii());
675-
let char = &(punct.char as u8);
676-
tmp_str = SmolStr::new_inline(
677-
std::str::from_utf8(std::slice::from_ref(char)).unwrap(),
678-
);
679-
(&tmp_str, punct.id)
674+
tmp = punct.char as u8;
675+
(std::str::from_utf8(std::slice::from_ref(&tmp)).unwrap(), punct.id)
680676
}
681-
tt::Leaf::Literal(lit) => (&lit.text, lit.id),
677+
tt::Leaf::Literal(lit) => (lit.text.as_str(), lit.id),
682678
};
683-
let range = TextRange::at(self.text_pos, TextSize::of(text.as_str()));
679+
let range = TextRange::at(self.text_pos, TextSize::of(text));
684680
self.token_map.insert(id, range);
685681
self.cursor = self.cursor.bump();
686682
text
@@ -740,7 +736,7 @@ impl<'a> TtTreeSink<'a> {
740736

741737
match self.roots.last_mut() {
742738
None | Some(0) => self.roots.push(1),
743-
Some(ref mut n) => **n += 1,
739+
Some(n) => *n += 1,
744740
};
745741
}
746742

0 commit comments

Comments
 (0)