Don't stop const-checking after erroneous trait bound
This commit is contained in:
parent
879d3794d3
commit
e02ea835a7
@ -598,9 +598,16 @@ pub mod ty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TraitBound;
|
pub struct TraitBound(pub mir::LocalKind);
|
||||||
impl NonConstOp for TraitBound {
|
impl NonConstOp for TraitBound {
|
||||||
const STOPS_CONST_CHECKING: bool = true;
|
fn importance(&self) -> DiagnosticImportance {
|
||||||
|
match self.0 {
|
||||||
|
mir::LocalKind::Var | mir::LocalKind::Temp => DiagnosticImportance::Secondary,
|
||||||
|
mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => {
|
||||||
|
DiagnosticImportance::Primary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
||||||
mcf_status_in_item(ccx)
|
mcf_status_in_item(ccx)
|
||||||
|
@ -364,11 +364,11 @@ impl Validator<'mir, 'tcx> {
|
|||||||
match pred.skip_binder() {
|
match pred.skip_binder() {
|
||||||
ty::ExistentialPredicate::AutoTrait(_)
|
ty::ExistentialPredicate::AutoTrait(_)
|
||||||
| ty::ExistentialPredicate::Projection(_) => {
|
| ty::ExistentialPredicate::Projection(_) => {
|
||||||
self.check_op(ops::ty::TraitBound)
|
self.check_op(ops::ty::TraitBound(kind))
|
||||||
}
|
}
|
||||||
ty::ExistentialPredicate::Trait(trait_ref) => {
|
ty::ExistentialPredicate::Trait(trait_ref) => {
|
||||||
if Some(trait_ref.def_id) != self.tcx.lang_items().sized_trait() {
|
if Some(trait_ref.def_id) != self.tcx.lang_items().sized_trait() {
|
||||||
self.check_op(ops::ty::TraitBound)
|
self.check_op(ops::ty::TraitBound(kind))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,15 +413,19 @@ impl Validator<'mir, 'tcx> {
|
|||||||
let def = generics.type_param(p, tcx);
|
let def = generics.type_param(p, tcx);
|
||||||
let span = tcx.def_span(def.def_id);
|
let span = tcx.def_span(def.def_id);
|
||||||
|
|
||||||
|
// These are part of the function signature, so treat them like
|
||||||
|
// arguments when determining importance.
|
||||||
|
let kind = LocalKind::Arg;
|
||||||
|
|
||||||
if constness == hir::Constness::Const {
|
if constness == hir::Constness::Const {
|
||||||
self.check_op_spanned(ops::ty::TraitBound, span);
|
self.check_op_spanned(ops::ty::TraitBound(kind), span);
|
||||||
} else if !tcx.features().const_fn
|
} else if !tcx.features().const_fn
|
||||||
|| self.ccx.is_const_stable_const_fn()
|
|| self.ccx.is_const_stable_const_fn()
|
||||||
{
|
{
|
||||||
// HACK: We shouldn't need the conditional above, but trait
|
// HACK: We shouldn't need the conditional above, but trait
|
||||||
// bounds on containing impl blocks are wrongly being marked as
|
// bounds on containing impl blocks are wrongly being marked as
|
||||||
// "not-const".
|
// "not-const".
|
||||||
self.check_op_spanned(ops::ty::TraitBound, span);
|
self.check_op_spanned(ops::ty::TraitBound(kind), span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// other kinds of bounds are either tautologies
|
// other kinds of bounds are either tautologies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user