Skip to content

Commit 8242636

Browse files
mchernyavskyyopox
authored andcommitted
ANN: Annotate Const Generics Defaults as experimental
1 parent 2dafeaf commit 8242636

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/main/kotlin/org/rust/ide/annotator/RsErrorAnnotator.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,11 @@ private fun checkDuplicates(
13401340
}
13411341

13421342
private fun checkConstGenerics(holder: RsAnnotationHolder, constParameter: RsConstParameter) {
1343+
val default = constParameter.blockExpr
1344+
if (default != null) {
1345+
CONST_GENERICS_DEFAULTS.check(holder, default, "const generics defaults")
1346+
}
1347+
13431348
val constGenericAvailability = CONST_GENERICS.availability(constParameter)
13441349
if (constGenericAvailability == AVAILABLE) return
13451350

src/test/kotlin/org/rust/ide/annotator/RsErrorAnnotatorTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,6 +2913,23 @@ class RsErrorAnnotatorTest : RsAnnotatorTestBase(RsErrorAnnotator::class) {
29132913
enum E<const C: i32> {}
29142914
""")
29152915

2916+
@MockRustcVersion("1.51.0")
2917+
fun `test const generics defaults E0658 1`() = checkErrors("""
2918+
fn f<const C: i32 = <error descr="const generics defaults is experimental [E0658]">{ 0 }</error>>() {}
2919+
struct S<const C: i32 = <error descr="const generics defaults is experimental [E0658]">{ 0 }</error>>(A);
2920+
trait T<const C: i32 = <error descr="const generics defaults is experimental [E0658]">{ 0 }</error>> {}
2921+
enum E<const C: i32 = <error descr="const generics defaults is experimental [E0658]">{ 0 }</error>> {}
2922+
""")
2923+
2924+
@MockRustcVersion("1.51.0-nightly")
2925+
fun `test const generics defaults E0658 2`() = checkErrors("""
2926+
#![feature(const_generics_defaults)]
2927+
fn f<const C: i32 = { 0 }>() {}
2928+
struct S<const C: i32 = { 0 }>(A);
2929+
trait T<const C: i32 = { 0 }> {}
2930+
enum E<const C: i32 = { 0 }> {}
2931+
""")
2932+
29162933
@MockRustcVersion("1.47.0")
29172934
fun `test min const generics E0658 1`() = checkErrors("""
29182935
fn f<<error descr="const generics is experimental [E0658]">const C: i32</error>>() {}

0 commit comments

Comments
 (0)