Skip to content

Commit abe1cc7

Browse files
committed
run rustfmt on compiletest folder in src/tools/ folder
1 parent ddf92ff commit abe1cc7

File tree

8 files changed

+273
-270
lines changed

8 files changed

+273
-270
lines changed

src/tools/compiletest/src/common.rs

+33-32
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,46 @@ impl FromStr for Mode {
3636
type Err = ();
3737
fn from_str(s: &str) -> Result<Mode, ()> {
3838
match s {
39-
"compile-fail" => Ok(CompileFail),
40-
"parse-fail" => Ok(ParseFail),
41-
"run-fail" => Ok(RunFail),
42-
"run-pass" => Ok(RunPass),
43-
"run-pass-valgrind" => Ok(RunPassValgrind),
44-
"pretty" => Ok(Pretty),
45-
"debuginfo-lldb" => Ok(DebugInfoLldb),
46-
"debuginfo-gdb" => Ok(DebugInfoGdb),
47-
"codegen" => Ok(Codegen),
48-
"rustdoc" => Ok(Rustdoc),
49-
"codegen-units" => Ok(CodegenUnits),
50-
"incremental" => Ok(Incremental),
51-
"run-make" => Ok(RunMake),
52-
"ui" => Ok(Ui),
53-
"mir-opt" => Ok(MirOpt),
54-
_ => Err(()),
39+
"compile-fail" => Ok(CompileFail),
40+
"parse-fail" => Ok(ParseFail),
41+
"run-fail" => Ok(RunFail),
42+
"run-pass" => Ok(RunPass),
43+
"run-pass-valgrind" => Ok(RunPassValgrind),
44+
"pretty" => Ok(Pretty),
45+
"debuginfo-lldb" => Ok(DebugInfoLldb),
46+
"debuginfo-gdb" => Ok(DebugInfoGdb),
47+
"codegen" => Ok(Codegen),
48+
"rustdoc" => Ok(Rustdoc),
49+
"codegen-units" => Ok(CodegenUnits),
50+
"incremental" => Ok(Incremental),
51+
"run-make" => Ok(RunMake),
52+
"ui" => Ok(Ui),
53+
"mir-opt" => Ok(MirOpt),
54+
_ => Err(()),
5555
}
5656
}
5757
}
5858

5959
impl fmt::Display for Mode {
6060
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6161
fmt::Display::fmt(match *self {
62-
CompileFail => "compile-fail",
63-
ParseFail => "parse-fail",
64-
RunFail => "run-fail",
65-
RunPass => "run-pass",
66-
RunPassValgrind => "run-pass-valgrind",
67-
Pretty => "pretty",
68-
DebugInfoGdb => "debuginfo-gdb",
69-
DebugInfoLldb => "debuginfo-lldb",
70-
Codegen => "codegen",
71-
Rustdoc => "rustdoc",
72-
CodegenUnits => "codegen-units",
73-
Incremental => "incremental",
74-
RunMake => "run-make",
75-
Ui => "ui",
76-
MirOpt => "mir-opt",
77-
}, f)
62+
CompileFail => "compile-fail",
63+
ParseFail => "parse-fail",
64+
RunFail => "run-fail",
65+
RunPass => "run-pass",
66+
RunPassValgrind => "run-pass-valgrind",
67+
Pretty => "pretty",
68+
DebugInfoGdb => "debuginfo-gdb",
69+
DebugInfoLldb => "debuginfo-lldb",
70+
Codegen => "codegen",
71+
Rustdoc => "rustdoc",
72+
CodegenUnits => "codegen-units",
73+
Incremental => "incremental",
74+
RunMake => "run-make",
75+
Ui => "ui",
76+
MirOpt => "mir-opt",
77+
},
78+
f)
7879
}
7980
}
8081

src/tools/compiletest/src/errors.rs

+46-33
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ pub struct Error {
6464
}
6565

