Skip to content

Commit 838ed2d

Browse files
authored
Enable allow_attributes_without_reason (#11195)
* Enable `allow_attributes_without_reason` This commit enables the `clippy::allow_attributes_without_reason` for the `wasmtime` crate which previously forcibly allowed it. The reason this was allowed was that when the workspace was first migrated the Wasmtime crate had too many instances that I was willing to fix. I've now come back around and tried to fix everything. In short: ideally delete `#[allow]`, otherwise use `#[expect]`, otherwise use `#[allow]`. prtest:full * Adjust some directives * Fix some warnings * Fix stack switching size tests on unix * Don't have a conditional `Drop` impl * Force `testing_freelist` method to be used Too lazy to write `#[cfg]`, but not too lazy to write a test.
1 parent bdb963d commit 838ed2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+182
-221
lines changed

crates/wasmtime/src/config.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,17 +2281,16 @@ impl Config {
22812281

22822282
match &self.allocation_strategy {
22832283
InstanceAllocationStrategy::OnDemand => {
2284-
#[allow(unused_mut)]
2285-
let mut allocator = Box::new(OnDemandInstanceAllocator::new(
2284+
let mut _allocator = Box::new(OnDemandInstanceAllocator::new(
22862285
self.mem_creator.clone(),
22872286
stack_size,
22882287
stack_zeroing,
22892288
));
22902289
#[cfg(feature = "async")]
22912290
if let Some(stack_creator) = &self.stack_creator {
2292-
allocator.set_stack_creator(stack_creator.clone());
2291+
_allocator.set_stack_creator(stack_creator.clone());
22932292
}
2294-
Ok(allocator)
2293+
Ok(_allocator)
22952294
}
22962295
#[cfg(feature = "pooling-allocator")]
22972296
InstanceAllocationStrategy::Pooling(config) => {
@@ -2317,7 +2316,7 @@ impl Config {
23172316
#[cfg(feature = "gc")]
23182317
#[cfg_attr(
23192318
not(any(feature = "gc-null", feature = "gc-drc")),
2320-
allow(unused_variables, unreachable_code)
2319+
expect(unreachable_code, reason = "definitions known to be dummy")
23212320
)]
23222321
{
23232322
Ok(Some(match self.collector.try_not_auto()? {
@@ -3571,7 +3570,10 @@ fn detect_host_feature(feature: &str) -> Option<bool> {
35713570
};
35723571
}
35733572

3574-
#[allow(unreachable_code)]
3573+
#[allow(
3574+
unreachable_code,
3575+
reason = "reachable or not depending on if a target above matches"
3576+
)]
35753577
{
35763578
let _ = feature;
35773579
return None;

crates/wasmtime/src/engine.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -761,25 +761,6 @@ impl Engine {
761761
crate::compile::HashedEngineCompileEnv(self)
762762
}
763763

764-
/// Executes `f1` and `f2` in parallel if parallel compilation is enabled at
765-
/// both runtime and compile time, otherwise runs them synchronously.
766-
#[allow(dead_code)] // only used for the component-model feature right now
767-
pub(crate) fn join_maybe_parallel<T, U>(
768-
&self,
769-
f1: impl FnOnce() -> T + Send,
770-
f2: impl FnOnce() -> U + Send,
771-
) -> (T, U)
772-
where
773-
T: Send,
774-
U: Send,
775-
{
776-
if self.config().parallel_compilation {
777-
#[cfg(feature = "parallel-compilation")]
778-
return rayon::join(f1, f2);
779-
}
780-
(f1(), f2())
781-
}
782-
783764
/// Returns the required alignment for a code image, if we
784765
/// allocate in a way that is not a system `mmap()` that naturally
785766
/// aligns it.

crates/wasmtime/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,14 @@
284284
// here to get warnings in all configurations of Wasmtime.
285285
#![cfg_attr(
286286
any(not(feature = "runtime"), not(feature = "std")),
287-
allow(dead_code, unused_imports)
287+
expect(dead_code, unused_imports, reason = "list not burned down yet")
288288
)]
289289
// Allow broken links when the default features is disabled because most of our
290290
// documentation is written for the "one build" of the `main` branch which has
291291
// most features enabled. This will present warnings in stripped-down doc builds
292292
// and will prevent the doc build from failing.
293293
#![cfg_attr(feature = "default", warn(rustdoc::broken_intra_doc_links))]
294294
#![no_std]
295-
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]
296295
#![expect(unsafe_op_in_unsafe_fn, reason = "crate isn't migrated yet")]
297296

298297
#[cfg(feature = "std")]
@@ -333,7 +332,7 @@ pub(crate) use hashbrown::{hash_map, hash_set};
333332
#[macro_export]
334333
macro_rules! map_maybe_uninit {
335334
($maybe_uninit:ident $($field:tt)*) => ({
336-
#[allow(unused_unsafe)]
335+
#[allow(unused_unsafe, reason = "macro-generated code")]
337336
{
338337
unsafe {
339338
use $crate::MaybeUninitExt;
@@ -391,7 +390,6 @@ mod sync_std;
391390
#[cfg(feature = "std")]
392391
use sync_std as sync;
393392

394-
#[cfg_attr(feature = "std", allow(dead_code))]
395393
mod sync_nostd;
396394
#[cfg(not(feature = "std"))]
397395
use sync_nostd as sync;

crates/wasmtime/src/profiling_agent/jitdump.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use object::elf;
1717
use std::process;
1818
use std::sync::Mutex;
1919
use target_lexicon::Architecture;
20+
use wasmtime_environ::Unsigned;
2021
use wasmtime_jit_debug::perf_jitdump::*;
2122

2223
/// Interface for driving the creation of jitdump files
@@ -54,8 +55,7 @@ impl ProfilingAgent for JitDumpAgent {
5455
let mut jitdump_file = JITDUMP_FILE.lock().unwrap();
5556
let jitdump_file = jitdump_file.as_mut().unwrap();
5657
let timestamp = jitdump_file.get_time_stamp();
57-
#[allow(trivial_numeric_casts)]
58-
let tid = rustix::thread::gettid().as_raw_nonzero().get() as u32;
58+
let tid = rustix::thread::gettid().as_raw_nonzero().get().unsigned();
5959
if let Err(err) = jitdump_file.dump_code_load_record(&name, code, timestamp, self.pid, tid)
6060
{
6161
println!("Jitdump: write_code_load_failed_record failed: {err:?}\n");

crates/wasmtime/src/runtime/component/bindgen_examples/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
//! [`wit_parser::Resolve::push_dir`]: https://docs.rs/wit-parser/latest/wit_parser/struct.Resolve.html#method.push_dir
4141
//! [open an issue]: https://github.com/bytecodealliance/wasmtime/issues/new
4242
43-
#![allow(missing_docs)]
43+
#![expect(
44+
missing_docs,
45+
reason = "bindgen-generated types known to not have docs"
46+
)]
4447

4548
// This "hack" will shadow the `bindgen` macro in general and be inherited to
4649
// following modules by default. This enables documenting sources as-is while

crates/wasmtime/src/runtime/component/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl Component {
466466
&self.inner.static_modules[idx]
467467
}
468468

469-
#[cfg_attr(not(feature = "profiling"), allow(dead_code))]
469+
#[cfg(feature = "profiling")]
470470
pub(crate) fn static_modules(&self) -> impl Iterator<Item = &Module> {
471471
self.inner.static_modules.values()
472472
}

crates/wasmtime/src/runtime/component/concurrent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) use futures_and_streams::{
2525

2626
mod futures_and_streams;
2727

28-
#[allow(dead_code)]
28+
#[expect(dead_code, reason = "to be used soon")]
2929
pub enum Status {
3030
Starting = 0,
3131
Started = 1,

crates/wasmtime/src/runtime/component/func/options.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ pub struct Options {
4949
async_: bool,
5050

5151
/// The callback for an async-lifted export, if specified.
52-
#[cfg_attr(not(feature = "component-model-async"), expect(unused))]
52+
#[cfg_attr(
53+
not(feature = "component-model-async"),
54+
expect(unused, reason = "to be used soon")
55+
)]
5356
callback: Option<NonNull<VMFuncRef>>,
5457
}
5558

crates/wasmtime/src/runtime/component/func/typed.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ macro_rules! integers {
10061006

10071007
unsafe impl Lower for $primitive {
10081008
#[inline]
1009-
#[allow(trivial_numeric_casts)]
1009+
#[allow(trivial_numeric_casts, reason = "macro-generated code")]
10101010
fn linear_lower_to_flat<T>(
10111011
&self,
10121012
_cx: &mut LowerContext<'_, T>,
@@ -1071,7 +1071,11 @@ macro_rules! integers {
10711071

10721072
unsafe impl Lift for $primitive {
10731073
#[inline]
1074-
#[allow(trivial_numeric_casts, clippy::cast_possible_truncation)]
1074+
#[allow(
1075+
trivial_numeric_casts,
1076+
clippy::cast_possible_truncation,
1077+
reason = "macro-generated code"
1078+
)]
10751079
fn linear_lift_from_flat(_cx: &mut LiftContext<'_>, ty: InterfaceType, src: &Self::Lower) -> Result<Self> {
10761080
debug_assert!(matches!(ty, InterfaceType::$ty));
10771081
Ok(src.$get() as $primitive)
@@ -2645,7 +2649,7 @@ where
26452649
///
26462650
/// Uses default type parameters to have fields be zero-sized and not present
26472651
/// in memory for smaller tuple values.
2648-
#[allow(non_snake_case)]
2652+
#[expect(non_snake_case, reason = "more amenable to macro-generated code")]
26492653
#[doc(hidden)]
26502654
#[derive(Clone, Copy)]
26512655
#[repr(C)]
@@ -2691,7 +2695,7 @@ pub struct TupleLower<
26912695

26922696
macro_rules! impl_component_ty_for_tuples {
26932697
($n:tt $($t:ident)*) => {
2694-
#[allow(non_snake_case)]
2698+
#[allow(non_snake_case, reason = "macro-generated code")]
26952699
unsafe impl<$($t,)*> ComponentType for ($($t,)*)
26962700
where $($t: ComponentType),*
26972701
{
@@ -2718,7 +2722,7 @@ macro_rules! impl_component_ty_for_tuples {
27182722
}
27192723
}
27202724

2721-
#[allow(non_snake_case)]
2725+
#[allow(non_snake_case, reason = "macro-generated code")]
27222726
unsafe impl<$($t,)*> Lower for ($($t,)*)
27232727
where $($t: Lower),*
27242728
{
@@ -2762,7 +2766,7 @@ macro_rules! impl_component_ty_for_tuples {
27622766
}
27632767
}
27642768

2765-
#[allow(non_snake_case)]
2769+
#[allow(non_snake_case, reason = "macro-generated code")]
27662770
unsafe impl<$($t,)*> Lift for ($($t,)*)
27672771
where $($t: Lift),*
27682772
{
@@ -2799,7 +2803,7 @@ macro_rules! impl_component_ty_for_tuples {
27992803
}
28002804
}
28012805

2802-
#[allow(non_snake_case)]
2806+
#[allow(non_snake_case, reason = "macro-generated code")]
28032807
unsafe impl<$($t,)*> ComponentNamedList for ($($t,)*)
28042808
where $($t: ComponentType),*
28052809
{}

crates/wasmtime/src/runtime/component/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@
9797
//!
9898
//! See the docs for [`bindgen!`] for more information on how to use it.
9999
100-
// rustdoc appears to lie about a warning above, so squelch it for now.
101-
#![allow(rustdoc::redundant_explicit_links)]
100+
#![allow(
101+
rustdoc::redundant_explicit_links,
102+
reason = "rustdoc appears to lie about a warning above, so squelch it for now"
103+
)]
102104

103105
mod component;
104106
#[cfg(feature = "component-model-async")]

0 commit comments

Comments
 (0)