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

More lints #3263

Merged
merged 2 commits into from
Dec 8, 2021
Merged
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
1 change: 1 addition & 0 deletions rust/src/cxxrsutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ macro_rules! cxxrs_bind {
paste! {
$(
#[repr(transparent)]
#[derive(Debug)]
pub struct [<FFI $ns $i>](pub(crate) $sys::[<$ns $i>]);

unsafe impl ExternType for [<FFI $ns $i>] {
Expand Down
3 changes: 3 additions & 0 deletions rust/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ static RPMOSTREE_DEPLOY_MSG: &str = "9bddbda177cd44d891b1b561a8a0ce9e";
static RPMOSTREE_HISTORY_DIR: &str = "/var/lib/rpm-ostree/history";

/// Context object used to iterate through `HistoryEntry` events.
// TODO use https://crates.io/crates/derivative to skip journal field
#[allow(missing_debug_implementations)]
pub struct HistoryCtx {
journal: journal::Journal,
marker_queue: VecDeque<Marker>,
Expand Down Expand Up @@ -425,6 +427,7 @@ mod mock_journal {
use super::Result;
pub use systemd::journal::{JournalRecord, JournalSeek};

#[derive(Debug)]
pub struct Journal {
pub entries: Vec<(u64, JournalRecord)>,
pub current_timestamp: Option<u64>,
Expand Down
19 changes: 15 additions & 4 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*/

#![deny(unused_must_use)]
// See https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
#![deny(missing_debug_implementations)]
#![deny(unsafe_op_in_unsafe_fn)]
#![forbid(unused_must_use)]
#![allow(clippy::ptr_arg)]

// pub(crate) utilities
Expand All @@ -25,6 +27,7 @@ pub(crate) use cxxrsutil::*;
/// side you currently *should* use `CxxResult`; see the docs of that for more information.
#[cxx::bridge(namespace = "rpmostreecxx")]
#[allow(clippy::needless_lifetimes)]
#[allow(unsafe_op_in_unsafe_fn)]
pub mod ffi {
// Types that are defined by gtk-rs generated bindings that
// we want to pass across the cxx-rs boundary. For more
Expand Down Expand Up @@ -136,6 +139,7 @@ pub mod ffi {
/// `ContainerImageState` is currently identical to ostree-rs-ext's `LayeredImageState` struct, because
/// cxx.rs currently requires types used as extern Rust types to be defined by the same crate
/// that contains the bridge using them, so we redefine an `ContainerImport` struct here.
#[derive(Debug)]
pub(crate) struct ContainerImageState {
pub base_commit: String,
pub merge_commit: String,
Expand Down Expand Up @@ -209,7 +213,7 @@ pub mod ffi {

// A grab-bag of metadata from the deployment's ostree commit
// around layering/derivation
#[derive(Default)]
#[derive(Debug, Default)]
struct DeploymentLayeredMeta {
is_layered: bool,
base_commit: String,
Expand Down Expand Up @@ -408,7 +412,7 @@ pub mod ffi {
) -> Result<*mut GVariant>;
}

#[derive(Default)]
#[derive(Debug, Default)]
/// A copy of LiveFsState that is bridged to C++; the main
/// change here is we can't use Option<> yet, so empty values
/// are represented by the empty string.
Expand Down Expand Up @@ -490,6 +494,7 @@ pub mod ffi {
fn generate_treefile(&self, src: &Treefile) -> Result<Box<Treefile>>;
}

#[derive(Debug)]
struct LockedPackage {
name: String,
evr: String,
Expand Down Expand Up @@ -525,6 +530,7 @@ pub mod ffi {

unsafe extern "C++" {
include!("rpmostree-cxxrsutil.hpp");
#[allow(missing_debug_implementations)]
type CxxGObjectArray;
fn length(self: Pin<&mut CxxGObjectArray>) -> u32;
fn get(self: Pin<&mut CxxGObjectArray>, i: u32) -> &mut GObject;
Expand Down Expand Up @@ -553,6 +559,7 @@ pub mod ffi {
unsafe extern "C++" {
include!("rpmostree-clientlib.h");
fn client_require_root() -> Result<()>;
#[allow(missing_debug_implementations)]
type ClientConnection;
fn new_client_connection() -> Result<UniquePtr<ClientConnection>>;
fn get_connection<'a>(self: Pin<&'a mut ClientConnection>) -> Pin<&'a mut GDBusConnection>;
Expand All @@ -561,6 +568,7 @@ pub mod ffi {

unsafe extern "C++" {
include!("rpmostree-diff.hpp");
#[allow(missing_debug_implementations)]
type RPMDiff;
fn n_removed(&self) -> i32;
fn n_added(&self) -> i32;
Expand All @@ -576,6 +584,7 @@ pub mod ffi {
}

// https://cxx.rs/shared.html#extern-enums
#[derive(Debug)]
enum RpmOstreeDiffPrintFormat {
RPMOSTREE_DIFF_PRINT_FORMAT_SUMMARY,
RPMOSTREE_DIFF_PRINT_FORMAT_FULL_ALIGNED,
Expand All @@ -585,6 +594,7 @@ pub mod ffi {
unsafe extern "C++" {
include!("rpmostree-libbuiltin.h");
include!("rpmostree-util.h");
#[allow(missing_debug_implementations)]
type RpmOstreeDiffPrintFormat;
/// # Safety: ensure @cancellable is a valid pointer
unsafe fn print_treepkg_diff_from_sysroot_path(
Expand All @@ -597,6 +607,7 @@ pub mod ffi {

unsafe extern "C++" {
include!("rpmostree-output.h");
#[allow(missing_debug_implementations)]
type Progress;

fn progress_begin_task(msg: &str) -> UniquePtr<Progress>;
Expand Down
3 changes: 2 additions & 1 deletion rust/src/treefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const COMPOSE_JSON_PATH: &str = "usr/share/rpm-ostree/treefile.json";

/// This struct holds file descriptors for any external files/data referenced by
/// a TreeComposeConfig.
#[derive(Default)]
#[derive(Debug, Default)]
pub(crate) struct TreefileExternals {
postprocess_script: Option<fs::File>,
add_files: collections::BTreeMap<String, fs::File>,
Expand All @@ -57,6 +57,7 @@ pub(crate) struct TreefileExternals {
}

// This type name is exposed through ffi.
#[derive(Debug)]
pub struct Treefile {
// This one isn't used today, but we may do more in the future.
_workdir: Option<openat::Dir>,
Expand Down
2 changes: 1 addition & 1 deletion rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::{fs, io};

use curl::easy::Easy;

#[derive(PartialEq)]
#[derive(Debug, PartialEq)]
/// Supported config serialization used by treefile and lockfile
pub enum InputFormat {
YAML,
Expand Down