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

Convert allow to expect #402

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions Guide/src/dev_guide/contrib/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,19 @@ project, and will fast-fail if it catches any warnings / errors.
### Suppressing Lints

In general, lints should be fixed by modifying the code to satisfy the lint.
However, there are cases where a lint may need to be `allow`'d inline.
However, there are cases where a lint may need to be `expect`'d inline.

In these cases, you _must_ provide a inline comment providing reasonable
In these cases, you _must_ provide a reason providing
justification for the suppressed lint.

e.g:

```rust
// x86_64-unknown-linux-musl targets have a different type defn for
// `libc::cmsghdr`, hence why these lints are being suppressed.
#[allow(clippy::needless_update, clippy::useless_conversion)]
#[expect(
clippy::needless_update,
clippy::useless_conversion,
reason = "x86_64-unknown-linux-musl targets have a different type defn for `libc::cmsghdr`"
)]
libc::cmsghdr {
cmsg_level: libc::SOL_SOCKET,
cmsg_type: libc::SCM_RIGHTS,
Expand Down
2 changes: 1 addition & 1 deletion flowey/flowey_cli/src/cli/exec_snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ pub(crate) mod serialized_request {
use serde::Deserializer;
use serde::Serializer;

#[allow(clippy::borrowed_box)] // required by serde
#[expect(clippy::borrowed_box, reason = "required by serde")]
pub fn serialize<S: Serializer>(v: &Box<[u8]>, ser: S) -> Result<S::Ok, S::Error> {
ser.serialize_str(
&serde_json::to_string(&serde_json::from_slice::<serde_json::Value>(v).unwrap())
Expand Down
4 changes: 2 additions & 2 deletions flowey/flowey_cli/src/cli/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub struct Pipeline<P: clap::Subcommand> {
/// today may not work after making changes to the pipeline definition /
/// updating flowey.
#[clap(help_heading = "Global Options (flowey)", global = true, long)]
#[allow(clippy::option_option)] // for clap derive
#[expect(clippy::option_option, reason = "For clap derive")]
include_jobs: Option<Option<IncludeJobs>>,

#[clap(subcommand)]
Expand Down Expand Up @@ -370,7 +370,7 @@ enum EarlyExit {
No,
}

#[allow(clippy::option_option)] // for clap derive
#[expect(clippy::option_option, reason = "For clap derive")]
fn resolve_include_jobs(
resolved_pipeline: &mut crate::pipeline_resolver::generic::ResolvedPipeline,
include_jobs: Option<Option<IncludeJobs>>,
Expand Down
4 changes: 2 additions & 2 deletions flowey/flowey_cli/src/flow_resolver/stage1_dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ impl flowey_core::node::NodeCtxBackend for EmitFlowCtx<'_> {
step: Step::Rust {
idx: self.step_idx_tracker,
label: label.into(),
#[allow(clippy::arc_with_non_send_sync)]
#[expect(clippy::arc_with_non_send_sync)]
code: Arc::new(Mutex::new(Some(code))),
},
});
Expand Down Expand Up @@ -763,7 +763,7 @@ impl flowey_core::node::NodeCtxBackend for EmitFlowCtx<'_> {
label: label.into(),
raw_yaml,
code_idx: self.step_idx_tracker,
#[allow(clippy::arc_with_non_send_sync)]
#[expect(clippy::arc_with_non_send_sync)]
code: Arc::new(Mutex::new(code)),
ado_to_rust,
rust_to_ado,
Expand Down
2 changes: 1 addition & 1 deletion flowey/flowey_hvlite/src/pipelines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod custom_vmfirmwareigvm_dll;
pub mod restore_packages;

#[derive(clap::Subcommand)]
#[allow(clippy::large_enum_variant)]
#[expect(clippy::large_enum_variant)]
pub enum OpenvmmPipelines {
/// Alias for root-level `regen` command.
// DEVNOTE: this enables the useful `cargo xflowey regen` alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Otherwise, press `ctrl-c` to cancel the run.
}
}

#[allow(unused)]
#[expect(unused)]
enum AzCopyAuthMethod {
/// Pull credentials from the Azure CLI instance running the command.
AzureCli,
Expand Down
2 changes: 1 addition & 1 deletion openhcl/build_info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl BuildInfo {
// to use.

// UNSAFETY: link_section and export_name are considered unsafe.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
#[unsafe(link_section = ".build_info")]
#[unsafe(export_name = "BUILD_INFO")]
static BUILD_INFO: BuildInfo = BuildInfo::new();
Expand Down
2 changes: 1 addition & 1 deletion openhcl/hcl/src/ioctl/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl MshvVtl {
return Ok(());
}

#[allow(clippy::undocumented_unsafe_blocks)] // TODO SNP
#[expect(clippy::undocumented_unsafe_blocks, reason = "TODO")] // TODO SNP
let ret = unsafe {
hcl_rmpadjust_pages(
self.file.as_raw_fd(),
Expand Down
2 changes: 1 addition & 1 deletion openhcl/host_fdt_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl<
error,
})?;

#[allow(clippy::single_match)]
#[expect(clippy::single_match)]
match openhcl_child.name {
"entropy" => {
let host_entropy = openhcl_child
Expand Down
2 changes: 1 addition & 1 deletion openhcl/minimal_rt/src/reloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ macro_rules! panic_no_relocs {

#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
#[allow(dead_code)]
#[expect(dead_code)]
enum ElfDynTag {
Null = 0,
RelA = 7,
Expand Down
2 changes: 1 addition & 1 deletion openhcl/openhcl_boot/src/arch/x86_64/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum AcceptGpaStatus {
Retry,
}

#[allow(dead_code)] // Printed via Debug in the error case.
#[expect(dead_code, reason = "Debug is used for logging")]
#[derive(Debug)]
pub enum AcceptGpaError {
MemorySecurityViolation {
Expand Down
2 changes: 1 addition & 1 deletion openhcl/openhcl_boot/src/boot_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(crate) use log;
//
// Allow unused macros for the same reason as unused_imports below, as there
// should be no usage of this macro normally.
#[allow(unused_macros)]
#[expect(unused_macros)]
macro_rules! debug_log {
($($arg:tt)*) => {
$crate::boot_logger::log!($($arg)*)
Expand Down
3 changes: 1 addition & 2 deletions openhcl/openhcl_boot/src/dt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ mod aarch64 {

#[derive(Debug)]
pub enum DtError {
// Field is stored solely for logging via debug, not actually dead.
Fdt(#[allow(dead_code)] fdt::builder::Error),
Fdt(#[expect(dead_code, reason = "Debug is used for logging")] fdt::builder::Error),
}

impl From<fdt::builder::Error> for DtError {
Expand Down
2 changes: 1 addition & 1 deletion openhcl/underhill_core/src/servicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl From<Firmware> for FirmwareType {
}
}

#[allow(clippy::option_option)]
#[expect(clippy::option_option)]
pub mod transposed {
use super::*;
use vmcore::save_restore::SaveRestore;
Expand Down
1 change: 0 additions & 1 deletion openhcl/underhill_core/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,6 @@ async fn new_underhill_vm(
// `agent_data` and `guest_secret_key` may also be used by vTPM
// initialization.
let platform_attestation_data = {
#[allow(clippy::if_same_then_else)] // clearer
if is_restoring {
// TODO CVM: Save and restore last returned data when live servicing is supported.
// We also need to revisit what states should be saved and restored.
Expand Down
2 changes: 1 addition & 1 deletion openhcl/underhill_crash/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Options {
}

impl Options {
#[allow(clippy::expect_fun_call)]
#[expect(clippy::expect_fun_call)]
pub(crate) fn parse() -> Self {
let mut args = std::env::args_os();

Expand Down
2 changes: 0 additions & 2 deletions openhcl/underhill_init/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub struct Options {
}

impl Options {
#[allow(clippy::expect_fun_call)]
pub(crate) fn parse() -> Self {
let mut opts = Self::default();

Expand Down Expand Up @@ -69,7 +68,6 @@ impl Options {
opts
}

#[allow(clippy::expect_fun_call)]
#[must_use]
fn parse_value_arg(opts: &mut Self, name: &str, value: &str) -> bool {
match name {
Expand Down
7 changes: 5 additions & 2 deletions openhcl/virt_mshv_vtl/src/processor/snp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ pub struct SnpBacked {
#[inspect(iter_by_index)]
direct_overlays_pfns: [u64; UhDirectOverlay::Count as usize],
#[inspect(skip)]
#[allow(dead_code)] // Allocation handle for direct overlays held until drop
#[expect(
dead_code,
reason = "Allocation handle for direct overlays held until drop"
)]
direct_overlay_pfns_handle: shared_pool_alloc::SharedPoolHandle,
#[inspect(hex)]
hv_sint_notifications: u16,
Expand Down Expand Up @@ -1682,7 +1685,7 @@ impl<T> hv1_hypercall::X64RegisterState for UhHypercallHandler<'_, '_, T, SnpBac
}
}

#[allow(unused)]
#[expect(unused)]
impl AccessVpState for UhVpStateAccess<'_, '_, SnpBacked> {
type Error = vp_state::Error;

Expand Down
5 changes: 4 additions & 1 deletion openhcl/virt_mshv_vtl/src/processor/tdx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,10 @@ pub struct TdxBacked {
#[inspect(iter_by_index)]
direct_overlays_pfns: [u64; UhDirectOverlay::Count as usize],
#[inspect(skip)]
#[allow(dead_code)] // Allocation handle for direct overlays held until drop
#[expect(
dead_code,
reason = "Allocation handle for direct overlays held until drop"
)]
direct_overlay_pfns_handle: shared_pool_alloc::SharedPoolHandle,

untrusted_synic: Option<ProcessorSynic>,
Expand Down
3 changes: 1 addition & 2 deletions openvmm/hvlite_core/src/worker/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ impl InitializedVm {
}
}

#[allow(dead_code)]
async fn new_with_hypervisor<P, H>(
driver_source: VmTaskDriverSource,
hypervisor: &mut H,
Expand Down Expand Up @@ -2417,7 +2416,7 @@ impl LoadedVmInner {
};
super::vm_loaders::igvm::load_igvm(params)?
}
#[allow(unreachable_patterns)]
#[expect(unreachable_patterns)]
_ => anyhow::bail!("load mode not supported on this platform"),
};

Expand Down
1 change: 0 additions & 1 deletion openvmm/membacking/src/memory_manager/device_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ struct DeviceMemoryControl(Arc<DeviceMemoryRegion>);
impl MappableGuestMemory for DeviceMemoryControl {
fn map_to_guest(&mut self, gpa: u64, writable: bool) -> io::Result<()> {
let mut state = self.0.state.lock();
#[allow(clippy::await_holding_lock)] // Treat all this as sync for now.
block_on(async {
if let Some(handle) = state.handle.take() {
handle.teardown().await;
Expand Down
2 changes: 1 addition & 1 deletion openvmm/openvmm_entry/src/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ flags:
///
/// Used internally for debugging and diagnostics.
#[clap(long, default_value = "control", hide(true))]
#[allow(clippy::option_option)]
#[expect(clippy::option_option)]
pub internal_worker: Option<Option<String>>,

/// redirect the VTL 0 vmbus control plane to a proxy in VTL 2.
Expand Down
2 changes: 1 addition & 1 deletion openvmm/openvmm_entry/src/ttrpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Worker for TtrpcWorker {
RpcTransport::Ttrpc => ResolvedTransport::Ttrpc,
#[cfg(feature = "grpc")]
RpcTransport::Grpc => ResolvedTransport::Grpc,
#[allow(unreachable_patterns)]
#[expect(unreachable_patterns)]
transport => bail!("unsupported transport {transport}"),
},
})
Expand Down
4 changes: 2 additions & 2 deletions petri/pipette/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Agent {
watch_send: mesh::OneshotSender<()>,
}

#[allow(dead_code)] // Not used on all platforms yet
#[allow(dead_code, reason = "Not used on all platforms yet")]
#[derive(Clone)]
pub struct DiagnosticSender(Arc<mesh::Sender<DiagnosticFile>>);

Expand Down Expand Up @@ -167,7 +167,7 @@ async fn write_file(mut request: pipette_protocol::WriteFileRequest) -> anyhow::
}

impl DiagnosticSender {
#[allow(dead_code)] // Not used on all platforms yet
#[expect(dead_code)] // Not used on all platforms yet
pub async fn send(&self, filename: &str) -> anyhow::Result<()> {
tracing::debug!(filename, "Beginning diagnostic file request");
let file = fs_err::File::open(filename)?;
Expand Down
4 changes: 2 additions & 2 deletions petri/pipette/src/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn handle_shutdown(request: pipette_protocol::ShutdownRequest) -> anyhow::Re
}

#[cfg(windows)]
#[allow(dead_code)] // Currently unused, but left as an example
#[expect(dead_code, reason = "Currently unused, but left as an example")]
pub fn start_shutdown_trace() -> anyhow::Result<()> {
use anyhow::Context;

Expand All @@ -150,7 +150,7 @@ pub fn start_shutdown_trace() -> anyhow::Result<()> {
}

#[cfg(windows)]
#[allow(dead_code)] // Currently unused, but left as an example
#[expect(dead_code, reason = "Currently unused, but left as an example")]
pub async fn send_shutdown_trace(
diag_file_send: crate::agent::DiagnosticSender,
) -> anyhow::Result<()> {
Expand Down
6 changes: 4 additions & 2 deletions petri/pipette_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ async fn recv_diag_files(output_dir: PathBuf, mut diag_file_recv: mesh::Receiver
.expect("failed to write diagnostic file");
tracing::debug!(name, "diagnostic file transfer complete");

// ATTACHMENT is most reliable when using true canonicalized paths
#[allow(clippy::disallowed_methods)]
#[expect(
clippy::disallowed_methods,
reason = "ATTACHMENT is most reliable when using true canonicalized paths"
)]
let canonical_path = path
.canonicalize()
.expect("failed to canonicalize attachment path");
Expand Down
2 changes: 1 addition & 1 deletion petri/src/openhcl_diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) struct OpenHclDiagHandler {

/// The result of running a VTL2 command.
#[derive(Debug)]
#[allow(dead_code)] // Fields output via Debug for debugging purposes.
#[expect(dead_code, reason = "Fields output via Debug for debugging purposes.")]
pub(crate) struct Vtl2CommandResult {
/// The stdout of the command.
pub stdout: String,
Expand Down
6 changes: 4 additions & 2 deletions petri/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ impl<'a> MakeWriter<'a> for PetriWriter {
/// that the file makes it into the test results.
pub fn trace_attachment(path: impl AsRef<Path>) {
fn trace(path: &Path) {
// ATTACHMENT is most reliable when using true canonicalized paths
#[allow(clippy::disallowed_methods)]
#[expect(
clippy::disallowed_methods,
reason = "ATTACHMENT is most reliable when using true canonicalized paths"
)]
match path.canonicalize() {
Ok(path) => {
// Use the inline junit syntax to attach the file to the test
Expand Down
5 changes: 4 additions & 1 deletion support/arc_cyclic_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ impl<T> ArcCyclicBuilderExt<T> for Arc<T> {
}
}

#[allow(clippy::disallowed_types)] // requiring parking_lot just for a test? nah
#[expect(
clippy::disallowed_types,
reason = "Requiring parking_lot just for a test? nah"
)]
#[cfg(test)]
mod test {
use super::*;
Expand Down
Loading
Loading