Auto merge of #12990 - edwin0cheng:improve-ws, r=Veykril
fix: Improve whitespace insertion in mbe Related: https://github.com/rust-lang/rust-analyzer/issues/12260#issuecomment-1126957162
This commit is contained in:
commit
d79d9e1a2e
@ -885,7 +885,7 @@ macro_rules! m {
|
||||
($t:ty) => ( fn bar() -> $ t {} )
|
||||
}
|
||||
|
||||
fn bar() -> & 'a Baz<u8> {}
|
||||
fn bar() -> &'a Baz<u8> {}
|
||||
|
||||
fn bar() -> extern "Rust"fn() -> Ret {}
|
||||
"#]],
|
||||
@ -1578,7 +1578,7 @@ impl $Struct { $$(fn $method() -> &'static [u32] { &[$$$$($$$$val),*] })*}
|
||||
($$($val: expr), *) = > {
|
||||
struct Foo;
|
||||
impl Foo {
|
||||
$(fn $method()-> & 'static[u32] {
|
||||
$(fn $method()-> &'static[u32] {
|
||||
&[$$($$val), *]
|
||||
}
|
||||
)*
|
||||
@ -1591,10 +1591,10 @@ impl Foo {
|
||||
($($val: expr), *) = > {
|
||||
struct Foo;
|
||||
impl Foo {
|
||||
fn alpha()-> & 'static[u32] {
|
||||
fn alpha()-> &'static[u32] {
|
||||
&[$($val), *]
|
||||
}
|
||||
fn beta()-> & 'static[u32] {
|
||||
fn beta()-> &'static[u32] {
|
||||
&[$($val), *]
|
||||
}
|
||||
}
|
||||
@ -1602,10 +1602,10 @@ fn beta()-> & 'static[u32] {
|
||||
}
|
||||
struct Foo;
|
||||
impl Foo {
|
||||
fn alpha() -> & 'static[u32] {
|
||||
fn alpha() -> &'static[u32] {
|
||||
&[1, 2, 3]
|
||||
}
|
||||
fn beta() -> & 'static[u32] {
|
||||
fn beta() -> &'static[u32] {
|
||||
&[1, 2, 3]
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Binary for isize {
|
||||
fn fmt(&self , f: &mut fmt::Formatter< '_>) -> fmt::Result {
|
||||
fn fmt(&self , f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
Binary.fmt_int(*self as usize, f)
|
||||
}
|
||||
}
|
||||
@ -724,7 +724,7 @@ fn $method_name(self $(: $self_selftype)* $(,$marg: $marg_ty)*) -> $mret {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl <> Data for & 'amut G where G: Data {}
|
||||
impl <> Data for &'amut G where G: Data {}
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ macro_rules! m {
|
||||
macro_rules! m {
|
||||
($($t:tt)*) => { $($t)*}
|
||||
}
|
||||
static bar: & 'static str = "hello";
|
||||
static bar: &'static str = "hello";
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ fn attribute_macro_syntax_completion_2() {
|
||||
fn foo() { bar.; blub }
|
||||
|
||||
fn foo() {
|
||||
bar. ;
|
||||
bar.;
|
||||
blub
|
||||
}"##]],
|
||||
);
|
||||
|
@ -251,9 +251,13 @@ fn format_args_expand(
|
||||
}
|
||||
for arg in &mut args {
|
||||
// Remove `key =`.
|
||||
if matches!(arg.token_trees.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=' && p.spacing != tt::Spacing::Joint)
|
||||
if matches!(arg.token_trees.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=')
|
||||
{
|
||||
arg.token_trees.drain(..2);
|
||||
// but not with `==`
|
||||
if !matches!(arg.token_trees.get(2), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=' )
|
||||
{
|
||||
arg.token_trees.drain(..2);
|
||||
}
|
||||
}
|
||||
}
|
||||
let _format_string = args.remove(0);
|
||||
|
@ -468,7 +468,7 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {a . __ra_fixup}
|
||||
fn foo () {a .__ra_fixup}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
@ -478,11 +478,11 @@ fn incomplete_field_expr_2() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() {
|
||||
a. ;
|
||||
a.;
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {a . __ra_fixup ;}
|
||||
fn foo () {a .__ra_fixup ;}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
@ -492,12 +492,12 @@ fn incomplete_field_expr_3() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() {
|
||||
a. ;
|
||||
a.;
|
||||
bar();
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {a . __ra_fixup ; bar () ;}
|
||||
fn foo () {a .__ra_fixup ; bar () ;}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
@ -525,7 +525,7 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {let x = a . __ra_fixup ;}
|
||||
fn foo () {let x = a .__ra_fixup ;}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
@ -541,7 +541,7 @@ fn foo() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo () {a . b ; bar () ;}
|
||||
fn foo () {a .b ; bar () ;}
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
@ -944,7 +944,7 @@ fn foo<'lt>(&'lt self) {}
|
||||
struct Foo(usize);
|
||||
|
||||
impl FooB for Foo {
|
||||
$0fn foo< 'lt>(& 'lt self){}
|
||||
$0fn foo<'lt>(&'lt self){}
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -228,16 +228,7 @@ struct StackEntry {
|
||||
}
|
||||
|
||||
let spacing = match conv.peek().map(|next| next.kind(conv)) {
|
||||
Some(kind)
|
||||
if !kind.is_trivia()
|
||||
&& kind.is_punct()
|
||||
&& kind != T!['[']
|
||||
&& kind != T!['{']
|
||||
&& kind != T!['(']
|
||||
&& kind != UNDERSCORE =>
|
||||
{
|
||||
tt::Spacing::Joint
|
||||
}
|
||||
Some(kind) if !kind.is_trivia() => tt::Spacing::Joint,
|
||||
_ => tt::Spacing::Alone,
|
||||
};
|
||||
let char = match token.to_char(conv) {
|
||||
|
@ -19,7 +19,7 @@ fn test_derive_error() {
|
||||
expect![[r##"
|
||||
SUBTREE $
|
||||
IDENT compile_error 4294967295
|
||||
PUNCH ! [alone] 4294967295
|
||||
PUNCH ! [joint] 4294967295
|
||||
SUBTREE () 4294967295
|
||||
LITERAL "#[derive(DeriveError)] struct S ;" 4294967295
|
||||
PUNCH ; [alone] 4294967295"##]],
|
||||
@ -109,7 +109,7 @@ fn test_fn_like_macro_clone_literals() {
|
||||
PUNCH , [alone] 4294967295
|
||||
LITERAL 2_u32 4294967295
|
||||
PUNCH , [alone] 4294967295
|
||||
PUNCH - [alone] 4294967295
|
||||
PUNCH - [joint] 4294967295
|
||||
LITERAL 4i64 4294967295
|
||||
PUNCH , [alone] 4294967295
|
||||
LITERAL 3.14f32 4294967295
|
||||
@ -130,7 +130,7 @@ fn test_attr_macro() {
|
||||
expect![[r##"
|
||||
SUBTREE $
|
||||
IDENT compile_error 4294967295
|
||||
PUNCH ! [alone] 4294967295
|
||||
PUNCH ! [joint] 4294967295
|
||||
SUBTREE () 4294967295
|
||||
LITERAL "#[attr_error(some arguments)] mod m {}" 4294967295
|
||||
PUNCH ; [alone] 4294967295"##]],
|
||||
|
Loading…
Reference in New Issue
Block a user