Add test, remove printlns

This commit is contained in:
Florian Diebold 2020-03-15 11:26:54 +01:00
parent c32529ddd0
commit 035db0fbb9
4 changed files with 53 additions and 3 deletions

View file

@ -206,7 +206,6 @@ fn macro_expand_with_arg(
};
let (tt, err) = macro_rules.0.expand(db, lazy_id, &macro_arg.0);
// Set a hard limit for the expanded tt
eprintln!("expansion size: {}", tt.count());
let count = tt.count();
if count > 65536 {
return (None, Some(format!("Total tokens count exceed limit : count = {}", count)));

View file

@ -905,6 +905,59 @@ mod tests {
);
}
#[test]
fn completes_in_simple_macro_without_closing_parens() {
assert_debug_snapshot!(
do_reference_completion(
r"
macro_rules! m { ($e:expr) => { $e } }
fn quux(x: i32) {
let y = 92;
m!(x<|>
}
"
),
@r###"
[
CompletionItem {
label: "m!",
source_range: [145; 146),
delete: [145; 146),
insert: "m!($0)",
kind: Macro,
detail: "macro_rules! m",
},
CompletionItem {
label: "quux(…)",
source_range: [145; 146),
delete: [145; 146),
insert: "quux(${1:x})$0",
kind: Function,
lookup: "quux",
detail: "fn quux(x: i32)",
trigger_call_info: true,
},
CompletionItem {
label: "x",
source_range: [145; 146),
delete: [145; 146),
insert: "x",
kind: Binding,
detail: "i32",
},
CompletionItem {
label: "y",
source_range: [145; 146),
delete: [145; 146),
insert: "y",
kind: Binding,
detail: "i32",
},
]
"###
);
}
#[test]
fn completes_unresolved_uses() {
assert_debug_snapshot!(

View file

@ -11,7 +11,6 @@ use rustc_hash::FxHashMap;
use crate::{ExpandError, ExpandResult};
pub(crate) fn expand(rules: &crate::MacroRules, input: &tt::Subtree) -> ExpandResult<tt::Subtree> {
eprintln!("expanding input: {:?}", input);
let (mut result, mut unmatched_tokens, mut unmatched_patterns, mut err) = (
tt::Subtree::default(),
usize::max_value(),

View file

@ -73,7 +73,6 @@ pub fn token_tree_to_syntax_node(
tt: &tt::Subtree,
fragment_kind: FragmentKind,
) -> Result<(Parse<SyntaxNode>, TokenMap), ExpandError> {
eprintln!("token_tree_to_syntax_node {:?} as {:?}", tt, fragment_kind);
let tmp;
let tokens = match tt {
tt::Subtree { delimiter: None, token_trees } => token_trees.as_slice(),