mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
Make clippy happy
This commit is contained in:
parent
58233c6a3b
commit
9474ad54cc
4 changed files with 24 additions and 32 deletions
|
@ -119,7 +119,7 @@ fn watch_event<F>(
|
|||
let mut needs_full_rebuild = false;
|
||||
|
||||
if let Some(hot_reload) = &hot_reload {
|
||||
hotreload_files(hot_reload, &mut needs_full_rebuild, &event, &config);
|
||||
hotreload_files(hot_reload, &mut needs_full_rebuild, &event, config);
|
||||
}
|
||||
|
||||
if needs_full_rebuild {
|
||||
|
@ -142,7 +142,7 @@ fn full_rebuild<F>(
|
|||
|
||||
#[allow(clippy::redundant_clone)]
|
||||
print_console_info(
|
||||
&config,
|
||||
config,
|
||||
PrettierOptions {
|
||||
changed: event.paths.clone(),
|
||||
warnings: res.warnings,
|
||||
|
@ -186,10 +186,7 @@ fn hotreload_files(
|
|||
// If the file was hotreloaded, update the file map in place
|
||||
match rsx_file_map.update_rsx(path, &config.crate_dir) {
|
||||
Ok(UpdateResult::UpdatedRsx(msgs)) => {
|
||||
messages.extend(
|
||||
msgs.into_iter()
|
||||
.map(|msg| HotReloadMsg::UpdateTemplate(msg)),
|
||||
);
|
||||
messages.extend(msgs.into_iter().map(HotReloadMsg::UpdateTemplate));
|
||||
}
|
||||
|
||||
// If the file was not updated, we need to do a full rebuild
|
||||
|
@ -227,7 +224,7 @@ fn hotreload_files(
|
|||
}
|
||||
|
||||
fn hotreload_file(
|
||||
path: &PathBuf,
|
||||
path: &Path,
|
||||
config: &CrateConfig,
|
||||
rsx_file_map: &std::sync::MutexGuard<'_, FileMap<HtmlCtx>>,
|
||||
messages: &mut Vec<HotReloadMsg>,
|
||||
|
@ -282,14 +279,14 @@ fn hotreload_file(
|
|||
}
|
||||
|
||||
fn attempt_css_reload(
|
||||
path: &PathBuf,
|
||||
path: &Path,
|
||||
asset_dir: PathBuf,
|
||||
rsx_file_map: &std::sync::MutexGuard<'_, FileMap<HtmlCtx>>,
|
||||
config: &CrateConfig,
|
||||
messages: &mut Vec<HotReloadMsg>,
|
||||
) -> Option<()> {
|
||||
// If the path is not in the asset directory, return
|
||||
if !path.starts_with(&asset_dir) {
|
||||
if !path.starts_with(asset_dir) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -312,7 +309,7 @@ fn attempt_css_reload(
|
|||
Some(())
|
||||
}
|
||||
|
||||
fn local_path_of_asset(path: &PathBuf) -> Option<PathBuf> {
|
||||
fn local_path_of_asset(path: &Path) -> Option<PathBuf> {
|
||||
path.file_name()?.to_str()?.to_string().parse().ok()
|
||||
}
|
||||
|
||||
|
@ -323,7 +320,7 @@ pub(crate) trait Platform {
|
|||
fn rebuild(&mut self, config: &CrateConfig) -> Result<BuildResult>;
|
||||
}
|
||||
|
||||
fn is_backup_file(path: &PathBuf) -> bool {
|
||||
fn is_backup_file(path: &Path) -> bool {
|
||||
// If there's a tilde at the end of the file, it's a backup file
|
||||
if let Some(name) = path.file_name() {
|
||||
if let Some(name) = name.to_str() {
|
||||
|
|
|
@ -559,7 +559,7 @@ impl VirtualDom {
|
|||
}
|
||||
|
||||
if let Some(RenderReturn::Ready(sync)) = scope.try_root_node() {
|
||||
if check_node_for_templates(&sync, template) {
|
||||
if check_node_for_templates(sync, template) {
|
||||
dirty.push(ScopeId(id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ impl<Ctx: HotReloadingContext> FileMap<Ctx> {
|
|||
// If the cached file is not a valid rsx file, rebuild the project, forcing errors
|
||||
// TODO: in theory the error is simply in the RsxCallbody. We could attempt to parse it using partial expansion
|
||||
// And collect out its errors instead of giving up to a full rebuild
|
||||
let old = syn::parse_file(&*old_cached.raw).map_err(|_e| HotreloadError::Parse)?;
|
||||
let old = syn::parse_file(&old_cached.raw).map_err(|_e| HotreloadError::Parse)?;
|
||||
|
||||
let instances = match diff_rsx(&syntax, &old) {
|
||||
// If the changes were just some rsx, we can just update the template
|
||||
|
@ -199,7 +199,7 @@ impl<Ctx: HotReloadingContext> FileMap<Ctx> {
|
|||
};
|
||||
|
||||
// update the cached file
|
||||
old_cached.templates.insert(template.name, template.clone());
|
||||
old_cached.templates.insert(template.name, template);
|
||||
|
||||
// Track any new assets
|
||||
old_cached
|
||||
|
@ -214,26 +214,21 @@ impl<Ctx: HotReloadingContext> FileMap<Ctx> {
|
|||
|
||||
fn populate_assets(template: Template) -> HashSet<PathBuf> {
|
||||
fn collect_assetlike_attrs(node: &TemplateNode, asset_urls: &mut HashSet<PathBuf>) {
|
||||
match node {
|
||||
TemplateNode::Element {
|
||||
attrs, children, ..
|
||||
} => {
|
||||
for attr in attrs.iter() {
|
||||
match attr {
|
||||
TemplateAttribute::Static { name, value, .. } => {
|
||||
if *name == "src" || *name == "href" {
|
||||
asset_urls.insert(PathBuf::from(*value));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
if let TemplateNode::Element {
|
||||
attrs, children, ..
|
||||
} = node
|
||||
{
|
||||
for attr in attrs.iter() {
|
||||
if let TemplateAttribute::Static { name, value, .. } = attr {
|
||||
if *name == "src" || *name == "href" {
|
||||
asset_urls.insert(PathBuf::from(*value));
|
||||
}
|
||||
}
|
||||
|
||||
for child in children.iter() {
|
||||
collect_assetlike_attrs(child, asset_urls);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
||||
for child in children.iter() {
|
||||
collect_assetlike_attrs(child, asset_urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ pub(crate) fn init() -> UnboundedReceiver<Template> {
|
|||
console::log_1(&links.clone().into());
|
||||
|
||||
for x in 0..links.length() {
|
||||
console::log_1(&x.clone().into());
|
||||
console::log_1(&x.into());
|
||||
|
||||
let link: Element = links.get(x).unwrap().unchecked_into();
|
||||
let href = link.get_attribute("href").unwrap();
|
||||
|
|
Loading…
Reference in a new issue