Skip to content

Commit aa6aac8

Browse files
committed
Run rustfmt
1 parent d2e7d4b commit aa6aac8

File tree

8 files changed

+121
-88
lines changed

8 files changed

+121
-88
lines changed

src/com.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use std::ops::Deref;
1313
use std::os::windows::ffi::{OsStrExt, OsStringExt};
1414
use std::ptr::null_mut;
1515
use std::slice::from_raw_parts;
16+
use winapi::CoInitializeEx;
17+
use winapi::IUnknown;
1618
use winapi::Interface;
1719
use winapi::BSTR;
18-
use winapi::CoInitializeEx;
1920
use winapi::COINIT_MULTITHREADED;
2021
use winapi::{SysFreeString, SysStringLen};
21-
use winapi::IUnknown;
2222
use winapi::{HRESULT, S_FALSE, S_OK};
2323

2424
pub fn initialize() -> Result<(), HRESULT> {

src/lib.rs

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@
6161
#[cfg(feature = "parallel")]
6262
extern crate rayon;
6363

64+
use std::collections::HashMap;
6465
use std::env;
6566
use std::ffi::{OsStr, OsString};
6667
use std::fs;
68+
use std::io::{self, BufRead, BufReader, Read, Write};
6769
use std::path::{Path, PathBuf};
6870
use std::process::{Child, Command, Stdio};
69-
use std::io::{self, BufRead, BufReader, Read, Write};
70-
use std::thread::{self, JoinHandle};
71-
use std::collections::HashMap;
7271
use std::sync::{Arc, Mutex};
72+
use std::thread::{self, JoinHandle};
7373

7474
// These modules are all glue to support reading the MSVC version from
7575
// the registry and from COM interfaces
@@ -891,7 +891,7 @@ impl Build {
891891
return Err(Error::new(
892892
ErrorKind::IOError,
893893
"Getting object file details failed.",
894-
))
894+
));
895895
}
896896
};
897897

