summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-08-26 16:31:06 -0400
committerMichael Goulet <michael@errs.io>2024-09-20 22:18:57 -0400
commit174c3f95192068b3d11c00ae77d06808f45c3ef3 (patch)
tree654c2282ab512f0ef960f64ad9da23dce36996e0 /compiler/rustc_ast_lowering
parent7c8e281f735d02cddfd5c5ff350482a19a3d62c5 (diff)
downloadrust-174c3f95192068b3d11c00ae77d06808f45c3ef3.tar.gz
rust-174c3f95192068b3d11c00ae77d06808f45c3ef3.zip
Add missing diagnostics and flesh out tests
Diffstat (limited to 'compiler/rustc_ast_lowering')
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs5
-rw-r--r--compiler/rustc_ast_lowering/src/path.rs15
2 files changed, 13 insertions, 7 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 5266eb0e91f..d13e26d2510 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -494,9 +494,14 @@ enum AllowReturnTypeNotation {
 }
 
 enum GenericArgsMode {
+    /// Allow paren sugar, don't allow RTN.
     ParenSugar,
+    /// Allow RTN, don't allow paren sugar.
     ReturnTypeNotation,
+    // Error if parenthesized generics or RTN are encountered.
     Err,
+    /// Silence errors when lowering generics. Only used with `Res::Err`.
+    Silence,
 }
 
 impl<'a, 'hir> LoweringContext<'a, 'hir> {
diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs
index 6f0641dbc40..03c8097e4c3 100644
--- a/compiler/rustc_ast_lowering/src/path.rs
+++ b/compiler/rustc_ast_lowering/src/path.rs
@@ -111,7 +111,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                             }
                         }
                         // Avoid duplicated errors.
-                        Res::Err => GenericArgsMode::ParenSugar,
+                        Res::Err => GenericArgsMode::Silence,
                         // An error
                         _ => GenericArgsMode::Err,
                     };
@@ -288,11 +288,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                             false,
                         )
                     }
-                    GenericArgsMode::ParenSugar => self.lower_parenthesized_parameter_data(
-                        data,
-                        itctx,
-                        bound_modifier_allowed_features,
-                    ),
+                    GenericArgsMode::ParenSugar | GenericArgsMode::Silence => self
+                        .lower_parenthesized_parameter_data(
+                            data,
+                            itctx,
+                            bound_modifier_allowed_features,
+                        ),
                     GenericArgsMode::Err => {
                         // Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
                         let sub = if !data.inputs.is_empty() {
@@ -330,7 +331,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                 },
                 GenericArgs::ParenthesizedElided(span) => {
                     match generic_args_mode {
-                        GenericArgsMode::ReturnTypeNotation => {
+                        GenericArgsMode::ReturnTypeNotation | GenericArgsMode::Silence => {
                             // Ok
                         }
                         GenericArgsMode::ParenSugar | GenericArgsMode::Err => {