Remove usages of assert(), add PRESUBMIT checks

assert() is controlled by NDEBUG, but that's confusing because we
actually control asserts via DAWN_ENABLE_ASSERTS. Make all asserts
consistently use DAWN_ASSERT and DAWN_ENABLE_ASSERTS.

DAWN_ASSERT is also better because it avoids unused variable warnings.
(The genesis of this change was discovering one [[maybe_unused]] that
was only necessary because of an assert().)

Adds both PRESUBMIT and Clang-Tidy rules to try to enforce this.
Unfortunately the NDEBUG check won't be totally warning-clean because
sometimes we actually want that and not DAWN_ENABLE_ASSERTS. In fact I
didn't find any place we used it wrong - there's only one place NDEBUG
is used; the other one that was incorrect was already fixed:
https://dawn.googlesource.com/dawn/+/098fd8d2225013faec7bfaa3bccd2022a19cb19f

Note there are some places where assert() is implicitly in scope for
some reason, but we didn't explicitly include <cassert>. These are
detected best-effort (if they're single-line) by PRESUBMIT. assert() is
a macro, not a function, so we can't detect these with
bugprone-unsafe-functions.CustomFunctions.

Bug: 501491694
Change-Id: I583edcedddc09c8f11d1315c6de76957e6f5d498
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/345796
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/.clang-tidy b/.clang-tidy
index 5b82893..29a6e1e 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -340,3 +340,5 @@
     value: dawn::to_underlying
   - key: modernize-use-to-underlying.ReplacementFunctionHeader
     value: src/utils/numeric.h
+  - key: portability-restrict-system-includes.Includes
+    value: "*,-cassert,-assert.h"
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 17b00af..e2b606f 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -126,9 +126,9 @@
             r'^src/tint/lang/glsl/validate/validate\.cc$',
         ),
         explanation=(
-            'Do not introduce new instances of TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE) ',
-            'or TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE_IN_CONTAINER). ',
-            'Use DAWN_UNSAFE_BUFFERS with a // SAFETY: comment instead, ',
+            'Do not introduce new instances of TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE)',
+            'or TINT_BEGIN_DISABLE_WARNING(UNSAFE_BUFFER_USAGE_IN_CONTAINER).',
+            'Use DAWN_UNSAFE_BUFFERS with a // SAFETY: comment instead,',
             'or rewrite to be safe.',
         ),
         treat_as_error=False,
@@ -137,8 +137,8 @@
     BanRule(
         pattern=r'/\bDAWN_UNSAFE_TODO\b',
         explanation=(
-            'Do not introduce new instances of DAWN_UNSAFE_TODO. ',
-            'Use DAWN_UNSAFE_BUFFERS with a // SAFETY: comment instead, ',
+            'Do not introduce new instances of DAWN_UNSAFE_TODO.',
+            'Use DAWN_UNSAFE_BUFFERS with a // SAFETY: comment instead,',
             'or rewrite to be safe.',
         ),
         treat_as_error=False,
@@ -147,17 +147,40 @@
     BanRule(
         pattern=r'/#pragma\s+allow_unsafe_buffers\b',
         explanation=(
-            '#pragma allow_unsafe_buffers is discouraged. Prefer using ',
-            'DAWN_UNSAFE_BUFFERS with a // SAFETY: comment for ',
+            '#pragma allow_unsafe_buffers is discouraged. Prefer using',
+            'DAWN_UNSAFE_BUFFERS with a // SAFETY: comment for',
             'specific blocks, or rewrite to be safe.',
         ),
         treat_as_error=False,
         surface_as_gerrit_lint=True,
     ),
     BanRule(
-        pattern=r'__EMSCRIPTEN__\b',
+        pattern=r'/\bNDEBUG\b',
+        excluded_paths=(r'^src/utils/compiler\.h$', ),
+        explanation=(
+            'Use DAWN_ENABLE_ASSERTS for anything assert-related, instead of NDEBUG.',
+            '(NDEBUG builds can still have asserts, due to dawn_always_assert.)',
+        ),
+        treat_as_error=False,
+        surface_as_gerrit_lint=True,
+    ),
+    BanRule(
+        pattern=r'/([<"]cassert[">]|[<"]assert\.h[">]|\bassert\(.*\);)',
+        excluded_paths=(
+            # assert() is allowed in public headers which don't have DAWN_ASSERT.
+            r'^generator/templates/api_cpp.h$',
+            r'^include/.*\.h$',
+        ),
+        explanation=('Use DAWN_ASSERT() instead of assert().', ),
+        treat_as_error=True,
+        surface_as_gerrit_lint=True,
+    ),
+    BanRule(
+        pattern=r'/\b__EMSCRIPTEN__\b',
         excluded_paths=(r'^src/utils/platform\.h$', ),
-        explanation='Use DAWN_PLATFORM_IS(EMSCRIPTEN) instead where possible.',
+        explanation=
+        ('Use DAWN_PLATFORM_IS(EMSCRIPTEN) instead of __EMSCRIPTEN__ where possible.',
+         ),
         treat_as_error=False,
         surface_as_gerrit_lint=True,
     ),
@@ -169,7 +192,7 @@
             r'^src/tint/',
         ),
         explanation=(
-            'Use DAWN_EXPECT_DEATH_IF_SUPPORTED or ',
+            'Use DAWN_EXPECT_DEATH_IF_SUPPORTED or',
             'DAWN_EXPECT_DEBUG_DEATH_IF_SUPPORTED instead.',
         ),
         treat_as_error=True,
