diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-11-21 23:46:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-21 23:46:19 +0100 |
| commit | a11be28e13047956e1550d9d5cc89ec0fdde0699 (patch) | |
| tree | 4f586df1575fd06103eb215c7836274f8dd3da07 | |
| parent | bdb929e7889a1ecaabe3240c3027388c2df5479a (diff) | |
| parent | 0000b35288f7f7d929dd9afe7a5f4b47305f8bff (diff) | |
Rollup merge of #118110 - compiler-errors:defining-anchor, r=aliemjay
Document `DefiningAnchor` a bit more r? types
| -rw-r--r-- | compiler/rustc_middle/src/traits/mod.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 6cd75e08727..8af4f57d5e8 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -956,13 +956,26 @@ pub enum CodegenObligationError { FulfillmentError, } +/// Defines the treatment of opaque types in a given inference context. +/// +/// This affects both what opaques are allowed to be defined, but also whether +/// opaques are replaced with inference vars eagerly in the old solver (e.g. +/// in projection, and in the signature during function type-checking). #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable, TypeFoldable, TypeVisitable)] pub enum DefiningAnchor { - /// `DefId` of the item. + /// Define opaques which are in-scope of the `LocalDefId`. Also, eagerly + /// replace opaque types in `replace_opaque_types_with_inference_vars`. Bind(LocalDefId), - /// When opaque types are not resolved, we `Bubble` up, meaning - /// return the opaque/hidden type pair from query, for caller of query to handle it. + /// In contexts where we don't currently know what opaques are allowed to be + /// defined, such as (old solver) canonical queries, we will simply allow + /// opaques to be defined, but "bubble" them up in the canonical response or + /// otherwise treat them to be handled later. + /// + /// We do not eagerly replace opaque types in `replace_opaque_types_with_inference_vars`, + /// which may affect what predicates pass and fail in the old trait solver. Bubble, - /// Used to catch type mismatch errors when handling opaque types. + /// Do not allow any opaques to be defined. This is used to catch type mismatch + /// errors when handling opaque types, and also should be used when we would + /// otherwise reveal opaques (such as [`Reveal::All`] reveal mode). Error, } |