@@ -1119,12 +1119,18 @@ impl Build {
11191119
// CFLAGS/CXXFLAGS, since those variables presumably already contain
11201120
// the desired set of warnings flags.
11211121

1122-
if self.warnings.unwrap_or(if self.has_flags() { false } else { true }) {
1122+
if self
1123+
.warnings
1124+
.unwrap_or(if self.has_flags() { false } else { true })
1125+
{
11231126
let wflags = cmd.family.warnings_flags().into();
11241127
cmd.push_cc_arg(wflags);
11251128
}
11261129

1127-
if self.extra_warnings.unwrap_or(if self.has_flags() { false } else { true }) {
1130+
if self
1131+
.extra_warnings
1132+
.unwrap_or(if self.has_flags() { false } else { true })
1133+
{
11281134
if let Some(wflags) = cmd.family.extra_warnings_flags() {
11291135
cmd.push_cc_arg(wflags.into());
11301136
}
@@ -1161,7 +1167,12 @@ impl Build {
11611167
Ok(cmd)
11621168
}
11631169

1164-
fn add_default_flags(&self, cmd: &mut Tool, target: &str, opt_level: &str) -> Result<(), Error> {
1170+
fn add_default_flags(
1171+
&self,
1172+
cmd: &mut Tool,
1173+
target: &str,
1174+
opt_level: &str,
1175+
) -> Result<(), Error> {
11651176
// Non-target flags
11661177
// If the flag is not conditioned on target variable, it belongs here :)
11671178
match cmd.family {
@@ -1175,8 +1186,9 @@ impl Build {
11751186
Some(true) => "/MT",
11761187
Some(false) => "/MD",
11771188
None => {
1178-
let features =
1179-
self.getenv("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
1189+
let features = self
1190+
.getenv("CARGO_CFG_TARGET_FEATURE")
1191+
.unwrap_or(String::new());
11801192
if features.contains("crt-static") {
11811193
"/MT"
11821194
} else {
@@ -1258,7 +1270,8 @@ impl Build {
12581270
// the SDK, but for all released versions of the
12591271
// Windows SDK it is required.
12601272
if target.contains("arm") || target.contains("thumb") {
1261-
cmd.args.push("/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1".into());
1273+
cmd.args
1274+
.push("/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1".into());
12621275
}
12631276
}
12641277
ToolFamily::Gnu => {
@@ -1271,14 +1284,18 @@ impl Build {
12711284
}
12721285

12731286
if self.static_flag.is_none() {
1274-
let features = self.getenv("CARGO_CFG_TARGET_FEATURE").unwrap_or(String::new());
1287+
let features = self
1288+
.getenv("CARGO_CFG_TARGET_FEATURE")
1289+
.unwrap_or(String::new());
12751290
if features.contains("crt-static") {
12761291
cmd.args.push("-static".into());
12771292
}
12781293
}
12791294

12801295
// armv7 targets get to use armv7 instructions
1281-
if (target.starts_with("armv7") || target.starts_with("thumbv7")) && target.contains("-linux-") {
1296+
if (target.starts_with("armv7") || target.starts_with("thumbv7"))
1297+
&& target.contains("-linux-")
1298+
{
12821299
cmd.args.push("-march=armv7-a".into());
12831300
}
12841301

@@ -1443,7 +1460,11 @@ impl Build {
14431460
fn has_flags(&self) -> bool {
14441461
let flags_env_var_name = if self.cpp { "CXXFLAGS" } else { "CFLAGS" };
14451462
let flags_env_var_value = self.get_var(flags_env_var_name);
1446-
if let Ok(_) = flags_env_var_value { true } else { false }
1463+
if let Ok(_) = flags_env_var_value {
1464+
true
1465+
} else {
1466+
false
1467+
}
14471468
}
14481469

14491470
fn msvc_macro_assembler(&self) -> Result<(Command, String), Error> {
@@ -1548,7 +1569,7 @@ impl Build {
15481569
return Err(Error::new(
15491570
ErrorKind::IOError,
15501571
"Could not copy or create a hard-link to the generated lib file.",
1551-
))
1572+
));
15521573
}
15531574
};
15541575
} else {
@@ -1585,7 +1606,7 @@ impl Build {
15851606
return Err(Error::new(
15861607
ErrorKind::ArchitectureInvalid,
15871608
"Unknown architecture for iOS target.",
1588-
))
1609+
));
15891610
}
15901611
};
15911612

@@ -1604,7 +1625,8 @@ impl Build {
16041625
};
16051626

16061627
self.print(&format!("Detecting iOS SDK path for {}", sdk));
1607-
let sdk_path = self.cmd("xcrun")
1628+
let sdk_path = self
1629+
.cmd("xcrun")
16081630
.arg("--show-sdk-path")
16091631
.arg("--sdk")
16101632
.arg(sdk)
@@ -1618,7 +1640,7 @@ impl Build {
16181640
return Err(Error::new(
16191641
ErrorKind::IOError,
16201642
"Unable to determine iOS SDK path.",
1621-
))
1643+
));
16221644
}
16231645
};
16241646

@@ -1669,7 +1691,8 @@ impl Build {
16691691

16701692
let cl_exe = windows_registry::find_tool(&target, "cl.exe");
16711693

1672-
let tool_opt: Option<Tool> = self.env_tool(env)
1694+
let tool_opt: Option<Tool> = self
1695+
.env_tool(env)
16731696
.map(|(tool, cc, args)| {
16741697
// chop off leading/trailing whitespace to work around
16751698
// semi-buggy build scripts which are shared in
@@ -1831,9 +1854,9 @@ impl Build {
18311854
// configure for invocations like `clang-cl` we still get a "works out
18321855
// of the box" experience.
18331856
if let Some(cl_exe) = cl_exe {
1834-
if tool.family == (ToolFamily::Msvc { clang_cl: true }) &&
1835-
tool.env.len() == 0 &&
1836-
target.contains("msvc")
1857+
if tool.family == (ToolFamily::Msvc { clang_cl: true })
1858+
&& tool.env.len() == 0
1859+
&& target.contains("msvc")
18371860
{
18381861
for &(ref k, ref v) in cl_exe.env.iter() {
18391862
tool.env.push((k.to_owned(), v.to_owned()));
@@ -1849,7 +1872,8 @@ impl Build {
18491872
let host = self.get_host()?;
18501873
let kind = if host == target { "HOST" } else { "TARGET" };
18511874
let target_u = target.replace("-", "_");
1852-
let res = self.getenv(&format!("{}_{}", var_base, target))
1875+
let res = self
1876+
.getenv(&format!("{}_{}", var_base, target))
18531877
.or_else(|| self.getenv(&format!("{}_{}", var_base, target_u)))
18541878
.or_else(|| self.getenv(&format!("{}_{}", kind, var_base)))
18551879
.or_else(|| self.getenv(var_base));
@@ -2040,7 +2064,7 @@ impl Build {
20402064
fn getenv(&self, v: &str) -> Option<String> {
20412065
let mut cache = self.env_cache.lock().unwrap();
20422066
if let Some(val) = cache.get(v) {
2043-
return val.clone()
2067+
return val.clone();
20442068
}
20452069
let r = env::var(v).ok();
20462070
self.print(&format!("{} = {:?}", v, r));
@@ -2081,10 +2105,11 @@ impl Tool {
20812105
let family = if let Some(fname) = path.file_name().and_then(|p| p.to_str()) {
20822106
if fname.contains("clang-cl") {
20832107
ToolFamily::Msvc { clang_cl: true }
2084-
} else if fname.contains("cl") &&
2085-
!fname.contains("cloudabi") &&
2086-
!fname.contains("uclibc") &&
2087-
!fname.contains("clang") {
2108+
} else if fname.contains("cl")
2109+
&& !fname.contains("cloudabi")
2110+
&& !fname.contains("uclibc")
2111+
&& !fname.contains("clang")
2112+
{
20882113
ToolFamily::Msvc { clang_cl: false }
20892114
} else if fname.contains("clang") {
20902115
ToolFamily::Clang
@@ -2140,9 +2165,10 @@ impl Tool {
21402165

21412166
// Check for existing optimization flags (-O, /O)
21422167
if chars.next() == Some('O') {
2143-
return self.args().iter().any(|ref a|
2144-
a.to_str().unwrap_or("").chars().nth(1) == Some('O')
2145-
);
2168+
return self
2169+
.args()
2170+
.iter()
2171+
.any(|ref a| a.to_str().unwrap_or("").chars().nth(1) == Some('O'));
21462172
}
21472173

21482174
// TODO Check for existing -m..., -m...=..., /arch:... flags
@@ -2174,7 +2200,11 @@ impl Tool {
21742200
};
21752201
cmd.args(&self.cc_wrapper_args);
21762202

2177-
let value = self.args.iter().filter(|a| !self.removed_args.contains(a)).collect::<Vec<_>>();
2203+
let value = self
2204+
.args
2205+
.iter()
2206+
.filter(|a| !self.removed_args.contains(a))
2207+
.collect::<Vec<_>>();
21782208
cmd.args(&value);
21792209

21802210
for &(ref k, ref v) in self.env.iter() {
@@ -2269,7 +2299,7 @@ fn run(cmd: &mut Command, program: &str) -> Result<(), Error> {
22692299
"Failed to wait on spawned child process, command {:?} with args {:?}.",
22702300
cmd, program
22712301
),
2272-
))
2302+
));
22732303
}
22742304
};
22752305
print.join().unwrap();
@@ -2307,7 +2337,7 @@ fn run_output(cmd: &mut Command, program: &str) -> Result<Vec<u8>, Error> {
23072337
"Failed to wait on spawned child process, command {:?} with args {:?}.",
23082338
cmd, program
23092339
),
2310-
))
2340+
));
23112341
}
23122342
};
23132343
print.join().unwrap();

src/setup_config.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
use std::ffi::OsString;
1212
use std::ptr::null_mut;
1313
use winapi::Interface;
14-
use winapi::{LPFILETIME, ULONG};
15-
use winapi::S_FALSE;
1614
use winapi::BSTR;
1715
use winapi::LPCOLESTR;
18-
use winapi::{CoCreateInstance, CLSCTX_ALL};
1916
use winapi::LPSAFEARRAY;
17+
use winapi::S_FALSE;
18+
use winapi::{CoCreateInstance, CLSCTX_ALL};
2019
use winapi::{IUnknown, IUnknownVtbl};
2120
use winapi::{HRESULT, LCID, LPCWSTR, PULONGLONG};
21+
use winapi::{LPFILETIME, ULONG};
2222

2323
use com::{BStr, ComPtr};
2424

@@ -31,7 +31,7 @@ pub const eRegistered: InstanceState = 2;
3131
pub const eNoRebootRequired: InstanceState = 4;
3232
pub const eComplete: InstanceState = -1i32 as u32;
3333

34-
RIDL!{#[uuid(0xb41463c3, 0x8866, 0x43b5, 0xbc, 0x33, 0x2b, 0x06, 0x76, 0xf7, 0xf4, 0x2e)]
34+
RIDL! {#[uuid(0xb41463c3, 0x8866, 0x43b5, 0xbc, 0x33, 0x2b, 0x06, 0x76, 0xf7, 0xf4, 0x2e)]
3535
interface ISetupInstance(ISetupInstanceVtbl): IUnknown(IUnknownVtbl) {
3636
fn GetInstanceId(
3737
pbstrInstanceId: *mut BSTR,
@@ -62,7 +62,7 @@ interface ISetupInstance(ISetupInstanceVtbl): IUnknown(IUnknownVtbl) {
6262
) -> HRESULT,
6363
}}
6464

65-
RIDL!{#[uuid(0x89143c9a, 0x05af, 0x49b0, 0xb7, 0x17, 0x72, 0xe2, 0x18, 0xa2, 0x18, 0x5c)]
65+
RIDL! {#[uuid(0x89143c9a, 0x05af, 0x49b0, 0xb7, 0x17, 0x72, 0xe2, 0x18, 0xa2, 0x18, 0x5c)]
6666
interface ISetupInstance2(ISetupInstance2Vtbl): ISetupInstance(ISetupInstanceVtbl) {
6767
fn GetState(
6868
pState: *mut InstanceState,
@@ -78,7 +78,7 @@ interface ISetupInstance2(ISetupInstance2Vtbl): ISetupInstance(ISetupInstanceVtb
7878
) -> HRESULT,
7979
}}
8080

81-
RIDL!{#[uuid(0x6380bcff, 0x41d3, 0x4b2e, 0x8b, 0x2e, 0xbf, 0x8a, 0x68, 0x10, 0xc8, 0x48)]
81+
RIDL! {#[uuid(0x6380bcff, 0x41d3, 0x4b2e, 0x8b, 0x2e, 0xbf, 0x8a, 0x68, 0x10, 0xc8, 0x48)]
8282
interface IEnumSetupInstances(IEnumSetupInstancesVtbl): IUnknown(IUnknownVtbl) {
8383
fn Next(
8484
celt: ULONG,
@@ -94,7 +94,7 @@ interface IEnumSetupInstances(IEnumSetupInstancesVtbl): IUnknown(IUnknownVtbl) {
9494
) -> HRESULT,
9595
}}
9696

97-
RIDL!{#[uuid(0x42843719, 0xdb4c, 0x46c2, 0x8e, 0x7c, 0x64, 0xf1, 0x81, 0x6e, 0xfd, 0x5b)]
97+
RIDL! {#[uuid(0x42843719, 0xdb4c, 0x46c2, 0x8e, 0x7c, 0x64, 0xf1, 0x81, 0x6e, 0xfd, 0x5b)]
9898
interface ISetupConfiguration(ISetupConfigurationVtbl): IUnknown(IUnknownVtbl) {
9999
fn EnumInstances(
100100
ppEnumInstances: *mut *mut IEnumSetupInstances,
@@ -108,15 +108,15 @@ interface ISetupConfiguration(ISetupConfigurationVtbl): IUnknown(IUnknownVtbl) {
108108
) -> HRESULT,
109109
}}
110110

111-
RIDL!{#[uuid(0x26aab78c, 0x4a60, 0x49d6, 0xaf, 0x3b, 0x3c, 0x35, 0xbc, 0x93, 0x36, 0x5d)]
111+
RIDL! {#[uuid(0x26aab78c, 0x4a60, 0x49d6, 0xaf, 0x3b, 0x3c, 0x35, 0xbc, 0x93, 0x36, 0x5d)]
112112
interface ISetupConfiguration2(ISetupConfiguration2Vtbl):
113113
ISetupConfiguration(ISetupConfigurationVtbl) {
114114
fn EnumAllInstances(
115115
ppEnumInstances: *mut *mut IEnumSetupInstances,
116116
) -> HRESULT,
117117
}}
118118

119-
RIDL!{#[uuid(0xda8d8a16, 0xb2b6, 0x4487, 0xa2, 0xf1, 0x59, 0x4c, 0xcc, 0xcd, 0x6b, 0xf5)]
119+
RIDL! {#[uuid(0xda8d8a16, 0xb2b6, 0x4487, 0xa2, 0xf1, 0x59, 0x4c, 0xcc, 0xcd, 0x6b, 0xf5)]
120120
interface ISetupPackageReference(ISetupPackageReferenceVtbl): IUnknown(IUnknownVtbl) {
121121
fn GetId(
122122
pbstrId: *mut BSTR,
@@ -141,7 +141,7 @@ interface ISetupPackageReference(ISetupPackageReferenceVtbl): IUnknown(IUnknownV
141141
) -> HRESULT,
142142
}}
143143

144-
RIDL!{#[uuid(0x42b21b78, 0x6192, 0x463e, 0x87, 0xbf, 0xd5, 0x77, 0x83, 0x8f, 0x1d, 0x5c)]
144+
RIDL! {#[uuid(0x42b21b78, 0x6192, 0x463e, 0x87, 0xbf, 0xd5, 0x77, 0x83, 0x8f, 0x1d, 0x5c)]
145145
interface ISetupHelper(ISetupHelperVtbl): IUnknown(IUnknownVtbl) {
146146
fn ParseVersion(
147147
pwszVersion: LPCOLESTR,
@@ -154,7 +154,7 @@ interface ISetupHelper(ISetupHelperVtbl): IUnknown(IUnknownVtbl) {
154154
) -> HRESULT,
155155
}}
156156

157-
DEFINE_GUID!{CLSID_SetupConfiguration,
157+
DEFINE_GUID! {CLSID_SetupConfiguration,
158158
0x177f0c4a, 0x1cd3, 0x4de7, 0xa3, 0x2c, 0x71, 0xdb, 0xbb, 0x9f, 0xa3, 0x6d}
159159

160160
// Safe wrapper around the COM interfaces

src/winapi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ macro_rules! DEFINE_GUID {
115115
Data3: $w2,
116116
Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8],
117117
};
118-
}
118+
};
119119
}
120120

121121
macro_rules! RIDL {
@@ -207,7 +207,7 @@ macro_rules! RIDL {
207207
);
208208
}
209209

210-
RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)]
210+
RIDL! {#[uuid(0x00000000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)]
211211
interface IUnknown(IUnknownVtbl) {
212212
fn QueryInterface(
213213
riid: REFIID,

0 commit comments

Comments
 (0)