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

style: Allow rustfmt to organize imports #4136

Merged
merged 2 commits into from
Nov 23, 2024
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
3 changes: 1 addition & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::env;
use std::process::{Command, Output};
use std::str;
use std::{env, str};

// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
// need to know all the possible cfgs that this script will set. If you need to set another cfg
Expand Down
3 changes: 2 additions & 1 deletion libc-test/test/cmsg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#[cfg(unix)]
mod t {

use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr};
use std::mem;

use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr};

extern "C" {
pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr;
// see below
Expand Down
4 changes: 3 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
error_on_line_overflow = true
edition = "2021"
error_on_line_overflow = true
group_imports = "StdExternalCrate"
imports_granularity = "Module"
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ cfg_if! {
use core::clone::Clone;
#[allow(unused_imports)]
use core::ffi;
pub use core::ffi::c_void;
#[allow(unused_imports)]
use core::fmt;
#[allow(unused_imports)]
Expand All @@ -61,8 +62,6 @@ use core::num;
#[allow(unused_imports)]
use core::option::Option;

pub use core::ffi::c_void;

cfg_if! {
if #[cfg(windows)] {
mod fixed_width_ints;
Expand Down
3 changes: 1 addition & 2 deletions src/unix/linux_like/emscripten/lfs64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ pub unsafe extern "C" fn mmap64(
//
// These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an
// argument, nor do their names clash with any declared types.
pub use open as open64;
pub use openat as openat64;
pub use {open as open64, openat as openat64};

#[inline]
pub unsafe extern "C" fn posix_fadvise64(
Expand Down
3 changes: 1 addition & 2 deletions src/unix/linux_like/linux/musl/lfs64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ pub unsafe extern "C" fn mmap64(
//
// These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an
// argument, nor do their names clash with any declared types.
pub use open as open64;
pub use openat as openat64;
pub use {open as open64, openat as openat64};

#[inline]
pub unsafe extern "C" fn posix_fadvise64(
Expand Down
6 changes: 1 addition & 5 deletions src/unix/nuttx/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use c_void;
use in6_addr;
use in_addr_t;
use timespec;
use DIR;
use {c_void, in6_addr, in_addr_t, timespec, DIR};

pub type nlink_t = u16;
pub type ino_t = u16;
Expand Down
1 change: 1 addition & 0 deletions src/unix/solarish/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Solaris, but often needed by other crates.

use core::cmp::min;

use unix::solarish::*;

const PTEM: &[u8] = b"ptem\0";
Expand Down
11 changes: 4 additions & 7 deletions src/unix/solarish/illumos.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use exit_status;
use NET_MAC_AWARE;
use NET_MAC_AWARE_INHERIT;
use PRIV_AWARE_RESET;
use PRIV_DEBUG;
use PRIV_PFEXEC;
use PRIV_XPOLICY;
use {
exit_status, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, PRIV_PFEXEC,
PRIV_XPOLICY,
};

pub type lgrp_rsrc_t = ::c_int;
pub type lgrp_affinity_t = ::c_int;
Expand Down
11 changes: 4 additions & 7 deletions src/unix/solarish/solaris.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use exit_status;
use NET_MAC_AWARE;
use NET_MAC_AWARE_INHERIT;
use PRIV_AWARE_RESET;
use PRIV_DEBUG;
use PRIV_PFEXEC;
use PRIV_XPOLICY;
use {
exit_status, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, PRIV_PFEXEC,
PRIV_XPOLICY,
};

pub type door_attr_t = ::c_uint;
pub type door_id_t = ::c_ulonglong;
Expand Down
3 changes: 2 additions & 1 deletion src/vxworks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Interface to VxWorks C library

use c_void;
use core::mem::size_of;
use core::ptr::null_mut;

use c_void;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum DIR {}
impl ::Copy for DIR {}
Expand Down
6 changes: 4 additions & 2 deletions src/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
//! `wasi-libc` project provides multiple libraries including emulated features, but we list only
//! basic features with `libc.a` here.

use super::{Send, Sync};
use c_void;
use core::iter::Iterator;

use c_void;

use super::{Send, Sync};

pub type c_char = i8;
pub type c_uchar = u8;
pub type c_schar = i8;
Expand Down