Reverse fixups

This commit is contained in:
Florian Diebold 2022-02-07 19:53:31 +01:00
parent 79ebf618ec
commit c3601e9860
3 changed files with 5 additions and 4 deletions

View File

@ -76,7 +76,6 @@ fn foo() {
#[test]
fn attribute_macro_syntax_completion_2() {
// common case of dot completion while typing
// right now not working
check(
r#"
//- proc_macros: identity_when_valid
@ -88,7 +87,7 @@ fn foo() { bar.; blub }
fn foo() { bar.; blub }
fn foo() {
bar.;
bar. ;
blub
}"##]],
);

View File

@ -430,7 +430,7 @@ fn macro_expand(db: &dyn AstDatabase, id: MacroCallId) -> ExpandResult<Option<Ar
// be reported at the definition site (when we construct a def map).
Err(err) => return ExpandResult::str_err(format!("invalid macro definition: {}", err)),
};
let ExpandResult { value: tt, err } = expander.expand(db, id, &macro_arg.0);
let ExpandResult { value: mut tt, err } = expander.expand(db, id, &macro_arg.0);
// Set a hard limit for the expanded tt
let count = tt.count();
// XXX: Make ExpandResult a real error and use .map_err instead?
@ -442,6 +442,8 @@ fn macro_expand(db: &dyn AstDatabase, id: MacroCallId) -> ExpandResult<Option<Ar
));
}
fixup::reverse_fixups(&mut tt);
ExpandResult { value: Some(Arc::new(tt)), err }
}

View File

@ -1,7 +1,7 @@
//! Conversions between [`SyntaxNode`] and [`tt::TokenTree`].
use rustc_hash::{FxHashMap, FxHashSet};
use stdx::{non_empty_vec::NonEmptyVec, always};
use stdx::{always, non_empty_vec::NonEmptyVec};
use syntax::{
ast::{self, make::tokens::doc_comment},
AstToken, Parse, PreorderWithTokens, SmolStr, SyntaxElement, SyntaxKind,