-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
tokio: enable the unsafe_op_in_unsafe_fn lint at the crate level
#7711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9409eaf
f41bfa1
bc19c53
24f9682
d8e0249
d2da2cd
d5d86a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ impl AtomicU16 { | |
| /// All mutations must have happened before the unsynchronized load. | ||
| /// Additionally, there must be no concurrent mutations. | ||
| pub(crate) unsafe fn unsync_load(&self) -> u16 { | ||
| core::ptr::read(self.inner.get() as *const u16) | ||
| unsafe { core::ptr::read(self.inner.get() as *const u16) } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is very short, and it’s clear enough for developers to reason about the safety requirements, so we don’t need additional "Safety" comments here” |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ impl AtomicU32 { | |
| /// All mutations must have happened before the unsynchronized load. | ||
| /// Additionally, there must be no concurrent mutations. | ||
| pub(crate) unsafe fn unsync_load(&self) -> u32 { | ||
| core::ptr::read(self.inner.get() as *const u32) | ||
| unsafe { core::ptr::read(self.inner.get() as *const u32) } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is very short, and it’s clear enough for developers to reason about the safety requirements, so we don’t need additional "Safety" comments here” |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ impl AtomicUsize { | |
| /// All mutations must have happened before the unsynchronized load. | ||
| /// Additionally, there must be no concurrent mutations. | ||
| pub(crate) unsafe fn unsync_load(&self) -> usize { | ||
| core::ptr::read(self.inner.get() as *const usize) | ||
| unsafe { core::ptr::read(self.inner.get() as *const usize) } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is very short, and it’s clear enough for developers to reason about the safety requirements, so we don’t need additional "Safety" comments here” |
||
| } | ||
|
|
||
| pub(crate) fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -750,7 +750,7 @@ impl Command { | |
| where | ||
| F: FnMut() -> io::Result<()> + Send + Sync + 'static, | ||
| { | ||
| self.std.pre_exec(f); | ||
| unsafe { self.std.pre_exec(f) }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is very short, and it’s clear enough for developers to reason about the safety requirements, so we don’t need additional "Safety" comments here” |
||
| self | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -392,6 +392,10 @@ impl Handle { | |
|
|
||
| #[track_caller] | ||
| #[allow(dead_code)] | ||
| /// # Safety | ||
| /// | ||
| /// This must only be called in `LocalRuntime` if the runtime has been verified to be owned | ||
| /// by the current thread. | ||
| pub(crate) unsafe fn spawn_local_named<F>( | ||
| &self, | ||
| future: F, | ||
|
|
@@ -412,7 +416,7 @@ impl Handle { | |
| let future = super::task::trace::Trace::root(future); | ||
| #[cfg(all(tokio_unstable, feature = "tracing"))] | ||
| let future = crate::util::trace::task(future, "task", meta, id.as_u64()); | ||
| self.inner.spawn_local(future, id, meta.spawned_at) | ||
| unsafe { self.inner.spawn_local(future, id, meta.spawned_at) } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is very short, and it’s clear enough for developers to reason about the safety requirements, so we don’t need additional "Safety" comments here” |
||
| } | ||
|
|
||
| /// Returns the flavor of the current `Runtime`. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is very short, and it’s clear enough for developers to reason about the safety requirements, so we don’t need additional "Safety" comments here”