Turn IllegalSizedBound into struct variant

This commit is contained in:
Esteban Küber 2023-01-05 07:12:04 +00:00
parent 670a6f1ef5
commit 2631a5df61
2 changed files with 9 additions and 4 deletions

View File

@ -57,7 +57,12 @@ pub enum MethodError<'tcx> {
PrivateMatch(DefKind, DefId, Vec<DefId>),
// Found a `Self: Sized` bound where `Self` is a trait object.
IllegalSizedBound(Vec<DefId>, bool, Span, &'tcx hir::Expr<'tcx>),
IllegalSizedBound {
candidates: Vec<DefId>,
needs_mut: bool,
bound_span: Span,
self_expr: &'tcx hir::Expr<'tcx>,
},
// Found a match, but the return type is wrong
BadReturnType,
@ -112,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Err(NoMatch(..)) => false,
Err(Ambiguity(..)) => true,
Err(PrivateMatch(..)) => allow_private,
Err(IllegalSizedBound(..)) => true,
Err(IllegalSizedBound { .. }) => true,
Err(BadReturnType) => bug!("no return type expectations but got BadReturnType"),
}
}
@ -236,7 +241,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => Vec::new(),
};
return Err(IllegalSizedBound(candidates, needs_mut, span, self_expr));
return Err(IllegalSizedBound { candidates, needs_mut, bound_span: span, self_expr });
}
Ok(result.callee)

View File

@ -176,7 +176,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.emit();
}
MethodError::IllegalSizedBound(candidates, needs_mut, bound_span, self_expr) => {
MethodError::IllegalSizedBound { candidates, needs_mut, bound_span, self_expr } => {
let msg = if needs_mut {
with_forced_trimmed_paths!(format!(
"the `{item_name}` method cannot be invoked on `{rcvr_ty}`"