diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2023-12-19 04:28:43 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2023-12-19 04:28:43 +0000 |
| commit | 324ca878cec59b623fb6e4dbcfad1e94937d477a (patch) | |
| tree | 76ad64c689b66b560eec57536d5aa9e2a96c2c18 | |
| parent | e4f237d39eed56803540eb57bc6297ad07488a58 (diff) | |
| download | rust-324ca878cec59b623fb6e4dbcfad1e94937d477a.tar.gz rust-324ca878cec59b623fb6e4dbcfad1e94937d477a.zip | |
fix ICE when `~const` used on non-const trait
| -rw-r--r-- | compiler/rustc_hir_analysis/src/astconv/mod.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 6f8e80172dd..1603e203205 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -378,7 +378,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { assert!(self_ty.is_none()); } - let arg_count = check_generic_arg_count( + let mut arg_count = check_generic_arg_count( tcx, span, def_id, @@ -560,6 +560,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { inferred_params: vec![], infer_args, }; + if let ty::BoundConstness::ConstIfConst = constness + && generics.has_self + && !tcx.has_attr(def_id, sym::const_trait) + { + let e = tcx.sess.emit_err(crate::errors::ConstBoundForNonConstTrait { span }); + arg_count.correct = + Err(GenericArgCountMismatch { reported: Some(e), invalid_args: vec![] }); + } let args = create_args_for_parent_generic_args( tcx, def_id, @@ -570,13 +578,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { &mut args_ctx, ); - if let ty::BoundConstness::ConstIfConst = constness - && generics.has_self - && !tcx.has_attr(def_id, sym::const_trait) - { - tcx.sess.emit_err(crate::errors::ConstBoundForNonConstTrait { span }); - } - (args, arg_count) } |
