Merge pull request #289 from gbj/forbid-unsafe
Forbid `unsafe` code in all packages
This commit is contained in:
commit
b8cafeb650
|
@ -1,3 +1,5 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::{ServiceFactory, ServiceRequest},
|
dev::{ServiceFactory, ServiceRequest},
|
||||||
http::header,
|
http::header,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
body::{Body, Bytes, Full, StreamBody},
|
body::{Body, Bytes, Full, StreamBody},
|
||||||
extract::Path,
|
extract::Path,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
//! # About Leptos
|
//! # About Leptos
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
|
||||||
use crate::errors::LeptosConfigError;
|
use crate::errors::LeptosConfigError;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
#![cfg_attr(not(feature = "stable"), feature(fn_traits))]
|
#![cfg_attr(not(feature = "stable"), feature(fn_traits))]
|
||||||
#![cfg_attr(not(feature = "stable"), feature(unboxed_closures))]
|
#![cfg_attr(not(feature = "stable"), feature(unboxed_closures))]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![cfg_attr(not(feature = "stable"), feature(proc_macro_span))]
|
#![cfg_attr(not(feature = "stable"), feature(proc_macro_span))]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate proc_macro_error;
|
extern crate proc_macro_error;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use std::{
|
use std::{
|
||||||
any::{Any, TypeId},
|
any::{Any, TypeId},
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::runtime::{with_runtime, RuntimeId};
|
use crate::runtime::{with_runtime, RuntimeId};
|
||||||
use crate::{debug_warn, Runtime, Scope, ScopeProperty};
|
use crate::{debug_warn, Runtime, Scope, ScopeProperty};
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{runtime::PinnedFuture, ResourceId};
|
use crate::{runtime::PinnedFuture, ResourceId};
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
|
@ -82,6 +82,7 @@ mod signal;
|
||||||
mod signal_wrappers_read;
|
mod signal_wrappers_read;
|
||||||
mod signal_wrappers_write;
|
mod signal_wrappers_write;
|
||||||
mod spawn;
|
mod spawn;
|
||||||
|
mod spawn_microtask;
|
||||||
mod stored_value;
|
mod stored_value;
|
||||||
mod suspense;
|
mod suspense;
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ pub use signal::*;
|
||||||
pub use signal_wrappers_read::*;
|
pub use signal_wrappers_read::*;
|
||||||
pub use signal_wrappers_write::*;
|
pub use signal_wrappers_write::*;
|
||||||
pub use spawn::*;
|
pub use spawn::*;
|
||||||
|
pub use spawn_microtask::*;
|
||||||
pub use stored_value::*;
|
pub use stored_value::*;
|
||||||
pub use suspense::*;
|
pub use suspense::*;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{ReadSignal, Scope, SignalError, UntrackedGettableSignal};
|
use crate::{ReadSignal, Scope, SignalError, UntrackedGettableSignal};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{
|
use crate::{
|
||||||
create_effect, create_isomorphic_effect, create_memo, create_signal, queue_microtask,
|
create_effect, create_isomorphic_effect, create_memo, create_signal, queue_microtask,
|
||||||
runtime::{with_runtime, RuntimeId},
|
runtime::{with_runtime, RuntimeId},
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{
|
use crate::{
|
||||||
hydration::SharedContext, serialization::Serializable, AnyEffect, AnyResource, Effect,
|
hydration::SharedContext, serialization::Serializable, AnyEffect, AnyResource, Effect,
|
||||||
EffectId, Memo, ReadSignal, ResourceId, ResourceState, RwSignal, Scope, ScopeDisposer, ScopeId,
|
EffectId, Memo, ReadSignal, ResourceId, ResourceState, RwSignal, Scope, ScopeDisposer, ScopeId,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{
|
use crate::{
|
||||||
runtime::{with_runtime, RuntimeId},
|
runtime::{with_runtime, RuntimeId},
|
||||||
EffectId, PinnedFuture, ResourceId, SignalId, SuspenseContext,
|
EffectId, PinnedFuture, ResourceId, SignalId, SuspenseContext,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use std::{cell::RefCell, collections::HashMap, fmt::Debug, hash::Hash, rc::Rc};
|
use std::{cell::RefCell, collections::HashMap, fmt::Debug, hash::Hash, rc::Rc};
|
||||||
|
|
||||||
use crate::{create_isomorphic_effect, create_signal, ReadSignal, Scope, WriteSignal};
|
use crate::{create_isomorphic_effect, create_signal, ReadSignal, Scope, WriteSignal};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{
|
use crate::{
|
||||||
debug_warn,
|
debug_warn,
|
||||||
runtime::{with_runtime, RuntimeId},
|
runtime::{with_runtime, RuntimeId},
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{store_value, Memo, ReadSignal, RwSignal, Scope, StoredValue, UntrackedGettableSignal};
|
use crate::{store_value, Memo, ReadSignal, RwSignal, Scope, StoredValue, UntrackedGettableSignal};
|
||||||
|
|
||||||
/// Helper trait for converting `Fn() -> T` closures into
|
/// Helper trait for converting `Fn() -> T` closures into
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{store_value, RwSignal, Scope, StoredValue, WriteSignal};
|
use crate::{store_value, RwSignal, Scope, StoredValue, WriteSignal};
|
||||||
|
|
||||||
/// Helper trait for converting `Fn(T)` into [`SignalSetter<T>`].
|
/// Helper trait for converting `Fn(T)` into [`SignalSetter<T>`].
|
||||||
|
|
|
@ -1,31 +1,7 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
cfg_if! {
|
|
||||||
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
|
||||||
/// Exposes the [queueMicrotask](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask) method
|
|
||||||
/// in the browser, and simply runs the given function when on the server.
|
|
||||||
pub fn queue_microtask(task: impl FnOnce() + 'static) {
|
|
||||||
microtask(wasm_bindgen::closure::Closure::once_into_js(task));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(feature = "csr", feature = "hydrate"))]
|
|
||||||
#[wasm_bindgen::prelude::wasm_bindgen(
|
|
||||||
inline_js = "export function microtask(f) { queueMicrotask(f); }"
|
|
||||||
)]
|
|
||||||
extern "C" {
|
|
||||||
fn microtask(task: wasm_bindgen::JsValue);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/// Exposes the [queueMicrotask](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask) method
|
|
||||||
/// in the browser, and simply runs the given function when on the server.
|
|
||||||
#[cfg(not(any(feature = "csr", feature = "hydrate")))]
|
|
||||||
pub fn queue_microtask(task: impl FnOnce()) {
|
|
||||||
task();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Spawns and runs a thread-local [std::future::Future] in a platform-independent way.
|
/// Spawns and runs a thread-local [std::future::Future] in a platform-independent way.
|
||||||
///
|
///
|
||||||
/// This can be used to interface with any `async` code.
|
/// This can be used to interface with any `async` code.
|
||||||
|
@ -33,7 +9,7 @@ pub fn spawn_local<F>(fut: F)
|
||||||
where
|
where
|
||||||
F: Future<Output = ()> + 'static,
|
F: Future<Output = ()> + 'static,
|
||||||
{
|
{
|
||||||
cfg_if::cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
||||||
wasm_bindgen_futures::spawn_local(fut)
|
wasm_bindgen_futures::spawn_local(fut)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
// `queue_microtask` needs to be in its own module, which is the only thing
|
||||||
|
// in this entire framework that requires "unsafe" code (because Rust seems to
|
||||||
|
// that a `wasm_bindgen` imported function like this is unsafe)
|
||||||
|
// this is stupid, and one day hopefully web_sys will add queue_microtask itself
|
||||||
|
|
||||||
|
use cfg_if::cfg_if;
|
||||||
|
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(any(feature = "csr", feature = "hydrate"))] {
|
||||||
|
/// Exposes the [queueMicrotask](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask) method
|
||||||
|
/// in the browser, and simply runs the given function when on the server.
|
||||||
|
pub fn queue_microtask(task: impl FnOnce() + 'static) {
|
||||||
|
microtask(wasm_bindgen::closure::Closure::once_into_js(task));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "csr", feature = "hydrate"))]
|
||||||
|
#[wasm_bindgen::prelude::wasm_bindgen(
|
||||||
|
inline_js = "export function microtask(f) { queueMicrotask(f); }"
|
||||||
|
)]
|
||||||
|
extern "C" {
|
||||||
|
fn microtask(task: wasm_bindgen::JsValue);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/// Exposes the [queueMicrotask](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask) method
|
||||||
|
/// in the browser, and simply runs the given function when on the server.
|
||||||
|
#[cfg(not(any(feature = "csr", feature = "hydrate")))]
|
||||||
|
pub fn queue_microtask(task: impl FnOnce()) {
|
||||||
|
task();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
use crate::{create_rw_signal, RwSignal, Scope, UntrackedGettableSignal, UntrackedSettableSignal};
|
use crate::{create_rw_signal, RwSignal, Scope, UntrackedGettableSignal, UntrackedSettableSignal};
|
||||||
|
|
||||||
/// A **non-reactive** wrapper for any value, which can be created with [store_value].
|
/// A **non-reactive** wrapper for any value, which can be created with [store_value].
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{create_signal, spawn::queue_microtask, ReadSignal, Scope, WriteSignal};
|
#![forbid(unsafe_code)]
|
||||||
|
use crate::{create_signal, queue_microtask, ReadSignal, Scope, WriteSignal};
|
||||||
|
|
||||||
/// Tracks [Resource](crate::Resource)s that are read under a suspense context,
|
/// Tracks [Resource](crate::Resource)s that are read under a suspense context,
|
||||||
/// i.e., within a [`Suspense`](https://docs.rs/leptos_core/latest/leptos_core/fn.Suspense.html) component.
|
/// i.e., within a [`Suspense`](https://docs.rs/leptos_core/latest/leptos_core/fn.Suspense.html) component.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
//! # Leptos Server Functions
|
//! # Leptos Server Functions
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
//! # Leptos Meta
|
//! # Leptos Meta
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
//! # Leptos Router
|
//! # Leptos Router
|
||||||
//!
|
//!
|
||||||
//! Leptos Router is a router and state management tool for web applications
|
//! Leptos Router is a router and state management tool for web applications
|
||||||
|
|
Loading…
Reference in New Issue