fix: move lint rules outside of quote_spanned (closes #2527) (#2709)

This commit is contained in:
Ar4ys 2024-07-24 13:54:46 +02:00 committed by GitHub
parent 0763a81cf1
commit 7e75801f7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 47 additions and 77 deletions

View File

@ -52,12 +52,10 @@ pub(crate) fn fragment_to_tokens(
None,
)?;
let node = quote_spanned! {span=>
#[allow(unused_braces)] {#node}
};
let node = quote_spanned!(span => { #node });
Some(quote! {
::leptos::IntoView::into_view(#node)
::leptos::IntoView::into_view(#[allow(unused_braces)] #node)
})
})
.peekable();
@ -339,9 +337,7 @@ pub(crate) fn element_to_tokens(
quote! {}
};
let ide_helper_close_tag = ide_helper_close_tag.into_iter();
Some(quote_spanned! {node.span()=>
#[allow(unused_braces)]
{
let result = quote_spanned! {node.span()=> {
#(#ide_helper_close_tag)*
#name
#(#attrs)*
@ -352,7 +348,10 @@ pub(crate) fn element_to_tokens(
#(#children)*
#view_marker
}
})
};
// We need to move "allow" out of "quote_spanned" because it breaks hovering in rust-analyzer
Some(quote!(#[allow(unused_braces)] #result))
}
}

View File

@ -70,12 +70,10 @@ pub(crate) fn component_to_tokens(
})
.unwrap_or_else(|| quote! { #name });
let value = quote_spanned! {value.span()=>
#[allow(unused_braces)] {#value}
};
let value = quote_spanned!(value.span()=> { #value });
quote_spanned! {attr.span()=>
.#name(#value)
.#name(#[allow(unused_braces)] #value)
}
});

View File

@ -83,12 +83,10 @@ pub(crate) fn fragment_to_tokens_ssr(
let nodes = nodes.iter().map(|node| {
let span = node.span();
let node = root_node_to_tokens_ssr(node, global_class, None);
let node = quote_spanned! {span=>
#[allow(unused_braces)] {#node}
};
let node = quote_spanned!(span=> { #node });
quote! {
::leptos::IntoView::into_view(#node)
::leptos::IntoView::into_view(#[allow(unused_braces)] #node)
}
});

View File

@ -61,12 +61,10 @@ pub(crate) fn slot_to_tokens(
})
.unwrap_or_else(|| quote! { #name });
let value = quote_spanned! {value.span()=>
#[allow(unused_braces)] {#value}
};
let value = quote_spanned!(value.span()=> { #value });
quote_spanned! {attr.span()=>
.#name(#value)
.#name(#[allow(unused_braces)] #value)
}
});
@ -187,7 +185,7 @@ pub(crate) fn slot_to_tokens(
};
let slot = quote_spanned! {node.span()=>
#[allow(unused_braces)] {
{
let slot = #component_name::builder()
#(#props)*
#(#slots)*
@ -200,6 +198,9 @@ pub(crate) fn slot_to_tokens(
},
};
// We need to move "allow" out of "quote_spanned" because it breaks hovering in rust-analyzer
let slot = quote!(#[allow(unused_braces)] #slot);
parent_slots
.entry(name)
.and_modify(|entry| entry.push(slot.clone()))

View File

@ -145,27 +145,27 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(51..52),
span: bytes(37..52),
},
],
span: bytes(51..52),
span: bytes(37..52),
},
],
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Brace,
@ -195,27 +195,27 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(70..71),
span: bytes(65..71),
},
],
span: bytes(70..71),
span: bytes(65..71),
},
],
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Brace,

View File

@ -145,27 +145,27 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(51..52),
span: bytes(37..52),
},
],
span: bytes(51..52),
span: bytes(37..52),
},
],
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Brace,
@ -195,27 +195,27 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(70..71),
span: bytes(65..71),
},
],
span: bytes(70..71),
span: bytes(65..71),
},
],
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Brace,

View File

@ -1,33 +1,27 @@
---
source: leptos_macro/src/view/tests.rs
assertion_line: 101
expression: result
---
TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(10..331),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(10..331),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(10..331),
},
],
span: bytes(10..331),
},
],
span: bytes(10..331),
},
Group {
delimiter: Brace,
@ -153,27 +147,22 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(28..83),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(28..83),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(28..83),
},
],
span: bytes(28..83),
},
],
span: bytes(28..83),
},
Group {
delimiter: Brace,
@ -404,27 +393,22 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(96..176),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(96..176),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(96..176),
},
],
span: bytes(96..176),
},
],
span: bytes(96..176),
},
Group {
delimiter: Brace,
@ -697,27 +681,22 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(189..223),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(189..223),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(189..223),
},
],
span: bytes(189..223),
},
],
span: bytes(189..223),
},
Group {
delimiter: Brace,
@ -902,27 +881,22 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(236..316),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(236..316),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(236..316),
},
],
span: bytes(236..316),
},
],
span: bytes(236..316),
},
Group {
delimiter: Brace,

View File

@ -145,27 +145,27 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(51..52),
span: bytes(37..52),
},
],
span: bytes(51..52),
span: bytes(37..52),
},
],
span: bytes(51..52),
span: bytes(37..52),
},
Group {
delimiter: Brace,
@ -195,27 +195,27 @@ TokenStream [
Punct {
char: '#',
spacing: Alone,
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
sym: allow,
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
sym: unused_braces,
span: bytes(70..71),
span: bytes(65..71),
},
],
span: bytes(70..71),
span: bytes(65..71),
},
],
span: bytes(70..71),
span: bytes(65..71),
},
Group {
delimiter: Brace,