diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index a2aa99e78e1e9..bf9edb5b83d6d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2909,9 +2909,6 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> { CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => { "const is compatible with trait" } - ExprAssignable => "expression is assignable", - IfExpression { .. } => "`if` and `else` have incompatible types", - IfExpressionWithNoElse => "`if` missing an `else` returns `()`", MainFunctionType => "`main` function has the correct type", StartFunctionType => "`#[start]` function has the correct type", LangFunctionType(_) => "lang item function has the correct type", @@ -2932,9 +2929,6 @@ impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> { CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat", CompareImplItemObligation { kind: ty::AssocKind::Type, .. } => "type_compat", CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => "const_compat", - ExprAssignable => "expr_assignable", - IfExpression { .. } => "if_else_different", - IfExpressionWithNoElse => "no_else", MainFunctionType => "fn_main_correct_type", StartFunctionType => "fn_start_correct_type", LangFunctionType(_) => "fn_lang_correct_type", diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 1ccd6fb56d9c1..853eea1a60958 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -250,9 +250,6 @@ pub enum ObligationCauseCode<'tcx> { /// A tuple is WF only if its middle elements are `Sized`. TupleElem, - /// This is the trait reference from the given projection. - ProjectionWf(ty::AliasTy<'tcx>), - /// Must satisfy all of the where-clause predicates of the /// given item. ItemObligation(DefId), @@ -343,7 +340,8 @@ pub enum ObligationCauseCode<'tcx> { parent_code: InternedObligationCauseCode<'tcx>, }, - /// Error derived when matching traits/impls; see ObligationCause for more details + /// Error derived when checking an impl item is compatible with + /// its corresponding trait item's definition CompareImplItemObligation { impl_item_def_id: LocalDefId, trait_item_def_id: DefId, @@ -372,9 +370,6 @@ pub enum ObligationCauseCode<'tcx> { origin_expr: bool, }, - /// Constants in patterns must have `Structural` type. - ConstPatternStructural, - /// Computing common supertype in an if expression IfExpression(Box>), @@ -407,9 +402,6 @@ pub enum ObligationCauseCode<'tcx> { /// `return` with an expression ReturnValue(hir::HirId), - /// Return type of this function - ReturnType, - /// Opaque return type of this function OpaqueReturnType(Option<(Ty<'tcx>, Span)>), @@ -419,9 +411,6 @@ pub enum ObligationCauseCode<'tcx> { /// #[feature(trivial_bounds)] is not enabled TrivialBound, - /// If `X` is the concrete type of an opaque type `impl Y`, then `X` must implement `Y` - OpaqueType, - AwaitableExpr(hir::HirId), ForLoopIterator, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index e260fcd5e7561..f73e6f144df9b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2592,11 +2592,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { | ObligationCauseCode::MethodReceiver | ObligationCauseCode::ReturnNoExpression | ObligationCauseCode::UnifyReceiver(..) - | ObligationCauseCode::OpaqueType | ObligationCauseCode::MiscObligation | ObligationCauseCode::WellFormed(..) | ObligationCauseCode::MatchImpl(..) - | ObligationCauseCode::ReturnType | ObligationCauseCode::ReturnValue(_) | ObligationCauseCode::BlockTailExpression(..) | ObligationCauseCode::AwaitableExpr(_) @@ -2607,7 +2605,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { | ObligationCauseCode::BinOp { .. } | ObligationCauseCode::AscribeUserTypeProvePredicate(..) | ObligationCauseCode::DropImpl - | ObligationCauseCode::ConstParam(_) => {} + | ObligationCauseCode::ConstParam(_) + | ObligationCauseCode::ReferenceOutlivesReferent(..) + | ObligationCauseCode::ObjectTypeBound(..) => {} ObligationCauseCode::RustCall => { if let Some(pred) = predicate.to_opt_poly_trait_pred() && Some(pred.def_id()) == self.tcx.lang_items().sized_trait() @@ -2621,19 +2621,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ObligationCauseCode::TupleElem => { err.note("only the last element of a tuple may have a dynamically sized type"); } - ObligationCauseCode::ProjectionWf(data) => { - err.note(format!("required so that the projection `{data}` is well-formed")); - } - ObligationCauseCode::ReferenceOutlivesReferent(ref_ty) => { - err.note(format!( - "required so that reference `{ref_ty}` does not outlive its referent" - )); - } - ObligationCauseCode::ObjectTypeBound(object_ty, region) => { - err.note(format!( - "required so that the lifetime bound of `{region}` for `{object_ty}` is satisfied", - )); - } ObligationCauseCode::ItemObligation(_) | ObligationCauseCode::ExprItemObligation(..) => { // We hold the `DefId` of the item introducing the obligation, but displaying it @@ -2985,9 +2972,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { "all values live across `{what}` must have a statically known size" )); } - ObligationCauseCode::ConstPatternStructural => { - err.note("constants used for pattern-matching must derive `PartialEq` and `Eq`"); - } ObligationCauseCode::SharedStatic => { err.note("shared static variables must have a type that implements `Sync`"); } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 5c28fec396005..5718ab3b96647 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -1448,7 +1448,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { | ObligationCauseCode::ExprItemObligation(..) | ObligationCauseCode::ExprBindingObligation(..) | ObligationCauseCode::Coercion { .. } - | ObligationCauseCode::OpaqueType ); // constrain inference variables a bit more to nested obligations from normalize so