Skip to content

Commit beba7ca

Browse files
Call them constants instead of types
1 parent 2ed0f29 commit beba7ca

12 files changed

+47
-42
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1587,9 +1587,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15871587
Mismatch::Variable(infer::ExpectedFound { expected, found }),
15881588
)
15891589
}
1590+
ValuePairs::Terms(infer::ExpectedFound {
1591+
expected: ty::Term::Const(_),
1592+
found: ty::Term::Const(_),
1593+
}) => (false, Mismatch::Fixed("constant")),
15901594
ValuePairs::TraitRefs(_) | ValuePairs::PolyTraitRefs(_) => {
15911595
(false, Mismatch::Fixed("trait"))
15921596
}
1597+
ValuePairs::Regions(_) => (false, Mismatch::Fixed("lifetime")),
15931598
_ => (false, Mismatch::Fixed("type")),
15941599
};
15951600
let vals = match self.values_str(values) {

src/test/ui/const-generics/defaults/generic-expr-default-concrete.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | Foo::<10, 12>
55
| ^^^^^^^^^^^^^ expected `11`, found `12`
66
|
7-
= note: expected type `11`
8-
found type `12`
7+
= note: expected constant `11`
8+
found constant `12`
99

1010
error: aborting due to previous error
1111

src/test/ui/const-generics/defaults/generic-expr-default-mismatched-types.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | Foo::<N, { N + 2 }>
55
| ^^^^^^^^^^^^^^^^^^^ expected `{ N + 1 }`, found `{ N + 2 }`
66
|
7-
= note: expected type `{ N + 1 }`
8-
found type `{ N + 2 }`
7+
= note: expected constant `{ N + 1 }`
8+
found constant `{ N + 2 }`
99

1010
error: aborting due to previous error
1111

src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ error[E0308]: mismatched types
2222
LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as u128 }>>();
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{ N as u128 }`, found `{ O as u128 }`
2424
|
25-
= note: expected type `{ N as u128 }`
26-
found type `{ O as u128 }`
25+
= note: expected constant `{ N as u128 }`
26+
found constant `{ O as u128 }`
2727

2828
error: unconstrained generic constant
2929
--> $DIR/abstract-const-as-cast-3.rs:20:5
@@ -49,26 +49,26 @@ error[E0308]: mismatched types
4949
LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as _ }>>();
5050
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{ N as _ }`, found `{ O as u128 }`
5151
|
52-
= note: expected type `{ N as _ }`
53-
found type `{ O as u128 }`
52+
= note: expected constant `{ N as _ }`
53+
found constant `{ O as u128 }`
5454

5555
error[E0308]: mismatched types
5656
--> $DIR/abstract-const-as-cast-3.rs:23:5
5757
|
5858
LL | assert_impl::<HasCastInTraitImpl<13, { 12 as u128 }>>();
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `12`, found `13`
6060
|
61-
= note: expected type `12`
62-
found type `13`
61+
= note: expected constant `12`
62+
found constant `13`
6363

6464
error[E0308]: mismatched types
6565
--> $DIR/abstract-const-as-cast-3.rs:25:5
6666
|
6767
LL | assert_impl::<HasCastInTraitImpl<14, 13>>();
6868
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `13`, found `14`
6969
|
70-
= note: expected type `13`
71-
found type `14`
70+
= note: expected constant `13`
71+
found constant `14`
7272

7373
error: unconstrained generic constant
7474
--> $DIR/abstract-const-as-cast-3.rs:35:5
@@ -94,8 +94,8 @@ error[E0308]: mismatched types
9494
LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as u128 }>>();
9595
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{ N as u128 }`, found `{ O as u128 }`
9696
|
97-
= note: expected type `{ N as u128 }`
98-
found type `{ O as u128 }`
97+
= note: expected constant `{ N as u128 }`
98+
found constant `{ O as u128 }`
9999

100100
error: unconstrained generic constant
101101
--> $DIR/abstract-const-as-cast-3.rs:38:5
@@ -121,26 +121,26 @@ error[E0308]: mismatched types
121121
LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as _ }>>();
122122
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{ N as _ }`, found `{ O as u128 }`
123123
|
124-
= note: expected type `{ N as _ }`
125-
found type `{ O as u128 }`
124+
= note: expected constant `{ N as _ }`
125+
found constant `{ O as u128 }`
126126

127127
error[E0308]: mismatched types
128128
--> $DIR/abstract-const-as-cast-3.rs:41:5
129129
|
130130
LL | assert_impl::<HasCastInTraitImpl<13, { 12 as u128 }>>();
131131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `12`, found `13`
132132
|
133-
= note: expected type `12`
134-
found type `13`
133+
= note: expected constant `12`
134+
found constant `13`
135135

