Skip to content

Commit 9e46c24

Browse files
authored
Rollup merge of rust-lang#106873 - BoxyUwU:ty_const_formatting, r=compiler-errors
dont randomly use `_` to print out const generic arguments const generics seem to get printed out as `_` for no reason a lot of the time, as someone who spends a lot of time with const generics this has gotten ✨ very annoying ✨. Latest example would be rust-lang#106423 where the ICE messaged formatted a `ty::Const` containing no infer vars, as `_`. For some reason printing of the const argument on arrays was custom instead of using the existing logic for printing `ty::Const`. Additionally the existing logic for printing `ty::Const` would print out `_` for anon consts that are in a separate crate leading to weird diagnostics (see second commit). There ought to be less cases of consts randomly getting printed as `_` hiding valuable info now.
2 parents d26e07b + 1171fe5 commit 9e46c24

39 files changed

+112
-80
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+16-29
Original file line numberDiff line numberDiff line change
@@ -854,24 +854,7 @@ pub trait PrettyPrinter<'tcx>:
854854
}
855855
p!("]");
856856
}
857-
ty::Array(ty, sz) => {
858-
p!("[", print(ty), "; ");
859-
if self.should_print_verbose() {
860-
p!(write("{:?}", sz));
861-
} else if let ty::ConstKind::Unevaluated(..) = sz.kind() {
862-
// Do not try to evaluate unevaluated constants. If we are const evaluating an
863-
// array length anon const, rustc will (with debug assertions) print the
864-
// constant's path. Which will end up here again.
865-
p!("_");
866-
} else if let Some(n) = sz.kind().try_to_bits(self.tcx().data_layout.pointer_size) {
867-
p!(write("{}", n));
868-
} else if let ty::ConstKind::Param(param) = sz.kind() {
869-
p!(print(param));
870-
} else {
871-
p!("_");
872-
}
873-
p!("]")
874-
}
857+
ty::Array(ty, sz) => p!("[", print(ty), "; ", print(sz), "]"),
875858
ty::Slice(ty) => p!("[", print(ty), "]"),
876859
}
877860

