Skip to content

Commit 2631a5d

Browse files
committed
Turn IllegalSizedBound into struct variant
1 parent 670a6f1 commit 2631a5d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

compiler/rustc_hir_typeck/src/method/mod.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ pub enum MethodError<'tcx> {
5757
PrivateMatch(DefKind, DefId, Vec<DefId>),
5858

5959
// Found a `Self: Sized` bound where `Self` is a trait object.
60-
IllegalSizedBound(Vec<DefId>, bool, Span, &'tcx hir::Expr<'tcx>),
60+
IllegalSizedBound {
61+
candidates: Vec<DefId>,
62+
needs_mut: bool,
63+
bound_span: Span,
64+
self_expr: &'tcx hir::Expr<'tcx>,
65+
},
6166

6267
// Found a match, but the return type is wrong
6368
BadReturnType,
@@ -112,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
112117
Err(NoMatch(..)) => false,
113118
Err(Ambiguity(..)) => true,
114119
Err(PrivateMatch(..)) => allow_private,
115-
Err(IllegalSizedBound(..)) => true,
120+
Err(IllegalSizedBound { .. }) => true,
116121
Err(BadReturnType) => bug!("no return type expectations but got BadReturnType"),
117122
}
118123
}
@@ -236,7 +241,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
236241
_ => Vec::new(),
237242
};
238243

239-
return Err(IllegalSizedBound(candidates, needs_mut, span, self_expr));
244+
return Err(IllegalSizedBound { candidates, needs_mut, bound_span: span, self_expr });
240245
}
241246

242247
Ok(result.callee)

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
176176
err.emit();
177177
}
178178

179-
MethodError::IllegalSizedBound(candidates, needs_mut, bound_span, self_expr) => {
179+
MethodError::IllegalSizedBound { candidates, needs_mut, bound_span, self_expr } => {
180180
let msg = if needs_mut {
181181
with_forced_trimmed_paths!(format!(
182182
"the `{item_name}` method cannot be invoked on `{rcvr_ty}`"

0 commit comments

Comments
 (0)