mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Rollup merge of #118201 - compiler-errors:obligation-causes, r=cjgillot
Miscellaneous `ObligationCauseCode` cleanups Remove some dead code/unused `ObligationCauseCode`s.
This commit is contained in:
commit
f4b7f35c4d
@ -2909,9 +2909,6 @@ impl<'tcx> ObligationCauseExt<'tcx> for ObligationCause<'tcx> {
|
|||||||
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => {
|
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => {
|
||||||
"const is compatible with trait"
|
"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",
|
MainFunctionType => "`main` function has the correct type",
|
||||||
StartFunctionType => "`#[start]` function has the correct type",
|
StartFunctionType => "`#[start]` function has the correct type",
|
||||||
LangFunctionType(_) => "lang item 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::Fn, .. } => "method_compat",
|
||||||
CompareImplItemObligation { kind: ty::AssocKind::Type, .. } => "type_compat",
|
CompareImplItemObligation { kind: ty::AssocKind::Type, .. } => "type_compat",
|
||||||
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => "const_compat",
|
CompareImplItemObligation { kind: ty::AssocKind::Const, .. } => "const_compat",
|
||||||
ExprAssignable => "expr_assignable",
|
|
||||||
IfExpression { .. } => "if_else_different",
|
|
||||||
IfExpressionWithNoElse => "no_else",
|
|
||||||
MainFunctionType => "fn_main_correct_type",
|
MainFunctionType => "fn_main_correct_type",
|
||||||
StartFunctionType => "fn_start_correct_type",
|
StartFunctionType => "fn_start_correct_type",
|
||||||
LangFunctionType(_) => "fn_lang_correct_type",
|
LangFunctionType(_) => "fn_lang_correct_type",
|
||||||
|
@ -250,9 +250,6 @@ pub enum ObligationCauseCode<'tcx> {
|
|||||||
/// A tuple is WF only if its middle elements are `Sized`.
|
/// A tuple is WF only if its middle elements are `Sized`.
|
||||||
TupleElem,
|
TupleElem,
|
||||||
|
|
||||||
/// This is the trait reference from the given projection.
|
|
||||||
ProjectionWf(ty::AliasTy<'tcx>),
|
|
||||||
|
|
||||||
/// Must satisfy all of the where-clause predicates of the
|
/// Must satisfy all of the where-clause predicates of the
|
||||||
/// given item.
|
/// given item.
|
||||||
ItemObligation(DefId),
|
ItemObligation(DefId),
|
||||||
@ -343,7 +340,8 @@ pub enum ObligationCauseCode<'tcx> {
|
|||||||
parent_code: InternedObligationCauseCode<'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 {
|
CompareImplItemObligation {
|
||||||
impl_item_def_id: LocalDefId,
|
impl_item_def_id: LocalDefId,
|
||||||
trait_item_def_id: DefId,
|
trait_item_def_id: DefId,
|
||||||
@ -372,9 +370,6 @@ pub enum ObligationCauseCode<'tcx> {
|
|||||||
origin_expr: bool,
|
origin_expr: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Constants in patterns must have `Structural` type.
|
|
||||||
ConstPatternStructural,
|
|
||||||
|
|
||||||
/// Computing common supertype in an if expression
|
/// Computing common supertype in an if expression
|
||||||
IfExpression(Box<IfExpressionCause<'tcx>>),
|
IfExpression(Box<IfExpressionCause<'tcx>>),
|
||||||
|
|
||||||
@ -407,9 +402,6 @@ pub enum ObligationCauseCode<'tcx> {
|
|||||||
/// `return` with an expression
|
/// `return` with an expression
|
||||||
ReturnValue(hir::HirId),
|
ReturnValue(hir::HirId),
|
||||||
|
|
||||||
/// Return type of this function
|
|
||||||
ReturnType,
|
|
||||||
|
|
||||||
/// Opaque return type of this function
|
/// Opaque return type of this function
|
||||||
OpaqueReturnType(Option<(Ty<'tcx>, Span)>),
|
OpaqueReturnType(Option<(Ty<'tcx>, Span)>),
|
||||||
|
|
||||||
@ -419,9 +411,6 @@ pub enum ObligationCauseCode<'tcx> {
|
|||||||
/// #[feature(trivial_bounds)] is not enabled
|
/// #[feature(trivial_bounds)] is not enabled
|
||||||
TrivialBound,
|
TrivialBound,
|
||||||
|
|
||||||
/// If `X` is the concrete type of an opaque type `impl Y`, then `X` must implement `Y`
|
|
||||||
OpaqueType,
|
|
||||||
|
|
||||||
AwaitableExpr(hir::HirId),
|
AwaitableExpr(hir::HirId),
|
||||||
|
|
||||||
ForLoopIterator,
|
ForLoopIterator,
|
||||||
|
@ -2592,11 +2592,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
| ObligationCauseCode::MethodReceiver
|
| ObligationCauseCode::MethodReceiver
|
||||||
| ObligationCauseCode::ReturnNoExpression
|
| ObligationCauseCode::ReturnNoExpression
|
||||||
| ObligationCauseCode::UnifyReceiver(..)
|
| ObligationCauseCode::UnifyReceiver(..)
|
||||||
| ObligationCauseCode::OpaqueType
|
|
||||||
| ObligationCauseCode::MiscObligation
|
| ObligationCauseCode::MiscObligation
|
||||||
| ObligationCauseCode::WellFormed(..)
|
| ObligationCauseCode::WellFormed(..)
|
||||||
| ObligationCauseCode::MatchImpl(..)
|
| ObligationCauseCode::MatchImpl(..)
|
||||||
| ObligationCauseCode::ReturnType
|
|
||||||
| ObligationCauseCode::ReturnValue(_)
|
| ObligationCauseCode::ReturnValue(_)
|
||||||
| ObligationCauseCode::BlockTailExpression(..)
|
| ObligationCauseCode::BlockTailExpression(..)
|
||||||
| ObligationCauseCode::AwaitableExpr(_)
|
| ObligationCauseCode::AwaitableExpr(_)
|
||||||
@ -2607,7 +2605,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
| ObligationCauseCode::BinOp { .. }
|
| ObligationCauseCode::BinOp { .. }
|
||||||
| ObligationCauseCode::AscribeUserTypeProvePredicate(..)
|
| ObligationCauseCode::AscribeUserTypeProvePredicate(..)
|
||||||
| ObligationCauseCode::DropImpl
|
| ObligationCauseCode::DropImpl
|
||||||
| ObligationCauseCode::ConstParam(_) => {}
|
| ObligationCauseCode::ConstParam(_)
|
||||||
|
| ObligationCauseCode::ReferenceOutlivesReferent(..)
|
||||||
|
| ObligationCauseCode::ObjectTypeBound(..) => {}
|
||||||
ObligationCauseCode::RustCall => {
|
ObligationCauseCode::RustCall => {
|
||||||
if let Some(pred) = predicate.to_opt_poly_trait_pred()
|
if let Some(pred) = predicate.to_opt_poly_trait_pred()
|
||||||
&& Some(pred.def_id()) == self.tcx.lang_items().sized_trait()
|
&& Some(pred.def_id()) == self.tcx.lang_items().sized_trait()
|
||||||
@ -2621,19 +2621,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
ObligationCauseCode::TupleElem => {
|
ObligationCauseCode::TupleElem => {
|
||||||
err.note("only the last element of a tuple may have a dynamically sized type");
|
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::ItemObligation(_)
|
||||||
| ObligationCauseCode::ExprItemObligation(..) => {
|
| ObligationCauseCode::ExprItemObligation(..) => {
|
||||||
// We hold the `DefId` of the item introducing the obligation, but displaying it
|
// 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"
|
"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 => {
|
ObligationCauseCode::SharedStatic => {
|
||||||
err.note("shared static variables must have a type that implements `Sync`");
|
err.note("shared static variables must have a type that implements `Sync`");
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1448,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
| ObligationCauseCode::ExprItemObligation(..)
|
| ObligationCauseCode::ExprItemObligation(..)
|
||||||
| ObligationCauseCode::ExprBindingObligation(..)
|
| ObligationCauseCode::ExprBindingObligation(..)
|
||||||
| ObligationCauseCode::Coercion { .. }
|
| ObligationCauseCode::Coercion { .. }
|
||||||
| ObligationCauseCode::OpaqueType
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// constrain inference variables a bit more to nested obligations from normalize so
|
// constrain inference variables a bit more to nested obligations from normalize so
|
||||||
|
Loading…
Reference in New Issue
Block a user