Skip to content

Commit 6b5ba53

Browse files
authored
Rollup merge of #83636 - JohnTitor:const-generics-defualts-regg-test, r=lcnr
Add a regression test for issue-82792 Closes #82792 r? ``@lcnr``
2 parents 25ade69 + c9562fd commit 6b5ba53

7 files changed

+66
-52
lines changed

src/test/ui/const-generics/defaults/complex-unord-param.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
#![allow(dead_code)]
77

88
struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> {
9-
//[min]~^ ERROR type parameters must be declared prior to const parameters
10-
args: &'a [&'a [T; M]; N],
11-
specifier: A,
9+
//[min]~^ ERROR type parameters must be declared prior to const parameters
10+
args: &'a [&'a [T; M]; N],
11+
specifier: A,
1212
}
1313

1414
fn main() {
15-
let array = [1, 2, 3];
16-
let nest = [&array];
17-
let _ = NestedArrays {
18-
args: &nest,
19-
specifier: true,
20-
};
15+
let array = [1, 2, 3];
16+
let nest = [&array];
17+
let _ = NestedArrays {
18+
args: &nest,
19+
specifier: true,
20+
};
2121
}

src/test/ui/const-generics/defaults/default-annotation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub struct ConstDefaultUnstable<const N: usize = 3>;
1313

1414
#[stable(feature = "const_default_unstable", since="none")]
1515
pub struct ConstDefaultStable<const N: usize = {
16-
#[stable(feature = "const_default_unstable_val", since="none")]
17-
3
16+
#[stable(feature = "const_default_unstable_val", since="none")]
17+
3
1818
}>;
1919

2020
fn main() {}

src/test/ui/const-generics/defaults/mismatch.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ pub struct Example3<const N: usize=13, T=u32>(T);
88
pub struct Example4<const N: usize=13, const M: usize=4>;
99

1010
fn main() {
11-
let e: Example::<13> = ();
12-
//~^ Error: mismatched types
13-
let e: Example2::<u32, 13> = ();
14-
//~^ Error: mismatched types
15-
let e: Example3::<13, u32> = ();
16-
//~^ Error: mismatched types
17-
let e: Example3::<7> = ();
18-
//~^ Error: mismatched types
19-
// FIXME(const_generics_defaults): There should be a note for the error below, but it is
20-
// missing.
21-
let e: Example4::<7> = ();
22-
//~^ Error: mismatched types
11+
let e: Example::<13> = ();
12+
//~^ Error: mismatched types
13+
let e: Example2::<u32, 13> = ();
14+
//~^ Error: mismatched types
15+
let e: Example3::<13, u32> = ();
16+
//~^ Error: mismatched types
17+
let e: Example3::<7> = ();
18+
//~^ Error: mismatched types
19+
// FIXME(const_generics_defaults): There should be a note for the error below, but it is
20+
// missing.
21+
let e: Example4::<7> = ();
22+
//~^ Error: mismatched types
2323
}

src/test/ui/const-generics/defaults/mismatch.stderr

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
error[E0308]: mismatched types
2-
--> $DIR/mismatch.rs:11:26
2+
--> $DIR/mismatch.rs:11:28
33
|
4-
LL | let e: Example::<13> = ();
5-
| ------------- ^^ expected struct `Example`, found `()`
6-
| |
7-
| expected due to this
4+
LL | let e: Example::<13> = ();
5+
| ------------- ^^ expected struct `Example`, found `()`
6+
| |
7+
| expected due to this
88

99
error[E0308]: mismatched types
10-
--> $DIR/mismatch.rs:13:32
10+
--> $DIR/mismatch.rs:13:34
1111
|
12-
LL | let e: Example2::<u32, 13> = ();
13-
| ------------------- ^^ expected struct `Example2`, found `()`
14-
| |
15-
| expected due to this
12+
LL | let e: Example2::<u32, 13> = ();
13+
| ------------------- ^^ expected struct `Example2`, found `()`
14+
| |
15+
| expected due to this
1616
|
1717
= note: expected struct `Example2`
1818
found unit type `()`
1919

2020
error[E0308]: mismatched types
21-
--> $DIR/mismatch.rs:15:32
21+
--> $DIR/mismatch.rs:15:34
2222
|
23-
LL | let e: Example3::<13, u32> = ();
24-
| ------------------- ^^ expected struct `Example3`, found `()`
25-
| |
26-
| expected due to this
23+
LL | let e: Example3::<13, u32> = ();
24+
| ------------------- ^^ expected struct `Example3`, found `()`
25+
| |
26+
| expected due to this
2727
|
2828
= note: expected struct `Example3`
2929
found unit type `()`
3030

3131
error[E0308]: mismatched types
32-
--> $DIR/mismatch.rs:17:26
32+
--> $DIR/mismatch.rs:17:28
3333
|
34-
LL | let e: Example3::<7> = ();
35-
| ------------- ^^ expected struct `Example3`, found `()`
36-
| |
37-
| expected due to this
34+
LL | let e: Example3::<7> = ();
35+
| ------------- ^^ expected struct `Example3`, found `()`
36+
| |
37+
| expected due to this
3838
|
3939
= note: expected struct `Example3<7_usize>`
4040
found unit type `()`
4141

4242
error[E0308]: mismatched types
43-
--> $DIR/mismatch.rs:21:26
43+
--> $DIR/mismatch.rs:21:28
4444
|
45-
LL | let e: Example4::<7> = ();
46-
| ------------- ^^ expected struct `Example4`, found `()`
47-
| |
48-
| expected due to this
45+
LL | let e: Example4::<7> = ();
46+
| ------------- ^^ expected struct `Example4`, found `()`
47+
| |
48+
| expected due to this
4949

5050
error: aborting due to 5 previous errors
5151

src/test/ui/const-generics/defaults/needs-feature.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ struct A<const N: usize, T=u32>(T);
1010
//[min]~^ ERROR type parameters must be declared prior
1111

1212
fn main() {
13-
let _: A<3> = A(0);
13+
let _: A<3> = A(0);
1414
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Regression test for #82792.
2+
3+
// run-pass
4+
5+
#![feature(const_generics_defaults)]
6+
#![allow(incomplete_features)]
7+
8+
#[repr(C)]
9+
pub struct Loaf<T: Sized, const N: usize = 1usize> {
10+
head: [T; N],
11+
slice: [T],
12+
}
13+
14+
fn main() {}

src/test/ui/const-generics/defaults/simple-defaults.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
#![allow(dead_code)]
77

88
struct FixedOutput<'a, const N: usize, T=u32> {
9-
//[min]~^ ERROR type parameters must be declared prior to const parameters
10-
out: &'a [T; N],
9+
//[min]~^ ERROR type parameters must be declared prior to const parameters
10+
out: &'a [T; N],
1111
}
1212

1313
trait FixedOutputter {
14-
fn out(&self) -> FixedOutput<'_, 10>;
14+
fn out(&self) -> FixedOutput<'_, 10>;
1515
}
1616

1717
fn main() {}

0 commit comments

Comments
 (0)