Skip to content

Commit 593e156

Browse files
committedMay 29, 2016
run rustfmt on librustc_llvm folder
1 parent 397cfae commit 593e156

File tree

3 files changed

+83
-56
lines changed

3 files changed

+83
-56
lines changed
 

‎src/librustc_llvm/archive_ro.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use std::path::Path;
1818
use std::slice;
1919
use std::str;
2020

21-
pub struct ArchiveRO { ptr: ArchiveRef }
21+
pub struct ArchiveRO {
22+
ptr: ArchiveRef,
23+
}
2224

2325
pub struct Iter<'a> {
2426
archive: &'a ArchiveRO,
@@ -61,11 +63,16 @@ impl ArchiveRO {
6163
}
6264
}
6365

64-
pub fn raw(&self) -> ArchiveRef { self.ptr }
66+
pub fn raw(&self) -> ArchiveRef {
67+
self.ptr
68+
}
6569

6670
pub fn iter(&self) -> Iter {
6771
unsafe {
68-
Iter { ptr: ::LLVMRustArchiveIteratorNew(self.ptr), archive: self }
72+
Iter {
73+
ptr: ::LLVMRustArchiveIteratorNew(self.ptr),
74+
archive: self,
75+
}
6976
}
7077
}
7178
}
@@ -86,7 +93,10 @@ impl<'a> Iterator for Iter<'a> {
8693
if ptr.is_null() {
8794
::last_error().map(Err)
8895
} else {
89-
Some(Ok(Child { ptr: ptr, _data: marker::PhantomData }))
96+
Some(Ok(Child {
97+
ptr: ptr,
98+
_data: marker::PhantomData,
99+
}))
90100
}
91101
}
92102
}
@@ -107,8 +117,7 @@ impl<'a> Child<'a> {
107117
if name_ptr.is_null() {
108118
None
109119
} else {
110-
let name = slice::from_raw_parts(name_ptr as *const u8,
111-
name_len as usize);
120+
let name = slice::from_raw_parts(name_ptr as *const u8, name_len as usize);
112121
str::from_utf8(name).ok().map(|s| s.trim())
113122
}
114123
}
@@ -125,11 +134,15 @@ impl<'a> Child<'a> {
125134
}
126135
}
127136

128-
pub fn raw(&self) -> ::ArchiveChildRef { self.ptr }
137+
pub fn raw(&self) -> ::ArchiveChildRef {
138+
self.ptr
139+
}
129140
}
130141

131142
impl<'a> Drop for Child<'a> {
132143
fn drop(&mut self) {
133-
unsafe { ::LLVMRustArchiveChildFree(self.ptr); }
144+
unsafe {
145+
::LLVMRustArchiveChildFree(self.ptr);
146+
}
134147
}
135148
}

‎src/librustc_llvm/build.rs

+36-25
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,25 @@ fn main() {
2121
println!("cargo:rustc-cfg=cargobuild");
2222

2323
let target = env::var("TARGET").unwrap();
24-
let llvm_config = env::var_os("LLVM_CONFIG").map(PathBuf::from)
25-
.unwrap_or_else(|| {
26-
match env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
27-
Some(dir) => {
28-
let to_test = dir.parent().unwrap().parent().unwrap()
29-
.join(&target).join("llvm/bin/llvm-config");
30-
if Command::new(&to_test).output().is_ok() {
31-
return to_test
32-
}
33-
}
34-
None => {}
35-
}
36-
PathBuf::from("llvm-config")
37-
});
24+
let llvm_config = env::var_os("LLVM_CONFIG")
25+
.map(PathBuf::from)
26+
.unwrap_or_else(|| {
27+
match env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
28+
Some(dir) => {
29+
let to_test = dir.parent()
30+
.unwrap()
31+
.parent()
32+
.unwrap()
33+
.join(&target)
34+
.join("llvm/bin/llvm-config");
35+
if Command::new(&to_test).output().is_ok() {
36+
return to_test;
37+
}
38+
}
39+
None => {}
40+
}
41+
PathBuf::from("llvm-config")
42+
});
3843

3944
println!("cargo:rerun-if-changed={}", llvm_config.display());
4045

@@ -63,20 +68,22 @@ fn main() {
6368
let host = env::var("HOST").unwrap();
6469
let is_crossed = target != host;
6570

66-
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc",
67-
"pnacl"];
71+
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl"];
6872

