Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a5965ab

Browse files
committedFeb 7, 2017
undo error regressions
1 parent 89fb0e0 commit a5965ab

15 files changed

+233
-369
lines changed
 

‎src/librustc_errors/diagnostic.rs

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
use CodeSuggestion;
1212
use Level;
13-
use RenderSpan;
14-
use RenderSpan::{Suggestion, Guesses};
1513
use std::{fmt, iter};
1614
use syntax_pos::{MultiSpan, Span};
1715
use snippet::Style;
@@ -24,6 +22,19 @@ pub struct Diagnostic {
2422
pub code: Option<String>,
2523
pub span: MultiSpan,
2624
pub children: Vec<SubDiagnostic>,
25+
pub code_hints: Option<DiagnosticCodeHint>,
26+
}
27+
28+
#[derive(Clone, Debug, PartialEq)]
29+
pub enum DiagnosticCodeHint {
30+
Suggestion {
31+
msg: String,
32+
sugg: CodeSuggestion,
33+
},
34+
Guesses {
35+
msg: String,
36+
guesses: Vec<CodeSuggestion>,
37+
},
2738
}
2839

2940
/// For example a note attached to an error.
@@ -32,7 +43,7 @@ pub struct SubDiagnostic {
3243
pub level: Level,
3344
pub message: Vec<(String, Style)>,
3445
pub span: MultiSpan,
35-
pub render_span: Option<RenderSpan>,
46+
pub render_span: Option<MultiSpan>,
3647
}
3748

3849
impl Diagnostic {
@@ -47,6 +58,7 @@ impl Diagnostic {
4758
code: code,
4859
span: MultiSpan::new(),
4960
children: vec![],
61+
code_hints: None,
5062
}
5163
}
5264

@@ -109,60 +121,62 @@ impl Diagnostic {
109121
}
110122

111123
pub fn note(&mut self, msg: &str) -> &mut Self {
112-
self.sub(Level::Note, msg, MultiSpan::new(), None);
124+
self.sub(Level::Note, msg, MultiSpan::new());
113125
self
114126
}
115127

116128
pub fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self {
117-
self.sub_with_highlights(Level::Note, msg, MultiSpan::new(), None);
129+
self.sub_with_highlights(Level::Note, msg, MultiSpan::new());
118130
self
119131
}
120132

121133
pub fn span_note<S: Into<MultiSpan>>(&mut self,
122134
sp: S,
123135
msg: &str)
124136
-> &mut Self {
125-
self.sub(Level::Note, msg, sp.into(), None);
137+
self.sub(Level::Note, msg, sp.into());
126138
self
127139
}
128140

129141
pub fn warn(&mut self, msg: &str) -> &mut Self {
130-
self.sub(Level::Warning, msg, MultiSpan::new(), None);
142+
self.sub(Level::Warning, msg, MultiSpan::new());
131143
self
132144
}
133145

134146
pub fn span_warn<S: Into<MultiSpan>>(&mut self,
135147
sp: S,
136148
msg: &str)
137149
-> &mut Self {
138-
self.sub(Level::Warning, msg, sp.into(), None);
150+
self.sub(Level::Warning, msg, sp.into());
139151
self
140152
}
141153

142154
pub fn help(&mut self , msg: &str) -> &mut Self {
143-
self.sub(Level::Help, msg, MultiSpan::new(), None);
155+
self.sub(Level::Help, msg, MultiSpan::new());
144156
self
145157
}
146158

147159
pub fn span_help<S: Into<MultiSpan>>(&mut self,
148160
sp: S,
149161
msg: &str)
150162
-> &mut Self {
151-
self.sub(Level::Help, msg, sp.into(), None);
163+
self.sub(Level::Help, msg, sp.into());
152164
self
153165
}
154166

155167
/// Prints out a message with a suggested edit of the code.
156168
///
157169
/// See `diagnostic::RenderSpan::Suggestion` for more information.
158170
pub fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self {
159-
self.sub(Level::Help,
160-
msg,
161-
MultiSpan::new(),
162-
Some(Suggestion(CodeSuggestion {
163-
msp: sp.into(),
164-
substitutes: vec![suggestion],
165-
})));
171+
assert!(self.code_hints.is_none(),
172+
"use guesses to assign multiple suggestions to an error");
173+
self.code_hints = Some(DiagnosticCodeHint::Suggestion {
174+
sugg: CodeSuggestion {
175+
msp: sp.into(),
176+
substitutes: vec![suggestion],
177+
},
178+
msg: msg.to_owned(),
179+
});
166180
self
167181
}
168182

