diff options
| author | bors <bors@rust-lang.org> | 2024-03-02 00:06:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-02 00:06:46 +0000 |
| commit | eaee1e9453bfb4e1fb3753aa37450bb47cd7629d (patch) | |
| tree | fa527cb250e0d9057b6f58b7fdae689dc842272b /compiler/rustc_middle/src/traits/solve.rs | |
| parent | e612d079a1102803fd2cae5dcd7f7f277e493b8e (diff) | |
| parent | 63e916e26c7d7d5b0df63639c7ff7b5b586a68e2 (diff) | |
| download | rust-eaee1e9453bfb4e1fb3753aa37450bb47cd7629d.tar.gz rust-eaee1e9453bfb4e1fb3753aa37450bb47cd7629d.zip | |
Auto merge of #121870 - matthiaskrgr:rollup-mfpa3jx, r=matthiaskrgr
Rollup of 11 pull requests
Successful merges:
- #111505 (Made `INVALID_DOC_ATTRIBUTES` lint deny by default)
- #120305 (Delete line if suggestion would replace it with an empty line)
- #121153 (Suggest removing superfluous semicolon when statements used as expression)
- #121497 (`-Znext-solver=coherence`: suggest increasing recursion limit)
- #121634 (Clarify behavior of slice prefix/suffix operations in case of equality)
- #121706 (match lowering: Remove hacky branch in sort_candidate)
- #121730 (Add profiling support to AIX)
- #121750 (match lowering: Separate the `bool` case from other integers in `TestKind`)
- #121803 (Never say "`Trait` is implemented for `{type error}`")
- #121811 (Move sanitizer ui tests to sanitizer directory)
- #121824 (Implement missing ABI structures in StableMIR)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_middle/src/traits/solve.rs')
| -rw-r--r-- | compiler/rustc_middle/src/traits/solve.rs | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/compiler/rustc_middle/src/traits/solve.rs b/compiler/rustc_middle/src/traits/solve.rs index 048df367bd6..0dc65126011 100644 --- a/compiler/rustc_middle/src/traits/solve.rs +++ b/compiler/rustc_middle/src/traits/solve.rs @@ -60,7 +60,6 @@ pub enum Certainty { impl Certainty { pub const AMBIGUOUS: Certainty = Certainty::Maybe(MaybeCause::Ambiguity); - pub const OVERFLOW: Certainty = Certainty::Maybe(MaybeCause::Overflow); /// Use this function to merge the certainty of multiple nested subgoals. /// @@ -79,16 +78,13 @@ impl Certainty { (Certainty::Yes, Certainty::Yes) => Certainty::Yes, (Certainty::Yes, Certainty::Maybe(_)) => other, (Certainty::Maybe(_), Certainty::Yes) => self, - (Certainty::Maybe(MaybeCause::Ambiguity), Certainty::Maybe(MaybeCause::Ambiguity)) => { - Certainty::Maybe(MaybeCause::Ambiguity) - } - (Certainty::Maybe(MaybeCause::Ambiguity), Certainty::Maybe(MaybeCause::Overflow)) - | (Certainty::Maybe(MaybeCause::Overflow), Certainty::Maybe(MaybeCause::Ambiguity)) - | (Certainty::Maybe(MaybeCause::Overflow), Certainty::Maybe(MaybeCause::Overflow)) => { - Certainty::Maybe(MaybeCause::Overflow) - } + (Certainty::Maybe(a), Certainty::Maybe(b)) => Certainty::Maybe(a.unify_with(b)), } } + + pub const fn overflow(suggest_increasing_limit: bool) -> Certainty { + Certainty::Maybe(MaybeCause::Overflow { suggest_increasing_limit }) + } } /// Why we failed to evaluate a goal. @@ -99,7 +95,21 @@ pub enum MaybeCause { /// or we hit a case where we just don't bother, e.g. `?x: Trait` goals. Ambiguity, /// We gave up due to an overflow, most often by hitting the recursion limit. - Overflow, + Overflow { suggest_increasing_limit: bool }, +} + +impl MaybeCause { + fn unify_with(self, other: MaybeCause) -> MaybeCause { + match (self, other) { + (MaybeCause::Ambiguity, MaybeCause::Ambiguity) => MaybeCause::Ambiguity, + (MaybeCause::Ambiguity, MaybeCause::Overflow { .. }) => other, + (MaybeCause::Overflow { .. }, MaybeCause::Ambiguity) => self, + ( + MaybeCause::Overflow { suggest_increasing_limit: a }, + MaybeCause::Overflow { suggest_increasing_limit: b }, + ) => MaybeCause::Overflow { suggest_increasing_limit: a || b }, + } + } } #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable, TypeFoldable, TypeVisitable)] |
