1
Fork 0

Rollup merge of #86340 - Smittyvb:ctfe-hard-error-message, r=RalfJung

Use better error message for hard errors in CTFE

I noticed this while working on #86255: currently the same message is used for hard errors and soft errors in CTFE. This changes the error messages to make hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it. This doesn't affect the behaviour of these error messages, only the content.

This changes the error logic to check if the error should be hard or soft where it is generated, instead of where it is emitted, to allow this distinction in error messages.
This commit is contained in:
Yuki Okushi 2021-06-17 21:56:43 +09:00 committed by GitHub
commit c062f3dddd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 80 additions and 107 deletions

View file

@ -518,4 +518,14 @@ impl InterpError<'_> {
_ => false,
}
}
/// Should this error be reported as a hard error, preventing compilation, or a soft error,
/// causing a deny-by-default lint?
pub fn is_hard_err(&self) -> bool {
use InterpError::*;
match *self {
MachineStop(ref err) => err.is_hard_err(),
_ => false,
}
}
}