@@ -174,13 +188,16 @@ impl Diagnostic {
174188
pub fn guesses<I>(&mut self, sp: Span, msg: &str, guesses: I) -> &mut Self
175189
where I: IntoIterator<Item = String>
176190
{
177-
self.sub(Level::Help,
178-
msg,
179-
MultiSpan::new(),
180-
Some(Guesses(guesses.into_iter().map(|guess| CodeSuggestion {
181-
msp: sp.into(),
182-
substitutes: vec![guess],
183-
}).collect())));
191+
assert!(self.code_hints.is_none(),
192+
"cannot attach multiple guesses to the same error");
193+
let guesses = guesses.into_iter().map(|guess| CodeSuggestion {
194+
msp: sp.into(),
195+
substitutes: vec![guess],
196+
}).collect();
197+
self.code_hints = Some(DiagnosticCodeHint::Guesses {
198+
guesses: guesses,
199+
msg: msg.to_owned(),
200+
});
184201
self
185202
}
186203

@@ -223,29 +240,25 @@ impl Diagnostic {
223240
fn sub(&mut self,
224241
level: Level,
225242
message: &str,
226-
span: MultiSpan,
227-
render_span: Option<RenderSpan>) {
228-
let sub = SubDiagnostic {
229-
level: level,
230-
message: vec![(message.to_owned(), Style::NoStyle)],
231-
span: span,
232-
render_span: render_span,
233-
};
234-
self.children.push(sub);
243+
span: MultiSpan) {
244+
self.sub_with_highlights(
245+
level,
246+
vec![(message.to_owned(), Style::NoStyle)],
247+
span,
248+
);
235249
}
236250

237251
/// Convenience function for internal use, clients should use one of the
238252
/// public methods above.
239253
fn sub_with_highlights(&mut self,
240254
level: Level,
241255
message: Vec<(String, Style)>,
242-
span: MultiSpan,
243-
render_span: Option<RenderSpan>) {
256+
span: MultiSpan) {
244257
let sub = SubDiagnostic {
245258
level: level,
246259
message: message,
247260
span: span,
248-
render_span: render_span,
261+
render_span: None,
249262
};
250263
self.children.push(sub);
251264
}

‎src/librustc_errors/emitter.rs

Lines changed: 80 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010

1111
use self::Destination::*;
1212

13-
use syntax_pos::{COMMAND_LINE_SP, DUMMY_SP, FileMap, Span, MultiSpan, CharPos};
13+
use syntax_pos::{COMMAND_LINE_SP, DUMMY_SP, FileMap, Span, MultiSpan, CharPos, SpanLabel};
1414

15-
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, CodeMapper};
16-
use RenderSpan::*;
15+
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, CodeMapper, DiagnosticCodeHint};
1716
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
1817
use styled_buffer::StyledBuffer;
1918

@@ -37,7 +36,8 @@ impl Emitter for EmitterWriter {
3736
&db.styled_message(),
3837
&db.code,
3938
&primary_span,
40-
&children);
39+
&children,
40+
db.code_hints.as_ref());
4141
}
4242
}
4343

@@ -110,7 +110,10 @@ impl EmitterWriter {
110110
}
111111
}
112112

