about summary refs log tree commit diff
path: root/src/librustc_errors/emitter.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-03-31 14:11:11 +0000
committerbors <bors@rust-lang.org>2019-03-31 14:11:11 +0000
commita89c03a30a1e8f1cd190114b765d01752d3ce8d8 (patch)
tree8454df10ef33efa7dbef5bae1de8b23586d57e59 /src/librustc_errors/emitter.rs
parentcee58fdc12bea8cc373366bd84fc786277729b1c (diff)
parentfb8396da843fd665fc73a0bf448d5fb83b1b978b (diff)
Auto merge of #59584 - Centril:rollup, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #58828 (libstd: deny(elided_lifetimes_in_paths))
 - #59234 (Mention `no merge policy` in the CONTRIBUTING guide)
 - #59572 (Include bounds in generic re-ordering diagnostic)
 - #59574 (Distinguish message for external macros depending on error level)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc_errors/emitter.rs')
-rw-r--r--src/librustc_errors/emitter.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 98db0097c74..ee2a1b69cbd 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -6,6 +6,7 @@ use crate::{
     Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic,
     SuggestionStyle, SourceMapperDyn, DiagnosticId,
 };
+use crate::Level::Error;
 use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
 use crate::styled_buffer::StyledBuffer;
 
@@ -72,6 +73,7 @@ impl Emitter for EmitterWriter {
 
         self.fix_multispans_in_std_macros(&mut primary_span,
                                           &mut children,
+                                          &db.level,
                                           db.handler.flags.external_macro_backtrace);
 
         self.emit_messages_default(&db.level,
@@ -888,18 +890,27 @@ impl EmitterWriter {
     fn fix_multispans_in_std_macros(&mut self,
                                     span: &mut MultiSpan,
                                     children: &mut Vec<SubDiagnostic>,
+                                    level: &Level,
                                     backtrace: bool) {
         let mut spans_updated = self.fix_multispan_in_std_macros(span, backtrace);
         for child in children.iter_mut() {
             spans_updated |= self.fix_multispan_in_std_macros(&mut child.span, backtrace);
         }
+        let msg = if level == &Error {
+            "this error originates in a macro outside of the current crate \
+             (in Nightly builds, run with -Z external-macro-backtrace \
+              for more info)".to_string()
+        } else {
+            "this warning originates in a macro outside of the current crate \
+             (in Nightly builds, run with -Z external-macro-backtrace \
+              for more info)".to_string()
+        };
+
         if spans_updated {
             children.push(SubDiagnostic {
                 level: Level::Note,
                 message: vec![
-                    ("this error originates in a macro outside of the current crate \
-                      (in Nightly builds, run with -Z external-macro-backtrace \
-                       for more info)".to_string(),
+                    (msg,
                      Style::NoStyle),
                 ],
                 span: MultiSpan::new(),