Skip to content

Commit 324ca87

Browse files
committed
fix ICE when ~const used on non-const trait
1 parent e4f237d commit 324ca87

File tree

1 file changed

+9
-8
lines changed
  • compiler/rustc_hir_analysis/src/astconv

1 file changed

+9
-8
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
378378
assert!(self_ty.is_none());
379379
}
380380

381-
let arg_count = check_generic_arg_count(
381+
let mut arg_count = check_generic_arg_count(
382382
tcx,
383383
span,
384384
def_id,
@@ -560,6 +560,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
560560
inferred_params: vec![],
561561
infer_args,
562562
};
563+
if let ty::BoundConstness::ConstIfConst = constness
564+
&& generics.has_self
565+
&& !tcx.has_attr(def_id, sym::const_trait)
566+
{
567+
let e = tcx.sess.emit_err(crate::errors::ConstBoundForNonConstTrait { span });
568+
arg_count.correct =
569+
Err(GenericArgCountMismatch { reported: Some(e), invalid_args: vec![] });
570+
}
563571
let args = create_args_for_parent_generic_args(
564572
tcx,
565573
def_id,
@@ -570,13 +578,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
570578
&mut args_ctx,
571579
);
572580

573-
if let ty::BoundConstness::ConstIfConst = constness
574-
&& generics.has_self
575-
&& !tcx.has_attr(def_id, sym::const_trait)
576-
{
577-
tcx.sess.emit_err(crate::errors::ConstBoundForNonConstTrait { span });
578-
}
579-
580581
(args, arg_count)
581582
}
582583

0 commit comments

Comments
 (0)