Skip to content

Commit f9ce9e0

Browse files
committed
style: fixed all clippy errors
This excludes `perseus-rocket`, for now.
1 parent 0800311 commit f9ce9e0

File tree

29 files changed

+79
-80
lines changed

29 files changed

+79
-80
lines changed

examples/core/idb_freezing/src/templates/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn index_page<'a, G: Html>(cx: BoundedScope<'_, 'a>, state: &'a IndexPropsRx) ->
3434
// The IndexedDB API is asynchronous, so we'll spawn a future
3535
#[cfg(client)] // The freezing types are only available in the browser
3636
spawn_local_scoped(cx, async {
37-
use perseus::state::{IdbFrozenStateStore, Freeze, PageThawPrefs, ThawPrefs};
37+
use perseus::state::{IdbFrozenStateStore, Freeze};
3838
// We do this here (rather than when we get the reactor) so that it's updated whenever we press the button
3939
let frozen_state = reactor.freeze();
4040
let idb_store = match IdbFrozenStateStore::new().await {
@@ -56,7 +56,7 @@ fn index_page<'a, G: Html>(cx: BoundedScope<'_, 'a>, state: &'a IndexPropsRx) ->
5656
// The IndexedDB API is asynchronous, so we'll spawn a future
5757
#[cfg(client)] // The freezing types are only available in the browser
5858
spawn_local_scoped(cx, async move {
59-
use perseus::state::{IdbFrozenStateStore, Freeze, PageThawPrefs, ThawPrefs};
59+
use perseus::state::{IdbFrozenStateStore, PageThawPrefs, ThawPrefs};
6060
let idb_store = match IdbFrozenStateStore::new().await {
6161
Ok(idb_store) => idb_store,
6262
Err(_) => {

examples/demos/auth/src/global_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl AuthDataRx {
7575
let auth_token = storage.get("username").unwrap(); // This is a `Result<Option<T>, E>`
7676

7777
if let Some(username) = auth_token {
78-
self.username.set(username.to_string());
78+
self.username.set(username);
7979
self.state.set(LoginState::Yes);
8080
} else {
8181
self.username.set(String::new());

examples/website/state_generation/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ async fn get_build_paths() -> BuildPaths {
8686
#[derive(thiserror::Error, Debug)]
8787
#[error(transparent)]
8888
struct MyError(io::Error);
89+
#[cfg(engine)]
8990
fn get_post_for_path(_path: String) -> Result<Post, io::Error> {
9091
unimplemented!()
9192
}
93+
#[cfg(engine)]
9294
fn parse_markdown(_content: String) -> String {
9395
unimplemented!()
9496
}

packages/perseus-cli/src/bin/main.rs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async fn core(dir: PathBuf) -> Result<i32, Error> {
236236
// To allow exclusions to work sanely, we have to manually resolve the file tree
237237
if entry.is_dir() {
238238
// The `notify` crate internally follows symlinks, so we do here too
239-
for entry in WalkDir::new(&entry).follow_links(true) {
239+
for entry in WalkDir::new(entry).follow_links(true) {
240240
let entry = entry
241241
.map_err(|err| WatchError::ReadCustomDirEntryFailed { source: err })?;
242242
let entry = entry.path();
@@ -296,16 +296,14 @@ async fn core(dir: PathBuf) -> Result<i32, Error> {
296296
})?;
297297
}
298298
}
299-
} else {
300-
if !file_watch_excludes.contains(&entry) {
301-
watcher
302-
// The recursivity flag here will be irrelevant in all cases
303-
.watch(&entry, RecursiveMode::Recursive)
304-
.map_err(|err| WatchError::WatchFileFailed {
305-
filename: entry.to_string_lossy().to_string(),
306-
source: err,
307-
})?;
308-
}
299+
} else if !file_watch_excludes.contains(&entry) {
300+
watcher
301+
// The recursivity flag here will be irrelevant in all cases
302+
.watch(&entry, RecursiveMode::Recursive)
303+
.map_err(|err| WatchError::WatchFileFailed {
304+
filename: entry.to_string_lossy().to_string(),
305+
source: err,
306+
})?;
309307
}
310308
}
311309
// Watch any other files/directories the user has nominated (pre-canonicalized
@@ -314,7 +312,7 @@ async fn core(dir: PathBuf) -> Result<i32, Error> {
314312
// To allow exclusions to work sanely, we have to manually resolve the file tree
315313
if entry.is_dir() {
316314
// The `notify` crate internally follows symlinks, so we do here too
317-
for entry in WalkDir::new(&entry).follow_links(true) {
315+
for entry in WalkDir::new(entry).follow_links(true) {
318316
let entry = entry
319317
.map_err(|err| WatchError::ReadCustomDirEntryFailed { source: err })?;
320318
if entry.path().is_dir() {
@@ -337,16 +335,14 @@ async fn core(dir: PathBuf) -> Result<i32, Error> {
337335
})?;
338336
}
339337
}
340-
} else {
341-
if !file_watch_excludes.contains(&entry) {
342-
watcher
343-
// The recursivity flag here will be irrelevant in all cases
344-
.watch(&entry, RecursiveMode::Recursive)
345-
.map_err(|err| WatchError::WatchFileFailed {
346-
filename: entry.to_string_lossy().to_string(),
347-
source: err,
348-
})?;
349-
}
338+
} else if !file_watch_excludes.contains(entry) {
339+
watcher
340+
// The recursivity flag here will be irrelevant in all cases
341+
.watch(entry, RecursiveMode::Recursive)
342+
.map_err(|err| WatchError::WatchFileFailed {
343+
filename: entry.to_string_lossy().to_string(),
344+
source: err,
345+
})?;
350346
}
351347
}
352348

@@ -462,8 +458,7 @@ async fn core_watch(dir: PathBuf, opts: Opts) -> Result<i32, Error> {
462458
delete_artifacts(dir.clone(), "static")?;
463459
delete_artifacts(dir.clone(), "mutable")?;
464460
}
465-
let exit_code = test(dir, &test_opts, &tools, &opts)?;
466-
exit_code
461+
test(dir, test_opts, &tools, &opts)?
467462
}
468463
Subcommand::Clean => {
469464
delete_dist(dir)?;

packages/perseus-cli/src/deploy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn minify_js(from: &Path, to: &Path) -> Result<(), DeployError> {
306306
.map_err(|err| DeployError::MinifyError { source: err })?;
307307
let minified =
308308
String::from_utf8(minified).map_err(|err| DeployError::MinifyNotUtf8 { source: err })?;
309-
fs::write(to, &minified).map_err(|err| DeployError::WriteMinifiedJsFailed { source: err })?;
309+
fs::write(to, minified).map_err(|err| DeployError::WriteMinifiedJsFailed { source: err })?;
310310

311311
Ok(())
312312
}

packages/perseus-cli/src/serve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub fn serve(
239239
// rest of the build stage yet
240240
let sb_thread = build_server(
241241
dir.clone(),
242-
&spinners,
242+
spinners,
243243
num_steps,
244244
Arc::clone(&exec),
245245
opts.release,
@@ -250,7 +250,7 @@ pub fn serve(
250250
if did_build {
251251
let (sg_thread, wb_thread) = build_internal(
252252
dir.clone(),
253-
&spinners,
253+
spinners,
254254
num_steps,
255255
opts.release,
256256
tools,

packages/perseus-cli/src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ pub fn test(
145145
// We've handled errors in the component threads, so the exit code is now zero
146146
Ok(0)
147147
} else {
148-
Err(ExecutionError::GetServerExecutableFailedSimple.into())
148+
Err(ExecutionError::GetServerExecutableFailedSimple)
149149
}
150150
}

packages/perseus/src/client.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ pub fn run_client<M: MutableStore, T: TranslationsManager>(
8989
let mut running = true;
9090
// === IF THIS DISPOSER IS CALLED, PERSEUS WILL TERMINATE! ===
9191
let app_disposer = create_scope(|cx| {
92-
let core = move || {
92+
// NOTE: To anyone who ever thinks it might be a good idea to put this whole
93+
// thing in a `with_hydration_cx()`, it's not, it's really not.
94+
running = {
9395
// Create the reactor
9496
match Reactor::try_from(app) {
9597
Ok(reactor) => {
@@ -108,10 +110,6 @@ pub fn run_client<M: MutableStore, T: TranslationsManager>(
108110
}
109111
}
110112
};
111-
112-
// NOTE: To anyone who ever thinks it might be a good idea to put this whole
113-
// thing in a `with_hydration_cx()`, it's not, it's really not.
114-
running = core();
115113
});
116114

117115
dispatch_loaded(running, false);

packages/perseus/src/error_views.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub struct ErrorViews<G: Html> {
5050
/// place where it can be safely extracted. The replacement function
5151
/// will panic if called, so this should **never** be manually executed.
5252
#[cfg(any(client, doc))]
53+
#[allow(clippy::type_complexity)]
5354
panic_handler: Arc<
5455
dyn Fn(Scope, ClientError, ErrorContext, ErrorPosition) -> (View<SsrNode>, View<G>)
5556
+ Send
@@ -408,6 +409,7 @@ impl<G: Html> ErrorViews<G> {
408409
/// Extracts the panic handler from within the error views. This should
409410
/// generally only be called by `PerseusApp`'s error views instantiation
410411
/// system.
412+
#[allow(clippy::type_complexity)]
411413
pub(crate) fn take_panic_handler(
412414
&mut self,
413415
) -> Arc<

packages/perseus/src/i18n/locale_detector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn compare_locale<S: Into<String> + std::fmt::Display>(cmp: &str, locales: &[S])
112112
// Any exact match voids anything after it (it'll be further down the list or
113113
// only a partial match from here on)
114114
break;
115-
} else if cmp_parts.get(0) == parts.get(0) {
115+
} else if cmp_parts.first() == parts.first() {
116116
// If we've already had a partial match higher up the chain, this is void
117117
// But we shouldn't break in case there's an exact match coming up
118118
if !matches!(outcome, LocaleMatch::Language(_)) {

0 commit comments

Comments
 (0)