Skip to content

Commit b7017d6

Browse files
committed
remove the now-unused multiline error code
1 parent 7724455 commit b7017d6

File tree

1 file changed

+4
-77
lines changed

1 file changed

+4
-77
lines changed

src/librustc/session/mod.rs

+4-77
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,14 @@ impl Session {
126126
sp: S,
127127
msg: &str)
128128
-> DiagnosticBuilder<'a> {
129-
match split_msg_into_multilines(msg) {
130-
Some(ref msg) => self.diagnostic().struct_span_err(sp, msg),
131-
None => self.diagnostic().struct_span_err(sp, msg),
132-
}
129+
self.diagnostic().struct_span_err(sp, msg)
133130
}
134131
pub fn struct_span_err_with_code<'a, S: Into<MultiSpan>>(&'a self,
135132
sp: S,
136133
msg: &str,
137134
code: &str)
138135
-> DiagnosticBuilder<'a> {
139-
match split_msg_into_multilines(msg) {
140-
Some(ref msg) => self.diagnostic().struct_span_err_with_code(sp, msg, code),
141-
None => self.diagnostic().struct_span_err_with_code(sp, msg, code),
142-
}
136+
self.diagnostic().struct_span_err_with_code(sp, msg, code)
143137
}
144138
pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
145139
self.diagnostic().struct_err(msg)
@@ -178,16 +172,10 @@ impl Session {
178172
}
179173
}
180174
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
181-
match split_msg_into_multilines(msg) {
182-
Some(msg) => self.diagnostic().span_err(sp, &msg),
183-
None => self.diagnostic().span_err(sp, msg)
184-
}
175+
self.diagnostic().span_err(sp, msg)
185176
}
186177
pub fn span_err_with_code<S: Into<MultiSpan>>(&self, sp: S, msg: &str, code: &str) {
187-
match split_msg_into_multilines(msg) {
188-
Some(msg) => self.diagnostic().span_err_with_code(sp, &msg, code),
189-
None => self.diagnostic().span_err_with_code(sp, msg, code)
190-
}
178+
self.diagnostic().span_err_with_code(sp, &msg, code)
191179
}
192180
pub fn err(&self, msg: &str) {
193181
self.diagnostic().err(msg)
@@ -343,67 +331,6 @@ impl Session {
343331
}
344332
}
345333

346-
fn split_msg_into_multilines(msg: &str) -> Option<String> {
347-
// Conditions for enabling multi-line errors:
348-
if !msg.contains("mismatched types") &&
349-
!msg.contains("type mismatch resolving") &&
350-
!msg.contains("if and else have incompatible types") &&
351-
!msg.contains("if may be missing an else clause") &&
352-
!msg.contains("match arms have incompatible types") &&
353-
!msg.contains("structure constructor specifies a structure of type") &&
354-
!msg.contains("has an incompatible type for trait") {
355-
return None
356-
}
357-
let first = msg.match_indices("expected").filter(|s| {
358-
let last = msg[..s.0].chars().rev().next();
359-
last == Some(' ') || last == Some('(')
360-
}).map(|(a, b)| (a - 1, a + b.len()));
361-
let second = msg.match_indices("found").filter(|s| {
362-
msg[..s.0].chars().rev().next() == Some(' ')
363-
}).map(|(a, b)| (a - 1, a + b.len()));
364-
365-
let mut new_msg = String::new();
366-
let mut head = 0;
367-
368-
// Insert `\n` before expected and found.
369-
for (pos1, pos2) in first.zip(second) {
370-
new_msg = new_msg +
371-
// A `(` may be preceded by a space and it should be trimmed
372-
msg[head..pos1.0].trim_right() + // prefix
373-
"\n" + // insert before first
374-
&msg[pos1.0..pos1.1] + // insert what first matched
375-
&msg[pos1.1..pos2.0] + // between matches
376-
"\n " + // insert before second
377-
// 123
378-
// `expected` is 3 char longer than `found`. To align the types,
379-
// `found` gets 3 spaces prepended.
380-
&msg[pos2.0..pos2.1]; // insert what second matched
381-
382-
head = pos2.1;
383-
}
384-
385-
let mut tail = &msg[head..];
386-
let third = tail.find("(values differ")
387-
.or(tail.find("(lifetime"))
388-
.or(tail.find("(cyclic type of infinite size"));
389-
// Insert `\n` before any remaining messages which match.
390-
if let Some(pos) = third {
391-
// The end of the message may just be wrapped in `()` without
392-
// `expected`/`found`. Push this also to a new line and add the
393-
// final tail after.
394-
new_msg = new_msg +
395-
// `(` is usually preceded by a space and should be trimmed.
396-
tail[..pos].trim_right() + // prefix
397-
"\n" + // insert before paren
398-
&tail[pos..]; // append the tail
399-
400-
tail = "";
401-
}
402-
403-
new_msg.push_str(tail);
404-
return Some(new_msg);
405-
}
406-
407334
pub fn build_session(sopts: config::Options,
408335
dep_graph: &DepGraph,
409336
local_crate_source_file: Option<PathBuf>,

0 commit comments

Comments
 (0)