about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/errors.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-11-16 04:57:15 +0000
committerbors <bors@rust-lang.org>2024-11-16 04:57:15 +0000
commit46e8d20301cb4abe91ab0a4bea43bb085e1d4e4a (patch)
tree12c60c9134bd5185c9c6f37dfcb1f9eda802cf0b /compiler/rustc_ast_lowering/src/errors.rs
parentd3a4b1f46ba0fff6239e3d75abd285287ccd17f9 (diff)
parentb462c68aee956602408373975d3ca898e464030b (diff)
downloadrust-46e8d20301cb4abe91ab0a4bea43bb085e1d4e4a.tar.gz
rust-46e8d20301cb4abe91ab0a4bea43bb085e1d4e4a.zip
Auto merge of #130443 - veluca93:legacy-const-generics-fix, r=BoxyUwU
Fix ICE when passing DefId-creating args to legacy_const_generics.

r? BoxyUwU

Fixes #123077
Fixes #129150
Diffstat (limited to 'compiler/rustc_ast_lowering/src/errors.rs')
-rw-r--r--compiler/rustc_ast_lowering/src/errors.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs
index 6b39c2d3955..e6a3f939f2d 100644
--- a/compiler/rustc_ast_lowering/src/errors.rs
+++ b/compiler/rustc_ast_lowering/src/errors.rs
@@ -451,3 +451,26 @@ pub(crate) struct YieldInClosure {
     #[suggestion(code = "#[coroutine] ", applicability = "maybe-incorrect", style = "verbose")]
     pub suggestion: Option<Span>,
 }
+
+#[derive(Diagnostic)]
+#[diag(ast_lowering_invalid_legacy_const_generic_arg)]
+pub(crate) struct InvalidLegacyConstGenericArg {
+    #[primary_span]
+    pub span: Span,
+    #[subdiagnostic]
+    pub suggestion: UseConstGenericArg,
+}
+
+#[derive(Subdiagnostic)]
+#[multipart_suggestion(
+    ast_lowering_invalid_legacy_const_generic_arg_suggestion,
+    applicability = "maybe-incorrect"
+)]
+pub(crate) struct UseConstGenericArg {
+    #[suggestion_part(code = "::<{const_args}>")]
+    pub end_of_fn: Span,
+    pub const_args: String,
+    pub other_args: String,
+    #[suggestion_part(code = "{other_args}")]
+    pub call_args: Span,
+}