@@ -183,7 +206,7 @@
             r'^src/tint/',
         ),
         explanation=(
-            'Use DAWN_ASSERT_DEATH_IF_SUPPORTED or ',
+            'Use DAWN_ASSERT_DEATH_IF_SUPPORTED or',
             'DAWN_ASSERT_DEBUG_DEATH_IF_SUPPORTED instead.',
         ),
         treat_as_error=True,
@@ -203,7 +226,7 @@
         # There's no ban rule on google-explicit-constructor because it's hard
         # to implement while allowing it on operators.
         explanation=(
-            'Use explicit(false) for constructors, and ',
+            'Use explicit(false) for constructors, and',
             'NOLINTNEXTLINE(google-explicit-constructor) for operators.',
         ),
         treat_as_error=True,
diff --git a/generator/templates/art/structures.cpp b/generator/templates/art/structures.cpp
index b0a3cd0..1325775 100644
--- a/generator/templates/art/structures.cpp
+++ b/generator/templates/art/structures.cpp
@@ -28,7 +28,6 @@
 {% from 'art/kotlin_record_conversion.cpp' import define_kotlin_record_structure, define_kotlin_to_struct_conversion with context %}
 #include "structures.h"
 
-#include <cassert>
 #include <string>
 #include <mutex>
 #include <unordered_map>
@@ -36,7 +35,6 @@
 #include <jni.h>
 #include <webgpu/webgpu.h>
 
-#include "src/utils/assert.h"
 #include "src/utils/log.h"
 #include "JNIClasses.h"
 #include "JNIContext.h"
diff --git a/src/dawn/common/Compiler.h b/src/dawn/common/Compiler.h
index b42561b..8000137 100644
--- a/src/dawn/common/Compiler.h
+++ b/src/dawn/common/Compiler.h
@@ -39,7 +39,7 @@
 
 // DAWN_FORCE_INLINE
 //
-// Annotate a function indicating it should really never be inline, even in debug mode.
+// Annotate a function (in release builds only) indicating it should REALLY be inline.
 #if DAWN_COMPILER_IS(CLANG) && defined(NDEBUG) && DAWN_HAS_CPP_ATTRIBUTE(clang::always_inline)
 #define DAWN_FORCE_INLINE [[clang::always_inline]] inline
 #elif DAWN_COMPILER_IS(GCC) && defined(NDEBUG) && DAWN_HAS_ATTRIBUTE(always_inline)