@@ -1303,21 +1286,25 @@ pub trait PrettyPrinter<'tcx>:
13031286
match ct.kind() {
13041287
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }) => {
13051288
match self.tcx().def_kind(def.did) {
1306-
DefKind::Static(..) | DefKind::Const | DefKind::AssocConst => {
1289+
DefKind::Const | DefKind::AssocConst => {
13071290
p!(print_value_path(def.did, substs))
13081291
}
1309-
_ => {
1310-
if def.is_local() {
1311-
let span = self.tcx().def_span(def.did);
1312-
if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) {
1313-
p!(write("{}", snip))
1314-
} else {
1315-
print_underscore!()
1316-
}
1292+
DefKind::AnonConst => {
1293+
if def.is_local()
1294+
&& let span = self.tcx().def_span(def.did)
1295+
&& let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span)
1296+
{
1297+
p!(write("{}", snip))
13171298
} else {
1318-
print_underscore!()
1299+
// Do not call `print_value_path` as if a parent of this anon const is an impl it will
1300+
// attempt to print out the impl trait ref i.e. `<T as Trait>::{constant#0}`. This would
1301+
// cause printing to enter an infinite recursion if the anon const is in the self type i.e.
1302+
// `impl<T: Default> Default for [T; 32 - 1 - 1 - 1] {`
1303+
// where we would try to print `<[T; /* print `constant#0` again */] as Default>::{constant#0}`
1304+
p!(write("{}::{}", self.tcx().crate_name(def.did.krate), self.tcx().def_path(def.did).to_string_no_crate_verbose()))
13191305
}
13201306
}
1307+
defkind => bug!("`{:?}` has unexpcted defkind {:?}", ct, defkind),
13211308
}
13221309
}
13231310
ty::ConstKind::Infer(infer_ct) => {
@@ -1339,7 +1326,7 @@ pub trait PrettyPrinter<'tcx>:
13391326
ty::ConstKind::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
13401327
// FIXME(generic_const_exprs):
13411328
// write out some legible representation of an abstract const?
1342-
ty::ConstKind::Expr(_) => p!("[Const Expr]"),
1329+
ty::ConstKind::Expr(_) => p!("[const expr]"),
13431330
ty::ConstKind::Error(_) => p!("[const error]"),
13441331
};
13451332
Ok(self)

tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|
2323
fn main() -> () {
2424
let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
25-
let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
25+
let mut _1: [usize; Const(Value(Leaf(0x00000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
2626
let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
2727
let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
2828
let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18

tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|
2323
fn main() -> () {
2424
let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11
25-
let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
25+
let mut _1: [usize; Const(Value(Leaf(0x0000000000000003)): usize)]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14
2626
let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17
2727
let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18
2828
let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18

tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
1010
LL | pub struct SelfDependent<const N: [u8; N]>;
1111
| ^ the type must not depend on the parameter `N`
1212

13-
error: `[u8; _]` is forbidden as the type of a const generic parameter
13+
error: `[u8; N]` is forbidden as the type of a const generic parameter
1414
--> $DIR/const-param-type-depends-on-const-param.rs:11:47
1515
|
1616
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
@@ -19,7 +19,7 @@ LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
1919
= note: the only supported types are integers, `bool` and `char`
2020
= help: more complex types are supported with `#![feature(adt_const_params)]`
2121

22-
error: `[u8; _]` is forbidden as the type of a const generic parameter
22+
error: `[u8; N]` is forbidden as the type of a const generic parameter
2323
--> $DIR/const-param-type-depends-on-const-param.rs:15:35
2424
|
2525
LL | pub struct SelfDependent<const N: [u8; N]>;

tests/ui/const-generics/const-param-type-depends-on-const-param.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
1212
//~^ ERROR: the type of const parameters must not depend on other generic parameters
13-
//[min]~^^ ERROR `[u8; _]` is forbidden
13+
//[min]~^^ ERROR `[u8; N]` is forbidden
1414

1515
pub struct SelfDependent<const N: [u8; N]>;
1616
//~^ ERROR: the type of const parameters must not depend on other generic parameters
17-
//[min]~^^ ERROR `[u8; _]` is forbidden
17+
//[min]~^^ ERROR `[u8; N]` is forbidden
1818

1919
fn main() {}

tests/ui/const-generics/dont-evaluate-array-len-on-err-1.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0277]: the trait bound `[Adt; _]: Foo` is not satisfied
1+
error[E0277]: the trait bound `[Adt; std::mem::size_of::<Self::Assoc>()]: Foo` is not satisfied
22
--> $DIR/dont-evaluate-array-len-on-err-1.rs:15:9
33
|
44
LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar()
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; _]`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; std::mem::size_of::<Self::Assoc>()]`
66

77
error: aborting due to previous error
88

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
pub struct Foo<const N: usize>;
5+
6+
pub fn foo<const N: usize>() -> Foo<{ N + 1 }> {
7+
Foo
8+
}

tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | ArrayHolder([0; Self::SIZE])
1515
| arguments to this struct are incorrect
1616
|
1717
= note: expected array `[u32; X]`
18-
found array `[u32; _]`
18+
found array `[u32; Self::SIZE]`
1919
note: tuple struct defined here
2020
--> $DIR/issue-62504.rs:14:8
2121
|

tests/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0308]: mismatched types
22
--> $DIR/issue-79518-default_trait_method_normalization.rs:16:32
33
|
44
LL | Self::AssocInstance == [(); std::mem::size_of::<Self::Assoc>()];
5-
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); _]`
5+
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found array `[(); std::mem::size_of::<Self::Assoc>()]`
66
| |
77
| expected because this is `<Self as Foo>::Assoc`
88
|
99
= note: expected associated type `<Self as Foo>::Assoc`
10-
found array `[(); _]`
11-
= help: consider constraining the associated type `<Self as Foo>::Assoc` to `[(); _]` or calling a method that returns `<Self as Foo>::Assoc`
10+
found array `[(); std::mem::size_of::<Self::Assoc>()]`
11+
= help: consider constraining the associated type `<Self as Foo>::Assoc` to `[(); std::mem::size_of::<Self::Assoc>()]` or calling a method that returns `<Self as Foo>::Assoc`
1212
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
1313

1414
error: aborting due to previous error
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// aux-build:anon_const_non_local.rs
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
extern crate anon_const_non_local;
7+
8+
fn bar<const M: usize>()
9+
where
10+
[(); M + 1]:,
11+
{
12+
let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
13+
//~^ ERROR: mismatched types
14+
}
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/non_local_anon_const_diagnostics.rs:12:43
3+
|
4+
LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `anon_const_non_local::::foo::{constant#0}`
6+
|
7+
= note: expected constant `2`
8+
found constant `anon_const_non_local::::foo::{constant#0}`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

tests/ui/const-generics/issues/issue-62878.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
44
LL | fn foo<const N: usize, const A: [u8; N]>() {}
55
| ^ the type must not depend on the parameter `N`
66

7-
error: `[u8; _]` is forbidden as the type of a const generic parameter
7+
error: `[u8; N]` is forbidden as the type of a const generic parameter
88
--> $DIR/issue-62878.rs:5:33
99
|
1010
LL | fn foo<const N: usize, const A: [u8; N]>() {}

tests/ui/const-generics/issues/issue-62878.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
fn foo<const N: usize, const A: [u8; N]>() {}
66
//~^ ERROR the type of const parameters must not
7-
//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter
7+
//[min]~| ERROR `[u8; N]` is forbidden as the type of a const generic parameter
88

99
fn main() {
1010
foo::<_, { [1] }>();

tests/ui/const-generics/issues/issue-71169.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0770]: the type of const parameters must not depend on other generic para
44
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
55
| ^^^ the type must not depend on the parameter `LEN`
66

7-
error: `[u8; _]` is forbidden as the type of a const generic parameter
7+
error: `[u8; LEN]` is forbidden as the type of a const generic parameter
88
--> $DIR/issue-71169.rs:5:38
99
|
1010
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}

tests/ui/const-generics/issues/issue-71169.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
66
//~^ ERROR the type of const parameters must not
7-
//[min]~^^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
7+
//[min]~^^ ERROR `[u8; LEN]` is forbidden as the type of a const generic parameter
88
fn main() {
99
const DATA: [u8; 4] = *b"ABCD";
1010
foo::<4, DATA>();

tests/ui/const-generics/issues/issue-73491.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `[u32; _]` is forbidden as the type of a const generic parameter
1+
error: `[u32; LEN]` is forbidden as the type of a const generic parameter
22
--> $DIR/issue-73491.rs:8:19
33
|
44
LL | fn hoge<const IN: [u32; LEN]>() {}

tests/ui/const-generics/issues/issue-73491.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
const LEN: usize = 1024;
77

88
fn hoge<const IN: [u32; LEN]>() {}
9-
//[min]~^ ERROR `[u32; _]` is forbidden as the type of a const generic parameter
9+
//[min]~^ ERROR `[u32; LEN]` is forbidden as the type of a const generic parameter
1010

1111
fn main() {}

tests/ui/const-generics/issues/issue-74101.min.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `[u8; _]` is forbidden as the type of a const generic parameter
1+
error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter
22
--> $DIR/issue-74101.rs:6:18
33
|
44
LL | fn test<const N: [u8; 1 + 2]>() {}
@@ -7,7 +7,7 @@ LL | fn test<const N: [u8; 1 + 2]>() {}
77
= note: the only supported types are integers, `bool` and `char`
88
= help: more complex types are supported with `#![feature(adt_const_params)]`
99

10-
error: `[u8; _]` is forbidden as the type of a const generic parameter
10+
error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter
1111
--> $DIR/issue-74101.rs:9:21
1212
|
1313
LL | struct Foo<const N: [u8; 1 + 2]>;

tests/ui/const-generics/issues/issue-74101.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#![cfg_attr(full, allow(incomplete_features))]
55

66
fn test<const N: [u8; 1 + 2]>() {}
7-
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
7+
//[min]~^ ERROR `[u8; 1 + 2]` is forbidden as the type of a const generic parameter
88

99
struct Foo<const N: [u8; 1 + 2]>;
10-
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
10+
//[min]~^ ERROR `[u8; 1 + 2]` is forbidden as the type of a const generic parameter
1111

1212
fn main() {}

tests/ui/const-generics/issues/issue-75047.min.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `[u8; _]` is forbidden as the type of a const generic parameter
1+
error: `[u8; Bar::<u32>::value()]` is forbidden as the type of a const generic parameter
22
--> $DIR/issue-75047.rs:14:21
33
|
44
LL | struct Foo<const N: [u8; Bar::<u32>::value()]>;

tests/ui/const-generics/issues/issue-75047.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ impl<T> Bar<T> {
1212
}
1313

1414
struct Foo<const N: [u8; Bar::<u32>::value()]>;
15-
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
15+
//[min]~^ ERROR `[u8; Bar::<u32>::value()]` is forbidden as the type of a const generic parameter
1616

1717
fn main() {}

tests/ui/const-generics/nested-type.min.stderr

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
error: `[u8; _]` is forbidden as the type of a const generic parameter
1+
error: `[u8; {
2+
struct Foo<const N: usize>;
3+
4+
impl<const N: usize> Foo<N> {
5+
fn value() -> usize {
6+
N
7+
}
8+
}
9+
10+
Foo::<17>::value()
11+
}]` is forbidden as the type of a const generic parameter
212
--> $DIR/nested-type.rs:6:21
313
|
414
LL | struct Foo<const N: [u8; {

tests/ui/consts/const-size_of-cycle.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`..
1515
LL | bytes: [u8; std::mem::size_of::<Foo>()]
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1717
= note: ...which requires computing layout of `Foo`...
18-
= note: ...which requires computing layout of `[u8; _]`...
19-
= note: ...which requires normalizing `[u8; _]`...
18+
= note: ...which requires computing layout of `[u8; std::mem::size_of::<Foo>()]`...
19+
= note: ...which requires normalizing `[u8; std::mem::size_of::<Foo>()]`...
2020
= note: ...which again requires evaluating type-level constant, completing the cycle
2121
note: cycle used when checking that `Foo` is well-formed
2222
--> $DIR/const-size_of-cycle.rs:3:1

tests/ui/consts/issue-44415.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ note: ...which requires const-evaluating + checking `Foo::bytes::{constant#0}`..
1515
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717
= note: ...which requires computing layout of `Foo`...
18-
= note: ...which requires computing layout of `[u8; _]`...
19-
= note: ...which requires normalizing `[u8; _]`...
18+
= note: ...which requires computing layout of `[u8; unsafe { intrinsics::size_of::<Foo>() }]`...
19+
= note: ...which requires normalizing `[u8; unsafe { intrinsics::size_of::<Foo>() }]`...
2020
= note: ...which again requires evaluating type-level constant, completing the cycle
2121
note: cycle used when checking that `Foo` is well-formed
2222
--> $DIR/issue-44415.rs:5:1

tests/ui/consts/too_generic_eval_ice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ impl<A, B> Foo<A, B> {
77
[5; Self::HOST_SIZE] == [6; 0]
88
//~^ ERROR constant expression depends on a generic parameter
99
//~| ERROR constant expression depends on a generic parameter
10-
//~| ERROR can't compare `[{integer}; _]` with `[{integer}; 0]`
10+
//~| ERROR can't compare `[{integer}; Self::HOST_SIZE]` with `[{integer}; 0]`
1111
}
1212
}
1313

tests/ui/consts/too_generic_eval_ice.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
1414
|
1515
= note: this may fail depending on what value the parameter takes
1616

17-
error[E0277]: can't compare `[{integer}; _]` with `[{integer}; 0]`
17+
error[E0277]: can't compare `[{integer}; Self::HOST_SIZE]` with `[{integer}; 0]`
1818
--> $DIR/too_generic_eval_ice.rs:7:30
1919
|
2020
LL | [5; Self::HOST_SIZE] == [6; 0]
21-
| ^^ no implementation for `[{integer}; _] == [{integer}; 0]`
21+
| ^^ no implementation for `[{integer}; Self::HOST_SIZE] == [{integer}; 0]`
2222
|
23-
= help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]`
23+
= help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; Self::HOST_SIZE]`
2424
= help: the following other types implement trait `PartialEq<Rhs>`:
2525
<&[B] as PartialEq<[A; N]>>
2626
<&[T] as PartialEq<Vec<U, A>>>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: values of the type `[u8; SIZE]` are too big for the current architecture
1+
error: values of the type `[u8; usize::MAX]` are too big for the current architecture
22

33
error: aborting due to previous error
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: values of the type `[u8; SIZE]` are too big for the current architecture
1+
error: values of the type `[u8; usize::MAX]` are too big for the current architecture
22

33
error: aborting due to previous error
44

tests/ui/inference/issue-83606.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn foo<const N: usize>(_: impl std::fmt::Display) -> [usize; N] {
66

77
fn main() {
88
let _ = foo("foo");
9-
//~^ ERROR: type annotations needed for `[usize; _]`
9+
//~^ ERROR: type annotations needed for `[usize; N]`
1010
}

tests/ui/inference/issue-83606.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error[E0282]: type annotations needed for `[usize; _]`
1+
error[E0282]: type annotations needed for `[usize; N]`
22
--> $DIR/issue-83606.rs:8:9
33
|
44
LL | let _ = foo("foo");
55
| ^
66
|
77
help: consider giving this pattern a type, where the the value of const parameter `N` is specified
88
|
9-
LL | let _: [usize; _] = foo("foo");
9+
LL | let _: [usize; N] = foo("foo");
1010
| ++++++++++++
1111

1212
error: aborting due to previous error

tests/ui/limits/issue-15919-32.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: values of the type `[usize; 4294967295]` are too big for the current architecture
1+
error: values of the type `[usize; usize::MAX]` are too big for the current architecture
22
--> $DIR/issue-15919-32.rs:9:9
33
|
44
LL | let x = [0usize; 0xffff_ffff];

tests/ui/limits/issue-15919-64.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: values of the type `[usize; 18446744073709551615]` are too big for the current architecture
1+
error: values of the type `[usize; usize::MAX]` are too big for the current architecture
22
--> $DIR/issue-15919-64.rs:9:9
33
|
44
LL | let x = [0usize; 0xffff_ffff_ffff_ffff];

0 commit comments

Comments
 (0)