136136
error[E0308]: mismatched types
137137
--> $DIR/abstract-const-as-cast-3.rs:43:5
138138
|
139139
LL | assert_impl::<HasCastInTraitImpl<14, 13>>();
140140
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `13`, found `14`
141141
|
142-
= note: expected type `13`
143-
found type `14`
142+
= note: expected constant `13`
143+
found constant `14`
144144

145145
error: aborting due to 12 previous errors
146146

src/test/ui/const-generics/generic_const_exprs/different-fn.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | [0; size_of::<Foo<T>>()]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `size_of::<T>()`, found `size_of::<Foo<T>>()`
66
|
7-
= note: expected type `size_of::<T>()`
8-
found type `size_of::<Foo<T>>()`
7+
= note: expected constant `size_of::<T>()`
8+
found constant `size_of::<Foo<T>>()`
99

1010
error: unconstrained generic constant
1111
--> $DIR/different-fn.rs:10:9

src/test/ui/const-generics/generic_const_exprs/issue-62504.full.stderr

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

1010
error: unconstrained generic constant
1111
--> $DIR/issue-62504.rs:18:25

src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ error[E0308]: mismatched types
44
LL | let x: Arr<{usize::MAX}> = Arr {};
55
| ^^^^^^^^^^^^^^^^^ expected `false`, found `true`
66
|
7-
= note: expected type `false`
8-
found type `true`
7+
= note: expected constant `false`
8+
found constant `true`
99

1010
error[E0308]: mismatched types
1111
--> $DIR/issue-72819-generic-in-const-eval.rs:20:32
1212
|
1313
LL | let x: Arr<{usize::MAX}> = Arr {};
1414
| ^^^ expected `false`, found `true`
1515
|
16-
= note: expected type `false`
17-
found type `true`
16+
= note: expected constant `false`
17+
found constant `true`
1818

1919
error: aborting due to 2 previous errors
2020

src/test/ui/const-generics/generic_const_exprs/issue-83765.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: method not compatible with trait
44
LL | fn size(&self) -> [usize; DIM] {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
66
|
7-
= note: expected type `Self::DIM`
8-
found type `DIM`
7+
= note: expected constant `Self::DIM`
8+
found constant `DIM`
99

1010
error: unconstrained generic constant
1111
--> $DIR/issue-83765.rs:32:24
@@ -26,8 +26,8 @@ error[E0308]: mismatched types
2626
LL | self.reference.size()
2727
| ^^^^^^^^^^^^^^^^^^^^^ expected `DIM`, found `Self::DIM`
2828
|
29-
= note: expected type `DIM`
30-
found type `Self::DIM`
29+
= note: expected constant `DIM`
30+
found constant `Self::DIM`
3131

3232
error: aborting due to 3 previous errors
3333

src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ error[E0308]: mismatched types
5454
LL | writes_to_specific_path(&cap);
5555
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `true`, found `{ contains::<T, U>() }`
5656
|
57-
= note: expected type `true`
58-
found type `{ contains::<T, U>() }`
57+
= note: expected constant `true`
58+
found constant `{ contains::<T, U>() }`
5959

6060
error: aborting due to 3 previous errors
6161

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ error[E0308]: mismatched types
44
LL | let x: Arr<{usize::MAX}> = Arr {};
55
| ^^^^^^^^^^^^^^^^^ expected `false`, found `true`
66
|
7-
= note: expected type `false`
8-
found type `true`
7+
= note: expected constant `false`
8+
found constant `true`
99

1010
error[E0308]: mismatched types
1111
--> $DIR/issue-73260.rs:16:32
1212
|
1313
LL | let x: Arr<{usize::MAX}> = Arr {};
1414
| ^^^ expected `false`, found `true`
1515
|
16-
= note: expected type `false`
17-
found type `true`
16+
= note: expected constant `false`
17+
found constant `true`
1818

1919
error: aborting due to 2 previous errors
2020

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | requires_distinct("str", 12);
55
| ^^^^^^^^^^^^^^^^^ expected `true`, found `false`
66
|
7-
= note: expected type `true`
8-
found type `false`
7+
= note: expected constant `true`
8+
found constant `false`
99

1010
error: aborting due to previous error
1111

src/test/ui/const-generics/types-mismatch-const-args.full.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ error[E0308]: mismatched types
44
LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {2u32 + 2u32}, {3u32}> { data: PhantomData };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `4`
66
|
7-
= note: expected type `2`
8-
found type `4`
7+
= note: expected constant `2`
8+
found constant `4`
99

1010
error[E0308]: mismatched types
1111
--> $DIR/types-mismatch-const-args.rs:16:41

0 commit comments

Comments
 (0)