mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
Fix: clippy, dont throw error on commas (#2869)
* Fix: clippy, hotreload css blocks, raw blocks * fix test * okay nevermind
This commit is contained in:
parent
5c002686d0
commit
005d52468d
4 changed files with 30 additions and 29 deletions
|
@ -316,7 +316,7 @@ impl SuspenseBoundaryProps {
|
||||||
// Store the (now mounted) children back into the scope state
|
// Store the (now mounted) children back into the scope state
|
||||||
let scope_state = &mut dom.scopes[scope_id.0];
|
let scope_state = &mut dom.scopes[scope_id.0];
|
||||||
let props = Self::downcast_from_props(&mut *scope_state.props).unwrap();
|
let props = Self::downcast_from_props(&mut *scope_state.props).unwrap();
|
||||||
props.children = children.clone();
|
props.children.clone_from(&children);
|
||||||
|
|
||||||
let scope_state = &mut dom.scopes[scope_id.0];
|
let scope_state = &mut dom.scopes[scope_id.0];
|
||||||
let suspense_context = scope_state
|
let suspense_context = scope_state
|
||||||
|
@ -435,7 +435,7 @@ impl SuspenseBoundaryProps {
|
||||||
// Store the (now mounted) children back into the scope state
|
// Store the (now mounted) children back into the scope state
|
||||||
let scope_state = &mut dom.scopes[scope_id.0];
|
let scope_state = &mut dom.scopes[scope_id.0];
|
||||||
let props = Self::downcast_from_props(&mut *scope_state.props).unwrap();
|
let props = Self::downcast_from_props(&mut *scope_state.props).unwrap();
|
||||||
props.children = children.clone();
|
props.children.clone_from(&children);
|
||||||
scope_state.last_rendered_node = Some(children);
|
scope_state.last_rendered_node = Some(children);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use proc_macro2::{Span, TokenStream};
|
use proc_macro2::{Span, TokenStream};
|
||||||
use quote::{quote, quote_spanned, ToTokens, TokenStreamExt};
|
use quote::{quote, quote_spanned, ToTokens, TokenStreamExt};
|
||||||
use std::{collections::HashMap, str::FromStr};
|
use std::collections::HashMap;
|
||||||
use syn::{
|
use syn::{
|
||||||
parse::{Parse, ParseStream},
|
parse::{Parse, ParseStream},
|
||||||
*,
|
*,
|
||||||
|
@ -25,9 +25,9 @@ impl IfmtInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_litstr(source: LitStr) -> Self {
|
pub fn new_litstr(source: LitStr) -> Result<Self> {
|
||||||
let segments = Self::from_raw(&source.value()).unwrap();
|
let segments = IfmtInput::from_raw(&source.value())?;
|
||||||
Self { segments, source }
|
Ok(Self { segments, source })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn span(&self) -> Span {
|
pub fn span(&self) -> Span {
|
||||||
|
@ -335,23 +335,10 @@ impl ToTokens for FormattedSegmentType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for IfmtInput {
|
|
||||||
type Err = syn::Error;
|
|
||||||
|
|
||||||
fn from_str(input: &str) -> Result<Self> {
|
|
||||||
let segments = IfmtInput::from_raw(input)?;
|
|
||||||
Ok(Self {
|
|
||||||
source: LitStr::new(input, Span::call_site()),
|
|
||||||
segments,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for IfmtInput {
|
impl Parse for IfmtInput {
|
||||||
fn parse(input: ParseStream) -> Result<Self> {
|
fn parse(input: ParseStream) -> Result<Self> {
|
||||||
let source: LitStr = input.parse()?;
|
let source: LitStr = input.parse()?;
|
||||||
let segments = IfmtInput::from_raw(&source.value())?;
|
Self::new_litstr(source)
|
||||||
Ok(Self { source, segments })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +357,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn segments_parse() {
|
fn segments_parse() {
|
||||||
let input = "blah {abc} {def}".parse::<IfmtInput>().unwrap();
|
let input: IfmtInput = parse_quote! { "blah {abc} {def}" };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
input.segments,
|
input.segments,
|
||||||
vec![
|
vec![
|
||||||
|
|
|
@ -65,7 +65,7 @@ impl Parse for HotLiteral {
|
||||||
Lit::Int(a) => HotLiteral::Int(a),
|
Lit::Int(a) => HotLiteral::Int(a),
|
||||||
Lit::Bool(a) => HotLiteral::Bool(a),
|
Lit::Bool(a) => HotLiteral::Bool(a),
|
||||||
Lit::Float(a) => HotLiteral::Float(a),
|
Lit::Float(a) => HotLiteral::Float(a),
|
||||||
Lit::Str(a) => HotLiteral::Fmted(IfmtInput::new_litstr(a).into()),
|
Lit::Str(a) => HotLiteral::Fmted(IfmtInput::new_litstr(a)?.into()),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(syn::Error::new(
|
return Err(syn::Error::new(
|
||||||
raw.span(),
|
raw.span(),
|
||||||
|
|
|
@ -224,16 +224,30 @@ impl RsxBlock {
|
||||||
// Parse a body node with diagnostics for unnecessary trailing commas
|
// Parse a body node with diagnostics for unnecessary trailing commas
|
||||||
fn parse_body_node_with_comma_diagnostics(
|
fn parse_body_node_with_comma_diagnostics(
|
||||||
content: &ParseBuffer,
|
content: &ParseBuffer,
|
||||||
diagnostics: &mut Diagnostics,
|
_diagnostics: &mut Diagnostics,
|
||||||
) -> syn::Result<BodyNode> {
|
) -> syn::Result<BodyNode> {
|
||||||
let body_node = content.parse::<BodyNode>()?;
|
let body_node = content.parse::<BodyNode>()?;
|
||||||
if !content.is_empty() && content.peek(Token![,]) {
|
if !content.is_empty() && content.peek(Token![,]) {
|
||||||
let comma = content.parse::<Token![,]>()?;
|
let _comma = content.parse::<Token![,]>()?;
|
||||||
diagnostics.push(
|
|
||||||
comma
|
// todo: we would've pushed a warning here but proc-macro-2 emits them as errors, which we
|
||||||
.span()
|
// dont' want. There's no built-in cfg way for checking if we're on nightly, and adding
|
||||||
.warning("Elements and text nodes do not need to be separated by commas."),
|
// that would require a build script, so for the interest of compile times, we won't throw
|
||||||
);
|
// any warning at all.
|
||||||
|
//
|
||||||
|
// Whenever the user formats their code with `dx fmt`, the comma will be removed, so active
|
||||||
|
// projects will implicitly be fixed.
|
||||||
|
//
|
||||||
|
// Whenever the issue is resolved or diagnostics are added, we can re-add this warning.
|
||||||
|
//
|
||||||
|
// - https://github.com/SergioBenitez/proc-macro2-diagnostics/issues/9
|
||||||
|
// - https://github.com/DioxusLabs/dioxus/issues/2807
|
||||||
|
//
|
||||||
|
// diagnostics.push(
|
||||||
|
// comma
|
||||||
|
// .span()
|
||||||
|
// .warning("Elements and text nodes do not need to be separated by commas."),
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
Ok(body_node)
|
Ok(body_node)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue