Skip to content

Commit 5ba5caa

Browse files
committed
[HACK] don't require T: ?Sized for type Foo<T> = Box<T>;
1 parent 0732b58 commit 5ba5caa

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/librustc_typeck/check/wfcheck.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,19 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def
156156
caller_bounds: fcx.tcx.mk_predicates(wf_predicates),
157157
reveal: fcx.param_env.reveal,
158158
};
159-
fcx.register_predicates(user_predicates.iter().map(|&predicate| {
159+
fcx.register_predicates(user_predicates.iter().filter_map(|&predicate| {
160+
// HACK(eddyb) Ignore `Sized` bounds on type parameters.
161+
if let ty::Predicate::Trait(trait_ref) = predicate {
162+
if Some(trait_ref.def_id()) == tcx.lang_items().sized_trait() {
163+
if let ty::Param(_) = trait_ref.skip_binder().self_ty().sty {
164+
return None;
165+
}
166+
}
167+
}
168+
160169
let code = ObligationCauseCode::MiscObligation;
161170
let cause = traits::ObligationCause::new(item.span, fcx.body_id, code);
162-
traits::Obligation::new(cause, wf_param_env, predicate)
171+
Some(traits::Obligation::new(cause, wf_param_env, predicate))
163172
}));
164173
}
165174

0 commit comments

Comments
 (0)