Skip to content

Commit 5b86cb9

Browse files
authored
Rollup merge of rust-lang#118110 - compiler-errors:defining-anchor, r=aliemjay
Document `DefiningAnchor` a bit more r? types
2 parents bad6b12 + 0000b35 commit 5b86cb9

File tree

1 file changed

+17
-4
lines changed
  • compiler/rustc_middle/src/traits

1 file changed

+17
-4
lines changed

compiler/rustc_middle/src/traits/mod.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -956,13 +956,26 @@ pub enum CodegenObligationError {
956956
FulfillmentError,
957957
}
958958

959+
/// Defines the treatment of opaque types in a given inference context.
960+
///
961+
/// This affects both what opaques are allowed to be defined, but also whether
962+
/// opaques are replaced with inference vars eagerly in the old solver (e.g.
963+
/// in projection, and in the signature during function type-checking).
959964
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable, TypeFoldable, TypeVisitable)]
960965
pub enum DefiningAnchor {
961-
/// `DefId` of the item.
966+
/// Define opaques which are in-scope of the `LocalDefId`. Also, eagerly
967+
/// replace opaque types in `replace_opaque_types_with_inference_vars`.
962968
Bind(LocalDefId),
963-
/// When opaque types are not resolved, we `Bubble` up, meaning
964-
/// return the opaque/hidden type pair from query, for caller of query to handle it.
969+
/// In contexts where we don't currently know what opaques are allowed to be
970+
/// defined, such as (old solver) canonical queries, we will simply allow
971+
/// opaques to be defined, but "bubble" them up in the canonical response or
972+
/// otherwise treat them to be handled later.
973+
///
974+
/// We do not eagerly replace opaque types in `replace_opaque_types_with_inference_vars`,
975+
/// which may affect what predicates pass and fail in the old trait solver.
965976
Bubble,
966-
/// Used to catch type mismatch errors when handling opaque types.
977+
/// Do not allow any opaques to be defined. This is used to catch type mismatch
978+
/// errors when handling opaque types, and also should be used when we would
979+
/// otherwise reveal opaques (such as [`Reveal::All`] reveal mode).
967980
Error,
968981
}

0 commit comments

Comments
 (0)