diff --git a/src/dawn/native/metal/DeviceMTL.mm b/src/dawn/native/metal/DeviceMTL.mm
index c917d49..1eaa6c0 100644
--- a/src/dawn/native/metal/DeviceMTL.mm
+++ b/src/dawn/native/metal/DeviceMTL.mm
@@ -426,7 +426,7 @@
 }
 
 void Device::StartTrace() {
-    assert(!mTraceInProgress);
+    DAWN_ASSERT(!mTraceInProgress);
 
     auto [filenameBase, shouldTrace] = GetTraceInfo();
     if (!shouldTrace) {
diff --git a/src/dawn/native/webgpu/CaptureContext.h b/src/dawn/native/webgpu/CaptureContext.h
index b1299f3..e582b13 100644
--- a/src/dawn/native/webgpu/CaptureContext.h
+++ b/src/dawn/native/webgpu/CaptureContext.h
@@ -95,7 +95,7 @@
     // capturing an implicit call to createXXX.
     template <typename T>
     ResultOrError<schema::ObjectId> AddResourceAndGetId(T* object) {
-        assert(object != nullptr);
+        DAWN_ASSERT(object != nullptr);
         schema::ObjectId id;
         Ref<ApiObjectBase> ref(object);
         auto it = mObjectIds.find(ref);
diff --git a/src/dawn/node/binding/AsyncRunner.cpp b/src/dawn/node/binding/AsyncRunner.cpp
index 9c16028..5f3f2a2 100644
--- a/src/dawn/node/binding/AsyncRunner.cpp
+++ b/src/dawn/node/binding/AsyncRunner.cpp
@@ -27,9 +27,10 @@
 
 #include "src/dawn/node/binding/AsyncRunner.h"
 
-#include <cassert>
 #include <limits>
 
+#include "src/utils/assert.h"
+
 namespace wgpu::binding {
 
 // static
@@ -42,14 +43,14 @@
 AsyncRunner::AsyncRunner(dawn::native::Instance* instance) : instance_(instance) {}
 
 void AsyncRunner::Begin(Napi::Env env) {
-    assert(tasks_waiting_ != std::numeric_limits<decltype(tasks_waiting_)>::max());
+    DAWN_ASSERT(tasks_waiting_ != std::numeric_limits<decltype(tasks_waiting_)>::max());
     if (tasks_waiting_++ == 0) {
         ScheduleProcessEvents(env);
     }
 }
 
 void AsyncRunner::End() {
-    assert(tasks_waiting_ > 0);
+    DAWN_ASSERT(tasks_waiting_ > 0);
     tasks_waiting_--;
 }
 
diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp
index 53a0ca4..fca3181 100644
--- a/src/dawn/node/binding/Converter.cpp
+++ b/src/dawn/node/binding/Converter.cpp
@@ -28,7 +28,6 @@
 #include "src/dawn/node/binding/Converter.h"
 
 #include <algorithm>
-#include <cassert>
 #include <limits>
 #include <sstream>
 #include <string>
@@ -41,6 +40,7 @@
 #include "src/dawn/node/binding/GPUTexture.h"
 #include "src/dawn/node/binding/GPUTextureView.h"
 #include "src/dawn/node/utils/Debug.h"
+#include "src/utils/assert.h"
 #include "src/utils/compiler.h"
 
 namespace wgpu::binding {
@@ -54,7 +54,7 @@
 bool Converter::HasFeature(wgpu::FeatureName feature) {
     // Not all uses of the converter will have a device (for example for adapter-related
     // conversions).
-    assert(device.Get() != nullptr);
+    DAWN_ASSERT(device.Get() != nullptr);
     return device.HasFeature(feature);
 }
 
@@ -578,7 +578,7 @@
             // Note: they need to be added below as well.
     }
 
-    assert(requiredFeature != wgpu::FeatureName(0u));
+    DAWN_ASSERT(requiredFeature != wgpu::FeatureName(0u));
     if (!HasFeature(requiredFeature)) {
         std::stringstream err;
         err << "" << out << " requires feature '" << requiredFeature << "'";
@@ -965,7 +965,7 @@
             return Throw(err.str());
     }
 
-    assert(requiredFeature != wgpu::FeatureName(0u));
+    DAWN_ASSERT(requiredFeature != wgpu::FeatureName(0u));
     if (!HasFeature(requiredFeature)) {
         std::stringstream err;
         err << "" << out << " requires feature '" << requiredFeature << "'";
@@ -2136,7 +2136,7 @@
         return false;
     }
 
-    assert(size64 <= std::numeric_limits<size_t>::max());
+    DAWN_ASSERT(size64 <= std::numeric_limits<size_t>::max());
     *out = DAWN_UNSAFE_TODO(std::span<const uint8_t>(reinterpret_cast<const uint8_t*>(src.data),
                                                      static_cast<size_t>(size64)));
 
diff --git a/src/dawn/node/binding/GPUAdapterInfo.cpp b/src/dawn/node/binding/GPUAdapterInfo.cpp
index e9420b1..f7e2d7d 100644
--- a/src/dawn/node/binding/GPUAdapterInfo.cpp
+++ b/src/dawn/node/binding/GPUAdapterInfo.cpp
@@ -27,13 +27,13 @@
 
 #include "src/dawn/node/binding/GPUAdapterInfo.h"
 
-#include <cassert>
 #include <cctype>
 #include <iomanip>
 #include <span>
 #include <sstream>
 
 #include "src/dawn/node/binding/Converter.h"
+#include "src/utils/assert.h"
 #include "src/utils/compiler.h"
 
 namespace wgpu::binding {
@@ -60,7 +60,7 @@
         case SubgroupMatrixComponentType::I8:
             return interop::GPUSubgroupMatrixComponentType::kI8;
     }
-    assert(false);
+    DAWN_ASSERT(false);
     return interop::GPUSubgroupMatrixComponentType::kF32;
 }
 
diff --git a/src/dawn/node/binding/GPUBuffer.cpp b/src/dawn/node/binding/GPUBuffer.cpp
index bf34b3b..8698496 100644
--- a/src/dawn/node/binding/GPUBuffer.cpp
+++ b/src/dawn/node/binding/GPUBuffer.cpp
@@ -27,12 +27,12 @@
 
 #include "src/dawn/node/binding/GPUBuffer.h"
 
-#include <cassert>
 #include <memory>
 #include <utility>
 
 #include "src/dawn/node/binding/Converter.h"
 #include "src/dawn/node/binding/Errors.h"
+#include "src/utils/assert.h"
 #include "src/utils/numeric.h"
 
 namespace wgpu::binding {
@@ -81,7 +81,7 @@
             // The promise may already have been resolved with an AbortError if there was an early
             // destroy() or early unmap().
             if (ctx->promise.GetState() != interop::PromiseState::Pending) {
-                assert(ctx->promise.GetState() == interop::PromiseState::Rejected);
+                DAWN_ASSERT(ctx->promise.GetState() == interop::PromiseState::Rejected);
                 return;
             }
 
@@ -92,7 +92,7 @@
                     break;
                 case wgpu::MapAsyncStatus::CallbackCancelled:
                 case wgpu::MapAsyncStatus::Aborted:
-                    assert(status != wgpu::MapAsyncStatus::CallbackCancelled);
+                    DAWN_ASSERT(status != wgpu::MapAsyncStatus::CallbackCancelled);
                     async_->Reject(ctx->env, ctx->promise, Errors::AbortError(ctx->env));
                     break;
                 case wgpu::MapAsyncStatus::Error:
@@ -102,7 +102,7 @@
 
             // This captured promise is the currently pending mapping, reset it so we can start new
             // mappings.
-            assert(*pending_map_ == ctx->promise);
+            DAWN_ASSERT(*pending_map_ == ctx->promise);
             pending_map_.reset();
         });
 
@@ -159,7 +159,7 @@
     }
 
     if (pending_map_) {
-        assert(pending_map_->GetState() == interop::PromiseState::Pending);
+        DAWN_ASSERT(pending_map_->GetState() == interop::PromiseState::Pending);
         return interop::GPUBufferMapState::kPending;
     }
 
diff --git a/src/dawn/node/binding/GPUDevice.cpp b/src/dawn/node/binding/GPUDevice.cpp
index 6f1cb6a..3056209 100644
--- a/src/dawn/node/binding/GPUDevice.cpp
+++ b/src/dawn/node/binding/GPUDevice.cpp
@@ -27,7 +27,6 @@
 
 #include "src/dawn/node/binding/GPUDevice.h"
 
-#include <cassert>
 #include <cstdio>
 #include <memory>
 #include <string_view>
@@ -55,6 +54,7 @@
 #include "src/dawn/node/binding/GPUSupportedLimits.h"
 #include "src/dawn/node/binding/GPUTexture.h"
 #include "src/dawn/node/utils/Debug.h"
+#include "src/utils/assert.h"
 #include "src/utils/compiler.h"
 #include "src/utils/numeric.h"
 
@@ -131,7 +131,7 @@
             // you're using an older version of Emscripten). It shouldn't happen in Dawn.
             break;
     }
