Skip to content

Commit 01c5e01

Browse files
committed
RFC 2027: Non object safe traits objects are well formed
1 parent 5b52d19 commit 01c5e01

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/librustc/ty/wf.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,21 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
379379
// obligations that don't refer to Self and
380380
// checking those
381381

382-
let cause = self.cause(traits::MiscObligation);
383-
let component_traits =
384-
data.auto_traits().chain(data.principal_def_id());
385-
self.out.extend(
386-
component_traits.map(|did| traits::Obligation::new(
387-
cause.clone(),
388-
param_env,
389-
ty::Predicate::ObjectSafe(did)
390-
))
391-
);
382+
let defer_to_coercion =
383+
self.infcx.tcx.features().object_safe_for_dispatch;
384+
385+
if !defer_to_coercion {
386+
let cause = self.cause(traits::MiscObligation);
387+
let component_traits =
388+
data.auto_traits().chain(data.principal_def_id());
389+
self.out.extend(
390+
component_traits.map(|did| traits::Obligation::new(
391+
cause.clone(),
392+
param_env,
393+
ty::Predicate::ObjectSafe(did)
394+
))
395+
);
396+
}
392397
}
393398

394399
// Inference variables are the complicated case, since we don't

0 commit comments

Comments
 (0)