Skip to content

Commit 64b3b42

Browse files
committed
do the coerce_unsized check last
it’s probably the most expensive checks, so this way we avoid doing it if another check fails first
1 parent 0f420fe commit 64b3b42

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/librustc/traits/object_safety.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,6 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
289289

290290
let sig = self.fn_sig(method.def_id);
291291

292-
let receiver_ty = sig.skip_binder().inputs()[0];
293-
294-
if !self.receiver_is_coercible(method, receiver_ty) {
295-
return Some(MethodViolationCode::UncoercibleReceiver);
296-
}
297-
298-
299292
for input_ty in &sig.skip_binder().inputs()[1..] {
300293
if self.contains_illegal_self_type_reference(trait_def_id, input_ty) {
301294
return Some(MethodViolationCode::ReferencesSelf);
@@ -322,6 +315,12 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
322315
return Some(MethodViolationCode::WhereClauseReferencesSelf(span));
323316
}
324317

318+
let receiver_ty = sig.skip_binder().inputs()[0];
319+
320+
if !self.receiver_is_coercible(method, receiver_ty) {
321+
return Some(MethodViolationCode::UncoercibleReceiver);
322+
}
323+
325324
None
326325
}
327326

0 commit comments

Comments
 (0)