Skip to content

Commit f4b7f35

Browse files
Rollup merge of #118201 - compiler-errors:obligation-causes, r=cjgillot
Miscellaneous `ObligationCauseCode` cleanups Remove some dead code/unused `ObligationCauseCode`s.
2 parents 3b2f33e + ca56739 commit f4b7f35

File tree

4 files changed

+5
-39
lines changed

4 files changed

+5
-39
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -2909,9 +2909,6 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
29092909
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => {
29102910
"const is compatible with trait"
29112911
}
2912-
ExprAssignable => "expression is assignable",
2913-
IfExpression { .. } => "`if` and `else` have incompatible types",
2914-
IfExpressionWithNoElse => "`if` missing an `else` returns `()`",
29152912
MainFunctionType => "`main` function has the correct type",
29162913
StartFunctionType => "`#[start]` function has the correct type",
29172914
LangFunctionType(_) => "lang item function has the correct type",
@@ -2932,9 +2929,6 @@ impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> {
29322929
CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat",
29332930
CompareImplItemObligation { kind: ty::AssocKind::Type, .. } => "type_compat",
29342931
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => "const_compat",
2935-
ExprAssignable => "expr_assignable",
2936-
IfExpression { .. } => "if_else_different",
2937-
IfExpressionWithNoElse => "no_else",
29382932
MainFunctionType => "fn_main_correct_type",
29392933
StartFunctionType => "fn_start_correct_type",
29402934
LangFunctionType(_) => "fn_lang_correct_type",

compiler/rustc_middle/src/traits/mod.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ pub enum ObligationCauseCode<'tcx> {
250250
/// A tuple is WF only if its middle elements are `Sized`.
251251
TupleElem,
252252

253-
/// This is the trait reference from the given projection.
254-
ProjectionWf(ty::AliasTy<'tcx>),
255-
256253
/// Must satisfy all of the where-clause predicates of the
257254
/// given item.
258255
ItemObligation(DefId),
@@ -343,7 +340,8 @@ pub enum ObligationCauseCode<'tcx> {
343340
parent_code: InternedObligationCauseCode<'tcx>,
344341
},
345342

346-
/// Error derived when matching traits/impls; see ObligationCause for more details
343+
/// Error derived when checking an impl item is compatible with
344+
/// its corresponding trait item's definition
347345
CompareImplItemObligation {
348346
impl_item_def_id: LocalDefId,
349347
trait_item_def_id: DefId,
@@ -372,9 +370,6 @@ pub enum ObligationCauseCode<'tcx> {
372370
origin_expr: bool,
373371
},
374372

375-
/// Constants in patterns must have `Structural` type.
376-
ConstPatternStructural,
377-
378373
/// Computing common supertype in an if expression
379374
IfExpression(Box<IfExpressionCause<'tcx>>),
380375

@@ -407,9 +402,6 @@ pub enum ObligationCauseCode<'tcx> {
407402
/// `return` with an expression
408403
ReturnValue(hir::HirId),
409404

410-
/// Return type of this function
411-
ReturnType,
412-
413405
/// Opaque return type of this function
414406
OpaqueReturnType(Option<(Ty<'tcx>, Span)>),
415407

@@ -419,9 +411,6 @@ pub enum ObligationCauseCode<'tcx> {
419411
/// #[feature(trivial_bounds)] is not enabled
420412
TrivialBound,
421413

422-
/// If `X` is the concrete type of an opaque type `impl Y`, then `X` must implement `Y`
423-
OpaqueType,
424-
425414
AwaitableExpr(hir::HirId),
426415

427416
ForLoopIterator,

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -2592,11 +2592,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
25922592
| ObligationCauseCode::MethodReceiver
25932593
| ObligationCauseCode::ReturnNoExpression
25942594
| ObligationCauseCode::UnifyReceiver(..)
2595-
| ObligationCauseCode::OpaqueType
25962595
| ObligationCauseCode::MiscObligation
25972596
| ObligationCauseCode::WellFormed(..)
25982597
| ObligationCauseCode::MatchImpl(..)
2599-
| ObligationCauseCode::ReturnType
26002598
| ObligationCauseCode::ReturnValue(_)
26012599
| ObligationCauseCode::BlockTailExpression(..)
26022600
| ObligationCauseCode::AwaitableExpr(_)
@@ -2607,7 +2605,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26072605
| ObligationCauseCode::BinOp { .. }
26082606
| ObligationCauseCode::AscribeUserTypeProvePredicate(..)
26092607
| ObligationCauseCode::DropImpl
2610-
| ObligationCauseCode::ConstParam(_) => {}
2608+
| ObligationCauseCode::ConstParam(_)
2609+
| ObligationCauseCode::ReferenceOutlivesReferent(..)
2610+
| ObligationCauseCode::ObjectTypeBound(..) => {}
26112611
ObligationCauseCode::RustCall => {
26122612
if let Some(pred) = predicate.to_opt_poly_trait_pred()
26132613
&& Some(pred.def_id()) == self.tcx.lang_items().sized_trait()
@@ -2621,19 +2621,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26212621
ObligationCauseCode::TupleElem => {
26222622
err.note("only the last element of a tuple may have a dynamically sized type");
26232623
}
2624-
ObligationCauseCode::ProjectionWf(data) => {
2625-
err.note(format!("required so that the projection `{data}` is well-formed"));
2626-
}
2627-
ObligationCauseCode::ReferenceOutlivesReferent(ref_ty) => {
2628-
err.note(format!(
2629-
"required so that reference `{ref_ty}` does not outlive its referent"
2630-
));
2631-
}
2632-
ObligationCauseCode::ObjectTypeBound(object_ty, region) => {
2633-
err.note(format!(
2634-
"required so that the lifetime bound of `{region}` for `{object_ty}` is satisfied",
2635-
));
2636-
}
26372624
ObligationCauseCode::ItemObligation(_)
26382625
| ObligationCauseCode::ExprItemObligation(..) => {
26392626
// We hold the `DefId` of the item introducing the obligation, but displaying it
@@ -2985,9 +2972,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
29852972
"all values live across `{what}` must have a statically known size"
29862973
));
29872974
}
2988-
ObligationCauseCode::ConstPatternStructural => {
2989-
err.note("constants used for pattern-matching must derive `PartialEq` and `Eq`");
2990-
}
29912975
ObligationCauseCode::SharedStatic => {
29922976
err.note("shared static variables must have a type that implements `Sync`");
29932977
}

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
14481448
| ObligationCauseCode::ExprItemObligation(..)
14491449
| ObligationCauseCode::ExprBindingObligation(..)
14501450
| ObligationCauseCode::Coercion { .. }
1451-
| ObligationCauseCode::OpaqueType
14521451
);
14531452

14541453
// constrain inference variables a bit more to nested obligations from normalize so

0 commit comments

Comments
 (0)