diff options
| author | bors <bors@rust-lang.org> | 2021-10-08 11:44:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-08 11:44:45 +0000 |
| commit | e0aaffd8a45cd0e9f331ec7734713e9de11aa6c8 (patch) | |
| tree | 11385f103f96e0bcc09ccf85b4b77e7351fd87d1 /compiler/rustc_middle | |
| parent | 44995f7afb18775913618ae50601be31b9f9dead (diff) | |
| parent | 0950d5afe227c7097e59bf797a85267d3a659744 (diff) | |
| download | rust-e0aaffd8a45cd0e9f331ec7734713e9de11aa6c8.tar.gz rust-e0aaffd8a45cd0e9f331ec7734713e9de11aa6c8.zip | |
Auto merge of #89576 - tom7980:issue-89275-fix, r=estebank
Prevent error reporting from outputting a recursion error if it finds an ambiguous trait impl during suggestions Closes #89275 This fixes the compiler reporting a recursion error during another already in progress error by trying to make a conversion method suggestion and encounters ambiguous trait implementations that can convert a the original type into a type that can then be recursively converted into itself via another method in the trait. Updated OverflowError struct to be an enum so I could differentiate between passes - it's no longer a ZST but I don't think that should be a problem as they only generate when there's an error in compiling code anyway
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/traits/mod.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/traits/select.rs | 14 |
2 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 88a7722c9cc..b089ae22d6d 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -449,6 +449,7 @@ pub enum SelectionError<'tcx> { TraitNotObjectSafe(DefId), NotConstEvaluatable(NotConstEvaluatable), Overflow, + ErrorReporting, } /// When performing resolution, it is typically the case that there diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs index e236c4712c8..87495a2d5b3 100644 --- a/compiler/rustc_middle/src/traits/select.rs +++ b/compiler/rustc_middle/src/traits/select.rs @@ -261,12 +261,18 @@ impl EvaluationResult { } } -/// Indicates that trait evaluation caused overflow. +/// Indicates that trait evaluation caused overflow and in which pass. #[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable)] -pub struct OverflowError; +pub enum OverflowError { + Cannonical, + ErrorReporting, +} impl<'tcx> From<OverflowError> for SelectionError<'tcx> { - fn from(OverflowError: OverflowError) -> SelectionError<'tcx> { - SelectionError::Overflow + fn from(overflow_error: OverflowError) -> SelectionError<'tcx> { + match overflow_error { + OverflowError::Cannonical => SelectionError::Overflow, + OverflowError::ErrorReporting => SelectionError::ErrorReporting, + } } } |
