check top level entry point invariants

This commit is contained in:
Aleksey Kladov 2022-01-02 18:41:32 +03:00
parent fa049d94d1
commit d846afdeef
5 changed files with 42 additions and 12 deletions

View file

@ -1,7 +1,7 @@
//! Conversions between [`SyntaxNode`] and [`tt::TokenTree`].
use rustc_hash::{FxHashMap, FxHashSet};
use stdx::non_empty_vec::NonEmptyVec;
use stdx::{never, non_empty_vec::NonEmptyVec};
use syntax::{
ast::{self, make::tokens::doc_comment},
AstToken, Parse, PreorderWithTokens, SmolStr, SyntaxElement, SyntaxKind,
@ -66,8 +66,7 @@ pub fn token_tree_to_syntax_node(
parser::Step::Error { msg } => tree_sink.error(msg.to_string()),
}
}
if tree_sink.roots.len() != 1 {
cov_mark::hit!(expansion_does_not_parse_as_expression);
if never!(tree_sink.roots.len() != 1) {
return Err(ExpandError::ConversionError);
}
//FIXME: would be cool to report errors