Skip to content

Commit

Permalink
Burn down the allow_attributes_without_reason backlog (#9712)
Browse files Browse the repository at this point in the history
* Burn down the `allow_attributes_without_reason` backlog

Just a bit, not everything fixed.

* Fix wasi-nn annotations

* Tweak `#[cfg]`
  • Loading branch information
alexcrichton authored Dec 3, 2024
1 parent c737a48 commit 71cb94b
Show file tree
Hide file tree
Showing 17 changed files with 16 additions and 43 deletions.
6 changes: 2 additions & 4 deletions benches/call.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

use criterion::measurement::WallTime;
use criterion::{criterion_group, criterion_main, BenchmarkGroup, Criterion};
use std::fmt::Debug;
Expand Down Expand Up @@ -445,7 +443,7 @@ trait ToVals {

macro_rules! tuples {
($($t:ident)*) => (
#[allow(non_snake_case)]
#[allow(non_snake_case, reason = "macro-generated code")]
impl<$($t:Copy + Into<Val>,)*> ToVals for ($($t,)*) {
fn to_vals(&self) -> Vec<Val> {
let mut _dst = Vec::new();
Expand Down Expand Up @@ -534,7 +532,7 @@ mod component {

macro_rules! tuples {
($($t:ident)*) => (
#[allow(non_snake_case)]
#[allow(non_snake_case, reason = "macro-generated code")]
impl<$($t:Copy + ToComponentVal,)*> ToComponentVals for ($($t,)*) {
fn to_component_vals(&self) -> Vec<component::Val> {
let mut _dst = Vec::new();
Expand Down
5 changes: 4 additions & 1 deletion cranelift/filetests/src/function_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ fn make_trampoline(name: UserFuncName, signature: &ir::Signature, isa: &dyn Targ
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::__m128i;
#[cfg(target_arch = "x86_64")]
#[allow(improper_ctypes_definitions)]
#[expect(
improper_ctypes_definitions,
reason = "manually verified to work for now"
)]
extern "C" fn __cranelift_x86_pshufb(a: __m128i, b: __m128i) -> __m128i {
union U {
reg: __m128i,
Expand Down
1 change: 0 additions & 1 deletion cranelift/filetests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! available filetest commands.
#![deny(missing_docs)]
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

pub use crate::function_runner::TestFileCompiler;
use crate::runner::TestRunner;
Expand Down
2 changes: 1 addition & 1 deletion cranelift/filetests/src/subtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Context<'a> {
pub isa: Option<&'a dyn TargetIsa>,

/// Full path to the file containing the test.
#[allow(dead_code)]
#[expect(dead_code, reason = "may get used later")]
pub file_path: &'a str,

/// Context used to update the original `file_path` in-place with its test
Expand Down
2 changes: 1 addition & 1 deletion cranelift/filetests/src/test_unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ mod windowsx64 {
version: u8,
flags: u8,
prologue_size: u8,
#[allow(dead_code)]
#[expect(dead_code, reason = "may get used later")]
unwind_code_count_raw: u8,
frame_register: u8,
frame_register_offset: u8,
Expand Down
3 changes: 0 additions & 3 deletions cranelift/frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@
#![deny(missing_docs)]
#![no_std]
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

#[allow(unused_imports)] // #[macro_use] is required for no_std
#[macro_use]
extern crate alloc;

#[cfg(feature = "std")]
Expand Down
2 changes: 1 addition & 1 deletion cranelift/frontend/src/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ mod tests {
let block = bx.create_block();
bx.switch_to_block(block);
let val = bx.ins().iconst(types::I8, 0);
#[allow(unused_mut)]
let mut switch = Switch::new();
let _ = &mut switch;
$(
let block = bx.create_block();
switch.set_entry($index, block);
Expand Down
1 change: 0 additions & 1 deletion cranelift/module/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![deny(missing_docs)]
#![no_std]
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

#[cfg(not(feature = "std"))]
#[macro_use]
Expand Down
9 changes: 2 additions & 7 deletions cranelift/module/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,10 @@ impl From<FuncOrDataId> for ModuleRelocTarget {
feature = "enable-serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[allow(missing_docs, reason = "self-describing fields")]
pub struct FunctionDeclaration {
#[allow(missing_docs)]
pub name: Option<String>,
#[allow(missing_docs)]
pub linkage: Linkage,
#[allow(missing_docs)]
pub signature: ir::Signature,
}

Expand Down Expand Up @@ -379,14 +377,11 @@ pub type ModuleResult<T> = Result<T, ModuleError>;
feature = "enable-serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[allow(missing_docs, reason = "self-describing fields")]
pub struct DataDeclaration {
#[allow(missing_docs)]
pub name: Option<String>,
#[allow(missing_docs)]
pub linkage: Linkage,
#[allow(missing_docs)]
pub writable: bool,
#[allow(missing_docs)]
pub tls: bool,
}

Expand Down
2 changes: 0 additions & 2 deletions cranelift/reader/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use crate::error::Location;
use cranelift_codegen::ir::types;
use cranelift_codegen::ir::{Block, Value};
#[allow(unused_imports, deprecated)]
use std::ascii::AsciiExt;
use std::str::CharIndices;
use std::u16;

Expand Down
3 changes: 1 addition & 2 deletions cranelift/reader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! testing Cranelift, but is not essential for a JIT compiler.
#![deny(missing_docs)]
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

pub use crate::error::{Location, ParseError, ParseResult};
pub use crate::isaspec::{parse_option, parse_options, IsaSpec, ParseOptionError};
Expand All @@ -30,7 +29,7 @@ use std::str::FromStr;
use target_lexicon::Triple;

/// Like `FlagsOrIsa`, but holds ownership.
#[allow(missing_docs)]
#[allow(missing_docs, reason = "self-describing variants")]
pub enum OwnedFlagsOrIsa {
Flags(settings::Flags),
Isa(OwnedTargetIsa),
Expand Down
2 changes: 1 addition & 1 deletion cranelift/reader/src/run_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Display for Invocation {
}

/// A CLIF comparison operation; e.g. `==`.
#[allow(missing_docs)]
#[allow(missing_docs, reason = "self-describing variants")]
#[derive(Debug, PartialEq)]
pub enum Comparison {
Equals,
Expand Down
5 changes: 1 addition & 4 deletions crates/component-macro/tests/codegen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(dead_code)]
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]
#![allow(dead_code, reason = "lots of macro-generated code")]

macro_rules! gentest {
($id:ident $name:tt $path:tt) => {
Expand Down Expand Up @@ -135,7 +134,6 @@ mod trappable_errors_with_versioned_and_unversioned_packages {
},
});

#[allow(dead_code)]
type MyX = u64;
}

Expand Down Expand Up @@ -177,7 +175,6 @@ mod trappable_errors {
},
});

#[allow(dead_code)]
type MyX = u32;
}

Expand Down
4 changes: 1 addition & 3 deletions crates/wasi-keyvalue/tests/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

use anyhow::{anyhow, Result};
use test_programs_artifacts::{foreach_keyvalue, KEYVALUE_MAIN_COMPONENT};
use wasmtime::{
Expand Down Expand Up @@ -48,7 +46,7 @@ async fn run_wasi(path: &str, ctx: Ctx) -> Result<()> {

macro_rules! assert_test_exists {
($name:ident) => {
#[allow(unused_imports)]
#[expect(unused_imports, reason = "just here to assert it exists")]
use self::$name as _;
};
}
Expand Down
6 changes: 1 addition & 5 deletions crates/wasi-nn/tests/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
//! - that various backends can be located on the system (see sub-modules)
//! - that certain ML model artifacts can be downloaded and cached.
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

#[allow(unused_imports)]
use anyhow::{anyhow, Context, Result};
use std::{
env,
path::{Path, PathBuf},
process::Command,
sync::Mutex,
};

#[cfg(any(feature = "onnx", feature = "winml"))]
#[cfg(any(feature = "onnx", all(feature = "winml", target_os = "windows")))]
pub mod onnx;
#[cfg(feature = "openvino")]
pub mod openvino;
Expand Down
3 changes: 0 additions & 3 deletions crates/wasi-nn/tests/check/onnx.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![allow(unused)]

use super::{artifacts_dir, download, DOWNLOAD_LOCK};
use anyhow::{Context, Result};
use std::sync::Mutex;
use std::{env, fs};

/// Return `Ok` if we find the cached MobileNet test artifacts; this will
Expand Down
3 changes: 0 additions & 3 deletions examples/mpk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
//! $ sysctl vm.max_map_count=$LARGER_LIMIT
//! ```
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]

use anyhow::anyhow;
use bytesize::ByteSize;
use clap::Parser;
Expand Down Expand Up @@ -115,7 +113,6 @@ fn probe_engine_size(args: &Args, mpk: MpkEnabled) -> Result<Pool> {
}

#[derive(Debug)]
#[allow(dead_code)]
struct Pool {
num_memories: u32,
mapped_bytes: usize,
Expand Down

0 comments on commit 71cb94b

Please sign in to comment.