6973
// FIXME: surely we don't need all these components, right? Stuff like mcjit
7074
// or interpreter the compiler itself never uses.
71-
let required_components = &["ipo", "bitreader", "bitwriter", "linker",
72-
"asmparser", "mcjit", "interpreter",
75+
let required_components = &["ipo",
76+
"bitreader",
77+
"bitwriter",
78+
"linker",
79+
"asmparser",
80+
"mcjit",
81+
"interpreter",
7382
"instrumentation"];
7483

7584
let components = output(Command::new(&llvm_config).arg("--components"));
7685
let mut components = components.split_whitespace().collect::<Vec<_>>();
77-
components.retain(|c| {
78-
optional_components.contains(c) || required_components.contains(c)
79-
});
86+
components.retain(|c| optional_components.contains(c) || required_components.contains(c));
8087

8188
for component in required_components {
8289
if !components.contains(component) {
@@ -96,7 +103,7 @@ fn main() {
96103
for flag in cxxflags.split_whitespace() {
97104
// Ignore flags like `-m64` when we're doing a cross build
98105
if is_crossed && flag.starts_with("-m") {
99-
continue
106+
continue;
100107
}
101108
cfg.flag(flag);
102109
}
@@ -131,7 +138,7 @@ fn main() {
131138
} else if lib.starts_with("-") {
132139
&lib[1..]
133140
} else {
134-
continue
141+
continue;
135142
};
136143

137144
// Don't need or want this library, but LLVM's CMake build system
@@ -140,10 +147,14 @@ fn main() {
140147
// library and it otherwise may just pull in extra dependencies on
141148
// libedit which we don't want
142149
if name == "LLVMLineEditor" {
143-
continue
150+
continue;
144151
}
145152

146-
let kind = if name.starts_with("LLVM") {"static"} else {"dylib"};
153+
let kind = if name.starts_with("LLVM") {
154+
"static"
155+
} else {
156+
"dylib"
157+
};
147158
println!("cargo:rustc-link-lib={}={}", kind, name);
148159
}
149160

‎src/librustc_llvm/diagnostic.rs

+26-23
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub use self::Diagnostic::*;
1616
use libc::{c_char, c_uint};
1717
use std::ptr;
1818

19-
use {ValueRef, TwineRef, DebugLocRef, DiagnosticInfoRef};
19+
use {DebugLocRef, DiagnosticInfoRef, TwineRef, ValueRef};
2020

2121
#[derive(Copy, Clone)]
2222
pub enum OptimizationDiagnosticKind {
@@ -46,8 +46,9 @@ pub struct OptimizationDiagnostic {
4646
}
4747

4848
impl OptimizationDiagnostic {
49-
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: DiagnosticInfoRef)
50-
-> OptimizationDiagnostic {
49+
unsafe fn unpack(kind: OptimizationDiagnosticKind,
50+
di: DiagnosticInfoRef)
51+
-> OptimizationDiagnostic {
5152

5253
let mut opt = OptimizationDiagnostic {
5354
kind: kind,
@@ -58,10 +59,10 @@ impl OptimizationDiagnostic {
5859
};
5960

6061
super::LLVMUnpackOptimizationDiagnostic(di,
61-
&mut opt.pass_name,
62-
&mut opt.function,
63-
&mut opt.debug_loc,
64-
&mut opt.message);
62+
&mut opt.pass_name,
63+
&mut opt.function,
64+
&mut opt.debug_loc,
65+
&mut opt.message);
6566

6667
opt
6768
}
@@ -75,8 +76,7 @@ pub struct InlineAsmDiagnostic {
7576
}
7677

7778
impl InlineAsmDiagnostic {
78-
unsafe fn unpack(di: DiagnosticInfoRef)
79-
-> InlineAsmDiagnostic {
79+
unsafe fn unpack(di: DiagnosticInfoRef) -> InlineAsmDiagnostic {
8080

8181
let mut opt = InlineAsmDiagnostic {
8282
cookie: 0,
@@ -85,9 +85,9 @@ impl InlineAsmDiagnostic {
8585
};
8686

8787
super::LLVMUnpackInlineAsmDiagnostic(di,
88-
&mut opt.cookie,
89-
&mut opt.message,
90-
&mut opt.instruction);
88+
&mut opt.cookie,
89+
&mut opt.message,
90+
&mut opt.instruction);
9191

9292
opt
9393
}
@@ -106,22 +106,25 @@ impl Diagnostic {
106106
let kind = super::LLVMGetDiagInfoKind(di);
107107

108108
match kind {
109-
super::DK_InlineAsm
110-
=> InlineAsm(InlineAsmDiagnostic::unpack(di)),
109+
super::DK_InlineAsm => InlineAsm(InlineAsmDiagnostic::unpack(di)),
111110

112-
super::DK_OptimizationRemark
113-
=> Optimization(OptimizationDiagnostic::unpack(OptimizationRemark, di)),
111+
super::DK_OptimizationRemark => {
112+
Optimization(OptimizationDiagnostic::unpack(OptimizationRemark, di))
113+
}
114114

115-
super::DK_OptimizationRemarkMissed
116-
=> Optimization(OptimizationDiagnostic::unpack(OptimizationMissed, di)),
115+
super::DK_OptimizationRemarkMissed => {
116+
Optimization(OptimizationDiagnostic::unpack(OptimizationMissed, di))
117+
}
117118

118-
super::DK_OptimizationRemarkAnalysis
119-
=> Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di)),
119+
super::DK_OptimizationRemarkAnalysis => {
120+
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di))
121+
}
120122

121-
super::DK_OptimizationFailure
122-
=> Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di)),
123+
super::DK_OptimizationFailure => {
124+
Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di))
125+
}
123126

124-
_ => UnknownDiagnostic(di)
127+
_ => UnknownDiagnostic(di),
125128
}
126129
}
127130
}

0 commit comments

Comments
 (0)
Please sign in to comment.