Skip to content

Allow const parameters in array sizes to be unified #60742

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

Merged
merged 17 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update tests after pretty printing
  • Loading branch information
varkor committed May 28, 2019
commit f865b7dda43cd8e453ec1ce485d9155e5591248f
2 changes: 1 addition & 1 deletion src/test/ui/const-generics/broken-mir-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
use std::fmt::Debug;

#[derive(Debug)]
struct S<T: Debug, const N: usize>([T; N]); //~ ERROR `[T; N]` doesn't implement `std::fmt::Debug`
struct S<T: Debug, const N: usize>([T; N]); //~ ERROR `[T; _]` doesn't implement `std::fmt::Debug`

fn main() {}
8 changes: 4 additions & 4 deletions src/test/ui/const-generics/broken-mir-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ warning: the feature `const_generics` is incomplete and may cause the compiler t
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^

error[E0277]: `[T; N]` doesn't implement `std::fmt::Debug`
error[E0277]: `[T; _]` doesn't implement `std::fmt::Debug`
--> $DIR/broken-mir-2.rs:7:36
|
LL | struct S<T: Debug, const N: usize>([T; N]);
| ^^^^^^ `[T; N]` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
| ^^^^^^ `[T; _]` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
|
= help: the trait `std::fmt::Debug` is not implemented for `[T; N]`
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; N]`
= help: the trait `std::fmt::Debug` is not implemented for `[T; _]`
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; _]`
= note: required for the cast to the object type `dyn std::fmt::Debug`

error: aborting due to previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E0308]: mismatched types
--> $DIR/cannot-infer-type-for-const-param.rs:10:22
|
LL | let _ = Foo::<3>([1, 2, 3]);
| ^^^^^^^^^ expected `Const { ty: usize, val: Unevaluated(DefId(0:18 ~ cannot_infer_type_for_const_param[317d]::main[0]::{{constant}}[0]), []) }`, found `Const { ty: usize, val: Scalar(Bits { size: 8, bits: 3 }) }`
| ^^^^^^^^^ expected `Const { ty: usize, val: Unevaluated(DefId(0:18 ~ cannot_infer_type_for_const_param[317d]::main[0]::{{constant}}[0]), []) }`, found `Const { ty: usize, val: Scalar(0x0000000000000003) }`
|
= note: expected type `[u8; _]`
found type `[u8; 3]`
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-array-oob-arith.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/const-array-oob-arith.rs:7:45
|
LL | const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
| ^^^ expected `Const { ty: usize, val: Scalar(Bits { size: 8, bits: 2 }) }`, found `Const { ty: usize, val: Scalar(Bits { size: 8, bits: 1 }) }`
| ^^^ expected `Const { ty: usize, val: Scalar(0x0000000000000002) }`, found `Const { ty: usize, val: Scalar(0x0000000000000001) }`
|
= note: expected type `[i32; 2]`
found type `[i32; 1]`
Expand All @@ -11,7 +11,7 @@ error[E0308]: mismatched types
--> $DIR/const-array-oob-arith.rs:8:44
|
LL | const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
| ^^^^^^^ expected `Const { ty: usize, val: Scalar(Bits { size: 8, bits: 1 }) }`, found `Const { ty: usize, val: Scalar(Bits { size: 8, bits: 2 }) }`
| ^^^^^^^ expected `Const { ty: usize, val: Scalar(0x0000000000000001) }`, found `Const { ty: usize, val: Scalar(0x0000000000000002) }`
|
= note: expected type `[i32; 1]`
found type `[i32; 2]`
Expand Down