rust: Update to 2018 edition

This mostly involves adjusting our path uses to be anchored, e.g. at
`self::` or `crate::`. I took the opportunity to also tweak `use`
ordering so that we consistently list modules in external crates first
before our own.

Closes: #1812
Approved by: lucab
This commit is contained in:
Jonathan Lebon 2019-04-14 14:54:32 -04:00 committed by Atomic Bot
parent 0da9f9972b
commit 60e71dfc66
8 changed files with 29 additions and 23 deletions

View File

@ -2,6 +2,7 @@
name = "rpmostree-rust"
version = "0.1.0"
authors = ["Colin Walters <walters@verbum.org>", "Jonathan Lebon <jonathan@jlebon.com>"]
edition = "2018"
[dependencies]
failure = "0.1.3"

View File

@ -23,7 +23,7 @@ use std::io;
use std::io::{BufRead, Write};
use std::path::Path;
use openat_utils::OpenatDirExt;
use crate::openat_utils::OpenatDirExt;
// rpm-ostree uses /home → /var/home by default as generated by our
// rootfs; we don't expect people to change this. Let's be nice
@ -37,7 +37,7 @@ use openat_utils::OpenatDirExt;
fn postprocess_useradd(rootfs_dfd: &openat::Dir) -> Fallible<()> {
let path = Path::new("usr/etc/default/useradd");
if let Some(f) = rootfs_dfd.open_file_optional(path)? {
let mut f = io::BufReader::new(f);
let f = io::BufReader::new(f);
let tmp_path = path.parent().unwrap().join("useradd.tmp");
let o = rootfs_dfd.write_file(&tmp_path, 0o644)?;
let mut bufw = io::BufWriter::new(&o);
@ -82,7 +82,7 @@ enable ostree-finalize-staged.path
fn postprocess_subs_dist(rootfs_dfd: &openat::Dir) -> Fallible<()> {
let path = Path::new("usr/etc/selinux/targeted/contexts/files/file_contexts.subs_dist");
if let Some(f) = rootfs_dfd.open_file_optional(path)? {
let mut f = io::BufReader::new(f);
let f = io::BufReader::new(f);
let tmp_path = path.parent().unwrap().join("file_contexts.subs_dist.tmp");
let o = rootfs_dfd.write_file(&tmp_path, 0o644)?;
let mut bufw = io::BufWriter::new(&o);
@ -117,10 +117,11 @@ fn compose_postprocess_final(rootfs_dfd: &openat::Dir) -> Fallible<()> {
mod ffi {
use super::*;
use ffiutil::*;
use glib_sys;
use libc;
use crate::ffiutil::*;
#[no_mangle]
pub extern "C" fn ror_compose_postprocess_final(
rootfs_dfd: libc::c_int,

View File

@ -19,6 +19,7 @@
use gio_sys;
use glib_sys;
use libc;
use openat;
use std::ffi::CString;
use std::ffi::{CStr, OsStr};
use std::fmt::Display;
@ -26,8 +27,6 @@ use std::os::unix::ffi::OsStrExt;
use std::os::unix::io::{FromRawFd, IntoRawFd};
use std::ptr;
use openat;
/* Helper functions for FFI between C and Rust.
*
* This code assumes that it was compiled with the system allocator:

View File

@ -147,9 +147,11 @@ fn journal_print_staging_failure() -> Fallible<()> {
mod ffi {
use super::*;
use ffiutil::*;
use glib_sys;
use libc;
use crate::ffiutil::*;
#[no_mangle]
pub extern "C" fn ror_journal_print_staging_failure(
gerror: *mut *mut glib_sys::GError,

View File

@ -39,15 +39,15 @@ extern crate serde_json;
extern crate serde_yaml;
mod ffiutil;
mod treefile;
pub use treefile::*;
mod composepost;
pub use composepost::*;
mod progress;
pub use progress::*;
mod journal;
pub use journal::*;
mod utils;
pub use utils::*;
mod openat_utils;
mod composepost;
pub use self::composepost::*;
mod journal;
pub use self::journal::*;
mod progress;
pub use self::progress::*;
mod treefile;
pub use self::treefile::*;
mod utils;
pub use self::utils::*;

View File

@ -168,10 +168,11 @@ mod tests {
mod ffi {
use super::*;
use ffiutil::*;
use libc;
use std::sync::MutexGuard;
use crate::ffiutil::*;
fn assert_empty(m: &MutexGuard<Option<ProgressState>>) {
if let Some(ref state) = **m {
panic!("Overwriting task: \"{}\"", state.message)

View File

@ -30,7 +30,8 @@ use std::collections::HashMap;
use std::io::prelude::*;
use std::path::Path;
use std::{collections, fs, io};
use utils;
use crate::utils;
const INCLUDE_MAXDEPTH: u32 = 50;
@ -990,14 +991,14 @@ packages:
mod ffi {
use super::*;
use ffiutil::*;
use glib_sys;
use libc;
use std::io::Seek;
use std::os::unix::io::{AsRawFd, RawFd};
use std::{fs, io, ptr};
use crate::ffiutil::*;
// Some of our file descriptors may be read multiple times.
// We try to consistently seek to the start to make that
// convenient from the C side. Note that this function

View File

@ -116,7 +116,6 @@ mod tests {
mod ffi {
use super::*;
use ffiutil::*;
use glib;
use glib_sys;
use libc;
@ -124,6 +123,8 @@ mod ffi {
use std::os::unix::io::IntoRawFd;
use std::ptr;
use crate::ffiutil::*;
#[no_mangle]
pub extern "C" fn ror_download_to_fd(
url: *const libc::c_char,