about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-11-16 16:36:49 +0100
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-11-16 16:36:49 +0100
commit47c7e430d35fc5b49b36d2fb5b5a75497059b05b (patch)
treea70915b851a69126eaf997066d83fad90032564d
parentc81f201d48c4f25d32f8b0f76103c9f794d37851 (diff)
downloadrust-47c7e430d35fc5b49b36d2fb5b5a75497059b05b.tar.gz
rust-47c7e430d35fc5b49b36d2fb5b5a75497059b05b.zip
Remove left over dead code from suggestion diagnostic refactoring
-rw-r--r--src/librustc_errors/diagnostic.rs7
-rw-r--r--src/librustc_errors/emitter.rs65
-rw-r--r--src/librustc_errors/lib.rs14
-rw-r--r--src/libsyntax/json.rs14
-rw-r--r--src/test/ui/impl-trait/universal_wrong_bounds.stderr2
-rw-r--r--src/test/ui/issue-22644.stderr2
-rw-r--r--src/test/ui/issue-35675.stderr2
-rw-r--r--src/test/ui/resolve/enums-are-namespaced-xc.stderr3
-rw-r--r--src/test/ui/resolve/issue-16058.stderr1
-rw-r--r--src/test/ui/resolve/issue-17518.stderr1
-rw-r--r--src/test/ui/resolve/issue-21221-1.stderr3
-rw-r--r--src/test/ui/resolve/issue-21221-2.stderr1
-rw-r--r--src/test/ui/resolve/issue-21221-3.stderr1
-rw-r--r--src/test/ui/resolve/issue-21221-4.stderr1
-rw-r--r--src/test/ui/resolve/issue-3907.stderr1
-rw-r--r--src/test/ui/resolve/privacy-struct-ctor.stderr3
-rw-r--r--src/test/ui/resolve/use_suggestion_placement.stderr3
-rw-r--r--src/test/ui/span/issue-35987.stderr1
-rw-r--r--src/test/ui/span/issue-39018.stderr1
-rw-r--r--src/test/ui/span/missing-unit-argument.stderr4
20 files changed, 28 insertions, 102 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index c7e9c8268f0..221c75186e9 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -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,
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 0e39f29204d..57523d2c058 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -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,37 +1193,23 @@ impl EmitterWriter {
                 }
                 if !self.short_message {
                     for child in children {
-                        match child.render_span {
-                            Some(FullSpan(ref msp)) => {
-                                match self.emit_message_default(msp,
-                                                                &child.styled_message(),
-                                                                &None,
-                                                                &child.level,
-                                                                max_line_num_len,
-                                                                true) {
-                                    Err(e) => panic!("failed to emit error: {}", e),
-                                    _ => ()
-                                }
-                            }
-                            Some(Suggestion(ref cs)) => {
-                                match self.emit_suggestion_default(cs,
-                                                                   &child.level,
-                                                                   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),
-                                    _ => (),
-                                }
-                            }
+                        let span = child.render_span.as_ref().unwrap_or(&child.span);
+                        match self.emit_message_default(&span,
+                                                        &child.styled_message(),
+                                                        &None,
+                                                        &child.level,
+                                                        max_line_num_len,
+                                                        true) {
+                            Err(e) => panic!("failed to emit error: {}", e),
+                            _ => ()
+                        }
+                    }
+                    for sugg in suggestions {
+                        match self.emit_suggestion_default(sugg,
+                                                           &Level::Help,
+                                                           max_line_num_len) {
+                            Err(e) => panic!("failed to emit error: {}", e),
+                            _ => ()
                         }
                     }
                 }
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 7bf64d24325..e83ac8831de 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -53,20 +53,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
     /// applicable suggestions
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs
index 6564046ffe6..e739c6d04e1 100644
--- a/src/libsyntax/json.rs
+++ b/src/libsyntax/json.rs
@@ -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 {
diff --git a/src/test/ui/impl-trait/universal_wrong_bounds.stderr b/src/test/ui/impl-trait/universal_wrong_bounds.stderr
index 5e7788812e6..600064c71dc 100644
--- a/src/test/ui/impl-trait/universal_wrong_bounds.stderr
+++ b/src/test/ui/impl-trait/universal_wrong_bounds.stderr
@@ -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;
diff --git a/src/test/ui/issue-22644.stderr b/src/test/ui/issue-22644.stderr
index f4967c4803b..5777c24ae88 100644
--- a/src/test/ui/issue-22644.stderr
+++ b/src/test/ui/issue-22644.stderr
@@ -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
diff --git a/src/test/ui/issue-35675.stderr b/src/test/ui/issue-35675.stderr
index ed330f47208..e125d74e28f 100644
--- a/src/test/ui/issue-35675.stderr
+++ b/src/test/ui/issue-35675.stderr
@@ -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;
diff --git a/src/test/ui/resolve/enums-are-namespaced-xc.stderr b/src/test/ui/resolve/enums-are-namespaced-xc.stderr
index a401861274d..52d798a2ca5 100644
--- a/src/test/ui/resolve/enums-are-namespaced-xc.stderr
+++ b/src/test/ui/resolve/enums-are-namespaced-xc.stderr
@@ -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;
diff --git a/src/test/ui/resolve/issue-16058.stderr b/src/test/ui/resolve/issue-16058.stderr
index 6d7406f891c..322a1fea52e 100644
--- a/src/test/ui/resolve/issue-16058.stderr
+++ b/src/test/ui/resolve/issue-16058.stderr
@@ -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;
diff --git a/src/test/ui/resolve/issue-17518.stderr b/src/test/ui/resolve/issue-17518.stderr
index 2f94dbdc2c5..bdc4fb0d349 100644
--- a/src/test/ui/resolve/issue-17518.stderr
+++ b/src/test/ui/resolve/issue-17518.stderr
@@ -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;
diff --git a/src/test/ui/resolve/issue-21221-1.stderr b/src/test/ui/resolve/issue-21221-1.stderr
index ddaee451e90..6038c683e43 100644
--- a/src/test/ui/resolve/issue-21221-1.stderr
+++ b/src/test/ui/resolve/issue-21221-1.stderr
@@ -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;
diff --git a/src/test/ui/resolve/issue-21221-2.stderr b/src/test/ui/resolve/issue-21221-2.stderr
index a759116c6ac..0ae8052758d 100644
--- a/src/test/ui/resolve/issue-21221-2.stderr
+++ b/src/test/ui/resolve/issue-21221-2.stderr
@@ -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;
diff --git a/src/test/ui/resolve/issue-21221-3.stderr b/src/test/ui/resolve/issue-21221-3.stderr
index da849ecc71a..b26a8cdacb0 100644
--- a/src/test/ui/resolve/issue-21221-3.stderr
+++ b/src/test/ui/resolve/issue-21221-3.stderr
@@ -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;
diff --git a/src/test/ui/resolve/issue-21221-4.stderr b/src/test/ui/resolve/issue-21221-4.stderr
index 78059ed37be..0a22d8e1fe1 100644
--- a/src/test/ui/resolve/issue-21221-4.stderr
+++ b/src/test/ui/resolve/issue-21221-4.stderr
@@ -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;
diff --git a/src/test/ui/resolve/issue-3907.stderr b/src/test/ui/resolve/issue-3907.stderr
index 7a4d0ca698e..26ff7e70fd0 100644
--- a/src/test/ui/resolve/issue-3907.stderr
+++ b/src/test/ui/resolve/issue-3907.stderr
@@ -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;
diff --git a/src/test/ui/resolve/privacy-struct-ctor.stderr b/src/test/ui/resolve/privacy-struct-ctor.stderr
index f7e5c602644..cb459ae4745 100644
--- a/src/test/ui/resolve/privacy-struct-ctor.stderr
+++ b/src/test/ui/resolve/privacy-struct-ctor.stderr
@@ -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;
diff --git a/src/test/ui/resolve/use_suggestion_placement.stderr b/src/test/ui/resolve/use_suggestion_placement.stderr
index 08640b292ea..401825367dd 100644
--- a/src/test/ui/resolve/use_suggestion_placement.stderr
+++ b/src/test/ui/resolve/use_suggestion_placement.stderr
@@ -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;
diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr
index b57b58e3d2a..5e7a492ca2a 100644
--- a/src/test/ui/span/issue-35987.stderr
+++ b/src/test/ui/span/issue-35987.stderr
@@ -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;
diff --git a/src/test/ui/span/issue-39018.stderr b/src/test/ui/span/issue-39018.stderr
index 2782753f6c8..e865b5192a4 100644
--- a/src/test/ui/span/issue-39018.stderr
+++ b/src/test/ui/span/issue-39018.stderr
@@ -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!";
diff --git a/src/test/ui/span/missing-unit-argument.stderr b/src/test/ui/span/missing-unit-argument.stderr
index af558d0ab83..672b0718a02 100644
--- a/src/test/ui/span/missing-unit-argument.stderr
+++ b/src/test/ui/span/missing-unit-argument.stderr
@@ -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::<()>(());