Skip to content

Commit 174c439

Browse files
committed
minor: drop dead code
1 parent 2e34a5e commit 174c439

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

crates/hir_expand/src/db.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option<SyntaxNod
215215
match file_id.0 {
216216
HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()),
217217
HirFileIdRepr::MacroFile(macro_file) => {
218+
// FIXME: Note how we convert from `Parse` to `SyntaxNode` here,
219+
// forgetting about parse errors.
218220
db.parse_macro_expansion(macro_file).value.map(|(it, _)| it.syntax_node())
219221
}
220222
}

crates/mbe/src/syntax_bridge.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Conversions between [`SyntaxNode`] and [`tt::TokenTree`].
22
33
use rustc_hash::{FxHashMap, FxHashSet};
4-
use stdx::{never, non_empty_vec::NonEmptyVec};
4+
use stdx::non_empty_vec::NonEmptyVec;
55
use syntax::{
66
ast::{self, make::tokens::doc_comment},
77
AstToken, Parse, PreorderWithTokens, SmolStr, SyntaxElement, SyntaxKind,
@@ -66,10 +66,6 @@ pub fn token_tree_to_syntax_node(
6666
parser::Step::Error { msg } => tree_sink.error(msg.to_string()),
6767
}
6868
}
69-
if never!(tree_sink.roots.len() != 1) {
70-
return Err(ExpandError::ConversionError);
71-
}
72-
//FIXME: would be cool to report errors
7369
let (parse, range_map) = tree_sink.finish();
7470
Ok((parse, range_map))
7571
}
@@ -614,10 +610,6 @@ struct TtTreeSink<'a> {
614610
text_pos: TextSize,
615611
inner: SyntaxTreeBuilder,
616612
token_map: TokenMap,
617-
618-
// Number of roots
619-
// Use for detect ill-form tree which is not single root
620-
roots: smallvec::SmallVec<[usize; 1]>,
621613
}
622614

623615
impl<'a> TtTreeSink<'a> {
@@ -628,7 +620,6 @@ impl<'a> TtTreeSink<'a> {
628620
open_delims: FxHashMap::default(),
629621
text_pos: 0.into(),
630622
inner: SyntaxTreeBuilder::default(),
631-
roots: smallvec::SmallVec::new(),
632623
token_map: TokenMap::default(),
633624
}
634625
}
@@ -733,16 +724,10 @@ impl<'a> TtTreeSink<'a> {
733724

734725
fn start_node(&mut self, kind: SyntaxKind) {
735726
self.inner.start_node(kind);
736-
737-
match self.roots.last_mut() {
738-
None | Some(0) => self.roots.push(1),
739-
Some(n) => *n += 1,
740-
};
741727
}
742728

743729
fn finish_node(&mut self) {
744730
self.inner.finish_node();
745-
*self.roots.last_mut().unwrap() -= 1;
746731
}
747732

748733
fn error(&mut self, error: String) {

0 commit comments

Comments
 (0)