1
Fork 0

Fix ice when error reporting recursion errors

Fixes: #90319, #92148, #93955
This commit is contained in:
lightning1141 2022-02-26 11:55:07 +08:00
parent 37b55c8a0c
commit 85e67b9a59
No known key found for this signature in database
GPG key ID: 1094D31F57130E68
9 changed files with 66 additions and 14 deletions

View file

@ -5,6 +5,7 @@
use self::EvaluationResult::*;
use super::{SelectionError, SelectionResult};
use rustc_errors::ErrorGuaranteed;
use crate::ty;
@ -264,14 +265,26 @@ impl EvaluationResult {
/// Indicates that trait evaluation caused overflow and in which pass.
#[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable)]
pub enum OverflowError {
Error(ErrorGuaranteed),
Canonical,
ErrorReporting,
}
impl From<ErrorGuaranteed> for OverflowError {
fn from(e: ErrorGuaranteed) -> OverflowError {
OverflowError::Error(e)
}
}
TrivialTypeFoldableAndLiftImpls! {
OverflowError,
}
impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
fn from(overflow_error: OverflowError) -> SelectionError<'tcx> {
match overflow_error {
OverflowError::Canonical => SelectionError::Overflow,
OverflowError::Error(e) => SelectionError::Overflow(OverflowError::Error(e)),
OverflowError::Canonical => SelectionError::Overflow(OverflowError::Canonical),
OverflowError::ErrorReporting => SelectionError::ErrorReporting,
}
}