Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a regression test for issue-82792 #83636

Merged
merged 2 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/test/ui/const-generics/defaults/complex-unord-param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#![allow(dead_code)]

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

fn main() {
let array = [1, 2, 3];
let nest = [&array];
let _ = NestedArrays {
args: &nest,
specifier: true,
};
let array = [1, 2, 3];
let nest = [&array];
let _ = NestedArrays {
args: &nest,
specifier: true,
};
}
4 changes: 2 additions & 2 deletions src/test/ui/const-generics/defaults/default-annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub struct ConstDefaultUnstable<const N: usize = 3>;

#[stable(feature = "const_default_unstable", since="none")]
pub struct ConstDefaultStable<const N: usize = {
#[stable(feature = "const_default_unstable_val", since="none")]
3
#[stable(feature = "const_default_unstable_val", since="none")]
3
}>;

fn main() {}
24 changes: 12 additions & 12 deletions src/test/ui/const-generics/defaults/mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ pub struct Example3<const N: usize=13, T=u32>(T);
pub struct Example4<const N: usize=13, const M: usize=4>;

fn main() {
let e: Example::<13> = ();
//~^ Error: mismatched types
let e: Example2::<u32, 13> = ();
//~^ Error: mismatched types
let e: Example3::<13, u32> = ();
//~^ Error: mismatched types
let e: Example3::<7> = ();
//~^ Error: mismatched types
// FIXME(const_generics_defaults): There should be a note for the error below, but it is
// missing.
let e: Example4::<7> = ();
//~^ Error: mismatched types
let e: Example::<13> = ();
//~^ Error: mismatched types
let e: Example2::<u32, 13> = ();
//~^ Error: mismatched types
let e: Example3::<13, u32> = ();
//~^ Error: mismatched types
let e: Example3::<7> = ();
//~^ Error: mismatched types
// FIXME(const_generics_defaults): There should be a note for the error below, but it is
// missing.
let e: Example4::<7> = ();
//~^ Error: mismatched types
}
50 changes: 25 additions & 25 deletions src/test/ui/const-generics/defaults/mismatch.stderr
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
error[E0308]: mismatched types
--> $DIR/mismatch.rs:11:26
--> $DIR/mismatch.rs:11:28
|
LL | let e: Example::<13> = ();
| ------------- ^^ expected struct `Example`, found `()`
| |
| expected due to this
LL | let e: Example::<13> = ();
| ------------- ^^ expected struct `Example`, found `()`
| |
| expected due to this

error[E0308]: mismatched types
--> $DIR/mismatch.rs:13:32
--> $DIR/mismatch.rs:13:34
|
LL | let e: Example2::<u32, 13> = ();
| ------------------- ^^ expected struct `Example2`, found `()`
| |
| expected due to this
LL | let e: Example2::<u32, 13> = ();
| ------------------- ^^ expected struct `Example2`, found `()`
| |
| expected due to this
|
= note: expected struct `Example2`
found unit type `()`

error[E0308]: mismatched types
--> $DIR/mismatch.rs:15:32
--> $DIR/mismatch.rs:15:34
|
LL | let e: Example3::<13, u32> = ();
| ------------------- ^^ expected struct `Example3`, found `()`
| |
| expected due to this
LL | let e: Example3::<13, u32> = ();
| ------------------- ^^ expected struct `Example3`, found `()`
| |
| expected due to this
|
= note: expected struct `Example3`
found unit type `()`

error[E0308]: mismatched types
--> $DIR/mismatch.rs:17:26
--> $DIR/mismatch.rs:17:28
|
LL | let e: Example3::<7> = ();
| ------------- ^^ expected struct `Example3`, found `()`
| |
| expected due to this
LL | let e: Example3::<7> = ();
| ------------- ^^ expected struct `Example3`, found `()`
| |
| expected due to this
|
= note: expected struct `Example3<7_usize>`
found unit type `()`

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

error: aborting due to 5 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/defaults/needs-feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ struct A<const N: usize, T=u32>(T);
//[min]~^ ERROR type parameters must be declared prior

fn main() {
let _: A<3> = A(0);
let _: A<3> = A(0);
}
14 changes: 14 additions & 0 deletions src/test/ui/const-generics/defaults/repr-c-issue-82792.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Regression test for #82792.

// run-pass

#![feature(const_generics_defaults)]
#![allow(incomplete_features)]

#[repr(C)]
pub struct Loaf<T: Sized, const N: usize = 1usize> {
head: [T; N],
slice: [T],
}

fn main() {}
6 changes: 3 additions & 3 deletions src/test/ui/const-generics/defaults/simple-defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#![allow(dead_code)]

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

trait FixedOutputter {
fn out(&self) -> FixedOutput<'_, 10>;
fn out(&self) -> FixedOutput<'_, 10>;
}

fn main() {}