-    assert(false);
+    DAWN_ASSERT(false);
     return {};
 }
 
@@ -332,7 +332,7 @@
     // Buffer creation may return nullptr if it fails to map at creation. Translate that to a
     // RangeError as required by the spec.
     if (dawnBuffer == nullptr) {
-        assert(descriptor.mappedAtCreation);
+        DAWN_ASSERT(descriptor.mappedAtCreation);
         Napi::RangeError::New(env, "createBuffer failed to allocate a buffer mapped at creation.")
             .ThrowAsJavaScriptException();
         return {};
diff --git a/src/dawn/node/binding/GPUQueue.cpp b/src/dawn/node/binding/GPUQueue.cpp
index bbaf067..52b0db4 100644
--- a/src/dawn/node/binding/GPUQueue.cpp
+++ b/src/dawn/node/binding/GPUQueue.cpp
@@ -27,7 +27,6 @@
 
 #include "src/dawn/node/binding/GPUQueue.h"
 
-#include <cassert>
 #include <limits>
 #include <memory>
 #include <utility>
diff --git a/src/dawn/node/binding/GPUShaderModule.cpp b/src/dawn/node/binding/GPUShaderModule.cpp
index e86bac2..5cb2384 100644
--- a/src/dawn/node/binding/GPUShaderModule.cpp
+++ b/src/dawn/node/binding/GPUShaderModule.cpp
@@ -33,7 +33,7 @@
 #include <vector>
 
 #include "src/dawn/node/binding/Converter.h"
-#include "src/utils/compiler.h"
+#include "src/utils/assert.h"
 
 namespace wgpu::binding {
 
@@ -60,7 +60,7 @@
             [[maybe_unused]] bool foundUtf16 = false;
             for (const auto* chain = m.nextInChain; chain != nullptr; chain = chain->nextInChain) {
                 if (chain->sType == wgpu::SType::DawnCompilationMessageUtf16) {
-                    assert(!foundUtf16);
+                    DAWN_ASSERT(!foundUtf16);
                     foundUtf16 = true;
                     const auto* utf16 =
                         reinterpret_cast<const wgpu::DawnCompilationMessageUtf16*>(chain);
@@ -69,7 +69,7 @@
                     length = utf16->length;
                 }
             }
-            assert(foundUtf16);
+            DAWN_ASSERT(foundUtf16);
 
             switch (m.type) {
                 case wgpu::CompilationMessageType::Error:
diff --git a/src/dawn/node/interop/Core.h b/src/dawn/node/interop/Core.h
index 8cb35b2..3586273 100644
--- a/src/dawn/node/interop/Core.h
+++ b/src/dawn/node/interop/Core.h
@@ -32,7 +32,6 @@
 #define SRC_DAWN_NODE_INTEROP_CORE_H_
 
 #include <algorithm>
-#include <cassert>
 #include <concepts>
 #include <cstdint>
 #include <limits>
@@ -46,6 +45,7 @@
 
 #include "src/dawn/node/interop/NodeAPI.h"
 #include "src/dawn/node/utils/Debug.h"
+#include "src/utils/assert.h"
 
 #define ENABLE_INTEROP_LOGGING 0  // Enable for verbose interop logging
 
@@ -838,7 +838,7 @@
 template <typename F>
 Napi::Value CatchExceptionIntoPromise(Napi::Env env, F&& f) {
     Napi::Value result = f();
-    assert(result.IsEmpty() || result.IsPromise());
+    DAWN_ASSERT(result.IsEmpty() || result.IsPromise());
     if (!env.IsExceptionPending()) {
         return result;
     }
diff --git a/src/dawn/node/napi_v8/napi_v8.cpp b/src/dawn/node/napi_v8/napi_v8.cpp
index 2aa97c5..038d693 100644
--- a/src/dawn/node/napi_v8/napi_v8.cpp
+++ b/src/dawn/node/napi_v8/napi_v8.cpp
@@ -28,13 +28,13 @@
 #include "src/dawn/node/napi_v8/napi_v8.h"
 
 #include <algorithm>
-#include <cassert>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <limits>
 #include <utility>
 
+#include "src/utils/assert.h"
 #include "src/utils/compiler.h"
 
 namespace {
@@ -188,14 +188,14 @@
     v8::Local<v8::Value> set_immediate_val;
     [[maybe_unused]] bool has_set_immediate =
         ctx->Global()->Get(ctx, key).ToLocal(&set_immediate_val) && set_immediate_val->IsFunction();
-    assert(has_set_immediate);
+    DAWN_ASSERT(has_set_immediate);
 
     v8::Local<v8::External> ext =
         v8::External::New(env->isolate, env, v8::kExternalPointerTypeTagDefault);
     v8::Local<v8::Function> drain_fn;
     [[maybe_unused]] bool has_drain_fn =
         v8::Function::New(ctx, DrainFinalizersV8Callback, ext).ToLocal(&drain_fn);
-    assert(has_drain_fn);
+    DAWN_ASSERT(has_drain_fn);
 
     env->finalizer_drain_scheduled = true;
     v8::Local<v8::Value> arg = drain_fn;
diff --git a/src/dawn/node/standalone/BUILD.gn b/src/dawn/node/standalone/BUILD.gn
index 220410e..38f5124 100644
--- a/src/dawn/node/standalone/BUILD.gn
+++ b/src/dawn/node/standalone/BUILD.gn
@@ -43,7 +43,10 @@
     # Private: EventLoop.h only forward declares the V8 types it holds pointers
     # to, so a consumer that never runs a task needs none of this.
     include_dirs = [ "${dawn_root}/third_party/v8/src/include" ]
-    deps = [ "//third_party/v8/src:v8" ]
+    deps = [
+      "${dawn_root}/src/utils",
+      "//third_party/v8/src:v8",
+    ]
 
     # Public because EventLoop::Task is an absl::AnyInvocable.
     public_deps = [ "${dawn_abseil_dir}:absl" ]
diff --git a/src/dawn/node/standalone/EventLoop.cpp b/src/dawn/node/standalone/EventLoop.cpp
index adac08c..af6d3ba 100644
--- a/src/dawn/node/standalone/EventLoop.cpp
+++ b/src/dawn/node/standalone/EventLoop.cpp
@@ -28,13 +28,14 @@
 #include "src/dawn/node/standalone/EventLoop.h"
 
 #include <algorithm>
-#include <cassert>
 #include <deque>
 #include <iostream>
 #include <optional>
 #include <thread>
 #include <utility>
 
+#include "src/utils/assert.h"
+
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wundef"
 #pragma clang diagnostic ignored "-Wcast-function-type-strict"
@@ -95,7 +96,7 @@
 EventLoop::~EventLoop() = default;
 
 void EventLoop::AssertOnLoopThread() const {
-    assert(std::this_thread::get_id() == thread_id_);
+    DAWN_ASSERT(std::this_thread::get_id() == thread_id_);
 }
 
 void EventLoop::PostTask(Task task) {
diff --git a/src/dawn/node/standalone/EventLoop.h b/src/dawn/node/standalone/EventLoop.h
index 58c6751..b8aba47 100644
--- a/src/dawn/node/standalone/EventLoop.h
+++ b/src/dawn/node/standalone/EventLoop.h
@@ -151,7 +151,7 @@
     v8::Isolate* const isolate_;
     v8::Platform* const platform_;
     // The thread the loop belongs to. Only read by AssertOnLoopThread().
-    [[maybe_unused]] const std::thread::id thread_id_ = std::this_thread::get_id();
+    const std::thread::id thread_id_ = std::this_thread::get_id();
     // Tasks waiting for the next check phase, in the order they were posted.
     std::deque<Task> immediates_;
     absl::btree_map<TimerKey, Task> timers_;
diff --git a/src/tint/lang/wgsl/writer/ast_printer/literal_test.cc b/src/tint/lang/wgsl/writer/ast_printer/literal_test.cc
index 728bd48..47fa404 100644
--- a/src/tint/lang/wgsl/writer/ast_printer/literal_test.cc
+++ b/src/tint/lang/wgsl/writer/ast_printer/literal_test.cc
@@ -32,7 +32,7 @@
 #include "src/tint/lang/wgsl/writer/ast_printer/helper_test.h"
 #include "src/tint/utils/memory/bitcast.h"
 #include "src/tint/utils/text/string_stream.h"
-#include "src/utils/compiler.h"
+#include "src/utils/assert.h"
 
 using namespace tint::core::number_suffixes;  // NOLINT
 using namespace tint::core::fluent_types;     // NOLINT
@@ -61,15 +61,15 @@
 // - 'exponent_bits' is placed in the exponent space.
 // - the exponent bias (15) already be included.
 f16 MakeF16(uint32_t sign, uint32_t f16_biased_exponent, uint16_t f16_mantissa) {
-    assert((f16_biased_exponent & 0xffffffe0u) == 0);
-    assert((f16_mantissa & 0xfc00u) == 0);
+    DAWN_ASSERT((f16_biased_exponent & 0xffffffe0u) == 0);
+    DAWN_ASSERT((f16_mantissa & 0xfc00u) == 0);
 
     const uint32_t sign_bit = sign ? 0x80000000u : 0u;
 
     // F16 has a exponent bias of 15, and f32 bias 127. Adding 127-15=112 to the f16-biased exponent
     // to get f32-biased exponent.
     uint32_t f32_biased_exponent = (f16_biased_exponent & 0x1fu) + 112;
-    assert((f32_biased_exponent & 0xffffff00u) == 0);
+    DAWN_ASSERT((f32_biased_exponent & 0xffffff00u) == 0);
 
     if (f16_biased_exponent == 0) {
         // +/- zero, or subnormal
@@ -82,7 +82,7 @@
         // There must be at least one of the 10 mantissa bits being 1, left-shift the mantissa bits
         // until the most significant 1 bit is left-shifted to 10th bit (count from zero), which
         // will be omitted in the resulting f32 mantissa part.
-        assert(f16_mantissa & 0x03ffu);
+        DAWN_ASSERT(f16_mantissa & 0x03ffu);
         while ((f16_mantissa & 0x0400u) == 0) {
             f16_mantissa = static_cast<uint16_t>(f16_mantissa << 1);
             f32_biased_exponent--;
diff --git a/tools/android/webgpu/src/main/cpp/JNIContext.cpp b/tools/android/webgpu/src/main/cpp/JNIContext.cpp
index 658acff..015f3e4 100644
--- a/tools/android/webgpu/src/main/cpp/JNIContext.cpp
+++ b/tools/android/webgpu/src/main/cpp/JNIContext.cpp
@@ -28,7 +28,6 @@
 #include "JNIContext.h"
 
 #include <algorithm>
-#include <cassert>
 
 #include "structures.h"