6666
#[derive(PartialEq, Debug)]
67-
enum WhichLine { ThisLine, FollowPrevious(usize), AdjustBackward(usize) }
67+
enum WhichLine {
68+
ThisLine,
69+
FollowPrevious(usize),
70+
AdjustBackward(usize),
71+
}
6872

6973
/// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"
7074
/// The former is a "follow" that inherits its target from the preceding line;
@@ -91,60 +95,59 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<Error> {
9195

9296
let tag = match cfg {
9397
Some(rev) => format!("//[{}]~", rev),
94-
None => format!("//~")
98+
None => format!("//~"),
9599
};
96100

97101
rdr.lines()
98-
.enumerate()
99-
.filter_map(|(line_num, line)| {
100-
parse_expected(last_nonfollow_error,
101-
line_num + 1,
102-
&line.unwrap(),
103-
&tag)
104-
.map(|(which, error)| {
105-
match which {
106-
FollowPrevious(_) => {}
107-
_ => last_nonfollow_error = Some(error.line_num),
108-
}
109-
error
110-
})
111-
})
112-
.collect()
102+
.enumerate()
103+
.filter_map(|(line_num, line)| {
104+
parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), &tag)
105+
.map(|(which, error)| {
106+
match which {
107+
FollowPrevious(_) => {}
108+
_ => last_nonfollow_error = Some(error.line_num),
109+
}
110+
error
111+
})
112+
})
113+
.collect()
113114
}
114115

115116
fn parse_expected(last_nonfollow_error: Option<usize>,
116117
line_num: usize,
117118
line: &str,
118119
tag: &str)
119120
-> Option<(WhichLine, Error)> {
120-
let start = match line.find(tag) { Some(i) => i, None => return None };
121+
let start = match line.find(tag) {
122+
Some(i) => i,
123+
None => return None,
124+
};
121125
let (follow, adjusts) = if line[start + tag.len()..].chars().next().unwrap() == '|' {
122126
(true, 0)
123127
} else {
124128
(false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())
125129
};
126130
let kind_start = start + tag.len() + adjusts + (follow as usize);
127131
let (kind, msg);
128-
match
129-
line[kind_start..].split_whitespace()
130-
.next()
131-
.expect("Encountered unexpected empty comment")
132-
.parse::<ErrorKind>()
133-
{
132+
match line[kind_start..]
133+
.split_whitespace()
134+
.next()
135+
.expect("Encountered unexpected empty comment")
136+
.parse::<ErrorKind>() {
134137
Ok(k) => {
135138
// If we find `//~ ERROR foo` or something like that:
136139
kind = Some(k);
137140
let letters = line[kind_start..].chars();
138141
msg = letters.skip_while(|c| c.is_whitespace())
139-
.skip_while(|c| !c.is_whitespace())
140-
.collect::<String>();
142+
.skip_while(|c| !c.is_whitespace())
143+
.collect::<String>();
141144
}
142145
Err(_) => {
143146
// Otherwise we found `//~ foo`:
144147
kind = None;
145148
let letters = line[kind_start..].chars();
146149
msg = letters.skip_while(|c| c.is_whitespace())
147-
.collect::<String>();
150+
.collect::<String>();
148151
}
149152
}
150153
let msg = msg.trim().to_owned();
@@ -155,15 +158,25 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
155158
preceding //~^ line.");
156159
(FollowPrevious(line_num), line_num)
157160
} else {
158-
let which =
159-
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
161+
let which = if adjusts > 0 {
162+
AdjustBackward(adjusts)
163+
} else {
164+
ThisLine
165+
};
160166
let line_num = line_num - adjusts;
161167
(which, line_num)
162168
};
163169

164170
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
165-
line_num, tag, which, kind, msg);
166-
Some((which, Error { line_num: line_num,
167-
kind: kind,
168-
msg: msg, }))
171+
line_num,
172+
tag,
173+
which,
174+
kind,
175+
msg);
176+
Some((which,
177+
Error {
178+
line_num: line_num,
179+
kind: kind,
180+
msg: msg,
181+
}))
169182
}

0 commit comments

Comments
 (0)