Remove left over dead code from suggestion diagnostic refactoring
This commit is contained in:
parent
c81f201d48
commit
47c7e430d3
20 changed files with 28 additions and 102 deletions
|
@ -12,7 +12,6 @@ use CodeSuggestion;
|
|||
use SubstitutionPart;
|
||||
use Substitution;
|
||||
use Level;
|
||||
use RenderSpan;
|
||||
use std::fmt;
|
||||
use syntax_pos::{MultiSpan, Span};
|
||||
use snippet::Style;
|
||||
|
@ -40,7 +39,7 @@ pub struct SubDiagnostic {
|
|||
pub level: Level,
|
||||
pub message: Vec<(String, Style)>,
|
||||
pub span: MultiSpan,
|
||||
pub render_span: Option<RenderSpan>,
|
||||
pub render_span: Option<MultiSpan>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
|
@ -307,7 +306,7 @@ impl Diagnostic {
|
|||
level: Level,
|
||||
message: &str,
|
||||
span: MultiSpan,
|
||||
render_span: Option<RenderSpan>) {
|
||||
render_span: Option<MultiSpan>) {
|
||||
let sub = SubDiagnostic {
|
||||
level,
|
||||
message: vec![(message.to_owned(), Style::NoStyle)],
|
||||
|
@ -323,7 +322,7 @@ impl Diagnostic {
|
|||
level: Level,
|
||||
message: Vec<(String, Style)>,
|
||||
span: MultiSpan,
|
||||
render_span: Option<RenderSpan>) {
|
||||
render_span: Option<MultiSpan>) {
|
||||
let sub = SubDiagnostic {
|
||||
level,
|
||||
message,
|
||||
|
|
|
@ -13,7 +13,6 @@ use self::Destination::*;
|
|||
use syntax_pos::{DUMMY_SP, FileMap, Span, MultiSpan};
|
||||
|
||||
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, CodeMapper, DiagnosticId};
|
||||
use RenderSpan::*;
|
||||
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
|
||||
use styled_buffer::StyledBuffer;
|
||||
|
||||
|
@ -35,6 +34,7 @@ impl Emitter for EmitterWriter {
|
|||
fn emit(&mut self, db: &DiagnosticBuilder) {
|
||||
let mut primary_span = db.span.clone();
|
||||
let mut children = db.children.clone();
|
||||
let mut suggestions: &[_] = &[];
|
||||
|
||||
if let Some((sugg, rest)) = db.suggestions.split_first() {
|
||||
if rest.is_empty() &&
|
||||
|
@ -60,14 +60,7 @@ impl Emitter for EmitterWriter {
|
|||
// to be consistent. We could try to figure out if we can
|
||||
// make one (or the first one) inline, but that would give
|
||||
// undue importance to a semi-random suggestion
|
||||
for sugg in &db.suggestions {
|
||||
children.push(SubDiagnostic {
|
||||
level: Level::Help,
|
||||
message: Vec::new(),
|
||||
span: MultiSpan::new(),
|
||||
render_span: Some(Suggestion(sugg.clone())),
|
||||
});
|
||||
}
|
||||
suggestions = &db.suggestions;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +69,8 @@ impl Emitter for EmitterWriter {
|
|||
&db.styled_message(),
|
||||
&db.code,
|
||||
&primary_span,
|
||||
&children);
|
||||
&children,
|
||||
&suggestions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1179,7 +1173,8 @@ impl EmitterWriter {
|
|||
message: &Vec<(String, Style)>,
|
||||
code: &Option<DiagnosticId>,
|
||||
span: &MultiSpan,
|
||||
children: &Vec<SubDiagnostic>) {
|
||||
children: &Vec<SubDiagnostic>,
|
||||
suggestions: &[CodeSuggestion]) {
|
||||
let max_line_num = self.get_max_line_num(span, children);
|
||||
let max_line_num_len = max_line_num.to_string().len();
|
||||
|
||||
|
@ -1198,9 +1193,8 @@ impl EmitterWriter {
|
|||
}
|
||||
if !self.short_message {
|
||||
for child in children {
|
||||
match child.render_span {
|
||||
Some(FullSpan(ref msp)) => {
|
||||
match self.emit_message_default(msp,
|
||||
let span = child.render_span.as_ref().unwrap_or(&child.span);
|
||||
match self.emit_message_default(&span,
|
||||
&child.styled_message(),
|
||||
&None,
|
||||
&child.level,
|
||||
|
@ -1210,27 +1204,14 @@ impl EmitterWriter {
|
|||
_ => ()
|
||||
}
|
||||
}
|
||||
Some(Suggestion(ref cs)) => {
|
||||
match self.emit_suggestion_default(cs,
|
||||
&child.level,
|
||||
for sugg in suggestions {
|
||||
match self.emit_suggestion_default(sugg,
|
||||
&Level::Help,
|
||||
max_line_num_len) {
|
||||
Err(e) => panic!("failed to emit error: {}", e),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
None => {
|
||||
match self.emit_message_default(&child.span,
|
||||
&child.styled_message(),
|
||||
&None,
|
||||
&child.level,
|
||||
max_line_num_len,
|
||||
true) {
|
||||
Err(e) => panic!("failed to emit error: {}", e),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => panic!("failed to emit error: {}", e),
|
||||
|
|
|
@ -52,20 +52,6 @@ mod lock;
|
|||
|
||||
use syntax_pos::{BytePos, Loc, FileLinesResult, FileMap, FileName, MultiSpan, Span, NO_EXPANSION};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub enum RenderSpan {
|
||||
/// A FullSpan renders with both with an initial line for the
|
||||
/// message, prefixed by file:linenum, followed by a summary of
|
||||
/// the source code covered by the span.
|
||||
FullSpan(MultiSpan),
|
||||
|
||||
/// A suggestion renders with both with an initial line for the
|
||||
/// message, prefixed by file:linenum, followed by a summary
|
||||
/// of hypothetical source code, where each `String` is spliced
|
||||
/// into the lines in place of the code covered by each span.
|
||||
Suggestion(CodeSuggestion),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub struct CodeSuggestion {
|
||||
/// Each substitute can have multiple variants due to multiple
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
use codemap::{CodeMap, FilePathMapping};
|
||||
use syntax_pos::{self, MacroBacktrace, Span, SpanLabel, MultiSpan};
|
||||
use errors::registry::Registry;
|
||||
use errors::{DiagnosticBuilder, SubDiagnostic, RenderSpan, CodeSuggestion, CodeMapper};
|
||||
use errors::{DiagnosticBuilder, SubDiagnostic, CodeSuggestion, CodeMapper};
|
||||
use errors::DiagnosticId;
|
||||
use errors::emitter::Emitter;
|
||||
|
||||
|
@ -188,7 +188,7 @@ impl Diagnostic {
|
|||
code: None,
|
||||
level: db.level.to_str(),
|
||||
spans: db.render_span.as_ref()
|
||||
.map(|sp| DiagnosticSpan::from_render_span(sp, je))
|
||||
.map(|sp| DiagnosticSpan::from_multispan(sp, je))
|
||||
.unwrap_or_else(|| DiagnosticSpan::from_multispan(&db.span, je)),
|
||||
children: vec![],
|
||||
rendered: None,
|
||||
|
@ -300,16 +300,6 @@ impl DiagnosticSpan {
|
|||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn from_render_span(rsp: &RenderSpan, je: &JsonEmitter) -> Vec<DiagnosticSpan> {
|
||||
match *rsp {
|
||||
RenderSpan::FullSpan(ref msp) =>
|
||||
DiagnosticSpan::from_multispan(msp, je),
|
||||
// regular diagnostics don't produce this anymore
|
||||
// FIXME(oli_obk): remove it entirely
|
||||
RenderSpan::Suggestion(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DiagnosticSpanLine {
|
||||
|
|
|
@ -9,7 +9,6 @@ error[E0405]: cannot find trait `Debug` in this scope
|
|||
|
|
||||
21 | fn wants_debug(g: impl Debug) { }
|
||||
| ^^^^^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
13 | use std::fmt::Debug;
|
||||
|
@ -20,7 +19,6 @@ error[E0405]: cannot find trait `Debug` in this scope
|
|||
|
|
||||
22 | fn wants_display(g: impl Debug) { }
|
||||
| ^^^^^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
13 | use std::fmt::Debug;
|
||||
|
|
|
@ -50,7 +50,6 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a com
|
|||
| ^ not interpreted as comparison
|
||||
27 | 4);
|
||||
| - interpreted as generic arguments
|
||||
|
|
||||
help: try comparing the casted value
|
||||
|
|
||||
23 | println!("{}", (a
|
||||
|
@ -65,7 +64,6 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a com
|
|||
| ^ not interpreted as comparison
|
||||
36 | 5);
|
||||
| - interpreted as generic arguments
|
||||
|
|
||||
help: try comparing the casted value
|
||||
|
|
||||
28 | println!("{}", (a
|
||||
|
|
|
@ -12,7 +12,6 @@ error[E0425]: cannot find function `Apple` in this scope
|
|||
|
|
||||
23 | Apple(5)
|
||||
| ^^^^^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
12 | use Fruit::Apple;
|
||||
|
@ -32,7 +31,6 @@ error[E0425]: cannot find function `Apple` in this scope
|
|||
|
|
||||
31 | Apple(5)
|
||||
| ^^^^^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
12 | use Fruit::Apple;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0425]: cannot find value `A` in module `namespaced_enums`
|
|||
|
|
||||
15 | let _ = namespaced_enums::A;
|
||||
| ^ not found in `namespaced_enums`
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
14 | use namespaced_enums::Foo::A;
|
||||
|
@ -14,7 +13,6 @@ error[E0425]: cannot find function `B` in module `namespaced_enums`
|
|||
|
|
||||
18 | let _ = namespaced_enums::B(10);
|
||||
| ^ not found in `namespaced_enums`
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
14 | use namespaced_enums::Foo::B;
|
||||
|
@ -25,7 +23,6 @@ error[E0422]: cannot find struct, variant or union type `C` in module `namespace
|
|||
|
|
||||
21 | let _ = namespaced_enums::C { a: 10 };
|
||||
| ^ not found in `namespaced_enums`
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
14 | use namespaced_enums::Foo::C;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0574]: expected struct, variant or union type, found enum `Result`
|
|||
|
|
||||
19 | Result {
|
||||
| ^^^^^^ not a struct, variant or union type
|
||||
|
|
||||
help: possible better candidates are found in other modules, you can import them into scope
|
||||
|
|
||||
12 | use std::fmt::Result;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0422]: cannot find struct, variant or union type `E` in this scope
|
|||
|
|
||||
16 | E { name: "foobar" }; //~ ERROR unresolved struct, variant or union type `E`
|
||||
| ^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
11 | use SomeEnum::E;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0405]: cannot find trait `Mul` in this scope
|
|||
|
|
||||
53 | impl Mul for Foo {
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: possible candidates are found in other modules, you can import them into scope
|
||||
|
|
||||
11 | use mul1::Mul;
|
||||
|
@ -18,7 +17,6 @@ error[E0412]: cannot find type `Mul` in this scope
|
|||
|
|
||||
72 | fn getMul() -> Mul {
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: possible candidates are found in other modules, you can import them into scope
|
||||
|
|
||||
11 | use mul1::Mul;
|
||||
|
@ -42,7 +40,6 @@ error[E0405]: cannot find trait `Div` in this scope
|
|||
|
|
||||
88 | impl Div for Foo {
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
11 | use std::ops::Div;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0405]: cannot find trait `T` in this scope
|
|||
|
|
||||
28 | impl T for Foo { }
|
||||
| ^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
11 | use foo::bar::T;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0405]: cannot find trait `OuterTrait` in this scope
|
|||
|
|
||||
25 | impl OuterTrait for Foo {}
|
||||
| ^^^^^^^^^^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
18 | use issue_21221_3::outer::OuterTrait;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0405]: cannot find trait `T` in this scope
|
|||
|
|
||||
20 | impl T for Foo {}
|
||||
| ^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
18 | use issue_21221_4::T;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0404]: expected trait, found type alias `Foo`
|
|||
|
|
||||
20 | impl Foo for S { //~ ERROR expected trait, found type alias `Foo`
|
||||
| ^^^ type aliases cannot be used for traits
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
14 | use issue_3907::Foo;
|
||||
|
|
|
@ -7,7 +7,6 @@ error[E0423]: expected value, found struct `Z`
|
|||
| did you mean `S`?
|
||||
| constructor is not visible here due to private fields
|
||||
| did you mean `Z { /* fields */ }`?
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
22 | use m::n::Z;
|
||||
|
@ -21,7 +20,6 @@ error[E0423]: expected value, found struct `S`
|
|||
| |
|
||||
| constructor is not visible here due to private fields
|
||||
| did you mean `S { /* fields */ }`?
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
32 | use m::S;
|
||||
|
@ -35,7 +33,6 @@ error[E0423]: expected value, found struct `xcrate::S`
|
|||
| |
|
||||
| constructor is not visible here due to private fields
|
||||
| did you mean `xcrate::S { /* fields */ }`?
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
32 | use m::S;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0412]: cannot find type `Path` in this scope
|
|||
|
|
||||
25 | type Bar = Path;
|
||||
| ^^^^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
21 | use std::path::Path;
|
||||
|
@ -14,7 +13,6 @@ error[E0425]: cannot find value `A` in this scope
|
|||
|
|
||||
30 | let _ = A;
|
||||
| ^ not found in this scope
|
||||
|
|
||||
help: possible candidate is found in another module, you can import it into scope
|
||||
|
|
||||
11 | use m::A;
|
||||
|
@ -25,7 +23,6 @@ error[E0412]: cannot find type `HashMap` in this scope
|
|||
|
|
||||
35 | type Dict<K, V> = HashMap<K, V>;
|
||||
| ^^^^^^^ not found in this scope
|
||||
|
|
||||
help: possible candidates are found in other modules, you can import them into scope
|
||||
|
|
||||
11 | use std::collections::HashMap;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0404]: expected trait, found type parameter `Add`
|
|||
|
|
||||
15 | impl<T: Clone, Add> Add for Foo<T> {
|
||||
| ^^^ not a trait
|
||||
|
|
||||
help: possible better candidate is found in another module, you can import it into scope
|
||||
|
|
||||
13 | use std::ops::Add;
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0369]: binary operation `+` cannot be applied to type `&str`
|
|||
|
|
||||
12 | let x = "Hello " + "World!";
|
||||
| ^^^^^^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings
|
||||
|
|
||||
help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
|
||||
|
|
||||
12 | let x = "Hello ".to_owned() + "World!";
|
||||
|
|
|
@ -3,7 +3,6 @@ error[E0061]: this function takes 1 parameter but 0 parameters were supplied
|
|||
|
|
||||
21 | let _: Result<(), String> = Ok();
|
||||
| ^^^^
|
||||
|
|
||||
help: expected the unit value `()`; create it with empty parentheses
|
||||
|
|
||||
21 | let _: Result<(), String> = Ok(());
|
||||
|
@ -35,7 +34,6 @@ error[E0061]: this function takes 1 parameter but 0 parameters were supplied
|
|||
...
|
||||
24 | bar();
|
||||
| ^^^^^
|
||||
|
|
||||
help: expected the unit value `()`; create it with empty parentheses
|
||||
|
|
||||
24 | bar(());
|
||||
|
@ -49,7 +47,6 @@ error[E0061]: this function takes 1 parameter but 0 parameters were supplied
|
|||
...
|
||||
25 | S.baz();
|
||||
| ^^^
|
||||
|
|
||||
help: expected the unit value `()`; create it with empty parentheses
|
||||
|
|
||||
25 | S.baz(());
|
||||
|
@ -63,7 +60,6 @@ error[E0061]: this function takes 1 parameter but 0 parameters were supplied
|
|||
...
|
||||
26 | S.generic::<()>();
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: expected the unit value `()`; create it with empty parentheses
|
||||
|
|
||||
26 | S.generic::<()>(());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue