about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-14 04:18:35 +0200
committerGitHub <noreply@github.com>2019-08-14 04:18:35 +0200
commitdda33cad3841a49e066f8eac56f89db8a0ce4e5c (patch)
tree59ed79117ef45c12c8b3217551e14898b0021c4b
parent60960a260f7b5c695fd0717311d72ce62dd4eb43 (diff)
parenta1df1329ced590a287558510878feb17509e09b5 (diff)
downloadrust-dda33cad3841a49e066f8eac56f89db8a0ce4e5c.tar.gz
rust-dda33cad3841a49e066f8eac56f89db8a0ce4e5c.zip
Rollup merge of #62760 - chansuke:dedupe-error-messages, r=zackmdavis
Deduplicate error messages in `librsctc_mir`

Deduplicated the error messages in `librustc_mir`. #62022
-rw-r--r--src/librustc_mir/const_eval.rs11
-rw-r--r--src/librustc_mir/interpret/intern.rs6
2 files changed, 8 insertions, 9 deletions
diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs
index 36d80d0cb57..52225ea8f02 100644
--- a/src/librustc_mir/const_eval.rs
+++ b/src/librustc_mir/const_eval.rs
@@ -540,6 +540,12 @@ pub fn error_to_const_error<'mir, 'tcx>(
     ConstEvalErr { error: error.kind, stacktrace, span: ecx.tcx.span }
 }
 
+pub fn note_on_undefined_behavior_error() -> &'static str {
+    "The rules on what exactly is undefined behavior aren't clear, \
+    so this check might be overzealous. Please open an issue on the rust compiler \
+    repository if you believe it should not be considered undefined behavior"
+}
+
 fn validate_and_turn_into_const<'tcx>(
     tcx: TyCtxt<'tcx>,
     constant: RawConst<'tcx>,
@@ -579,10 +585,7 @@ fn validate_and_turn_into_const<'tcx>(
         let err = error_to_const_error(&ecx, error);
         match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") {
             Ok(mut diag) => {
-                diag.note("The rules on what exactly is undefined behavior aren't clear, \
-                    so this check might be overzealous. Please open an issue on the rust compiler \
-                    repository if you believe it should not be considered undefined behavior",
-                );
+                diag.note(note_on_undefined_behavior_error());
                 diag.emit();
                 ErrorHandled::Reported
             }
diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs
index 1074ab941a7..32ba70a81c9 100644
--- a/src/librustc_mir/interpret/intern.rs
+++ b/src/librustc_mir/interpret/intern.rs
@@ -296,11 +296,7 @@ pub fn intern_const_alloc_recursive(
                 let err = crate::const_eval::error_to_const_error(&ecx, error);
                 match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") {
                     Ok(mut diag) => {
-                        diag.note("The rules on what exactly is undefined behavior aren't clear, \
-                            so this check might be overzealous. Please open an issue on the rust \
-                            compiler repository if you believe it should not be considered \
-                            undefined behavior",
-                        );
+                        diag.note(crate::const_eval::note_on_undefined_behavior_error());
                         diag.emit();
                     }
                     Err(ErrorHandled::TooGeneric) |