Skip to content

Commit a14af7f

Browse files
authored
Rollup merge of #72052 - lcnr:const_pprint, r=ecstatic-morse
display `ConstKind::Param`
2 parents eade6f7 + 0db2aec commit a14af7f

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

src/librustc_middle/ty/print/pretty.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,14 @@ pub trait PrettyPrinter<'tcx>:
701701
if self.tcx().sess.verbose() {
702702
p!(write("{:?}", sz));
703703
} else if let ty::ConstKind::Unevaluated(..) = sz.val {
704-
// do not try to evaluate unevaluated constants. If we are const evaluating an
704+
// Do not try to evaluate unevaluated constants. If we are const evaluating an
705705
// array length anon const, rustc will (with debug assertions) print the
706706
// constant's path. Which will end up here again.
707707
p!(write("_"));
708708
} else if let Some(n) = sz.val.try_to_bits(self.tcx().data_layout.pointer_size) {
709709
p!(write("{}", n));
710+
} else if let ty::ConstKind::Param(param) = sz.val {
711+
p!(write("{}", param));
710712
} else {
711713
p!(write("_"));
712714
}

src/test/ui/array-slice-vec/match_arr_unknown_len.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | [1, 2] => true,
1313
| ^^^^^^ expected `2usize`, found `N`
1414
|
1515
= note: expected array `[u32; 2]`
16-
found array `[u32; _]`
16+
found array `[u32; N]`
1717

1818
error: aborting due to previous error; 1 warning emitted
1919

src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ LL | let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::boxed::Box<[i32]>>` is not implemented for `std::boxed::Box<[i32; 33]>`
3030
|
3131
= help: the following implementations were found:
32-
<std::boxed::Box<[T; _]> as std::convert::TryFrom<std::boxed::Box<[T]>>>
32+
<std::boxed::Box<[T; N]> as std::convert::TryFrom<std::boxed::Box<[T]>>>
3333

3434
error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From<std::rc::Rc<[i32]>>` is not satisfied
3535
--> $DIR/alloc-types-no-impls-length-33.rs:19:23
@@ -53,7 +53,7 @@ LL | let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::rc::Rc<[i32]>>` is not implemented for `std::rc::Rc<[i32; 33]>`
5454
|
5555
= help: the following implementations were found:
56-
<std::rc::Rc<[T; _]> as std::convert::TryFrom<std::rc::Rc<[T]>>>
56+
<std::rc::Rc<[T; N]> as std::convert::TryFrom<std::rc::Rc<[T]>>>
5757

5858
error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From<std::sync::Arc<[i32]>>` is not satisfied
5959
--> $DIR/alloc-types-no-impls-length-33.rs:26:23
@@ -77,7 +77,7 @@ LL | let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
7777
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::sync::Arc<[i32]>>` is not implemented for `std::sync::Arc<[i32; 33]>`
7878
|
7979
= help: the following implementations were found:
80-
<std::sync::Arc<[T; _]> as std::convert::TryFrom<std::sync::Arc<[T]>>>
80+
<std::sync::Arc<[T; N]> as std::convert::TryFrom<std::sync::Arc<[T]>>>
8181

8282
error: aborting due to 7 previous errors
8383

src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ LL | for _ in &[0_usize; 33] {
3939
| ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]`
4040
|
4141
= help: the following implementations were found:
42-
<&'a [T; _] as std::iter::IntoIterator>
42+
<&'a [T; N] as std::iter::IntoIterator>
4343
<&'a [T] as std::iter::IntoIterator>
44-
<&'a mut [T; _] as std::iter::IntoIterator>
44+
<&'a mut [T; N] as std::iter::IntoIterator>
4545
<&'a mut [T] as std::iter::IntoIterator>
4646
= note: required by `std::iter::IntoIterator::into_iter`
4747

src/test/ui/const-generics/broken-mir-2.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
1010
--> $DIR/broken-mir-2.rs:7:36
1111
|
1212
LL | struct S<T: Debug, const N: usize>([T; N]);
13-
| ^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[T; _]`
13+
| ^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[T; N]`
1414
|
15-
= note: required because of the requirements on the impl of `std::fmt::Debug` for `[T; _]`
16-
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; _]`
15+
= note: required because of the requirements on the impl of `std::fmt::Debug` for `[T; N]`
16+
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; N]`
1717
= note: required for the cast to the object type `dyn std::fmt::Debug`
1818
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
1919

src/test/ui/const-generics/derive-debug-array-wrapper.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32
1010
--> $DIR/derive-debug-array-wrapper.rs:6:5
1111
|
1212
LL | a: [u32; N],
13-
| ^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[u32; _]`
13+
| ^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[u32; N]`
1414
|
15-
= note: required because of the requirements on the impl of `std::fmt::Debug` for `[u32; _]`
16-
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[u32; _]`
15+
= note: required because of the requirements on the impl of `std::fmt::Debug` for `[u32; N]`
16+
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[u32; N]`
1717
= note: required for the cast to the object type `dyn std::fmt::Debug`
1818
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
1919

src/test/ui/const-generics/issues/issue-62504.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | ArrayHolder([0; Self::SIZE])
55
| ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE`
66
|
7-
= note: expected array `[u32; _]`
7+
= note: expected array `[u32; X]`
88
found array `[u32; _]`
99

1010
error: constant expression depends on a generic parameter

0 commit comments

Comments
 (0)