Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs')
| -rw-r--r-- | crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs b/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs index b79894dd15..b617c09498 100644 --- a/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs +++ b/crates/ide-diagnostics/src/handlers/generic_args_prohibited.rs @@ -36,6 +36,7 @@ fn describe_reason(reason: GenericArgsProhibitedReason) -> String { } GenericArgsProhibitedReason::Const => "constants", GenericArgsProhibitedReason::Static => "statics", + GenericArgsProhibitedReason::LocalVariable => "local variables", }; format!("generic arguments are not allowed on {kind}") } @@ -320,7 +321,7 @@ trait E<A: foo::<()>::Trait> // ^^^^^ 💡 error: generic arguments are not allowed on builtin types } -impl<A: foo::<()>::Trait> E for () +impl<A: foo::<()>::Trait> E<()> for () // ^^^^^^ 💡 error: generic arguments are not allowed on modules where bool<i32>: foo::Trait // ^^^^^ 💡 error: generic arguments are not allowed on builtin types @@ -518,14 +519,14 @@ fn baz() { } #[test] - fn const_and_static() { + fn const_param_and_static() { check_diagnostics( r#" const CONST: i32 = 0; static STATIC: i32 = 0; -fn baz() { - let _ = CONST::<()>; - // ^^^^^^ 💡 error: generic arguments are not allowed on constants +fn baz<const CONST_PARAM: usize>() { + let _ = CONST_PARAM::<()>; + // ^^^^^^ 💡 error: generic arguments are not allowed on constants let _ = STATIC::<()>; // ^^^^^^ 💡 error: generic arguments are not allowed on statics } @@ -534,6 +535,19 @@ fn baz() { } #[test] + fn local_variable() { + check_diagnostics( + r#" +fn baz() { + let x = 1; + let _ = x::<()>; + // ^^^^^^ 💡 error: generic arguments are not allowed on local variables +} + "#, + ); + } + + #[test] fn enum_variant() { check_diagnostics( r#" |