113-
fn preprocess_annotations(&self, msp: &MultiSpan) -> Vec<FileWithAnnotatedLines> {
113+
fn preprocess_annotations(&self,
114+
msp: &MultiSpan,
115+
code_hint: &mut Option<&DiagnosticCodeHint>)
116+
-> Vec<FileWithAnnotatedLines> {
114117
fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
115118
file: Rc<FileMap>,
116119
line_index: usize,
@@ -149,11 +152,49 @@ impl EmitterWriter {
149152
let mut output = vec![];
150153
let mut multiline_annotations = vec![];
151154

155+
let hint = code_hint.and_then(|hint| match *hint {
156+
DiagnosticCodeHint::Suggestion { ref msg, ref sugg } => Some((msg, sugg)),
157+
DiagnosticCodeHint::Guesses { ref msg, ref guesses} => {
158+
if guesses.len() == 1 {
159+
Some((msg, &guesses[0]))
160+
} else {
161+
None
162+
}
163+
},
164+
});
165+
let mut hint = hint.and_then(|(msg, sugg)| {
166+
if sugg.substitutes.len() == 1 && !sugg.substitutes[0].is_empty() {
167+
let prim = sugg.msp.primary_spans();
168+
assert_eq!(prim.len(), 1);
169+
Some(SpanLabel {
170+
span: prim[0],
171+
is_primary: true,
172+
label: Some(format!("{} `{}`", msg, sugg.substitutes[0])),
173+
})
174+
} else {
175+
None
176+
}
177+
});
178+
152179
if let Some(ref cm) = self.cm {
153-
for span_label in msp.span_labels() {
180+
let mut span_labels = msp.span_labels();
181+
// insert the hint into the correct label
182+
for mut span_label in &mut span_labels {
183+
if let Some(hint_label) = hint.take() {
184+
if span_label.span == hint_label.span {
185+
span_label.label = hint_label.label;
186+
*code_hint = None;
187+
} else {
188+
hint = Some(hint_label);
189+
}
190+
}
191+
}
192+
// if no matching label found, print hint as an extra message
193+
for span_label in span_labels.into_iter().chain(hint) {
154194
if span_label.span == DUMMY_SP || span_label.span == COMMAND_LINE_SP {
155195
continue;
156196
}
197+
157198
let lo = cm.lookup_char_pos(span_label.span.lo);
158199
let mut hi = cm.lookup_char_pos(span_label.span.hi);
159200
let mut is_minimized = false;
@@ -728,7 +769,7 @@ impl EmitterWriter {
728769
/// displayed, keeping the provided highlighting.
729770
fn msg_to_buffer(&self,
730771
buffer: &mut StyledBuffer,
731-
msg: &Vec<(String, Style)>,
772+
msg: &[(String, Style)],
732773
padding: usize,
733774
label: &str,
734775
override_style: Option<Style>) {
@@ -806,7 +847,8 @@ impl EmitterWriter {
806847
code: &Option<String>,
807848
level: &Level,
808849
max_line_num_len: usize,
809-
is_secondary: bool)
850+
is_secondary: bool,
851+
code_hints: &mut Option<&DiagnosticCodeHint>)
810852
-> io::Result<()> {
811853
let mut buffer = StyledBuffer::new();
812854

@@ -837,7 +879,7 @@ impl EmitterWriter {
837879

838880
// Preprocess all the annotations so that they are grouped by file and by line number
839881
// This helps us quickly iterate over the whole message (including secondary file spans)
840-
let mut annotated_files = self.preprocess_annotations(msp);
882+
let mut annotated_files = self.preprocess_annotations(msp, code_hints);
841883

842884
// Make sure our primary file comes first
843885
let primary_lo = if let (Some(ref cm), Some(ref primary_span)) =
@@ -941,8 +983,8 @@ impl EmitterWriter {
941983
}
942984
fn emit_suggestion_default(&mut self,
943985
suggestion: &CodeSuggestion,
986+
msg: &str,
944987
level: &Level,
945-
msg: &Vec<(String, Style)>,
946988
max_line_num_len: usize)
947989
-> io::Result<()> {
948990
use std::borrow::Borrow;
@@ -954,7 +996,7 @@ impl EmitterWriter {
954996
buffer.append(0, &level.to_string(), Style::Level(level.clone()));
955997
buffer.append(0, ": ", Style::HeaderMsg);
956998
self.msg_to_buffer(&mut buffer,
957-
msg,
999+
&[(msg.to_owned(), Style::NoStyle)],
9581000
max_line_num_len,
9591001
"suggestion",
9601002
Some(Style::HeaderMsg));
@@ -989,12 +1031,27 @@ impl EmitterWriter {
9891031
message: &Vec<(String, Style)>,
9901032
code: &Option<String>,
9911033
span: &MultiSpan,
992-
children: &Vec<SubDiagnostic>) {
1034+
children: &Vec<SubDiagnostic>,
1035+
mut code_hints: Option<&DiagnosticCodeHint>) {
9931036
let max_line_num = self.get_max_line_num(span, children);
9941037
let max_line_num_len = max_line_num.to_string().len();
9951038

996-
match self.emit_message_default(span, message, code, level, max_line_num_len, false) {
1039+
match self.emit_message_default(span, message, code, level,
1040+
max_line_num_len, false, &mut code_hints) {
9971041
Ok(()) => {
1042+
if let Some(&DiagnosticCodeHint::Guesses { ref msg, ref guesses}) = code_hints {
1043+
if guesses.len() > 1 {
1044+
for cs in guesses {
1045+
match self.emit_suggestion_default(cs,
1046+
msg,
1047+
&Level::Note,
1048+
max_line_num_len) {
1049+
Err(e) => panic!("failed to emit error: {}", e),
1050+
_ => ()
1051+
}
1052+
}
1053+
}
1054+
}
9981055
if !children.is_empty() {
9991056
let mut buffer = StyledBuffer::new();
10001057
draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
@@ -1004,47 +1061,16 @@ impl EmitterWriter {
10041061
}
10051062
}
10061063
for child in children {
1007-
match child.render_span {
1008-
Some(FullSpan(ref msp)) => {
1009-
match self.emit_message_default(msp,
1010-
&child.styled_message(),
1011-
&None,
1012-
&child.level,
1013-
max_line_num_len,
1014-
true) {
1015-
Err(e) => panic!("failed to emit error: {}", e),
1016-
_ => ()
1017-
}
1018-
},
1019-
Some(Suggestion(ref cs)) => {
1020-
match self.emit_suggestion_default(cs,
1021-
&child.level,
1022-
&child.styled_message(),
1023-
max_line_num_len) {
1024-
Err(e) => panic!("failed to emit error: {}", e),
1025-
_ => ()
1026-
}
1027-
},
1028-
Some(Guesses(ref guesses)) => for cs in guesses {
1029-
match self.emit_suggestion_default(cs,
1030-
&child.level,
1031-
&child.styled_message(),
1032-
max_line_num_len) {
1033-
Err(e) => panic!("failed to emit error: {}", e),
1034-
_ => ()
1035-
}
1036-
},
1037-
None => {
1038-
match self.emit_message_default(&child.span,
1039-
&child.styled_message(),
1040-
&None,
1041-
&child.level,
1042-
max_line_num_len,
1043-
true) {
1044-
Err(e) => panic!("failed to emit error: {}", e),
1045-
_ => (),
1046-
}
1047-
}
1064+
let msp = child.render_span.as_ref().unwrap_or(&child.span);
1065+
match self.emit_message_default(msp,
1066+
&child.styled_message(),
1067+
&None,
1068+
&child.level,
1069+
max_line_num_len,
1070+
true,
1071+
&mut None) {
1072+
Err(e) => panic!("failed to emit error: {}", e),
1073+
_ => ()
10481074
}
10491075
}
10501076
}

‎src/librustc_errors/lib.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,6 @@ mod lock;
4949
use syntax_pos::{BytePos, Loc, FileLinesResult, FileName, MultiSpan, Span, NO_EXPANSION};
5050
use syntax_pos::MacroBacktrace;
5151

52-
#[derive(Clone, Debug, PartialEq)]
53-
pub enum RenderSpan {
54-
/// A FullSpan renders with both with an initial line for the
55-
/// message, prefixed by file:linenum, followed by a summary of
56-
/// the source code covered by the span.
57-
FullSpan(MultiSpan),
58-
59-
/// A suggestion renders with both with an initial line for the
60-
/// message, prefixed by file:linenum, followed by a summary
61-
/// of hypothetical source code, where each `String` is spliced
62-
/// into the lines in place of the code covered by each span.
63-
Suggestion(CodeSuggestion),
64-
65-
/// Guesses work just like suggestions, but there can be one or
66-
/// multiple guesses that aren't guaranteed to be correct.
67-
/// This allows updating `did you mean` style error messages
68-
/// to automatically applicable suggestions, but notifying the
69-
/// user that care must be taken when doing so.
70-
Guesses(Vec<CodeSuggestion>),
71-
}
72-
7352
#[derive(Clone, Debug, PartialEq)]
7453
pub struct CodeSuggestion {
7554
pub msp: MultiSpan,
@@ -210,7 +189,7 @@ impl error::Error for ExplicitBug {
210189
}
211190
}
212191

213-
pub use diagnostic::{Diagnostic, SubDiagnostic};
192+
pub use diagnostic::{Diagnostic, SubDiagnostic, DiagnosticCodeHint};
214193
pub use diagnostic_builder::DiagnosticBuilder;
215194

216195
/// A handler deals with errors; certain errors

‎src/libsyntax/json.rs

Lines changed: 37 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use codemap::CodeMap;
2323
use syntax_pos::{self, MacroBacktrace, Span, SpanLabel, MultiSpan};
2424
use errors::registry::Registry;
25-
use errors::{DiagnosticBuilder, SubDiagnostic, RenderSpan, CodeSuggestion, CodeMapper};
25+
use errors::{DiagnosticBuilder, SubDiagnostic, DiagnosticCodeHint, CodeSuggestion, CodeMapper};
2626
use errors::emitter::Emitter;
2727

2828
use std::rc::Rc;
@@ -95,6 +95,8 @@ struct Diagnostic {
9595

9696
#[derive(RustcEncodable)]
9797
struct Guess {
98+
/// A message explaining the guesses ("did you mean ...?")
99+
msg: String,
98100
/// one or multiple spans to be replaced by this guess
99101
spans: Vec<DiagnosticSpan>,
100102
}
@@ -162,42 +164,61 @@ impl Diagnostic {
162164
fn from_diagnostic_builder(db: &DiagnosticBuilder,
163165
je: &JsonEmitter)
164166
-> Diagnostic {
167+
let (suggestion, guesses) = match db.code_hints {
168+
Some(DiagnosticCodeHint::Suggestion{ref msg, ref sugg}) => {
169+
use std::borrow::Borrow;
170+
let sugg = Diagnostic {
171+
message: msg.clone(),
172+
code: None,
173+
level: "note",
174+
spans: DiagnosticSpan::from_suggestion(sugg, je),
175+
children: Vec::new(),
176+
rendered: Some(sugg.splice_lines(je.cm.borrow())),
177+
guesses: Vec::new(),
178+
};
179+
(Some(sugg), Vec::new())
180+
},
181+
Some(DiagnosticCodeHint::Guesses{ref msg, ref guesses}) => {
182+
let guesses = guesses.iter()
183+
.map(|guess| {
184+
assert_eq!(guess.msp.span_labels().len(), guess.substitutes.len());
185+
Guess {
186+
msg: msg.clone(),
187+
spans: DiagnosticSpan::from_suggestion(guess, je),
188+
}
189+
})
190+
.collect();
191+
(None, guesses)
192+
},
193+
None => (None, Vec::new())
194+
};
165195
Diagnostic {
166196
message: db.message(),
167197
code: DiagnosticCode::map_opt_string(db.code.clone(), je),
168198
level: db.level.to_str(),
169199
spans: DiagnosticSpan::from_multispan(&db.span, je),
170200
children: db.children.iter().map(|c| {
171201
Diagnostic::from_sub_diagnostic(c, je)
172-
}).collect(),
202+
}).chain(suggestion).collect(),
173203
rendered: None,
174-
guesses: Vec::new(),
204+
guesses: guesses,
175205
}
176206
}
177207

178208
fn from_sub_diagnostic(db: &SubDiagnostic, je: &JsonEmitter) -> Diagnostic {
179-
let SubDiagnosticParts {
180-
spans, rendered, guesses,
181-
} = DiagnosticSpan::from_render_span(db.render_span.as_ref(), &db.span, je);
209+
let msp = db.render_span.as_ref().unwrap_or(&db.span);
182210
Diagnostic {
183211
message: db.message(),
184212
code: None,
185213
level: db.level.to_str(),
186-
spans,
214+
spans: DiagnosticSpan::from_multispan(msp, je),
187215
children: vec![],
188-
rendered,
189-
guesses,
216+
rendered: None,
217+
guesses: Vec::new(),
190218
}
191219
}
192220
}
193221

194-
#[derive(Default)]
195-
struct SubDiagnosticParts {
196-
spans: Vec<DiagnosticSpan>,
197-
rendered: Option<String>,
198-
guesses: Vec<Guess>,
199-
}
200-
201222
impl DiagnosticSpan {
202223
fn from_span_label(span: SpanLabel,
203224
suggestion: Option<&String>,
@@ -297,43 +318,6 @@ impl DiagnosticSpan {
297318
})
298319
.collect()
299320
}
300-
301-
fn from_guesses(guesses: &[CodeSuggestion], je: &JsonEmitter) -> Vec<Guess> {
302-
guesses.iter()
303-
.map(|guess| {
304-
assert_eq!(guess.msp.span_labels().len(), guess.substitutes.len());
305-
Guess {
306-
spans: DiagnosticSpan::from_suggestion(guess, je),
307-
}
308-
})
309-
.collect()
310-
}
311-
312-
fn from_render_span(rsp: Option<&RenderSpan>,
313-
alt_span: &MultiSpan,
314-
je: &JsonEmitter,
315-
) -> SubDiagnosticParts {
316-
use std::borrow::Borrow;
317-
match rsp {
318-
None => SubDiagnosticParts {
319-
spans: DiagnosticSpan::from_multispan(alt_span, je),
320-
.. Default::default()
321-
},
322-
Some(&RenderSpan::FullSpan(ref msp)) => SubDiagnosticParts {
323-
spans: DiagnosticSpan::from_multispan(msp, je),
324-
.. Default::default()
325-
},
326-
Some(&RenderSpan::Suggestion(ref suggestion)) => SubDiagnosticParts {
327-
spans: DiagnosticSpan::from_suggestion(suggestion, je),
328-
rendered: Some(suggestion.splice_lines(je.cm.borrow())),
329-
.. Default::default()
330-
},
331-
Some(&RenderSpan::Guesses(ref guesses)) => SubDiagnosticParts {
332-
guesses: DiagnosticSpan::from_guesses(guesses, je),
333-
.. Default::default()
334-
},
335-
}
336-
}
337321
}
338322

339323
impl DiagnosticSpanLine {

‎src/test/ui/did_you_mean/issue-36798.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error: no field `baz` on type `Foo`
22
--> $DIR/issue-36798.rs:17:7
33
|
44
17 | f.baz;
5-
| ^^^
6-
|
7-
help: did you mean
8-
| f.bar;
5+
| ^^^ did you mean `bar`
96

107
error: aborting due to previous error
118

‎src/test/ui/mismatched_types/cast-rfc0401.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ error: casting `&{float}` as `f32` is invalid
228228
--> $DIR/cast-rfc0401.rs:81:30
229229
|
230230
81 | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
231-
| ^^^^^^^^ cannot cast `&{float}` as `f32`
232-
|
233-
help: did you mean
234-
| vec![0.0].iter().map(|s| *s as f32).collect::<Vec<f32>>();
231+
| ^^^^^^^^
232+
| |
233+
| cannot cast `&{float}` as `f32`
234+
| did you mean `*s`
235235

236236
error: aborting due to 34 previous errors
237237

‎src/test/ui/resolve/issue-14254.stderr

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0425]: cannot find function `baz` in this scope
22
--> $DIR/issue-14254.rs:29:9
33
|
44
29 | baz();
5-
| ^^^
6-
|
7-
help: did you intend to call a method of the same name?
8-
| self.baz();
5+
| ^^^ did you intend to call a method of the same name? `self.baz`
96

107
error[E0425]: cannot find value `a` in this scope
118
--> $DIR/issue-14254.rs:32:9
@@ -17,28 +14,19 @@ error[E0425]: cannot find function `baz` in this scope
1714
--> $DIR/issue-14254.rs:40:9
1815
|
1916
40 | baz();
20-
| ^^^
21-
|
22-
help: did you intend to call a method of the same name?
23-
| self.baz();
17+
| ^^^ did you intend to call a method of the same name? `self.baz`
2418

2519
error[E0425]: cannot find value `x` in this scope
2620
--> $DIR/issue-14254.rs:43:9
2721
|
2822
43 | x;
29-
| ^
30-
|
31-
help: did you intend to access a struct field?
32-
| self.x;
23+
| ^ did you intend to access a struct field? `self.x`
3324

3425
error[E0425]: cannot find value `y` in this scope
3526
--> $DIR/issue-14254.rs:46:9
3627
|
3728
46 | y;
38-
| ^
39-
|
40-
help: did you intend to access a struct field?
41-
| self.y;
29+
| ^ did you intend to access a struct field? `self.y`
4230

4331
error[E0425]: cannot find value `a` in this scope
4432
--> $DIR/issue-14254.rs:49:9
@@ -50,10 +38,7 @@ error[E0425]: cannot find value `bah` in this scope
5038
--> $DIR/issue-14254.rs:52:9
5139
|
5240
52 | bah;
53-
| ^^^
54-
|
55-
help: did you mean an associated item of the same name?
56-
| Self::bah;
41+
| ^^^ did you mean an associated item of the same name? `Self::bah`
5742

5843
error[E0425]: cannot find value `b` in this scope
5944
--> $DIR/issue-14254.rs:55:9
@@ -65,28 +50,19 @@ error[E0425]: cannot find function `baz` in this scope
6550
--> $DIR/issue-14254.rs:63:9
6651
|
6752
63 | baz();
68-
| ^^^
69-
|
70-
help: did you intend to call a method of the same name?
71-
| self.baz();
53+
| ^^^ did you intend to call a method of the same name? `self.baz`
7254

7355
error[E0425]: cannot find value `x` in this scope
7456
--> $DIR/issue-14254.rs:66:9
7557
|
7658
66 | x;
77-
| ^
78-
|
79-
help: did you intend to access a struct field?
80-
| self.x;
59+
| ^ did you intend to access a struct field? `self.x`
8160

8261
error[E0425]: cannot find value `y` in this scope
8362
--> $DIR/issue-14254.rs:69:9
8463
|
8564
69 | y;
86-
| ^
87-
|
88-
help: did you intend to access a struct field?
89-
| self.y;
65+
| ^ did you intend to access a struct field? `self.y`
9066

9167
error[E0425]: cannot find value `a` in this scope
9268
--> $DIR/issue-14254.rs:72:9
@@ -98,10 +74,7 @@ error[E0425]: cannot find value `bah` in this scope
9874
--> $DIR/issue-14254.rs:75:9
9975
|
10076
75 | bah;
101-
| ^^^
102-
|
103-
help: did you mean an associated item of the same name?
104-
| Self::bah;
77+
| ^^^ did you mean an associated item of the same name? `Self::bah`
10578

10679
error[E0425]: cannot find value `b` in this scope
10780
--> $DIR/issue-14254.rs:78:9
@@ -113,91 +86,61 @@ error[E0425]: cannot find function `baz` in this scope
11386
--> $DIR/issue-14254.rs:86:9
11487
|
11588
86 | baz();
116-
| ^^^
117-
|
118-
help: did you intend to call a method of the same name?
119-
| self.baz();
89+
| ^^^ did you intend to call a method of the same name? `self.baz`
12090

12191
error[E0425]: cannot find value `bah` in this scope
12292
--> $DIR/issue-14254.rs:89:9
12393
|
12494
89 | bah;
125-
| ^^^
126-
|
127-
help: did you mean an associated item of the same name?
128-
| Self::bah;
95+
| ^^^ did you mean an associated item of the same name? `Self::bah`
12996

13097
error[E0425]: cannot find function `baz` in this scope
13198
--> $DIR/issue-14254.rs:97:9
13299
|
133100
97 | baz();
134-
| ^^^
135-
|
136-
help: did you intend to call a method of the same name?
137-
| self.baz();
101+
| ^^^ did you intend to call a method of the same name? `self.baz`
138102

139103
error[E0425]: cannot find value `bah` in this scope
140104
--> $DIR/issue-14254.rs:100:9
141105
|
142106
100 | bah;
143-
| ^^^
144-
|
145-
help: did you mean an associated item of the same name?
146-
| Self::bah;
107+
| ^^^ did you mean an associated item of the same name? `Self::bah`
147108

148109
error[E0425]: cannot find function `baz` in this scope
149110
--> $DIR/issue-14254.rs:108:9
150111
|
151112
108 | baz();
152-
| ^^^
153-
|
154-
help: did you intend to call a method of the same name?
155-
| self.baz();
113+
| ^^^ did you intend to call a method of the same name? `self.baz`
156114

157115
error[E0425]: cannot find value `bah` in this scope
158116
--> $DIR/issue-14254.rs:111:9
159117
|
160118
111 | bah;
161-
| ^^^
162-
|
163-
help: did you mean an associated item of the same name?
164-
| Self::bah;
119+
| ^^^ did you mean an associated item of the same name? `Self::bah`
165120

166121
error[E0425]: cannot find function `baz` in this scope
167122
--> $DIR/issue-14254.rs:119:9
168123
|
169124
119 | baz();
170-
| ^^^
171-
|
172-
help: did you intend to call a method of the same name?
173-
| self.baz();
125+
| ^^^ did you intend to call a method of the same name? `self.baz`
174126

175127
error[E0425]: cannot find value `bah` in this scope
176128
--> $DIR/issue-14254.rs:122:9
177129
|
178130
122 | bah;
179-
| ^^^
180-
|
181-
help: did you mean an associated item of the same name?
182-
| Self::bah;
131+
| ^^^ did you mean an associated item of the same name? `Self::bah`
183132

184133
error[E0425]: cannot find function `baz` in this scope
185134
--> $DIR/issue-14254.rs:130:9
186135
|
187136
130 | baz();
188-
| ^^^
189-
|
190-
help: did you intend to call a method of the same name?
191-
| self.baz();
137+
| ^^^ did you intend to call a method of the same name? `self.baz`
192138

193139
error[E0425]: cannot find value `bah` in this scope
194140
--> $DIR/issue-14254.rs:133:9
195141
|
196142
133 | bah;
197-
| ^^^
198-
|
199-
help: did you mean an associated item of the same name?
200-
| Self::bah;
143+
| ^^^ did you mean an associated item of the same name? `Self::bah`
201144

202145
error: main function not found
203146

‎src/test/ui/resolve/issue-2356.stderr

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,25 @@ error[E0425]: cannot find function `clone` in this scope
88
--> $DIR/issue-2356.rs:35:5
99
|
1010
35 | clone();
11-
| ^^^^^
12-
|
13-
help: did you intend to call a method of the same name?
14-
| self.clone();
11+
| ^^^^^ did you intend to call a method of the same name? `self.clone`
1512

1613
error[E0425]: cannot find function `default` in this scope
1714
--> $DIR/issue-2356.rs:43:5
1815
|
1916
43 | default();
20-
| ^^^^^^^
21-
|
22-
help: did you mean an associated item of the same name?
23-
| Self::default();
17+
| ^^^^^^^ did you mean an associated item of the same name? `Self::default`
2418

2519
error[E0425]: cannot find value `whiskers` in this scope
2620
--> $DIR/issue-2356.rs:52:5
2721
|
2822
52 | whiskers -= other;
29-
| ^^^^^^^^ `self` value is only available in methods with `self` parameter
30-
|
31-
help: did you intend to access a struct field?
32-
| self.whiskers -= other;
23+
| ^^^^^^^^ did you intend to access a struct field? `self.whiskers`
3324

3425
error[E0425]: cannot find function `shave` in this scope
3526
--> $DIR/issue-2356.rs:57:5
3627
|
3728
57 | shave(4);
38-
| ^^^^^
39-
|
40-
help: did you mean an associated item of the same name?
41-
| Self::shave(4);
29+
| ^^^^^ did you mean an associated item of the same name? `Self::shave`
4230

4331
error[E0425]: cannot find function `purr` in this scope
4432
--> $DIR/issue-2356.rs:60:5
@@ -92,19 +80,13 @@ error[E0425]: cannot find value `whiskers` in this scope
9280
--> $DIR/issue-2356.rs:104:5
9381
|
9482
104 | whiskers = 0;
95-
| ^^^^^^^^
96-
|
97-
help: did you intend to access a struct field?
98-
| self.whiskers = 0;
83+
| ^^^^^^^^ did you intend to access a struct field? `self.whiskers`
9984

10085
error[E0425]: cannot find value `whiskers` in this scope
10186
--> $DIR/issue-2356.rs:110:5
10287
|
10388
110 | whiskers = 4;
104-
| ^^^^^^^^ `self` value is only available in methods with `self` parameter
105-
|
106-
help: did you intend to access a struct field?
107-
| self.whiskers = 4;
89+
| ^^^^^^^^ did you intend to access a struct field? `self.whiskers`
10890

10991
error[E0425]: cannot find function `purr_louder` in this scope
11092
--> $DIR/issue-2356.rs:115:5

‎src/test/ui/resolve/levenshtein.stderr

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,19 @@ error[E0412]: cannot find type `esize` in this scope
22
--> $DIR/levenshtein.rs:15:11
33
|
44
15 | fn foo(c: esize) {} // Misspelled primitive type name.
5-
| ^^^^^
6-
|
7-
help: did you mean
8-
| fn foo(c: isize) {} // Misspelled primitive type name.
5+
| ^^^^^ did you mean `isize`
96

107
error[E0412]: cannot find type `Baz` in this scope
118
--> $DIR/levenshtein.rs:19:10
129
|
1310
19 | type A = Baz; // Misspelled type name.
14-
| ^^^
15-
|
16-
help: did you mean
17-
| type A = Bar; // Misspelled type name.
11+
| ^^^ did you mean `Bar`
1812

1913
error[E0412]: cannot find type `Opiton` in this scope
2014
--> $DIR/levenshtein.rs:20:10
2115
|
2216
20 | type B = Opiton<u8>; // Misspelled type name from the prelude.
23-
| ^^^^^^^^^^
24-
|
25-
help: did you mean
26-
| type B = Option; // Misspelled type name from the prelude.
17+
| ^^^^^^^^^^ did you mean `Option`
2718

2819
error[E0412]: cannot find type `Baz` in this scope
2920
--> $DIR/levenshtein.rs:23:14
@@ -35,37 +26,25 @@ error[E0425]: cannot find value `MAXITEM` in this scope
3526
--> $DIR/levenshtein.rs:30:20
3627
|
3728
30 | let v = [0u32; MAXITEM]; // Misspelled constant name.
38-
| ^^^^^^^
39-
|
40-
help: did you mean
41-
| let v = [0u32; MAX_ITEM]; // Misspelled constant name.
29+
| ^^^^^^^ did you mean `MAX_ITEM`
4230

4331
error[E0425]: cannot find function `foobar` in this scope
4432
--> $DIR/levenshtein.rs:31:5
4533
|
4634
31 | foobar(); // Misspelled function name.
47-
| ^^^^^^
48-
|
49-
help: did you mean
50-
| foo_bar(); // Misspelled function name.
35+
| ^^^^^^ did you mean `foo_bar`
5136

5237
error[E0412]: cannot find type `first` in module `m`
5338
--> $DIR/levenshtein.rs:32:12
5439
|
5540
32 | let b: m::first = m::second; // Misspelled item in module.
56-
| ^^^^^^^^
57-
|
58-
help: did you mean
59-
| let b: m::First = m::second; // Misspelled item in module.
41+
| ^^^^^^^^ did you mean `m::First`
6042

6143
error[E0425]: cannot find value `second` in module `m`
6244
--> $DIR/levenshtein.rs:32:23
6345
|
6446
32 | let b: m::first = m::second; // Misspelled item in module.
65-
| ^^^^^^^^^
66-
|
67-
help: did you mean
68-
| let b: m::first = m::Second; // Misspelled item in module.
47+
| ^^^^^^^^^ did you mean `m::Second`
6948

7049
error[E0080]: constant evaluation error
7150
--> $DIR/levenshtein.rs:30:20

‎src/test/ui/resolve/resolve-assoc-suggestions.stderr

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,13 @@ error[E0425]: cannot find value `field` in this scope
1414
--> $DIR/resolve-assoc-suggestions.rs:32:9
1515
|
1616
32 | field;
17-
| ^^^^^
18-
|
19-
help: did you intend to access a struct field?
20-
| self.field;
17+
| ^^^^^ did you intend to access a struct field? `self.field`
2118

2219
error[E0412]: cannot find type `Type` in this scope
2320
--> $DIR/resolve-assoc-suggestions.rs:36:16
2421
|
2522
36 | let _: Type;
26-
| ^^^^
27-
|
28-
help: did you mean an associated item of the same name?
29-
| let _: Self::Type;
23+
| ^^^^ did you mean an associated item of the same name? `Self::Type`
3024

3125
error[E0531]: cannot find tuple struct/variant `Type` in this scope
3226
--> $DIR/resolve-assoc-suggestions.rs:39:13
@@ -56,10 +50,7 @@ error[E0425]: cannot find value `method` in this scope
5650
--> $DIR/resolve-assoc-suggestions.rs:52:9
5751
|
5852
52 | method;
59-
| ^^^^^^
60-
|
61-
help: did you intend to call a method of the same name?
62-
| self.method;
53+
| ^^^^^^ did you intend to call a method of the same name? `self.method`
6354

6455
error: aborting due to 9 previous errors
6556

‎src/test/ui/resolve/resolve-hint-macro.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0423]: expected function, found macro `assert`
22
--> $DIR/resolve-hint-macro.rs:12:5
33
|
44
12 | assert(true);
5-
| ^^^^^^
6-
|
7-
help: did you intend to invoke a macro of the same name?
8-
| assert!(true);
5+
| ^^^^^^ did you intend to invoke a macro of the same name? `assert!`
96

107
error: aborting due to previous error
118

‎src/test/ui/resolve/resolve-speculative-adjustment.stderr

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,13 @@ error[E0425]: cannot find value `field` in this scope
1414
--> $DIR/resolve-speculative-adjustment.rs:35:9
1515
|
1616
35 | field;
17-
| ^^^^^
18-
|
19-
help: did you intend to access a struct field?
20-
| self.field;
17+
| ^^^^^ did you intend to access a struct field? `self.field`
2118

2219
error[E0425]: cannot find function `method` in this scope
2320
--> $DIR/resolve-speculative-adjustment.rs:38:9
2421
|
2522
38 | method();
26-
| ^^^^^^
27-
|
28-
help: did you intend to call a method of the same name?
29-
| self.method();
23+
| ^^^^^^ did you intend to call a method of the same name? `self.method`
3024

3125
error: aborting due to 4 previous errors
3226

‎src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,67 @@ error[E0423]: expected value, found module `a`
22
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:27:5
33
|
44
27 | a.I
5-
| ^
6-
|
7-
help: did you mean
8-
| a::I
5+
| ^^^
6+
| |
7+
| did you mean `a::I`
98

109
error[E0423]: expected value, found module `a`
1110
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:33:5
1211
|
1312
33 | a.g()
14-
| ^
15-
|
16-
help: did you mean
17-
| a::g()
13+
| ^^^
14+
| |
15+
| did you mean `a::g`
1816

1917
error[E0423]: expected value, found module `a`
2018
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:39:5
2119
|
2220
39 | a.b.J
23-
| ^
24-
|
25-
help: did you mean
26-
| a::b.J
21+
| ^^^
22+
| |
23+
| did you mean `a::b`
2724

2825
error[E0423]: expected value, found module `a::b`
2926
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:45:5
3027
|
3128
45 | a::b.J
32-
| ^^^^
33-
|
34-
help: did you mean
35-
| a::b::J
29+
| ^^^^^^
30+
| |
31+
| did you mean `a::b::J`
3632

3733
error[E0423]: expected value, found module `a`
3834
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:51:5
3935
|
4036
51 | a.b.f();
41-
| ^
42-
|
43-
help: did you mean
44-
| a::b.f();
37+
| ^^^
38+
| |
39+
| did you mean `a::b`
4540

4641
error[E0423]: expected value, found module `a::b`
4742
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:55:12
4843
|
4944
55 | v.push(a::b);
50-
| ^^^^
51-
|
52-
help: did you mean
53-
| v.push(a::I);
45+
| ^^^^ did you mean `a::I`
5446

5547
error[E0423]: expected value, found module `a::b`
5648
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:61:5
5749
|
5850
61 | a::b.f()
59-
| ^^^^
60-
|
61-
help: did you mean
62-
| a::b::f()
51+
| ^^^^^^
52+
| |
53+
| did you mean `a::b::f`
6354

6455
error[E0423]: expected value, found module `a::b`
6556
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:67:5
6657
|
6758
67 | a::b
68-
| ^^^^
69-
|
70-
help: did you mean
71-
| a::I
59+
| ^^^^ did you mean `a::I`
7260

7361
error[E0423]: expected function, found module `a::b`
7462
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:73:5
7563
|
7664
73 | a::b()
77-
| ^^^^
78-
|
79-
help: did you mean
80-
| a::I()
65+
| ^^^^ did you mean `a::I`
8166

8267
error: main function not found
8368

‎src/test/ui/resolve/unresolved_static_type_field.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0425]: cannot find value `cx` in this scope
22
--> $DIR/unresolved_static_type_field.rs:19:11
33
|
44
19 | f(cx);
5-
| ^^ `self` value is only available in methods with `self` parameter
6-
|
7-
help: did you intend to access a struct field?
8-
| f(self.cx);
5+
| ^^ did you intend to access a struct field? `self.cx`
96

107
error: aborting due to previous error
118

‎src/test/ui/span/typo-suggestion.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ error[E0425]: cannot find value `fob` in this scope
88
--> $DIR/typo-suggestion.rs:18:26
99
|
1010
18 | println!("Hello {}", fob);
11-
| ^^^
12-
|
13-
help: did you mean
14-
| println!("Hello {}", foo);
11+
| ^^^ did you mean `foo`
1512

1613
error: aborting due to 2 previous errors
1714

0 commit comments

Comments
 (0)
Please sign in to comment.