Skip to content

Commit

Permalink
Rollup merge of rust-lang#62760 - chansuke:dedupe-error-messages, r=z…
Browse files Browse the repository at this point in the history
…ackmdavis

Deduplicate error messages in `librsctc_mir`

Deduplicated the error messages in `librustc_mir`. rust-lang#62022
  • Loading branch information
Centril authored Aug 13, 2019
2 parents 60960a2 + a1df132 commit 9365d44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 7 additions & 4 deletions src/librustc_mir/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_mir/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down

0 comments on commit 9365d44

Please sign in to comment.