1
Fork 0

Apply PR feedback.

This commit is contained in:
Ben Reeves 2022-11-10 12:56:09 -06:00
parent c0ae62ee95
commit fe53cacff9
2 changed files with 10 additions and 11 deletions

View file

@ -426,15 +426,13 @@ fn trait_predicates_eq<'tcx>(
predicate2: ty::Predicate<'tcx>, predicate2: ty::Predicate<'tcx>,
span: Span, span: Span,
) -> bool { ) -> bool {
let pred1_kind = predicate1.kind().no_bound_vars(); let pred1_kind = predicate1.kind().skip_binder();
let pred2_kind = predicate2.kind().no_bound_vars(); let pred2_kind = predicate2.kind().skip_binder();
let (trait_pred1, trait_pred2) = match (pred1_kind, pred2_kind) { let (trait_pred1, trait_pred2) = match (pred1_kind, pred2_kind) {
(Some(ty::PredicateKind::Trait(pred1)), Some(ty::PredicateKind::Trait(pred2))) => { (ty::PredicateKind::Trait(pred1), ty::PredicateKind::Trait(pred2)) => (pred1, pred2),
(pred1, pred2)
}
// Just use plain syntactic equivalence if either of the predicates aren't // Just use plain syntactic equivalence if either of the predicates aren't
// trait predicates or have bound vars. // trait predicates or have bound vars.
_ => return pred1_kind == pred2_kind, _ => return predicate1 == predicate2,
}; };
let predicates_equal_modulo_constness = { let predicates_equal_modulo_constness = {
@ -451,10 +449,11 @@ fn trait_predicates_eq<'tcx>(
// Check that the predicate on the specializing impl is at least as const as // Check that the predicate on the specializing impl is at least as const as
// the one on the base. // the one on the base.
if trait_pred2.constness == ty::BoundConstness::ConstIfConst match (trait_pred2.constness, trait_pred1.constness) {
&& trait_pred1.constness == ty::BoundConstness::NotConst (ty::BoundConstness::ConstIfConst, ty::BoundConstness::NotConst) => {
{ tcx.sess.struct_span_err(span, "missing `~const` qualifier for specialization").emit();
tcx.sess.struct_span_err(span, "missing `~const` qualifier").emit(); }
_ => {}
} }
true true

View file

@ -1,4 +1,4 @@
error: missing `~const` qualifier error: missing `~const` qualifier for specialization
--> $DIR/const-default-bound-non-const-specialized-bound.rs:28:8 --> $DIR/const-default-bound-non-const-specialized-bound.rs:28:8
| |
LL | T: Foo, LL | T: Foo,