about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-05-08 22:34:47 -0400
committerGitHub <noreply@github.com>2017-05-08 22:34:47 -0400
commit1940c31c92d2a0e4def356a17d6445388779d781 (patch)
tree071b6d4ebd26475f0486c72f992913bfe6d5a984 /src/librustc_errors
parentc104db48018ad01588153a59de6bdf9f177bf8f9 (diff)
parent8c9ad8d72c5a3ad73af33e3ad9a409327645ac28 (diff)
downloadrust-1940c31c92d2a0e4def356a17d6445388779d781.tar.gz
rust-1940c31c92d2a0e4def356a17d6445388779d781.zip
Rollup merge of #41520 - estebank:trace-macro, r=nikomatsakis
Use diagnostics for trace_macro instead of println

When using `trace_macro`, use `span_label`s instead of `println`:

```rust
note: trace_macro
  --> $DIR/trace-macro.rs:14:5
   |
14 |     println!("Hello, World!");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expands to `println! { "Hello, World!" }`
   = note: expands to `print! { concat ! ( "Hello, World!" , "\n" ) }`
```

Fix #22597.
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 02d8297dd46..db8c9ac306b 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -388,6 +388,14 @@ impl Handler {
     pub fn span_note_without_error<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
         self.emit(&sp.into(), msg, Note);
     }
+    pub fn span_note_diag<'a>(&'a self,
+                              sp: Span,
+                              msg: &str)
+                              -> DiagnosticBuilder<'a> {
+        let mut db = DiagnosticBuilder::new(self, Note, msg);
+        db.set_span(sp);
+        db
+    }
     pub fn span_unimpl<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
         self.span_bug(sp, &format!("unimplemented {}", msg));
     }