Skip to content
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

warn when calling broken functions that invoke UB #867

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
warn when calling broken functions that invoke UB
cyrgani committed Dec 18, 2024
commit 919f3ad1e4ac99a2c886bdcc2706a42a4f32daec
8 changes: 8 additions & 0 deletions src/experimental/coroutines.rs
Original file line number Diff line number Diff line change
@@ -316,6 +316,10 @@
}
}

#[deprecated(
since = "0.4.14",
note = "this invokes undefined behaviour, see issue #723"
)]
pub fn linear<T, T1, F>(
handle: Handle<T1>,
lens: F,
@@ -337,6 +341,10 @@
}
}

#[deprecated(
since = "0.4.14",
note = "this invokes undefined behaviour, see issue #723"
)]
pub async fn follow_path<T, T1, F>(handle: Handle<T1>, mut lens: F, path: Vec<T>, time: f32)
where
T: Copy + Add<Output = T> + Sub<Output = T> + Mul<f32, Output = T>,
@@ -344,7 +352,7 @@
F: for<'r> FnMut(&'r mut T1) -> &'r mut T,
{
for point in path.windows(2) {
linear(

Check warning on line 355 in src/experimental/coroutines.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

use of deprecated function `experimental::coroutines::tweens::linear`: this invokes undefined behaviour, see issue #723

Check warning on line 355 in src/experimental/coroutines.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

use of deprecated function `experimental::coroutines::tweens::linear`: this invokes undefined behaviour, see issue #723

Check warning on line 355 in src/experimental/coroutines.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

use of deprecated function `experimental::coroutines::tweens::linear`: this invokes undefined behaviour, see issue #723

Check warning on line 355 in src/experimental/coroutines.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

use of deprecated function `experimental::coroutines::tweens::linear`: this invokes undefined behaviour, see issue #723

Check warning on line 355 in src/experimental/coroutines.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

use of deprecated function `experimental::coroutines::tweens::linear`: this invokes undefined behaviour, see issue #723
handle,
&mut lens,
point[0],

Unchanged files with check annotations Beta

last_frame_time: f64,
frame_time: f64,
#[cfg(one_screenshot)]

Check warning on line 218 in src/lib.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 218 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 218 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 218 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 218 in src/lib.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

unexpected `cfg` condition name: `one_screenshot`
counter: usize,
camera_stack: Vec<camera::CameraState>,
last_frame_time: miniquad::date::now(),
frame_time: 1. / 60.,
#[cfg(one_screenshot)]

Check warning on line 360 in src/lib.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 360 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 360 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 360 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 360 in src/lib.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

unexpected `cfg` condition name: `one_screenshot`
counter: 0,
unwind: false,
recovery_future: None,
get_quad_context().commit_frame();
#[cfg(one_screenshot)]

Check warning on line 410 in src/lib.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 410 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 410 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 410 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

unexpected `cfg` condition name: `one_screenshot`

Check warning on line 410 in src/lib.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

unexpected `cfg` condition name: `one_screenshot`
{
get_context().counter += 1;
if get_context().counter == 3 {
fn get_context() -> &'static mut Context {
thread_assert::same_thread();
unsafe { CONTEXT.as_mut().unwrap_or_else(|| panic!()) }

Check warning on line 485 in src/lib.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

creating a mutable reference to mutable static is discouraged

Check warning on line 485 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

creating a mutable reference to mutable static is discouraged

Check warning on line 485 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

creating a mutable reference to mutable static is discouraged

Check warning on line 485 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

creating a mutable reference to mutable static is discouraged

Check warning on line 485 in src/lib.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

creating a mutable reference to mutable static is discouraged
}
fn get_quad_context() -> &'static mut dyn miniquad::RenderingBackend {
thread_assert::same_thread();
unsafe {
assert!(CONTEXT.is_some());

Check warning on line 492 in src/lib.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

creating a shared reference to mutable static is discouraged

Check warning on line 492 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

creating a shared reference to mutable static is discouraged

Check warning on line 492 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

creating a shared reference to mutable static is discouraged

Check warning on line 492 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

creating a shared reference to mutable static is discouraged

Check warning on line 492 in src/lib.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

creating a shared reference to mutable static is discouraged
}
unsafe { &mut *CONTEXT.as_mut().unwrap().quad_context }

Check warning on line 495 in src/lib.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

creating a mutable reference to mutable static is discouraged

Check warning on line 495 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

creating a mutable reference to mutable static is discouraged

Check warning on line 495 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

creating a mutable reference to mutable static is discouraged

Check warning on line 495 in src/lib.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

creating a mutable reference to mutable static is discouraged

Check warning on line 495 in src/lib.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

creating a mutable reference to mutable static is discouraged
}
struct Stage {
/// Will silently overwrite an old value if any.
pub fn store<T: Any>(data: T) {
unsafe {
if STORAGE.is_none() {

Check warning on line 32 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

creating a shared reference to mutable static is discouraged

Check warning on line 32 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

creating a shared reference to mutable static is discouraged

Check warning on line 32 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

creating a shared reference to mutable static is discouraged

Check warning on line 32 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

creating a shared reference to mutable static is discouraged

Check warning on line 32 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

creating a shared reference to mutable static is discouraged
STORAGE = Some(HashMap::new());
}
STORAGE

Check warning on line 36 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

creating a mutable reference to mutable static is discouraged

Check warning on line 36 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

creating a mutable reference to mutable static is discouraged

Check warning on line 36 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-pc-windows-gnu)

creating a mutable reference to mutable static is discouraged

Check warning on line 36 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

creating a mutable reference to mutable static is discouraged

Check warning on line 36 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

creating a mutable reference to mutable static is discouraged
.as_mut()
.unwrap()
.insert(TypeId::of::<T>(), Box::new(Rc::new(RefCell::new(data))))
/// Will return None if there is no data available with this type.
pub fn try_get<T: Any>() -> Option<impl Deref<Target = T>> {
unsafe {
if STORAGE.is_none() {

Check warning on line 53 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (macos-latest, x86_64-apple-darwin)

creating a shared reference to mutable static is discouraged

Check warning on line 53 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, wasm32-unknown-unknown)

creating a shared reference to mutable static is discouraged

Check warning on line 53 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (ubuntu-latest, x86_64-unknown-linux-gnu)

creating a shared reference to mutable static is discouraged

Check warning on line 53 in src/experimental/collections/storage.rs

GitHub Actions / Cross-compile (windows-latest, x86_64-pc-windows-msvc)

creating a shared reference to mutable static is discouraged
STORAGE = Some(HashMap::new());
}