Skip to content

Commit dda33ca

Browse files
authored
Rollup merge of rust-lang#62760 - chansuke:dedupe-error-messages, r=zackmdavis
Deduplicate error messages in `librsctc_mir` Deduplicated the error messages in `librustc_mir`. rust-lang#62022
2 parents 60960a2 + a1df132 commit dda33ca

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/librustc_mir/const_eval.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ pub fn error_to_const_error<'mir, 'tcx>(
540540
ConstEvalErr { error: error.kind, stacktrace, span: ecx.tcx.span }
541541
}
542542

543+
pub fn note_on_undefined_behavior_error() -> &'static str {
544+
"The rules on what exactly is undefined behavior aren't clear, \
545+
so this check might be overzealous. Please open an issue on the rust compiler \
546+
repository if you believe it should not be considered undefined behavior"
547+
}
548+
543549
fn validate_and_turn_into_const<'tcx>(
544550
tcx: TyCtxt<'tcx>,
545551
constant: RawConst<'tcx>,
@@ -579,10 +585,7 @@ fn validate_and_turn_into_const<'tcx>(
579585
let err = error_to_const_error(&ecx, error);
580586
match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") {
581587
Ok(mut diag) => {
582-
diag.note("The rules on what exactly is undefined behavior aren't clear, \
583-
so this check might be overzealous. Please open an issue on the rust compiler \
584-
repository if you believe it should not be considered undefined behavior",
585-
);
588+
diag.note(note_on_undefined_behavior_error());
586589
diag.emit();
587590
ErrorHandled::Reported
588591
}

src/librustc_mir/interpret/intern.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,7 @@ pub fn intern_const_alloc_recursive(
296296
let err = crate::const_eval::error_to_const_error(&ecx, error);
297297
match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") {
298298
Ok(mut diag) => {
299-
diag.note("The rules on what exactly is undefined behavior aren't clear, \
300-
so this check might be overzealous. Please open an issue on the rust \
301-
compiler repository if you believe it should not be considered \
302-
undefined behavior",
303-
);
299+
diag.note(crate::const_eval::note_on_undefined_behavior_error());
304300
diag.emit();
305301
}
306302
Err(ErrorHandled::TooGeneric) |

0 commit comments

Comments
 (0)