]> git.lizzy.rs Git - rust.git/commitdiff
Distinguish depending on error level
authorYuki OKUSHI <huyuumi.dev@gmail.com>
Sat, 30 Mar 2019 21:30:45 +0000 (06:30 +0900)
committerYuki OKUSHI <huyuumi.dev@gmail.com>
Sat, 30 Mar 2019 22:51:31 +0000 (07:51 +0900)
Remove unnecessary comment

src/librustc_errors/emitter.rs
src/test/ui/imports/import-crate-var.stderr
src/test/ui/macros/must-use-in-macro-55516.stderr

index e9f269b6e2410b311fbee1c6ad15fd632baf17fe..1c5d0c5bab129c255b3de993ffe05aff2c9bf1f4 100644 (file)
@@ -6,6 +6,7 @@
     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 @@ fn emit(&mut self, db: &DiagnosticBuilder<'_>) {
 
         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,
@@ -856,18 +858,27 @@ fn fix_multispan_in_std_macros(&mut self,
     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(),
index 928256543bcb9f8907aa0bc9965f71c02c320bf9..4c358a81cc1a451f10775457142b398b51161e5d 100644 (file)
@@ -5,5 +5,5 @@ LL |     m!();
    |     ^^^^^
    |
    = note: `use $crate;` was erroneously allowed and will become a hard error in a future release
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
 
index 623b5745a357d36778ea8c781e18bf1729b9f2d1..302c8aa7e6a5558e23738afe58a93b8d2ab77936 100644 (file)
@@ -6,5 +6,5 @@ LL |     write!(&mut example, "{}", 42);
    |
    = note: `-W unused-must-use` implied by `-W unused`
    = note: this `Result` may be an `Err` variant, which should be handled
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)