Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bbf0477

Browse files
committedSep 9, 2024·
Re-enable ConstArgKind::Path lowering by default
...and remove the `const_arg_path` feature gate as a result. It was only a stopgap measure to fix the regression that the new lowering introduced (which should now be fixed by this PR).
1 parent 2c42bda commit bbf0477

32 files changed

+69
-198
lines changed
 

‎compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
220220
let parent_def_id = self.current_def_id_parent;
221221
let node_id = self.next_node_id();
222222
// HACK(min_generic_const_args): see lower_anon_const
223-
if !self.tcx.features().const_arg_path
224-
|| !expr.is_potential_trivial_const_arg()
225-
{
223+
if !expr.is_potential_trivial_const_arg() {
226224
self.create_def(
227225
parent_def_id,
228226
node_id,

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
387387
let node_id = self.next_node_id();
388388

389389
// HACK(min_generic_const_args): see lower_anon_const
390-
if !self.tcx.features().const_arg_path || !arg.is_potential_trivial_const_arg() {
390+
if !arg.is_potential_trivial_const_arg() {
391391
// Add a definition for the in-band const def.
392392
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
393393
}

‎compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23352335
span: Span,
23362336
) -> &'hir hir::ConstArg<'hir> {
23372337
let ct_kind = match res {
2338-
Res::Def(DefKind::ConstParam, _) if self.tcx.features().const_arg_path => {
2338+
Res::Def(DefKind::ConstParam, _) => {
23392339
let qpath = self.lower_qpath(
23402340
ty_id,
23412341
&None,
@@ -2410,8 +2410,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24102410
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
24112411
debug!("res={:?}", maybe_res);
24122412
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
2413-
if self.tcx.features().const_arg_path
2414-
&& let Some(res) = maybe_res
2413+
if let Some(res) = maybe_res
24152414
&& let Res::Def(DefKind::ConstParam, _) = res
24162415
&& let ExprKind::Path(qself, path) = &expr.kind
24172416
{
@@ -2442,7 +2441,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24422441
/// See [`hir::ConstArg`] for when to use this function vs
24432442
/// [`Self::lower_anon_const_to_const_arg`].
24442443
fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
2445-
if self.tcx.features().const_arg_path && c.value.is_potential_trivial_const_arg() {
2444+
if c.value.is_potential_trivial_const_arg() {
24462445
// HACK(min_generic_const_args): see DefCollector::visit_anon_const
24472446
// Over there, we guess if this is a bare param and only create a def if
24482447
// we think it's not. However we may can guess wrong (see there for example)

‎compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ declare_features! (
193193
(unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None),
194194
/// Allows identifying the `compiler_builtins` crate.
195195
(internal, compiler_builtins, "1.13.0", None),
196-
/// Gating for a new desugaring of const arguments of usages of const parameters
197-
(internal, const_arg_path, "1.81.0", None),
198196
/// Allows writing custom MIR
199197
(internal, custom_mir, "1.65.0", None),
200198
/// Outputs useful `assert!` messages

‎compiler/rustc_middle/src/ty/consts.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,20 +295,12 @@ impl<'tcx> Const<'tcx> {
295295
_ => expr,
296296
};
297297

298-
if let hir::ExprKind::Path(
299-
qpath @ hir::QPath::Resolved(
300-
_,
301-
&hir::Path { res: Res::Def(DefKind::ConstParam, _), .. },
302-
),
303-
) = expr.kind
298+
if let hir::ExprKind::Path(hir::QPath::Resolved(
299+
_,
300+
&hir::Path { res: Res::Def(DefKind::ConstParam, _), .. },
301+
)) = expr.kind
304302
{
305-
if tcx.features().const_arg_path {
306-
span_bug!(
307-
expr.span,
308-
"try_from_lit: received const param which shouldn't be possible"
309-
);
310-
}
311-
return Some(Const::from_param(tcx, qpath, expr.hir_id));
303+
span_bug!(expr.span, "try_from_lit: received const param which shouldn't be possible");
312304
};
313305

314306
let lit_input = match expr.kind {

‎compiler/rustc_resolve/src/def_collector.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -347,22 +347,20 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
347347
}
348348

349349
fn visit_anon_const(&mut self, constant: &'a AnonConst) {
350-
if self.resolver.tcx.features().const_arg_path {
351-
// HACK(min_generic_const_args): don't create defs for anon consts if we think they will
352-
// later be turned into ConstArgKind::Path's. because this is before resolve is done, we
353-
// may accidentally identify a construction of a unit struct as a param and not create a
354-
// def. we'll then create a def later in ast lowering in this case. the parent of nested
355-
// items will be messed up, but that's ok because there can't be any if we're just looking
356-
// for bare idents.
357-
358-
if matches!(constant.value.maybe_unwrap_block().kind, ExprKind::MacCall(..)) {
359-
// See self.pending_anon_const_info for explanation
360-
self.pending_anon_const_info =
361-
Some(PendingAnonConstInfo { id: constant.id, span: constant.value.span });
362-
return visit::walk_anon_const(self, constant);
363-
} else if constant.value.is_potential_trivial_const_arg() {
364-
return visit::walk_anon_const(self, constant);
365-
}
350+
// HACK(min_generic_const_args): don't create defs for anon consts if we think they will
351+
// later be turned into ConstArgKind::Path's. because this is before resolve is done, we
352+
// may accidentally identify a construction of a unit struct as a param and not create a
353+
// def. we'll then create a def later in ast lowering in this case. the parent of nested
354+
// items will be messed up, but that's ok because there can't be any if we're just looking
355+
// for bare idents.
356+
357+
if matches!(constant.value.maybe_unwrap_block().kind, ExprKind::MacCall(..)) {
358+
// See self.pending_anon_const_info for explanation
359+
self.pending_anon_const_info =
360+
Some(PendingAnonConstInfo { id: constant.id, span: constant.value.span });
361+
return visit::walk_anon_const(self, constant);
362+
} else if constant.value.is_potential_trivial_const_arg() {
363+
return visit::walk_anon_const(self, constant);
366364
}
367365

368366
let def = self.create_def(constant.id, kw::Empty, DefKind::AnonConst, constant.value.span);

‎compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ symbols! {
599599
conservative_impl_trait,
600600
console,
601601
const_allocate,
602-
const_arg_path,
603602
const_async_blocks,
604603
const_closures,
605604
const_compare_raw_pointers,

‎tests/ui/coherence/negative-coherence/generic_const_type_mismatch.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
#![feature(with_negative_coherence)]
66
trait Trait {}
77
impl<const N: u8> Trait for [(); N] {}
8-
//~^ ERROR: mismatched types
98
impl<const N: i8> Trait for [(); N] {}
109
//~^ ERROR: conflicting implementations of trait `Trait`
11-
//~| ERROR: mismatched types
1210

1311
fn main() {}
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
error[E0119]: conflicting implementations of trait `Trait` for type `[(); _]`
2-
--> $DIR/generic_const_type_mismatch.rs:9:1
2+
--> $DIR/generic_const_type_mismatch.rs:8:1
33
|
44
LL | impl<const N: u8> Trait for [(); N] {}
55
| ----------------------------------- first implementation here
6-
LL |
76
LL | impl<const N: i8> Trait for [(); N] {}
87
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); _]`
98

10-
error[E0308]: mismatched types
11-
--> $DIR/generic_const_type_mismatch.rs:7:34
12-
|
13-
LL | impl<const N: u8> Trait for [(); N] {}
14-
| ^ expected `usize`, found `u8`
15-
16-
error[E0308]: mismatched types
17-
--> $DIR/generic_const_type_mismatch.rs:9:34
18-
|
19-
LL | impl<const N: i8> Trait for [(); N] {}
20-
| ^ expected `usize`, found `i8`
21-
22-
error: aborting due to 3 previous errors
9+
error: aborting due to 1 previous error
2310

24-
Some errors have detailed explanations: E0119, E0308.
25-
For more information about an error, try `rustc --explain E0119`.
11+
For more information about this error, try `rustc --explain E0119`.

‎tests/ui/const-generics/bad-subst-const-kind.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ trait Q {
77

88
impl<const N: u64> Q for [u8; N] {
99
//~^ ERROR: the constant `N` is not of type `usize`
10-
//~| ERROR: mismatched types
1110
const ASSOC: usize = 1;
1211
}
1312

‎tests/ui/const-generics/bad-subst-const-kind.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | impl<const N: u64> Q for [u8; N] {
55
| ^^^^^^^ expected `usize`, found `u64`
66

77
error: the constant `13` is not of type `u64`
8-
--> $DIR/bad-subst-const-kind.rs:14:24
8+
--> $DIR/bad-subst-const-kind.rs:13:24
99
|
1010
LL | pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] {
1111
| ^^^^^^^^ expected `u64`, found `usize`
@@ -18,12 +18,5 @@ LL | impl<const N: u64> Q for [u8; N] {
1818
| |
1919
| unsatisfied trait bound introduced here
2020

21-
error[E0308]: mismatched types
22-
--> $DIR/bad-subst-const-kind.rs:8:31
23-
|
24-
LL | impl<const N: u64> Q for [u8; N] {
25-
| ^ expected `usize`, found `u64`
26-
27-
error: aborting due to 3 previous errors
21+
error: aborting due to 2 previous errors
2822

29-
For more information about this error, try `rustc --explain E0308`.

‎tests/ui/const-generics/generic_const_exprs/type_mismatch.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ trait Q {
88
impl<const N: u64> Q for [u8; N] {}
99
//~^ ERROR not all trait items implemented
1010
//~| ERROR the constant `N` is not of type `usize`
11-
//~| ERROR mismatched types
1211

1312
pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
1413
//~^ ERROR the constant `13` is not of type `u64`

‎tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | impl<const N: u64> Q for [u8; N] {}
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation
1515

1616
error: the constant `13` is not of type `u64`
17-
--> $DIR/type_mismatch.rs:13:26
17+
--> $DIR/type_mismatch.rs:12:26
1818
|
1919
LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
2020
| ^^^^^^^^ expected `u64`, found `usize`
@@ -28,20 +28,14 @@ LL | impl<const N: u64> Q for [u8; N] {}
2828
| unsatisfied trait bound introduced here
2929

3030
error[E0308]: mismatched types
31-
--> $DIR/type_mismatch.rs:13:20
31+
--> $DIR/type_mismatch.rs:12:20
3232
|
3333
LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
3434
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; <[u8; 13] as Q>::ASSOC]`, found `()`
3535
| |
3636
| implicitly returns `()` as its body has no tail or `return` expression
3737

38-
error[E0308]: mismatched types
39-
--> $DIR/type_mismatch.rs:8:31
40-
|
41-
LL | impl<const N: u64> Q for [u8; N] {}
42-
| ^ expected `usize`, found `u64`
43-
44-
error: aborting due to 5 previous errors
38+
error: aborting due to 4 previous errors
4539

4640
Some errors have detailed explanations: E0046, E0308.
4741
For more information about an error, try `rustc --explain E0046`.

‎tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ mod v20 {
2626
}
2727

2828
impl<const v10: usize> v17<v10, v2> {
29-
//~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
30-
//~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
29+
//~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
30+
//~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
3131
pub const fn v21() -> v18 {
3232
//~^ ERROR cannot find type `v18` in this scope
3333
v18 { _p: () }

‎tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
7272
LL + #![feature(adt_const_params)]
7373
|
7474

75-
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
75+
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
7676
--> $DIR/unevaluated-const-ice-119731.rs:28:37
7777
|
7878
LL | impl<const v10: usize> v17<v10, v2> {
7979
| ^^
8080

81-
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
81+
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
8282
--> $DIR/unevaluated-const-ice-119731.rs:28:37
8383
|
8484
LL | impl<const v10: usize> v17<v10, v2> {

‎tests/ui/const-generics/transmute-fail.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ fn foo<const W: usize, const H: usize>(v: [[u32; H + 1]; W]) -> [[u32; W + 1]; H
1111

1212
fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
1313
//~^ ERROR: the constant `W` is not of type `usize`
14-
//~| ERROR: mismatched types
15-
//~| ERROR: mismatched types
1614
unsafe {
1715
std::mem::transmute(v)
1816
//~^ ERROR: the constant `W` is not of type `usize`

‎tests/ui/const-generics/transmute-fail.stderr

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ LL | std::mem::transmute(v)
1414
= note: target type: `[[u32; W + 1]; H]` (size can vary because of [u32; W + 1])
1515

1616
error: the constant `W` is not of type `usize`
17-
--> $DIR/transmute-fail.rs:17:9
17+
--> $DIR/transmute-fail.rs:15:9
1818
|
1919
LL | std::mem::transmute(v)
2020
| ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool`
2121

2222
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
23-
--> $DIR/transmute-fail.rs:24:9
23+
--> $DIR/transmute-fail.rs:22:9
2424
|
2525
LL | std::mem::transmute(v)
2626
| ^^^^^^^^^^^^^^^^^^^
@@ -29,7 +29,7 @@ LL | std::mem::transmute(v)
2929
= note: target type: `[u32; W * H * H]` (this type does not have a fixed size)
3030

3131
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
32-
--> $DIR/transmute-fail.rs:31:9
32+
--> $DIR/transmute-fail.rs:29:9
3333
|
3434
LL | std::mem::transmute(v)
3535
| ^^^^^^^^^^^^^^^^^^^
@@ -38,7 +38,7 @@ LL | std::mem::transmute(v)
3838
= note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture)
3939

4040
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
41-
--> $DIR/transmute-fail.rs:38:9
41+
--> $DIR/transmute-fail.rs:36:9
4242
|
4343
LL | std::mem::transmute(v)
4444
| ^^^^^^^^^^^^^^^^^^^
@@ -47,7 +47,7 @@ LL | std::mem::transmute(v)
4747
= note: target type: `[[u32; W]; H]` (size can vary because of [u32; W])
4848

4949
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
50-
--> $DIR/transmute-fail.rs:49:9
50+
--> $DIR/transmute-fail.rs:47:9
5151
|
5252
LL | std::mem::transmute(v)
5353
| ^^^^^^^^^^^^^^^^^^^
@@ -56,7 +56,7 @@ LL | std::mem::transmute(v)
5656
= note: target type: `[u32; W * H]` (this type does not have a fixed size)
5757

5858
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
59-
--> $DIR/transmute-fail.rs:56:9
59+
--> $DIR/transmute-fail.rs:54:9
6060
|
6161
LL | std::mem::transmute(v)
6262
| ^^^^^^^^^^^^^^^^^^^
@@ -65,7 +65,7 @@ LL | std::mem::transmute(v)
6565
= note: target type: `[[u32; W]; H]` (size can vary because of [u32; W])
6666

6767
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
68-
--> $DIR/transmute-fail.rs:65:9
68+
--> $DIR/transmute-fail.rs:63:9
6969
|
7070
LL | std::mem::transmute(v)
7171
| ^^^^^^^^^^^^^^^^^^^
@@ -74,7 +74,7 @@ LL | std::mem::transmute(v)
7474
= note: target type: `[u32; D * W * H]` (this type does not have a fixed size)
7575

7676
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
77-
--> $DIR/transmute-fail.rs:74:9
77+
--> $DIR/transmute-fail.rs:72:9
7878
|
7979
LL | std::mem::transmute(v)
8080
| ^^^^^^^^^^^^^^^^^^^
@@ -83,7 +83,7 @@ LL | std::mem::transmute(v)
8383
= note: target type: `[[u32; D * W]; H]` (size can vary because of [u32; D * W])
8484

8585
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
86-
--> $DIR/transmute-fail.rs:81:9
86+
--> $DIR/transmute-fail.rs:79:9
8787
|
8888
LL | std::mem::transmute(v)
8989
| ^^^^^^^^^^^^^^^^^^^
@@ -92,7 +92,7 @@ LL | std::mem::transmute(v)
9292
= note: target type: `[u8; L * 2]` (this type does not have a fixed size)
9393

9494
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
95-
--> $DIR/transmute-fail.rs:88:9
95+
--> $DIR/transmute-fail.rs:86:9
9696
|
9797
LL | std::mem::transmute(v)
9898
| ^^^^^^^^^^^^^^^^^^^
@@ -101,7 +101,7 @@ LL | std::mem::transmute(v)
101101
= note: target type: `[u16; L]` (this type does not have a fixed size)
102102

103103
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
104-
--> $DIR/transmute-fail.rs:95:9
104+
--> $DIR/transmute-fail.rs:93:9
105105
|
106106
LL | std::mem::transmute(v)
107107
| ^^^^^^^^^^^^^^^^^^^
@@ -110,27 +110,14 @@ LL | std::mem::transmute(v)
110110
= note: target type: `[[u8; 1]; L]` (this type does not have a fixed size)
111111

112112
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
113-
--> $DIR/transmute-fail.rs:104:9
113+
--> $DIR/transmute-fail.rs:102:9
114114
|
115115
LL | std::mem::transmute(v)
116116
| ^^^^^^^^^^^^^^^^^^^
117117
|
118118
= note: source type: `[[u32; 2 * H]; W + W]` (size can vary because of [u32; 2 * H])
119119
= note: target type: `[[u32; W + W]; 2 * H]` (size can vary because of [u32; W + W])
120120

121-
error[E0308]: mismatched types
122-
--> $DIR/transmute-fail.rs:12:53
123-
|
124-
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
125-
| ^ expected `usize`, found `bool`
126-
127-
error[E0308]: mismatched types
128-
--> $DIR/transmute-fail.rs:12:67
129-
|
130-
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
131-
| ^ expected `usize`, found `bool`
132-
133-
error: aborting due to 16 previous errors
121+
error: aborting due to 14 previous errors
134122

135-
Some errors have detailed explanations: E0308, E0512.
136-
For more information about an error, try `rustc --explain E0308`.
123+
For more information about this error, try `rustc --explain E0512`.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
fn foo<const N: usize>() -> [u8; N] {
22
bar::<N>()
33
//~^ ERROR the constant `N` is not of type `u8`
4-
//~| ERROR: mismatched types
54
}
65

76
fn bar<const N: u8>() -> [u8; N] {}
87
//~^ ERROR the constant `N` is not of type `usize`
9-
//~| ERROR: mismatched types
108
//~| ERROR mismatched types
119

1210
fn main() {}
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the constant `N` is not of type `usize`
2-
--> $DIR/type_mismatch.rs:7:26
2+
--> $DIR/type_mismatch.rs:6:26
33
|
44
LL | fn bar<const N: u8>() -> [u8; N] {}
55
| ^^^^^^^ expected `usize`, found `u8`
@@ -11,31 +11,19 @@ LL | bar::<N>()
1111
| ^ expected `u8`, found `usize`
1212
|
1313
note: required by a const generic parameter in `bar`
14-
--> $DIR/type_mismatch.rs:7:8
14+
--> $DIR/type_mismatch.rs:6:8
1515
|
1616
LL | fn bar<const N: u8>() -> [u8; N] {}
1717
| ^^^^^^^^^^^ required by this const generic parameter in `bar`
1818

1919
error[E0308]: mismatched types
20-
--> $DIR/type_mismatch.rs:7:26
20+
--> $DIR/type_mismatch.rs:6:26
2121
|
2222
LL | fn bar<const N: u8>() -> [u8; N] {}
2323
| --- ^^^^^^^ expected `[u8; N]`, found `()`
2424
| |
2525
| implicitly returns `()` as its body has no tail or `return` expression
2626

27-
error[E0308]: mismatched types
28-
--> $DIR/type_mismatch.rs:2:11
29-
|
30-
LL | bar::<N>()
31-
| ^ expected `u8`, found `usize`
32-
33-
error[E0308]: mismatched types
34-
--> $DIR/type_mismatch.rs:7:31
35-
|
36-
LL | fn bar<const N: u8>() -> [u8; N] {}
37-
| ^ expected `usize`, found `u8`
38-
39-
error: aborting due to 5 previous errors
27+
error: aborting due to 3 previous errors
4028

4129
For more information about this error, try `rustc --explain E0308`.

‎tests/ui/consts/issue-36163.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0391]: cycle detected when simplifying constant for the type system `Foo::B::{constant#0}`
1+
error[E0391]: cycle detected when simplifying constant for the type system `Foo::{constant#0}`
22
--> $DIR/issue-36163.rs:4:9
33
|
44
LL | B = A,
55
| ^
66
|
7-
note: ...which requires const-evaluating + checking `Foo::B::{constant#0}`...
7+
note: ...which requires const-evaluating + checking `Foo::{constant#0}`...
88
--> $DIR/issue-36163.rs:4:9
99
|
1010
LL | B = A,
@@ -19,7 +19,7 @@ note: ...which requires const-evaluating + checking `A`...
1919
|
2020
LL | const A: isize = Foo::B as isize;
2121
| ^^^^^^^^^^^^^^^
22-
= note: ...which again requires simplifying constant for the type system `Foo::B::{constant#0}`, completing the cycle
22+
= note: ...which again requires simplifying constant for the type system `Foo::{constant#0}`, completing the cycle
2323
note: cycle used when checking that `Foo` is well-formed
2424
--> $DIR/issue-36163.rs:3:1
2525
|

‎tests/ui/lifetimes/issue-95023.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ impl Fn(&isize) for Error {
99
//~^ ERROR associated function in `impl` without body
1010
//~| ERROR method `foo` is not a member of trait `Fn` [E0407]
1111
//~| ERROR associated type `B` not found for `Self` [E0220]
12-
//~| ERROR: associated type `B` not found for `Self`
1312
}
1413
fn main() {}

‎tests/ui/lifetimes/issue-95023.stderr

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,7 @@ error[E0220]: associated type `B` not found for `Self`
5656
LL | fn foo<const N: usize>(&self) -> Self::B<{ N }>;
5757
| ^ help: `Self` has the following associated type: `Output`
5858

59-
error[E0220]: associated type `B` not found for `Self`
60-
--> $DIR/issue-95023.rs:8:44
61-
|
62-
LL | fn foo<const N: usize>(&self) -> Self::B<{ N }>;
63-
| ^ help: `Self` has the following associated type: `Output`
64-
|
65-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
66-
67-
error: aborting due to 8 previous errors
59+
error: aborting due to 7 previous errors
6860

6961
Some errors have detailed explanations: E0046, E0183, E0220, E0229, E0277, E0407.
7062
For more information about an error, try `rustc --explain E0046`.

‎tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ struct Wrapper<const C: <i32 as Trait>::Type> {}
1414

1515
impl<const C: usize> Wrapper<C> {}
1616
//~^ ERROR the constant `C` is not of type `<i32 as Trait>::Type`
17-
//~| ERROR: mismatched types
1817

1918
fn main() {}

‎tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,5 @@ note: required by a const generic parameter in `Wrapper`
2020
LL | struct Wrapper<const C: <i32 as Trait>::Type> {}
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `Wrapper`
2222

23-
error[E0308]: mismatched types
24-
--> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:15:30
25-
|
26-
LL | impl<const C: usize> Wrapper<C> {}
27-
| ^ expected associated type, found `usize`
28-
|
29-
= note: expected associated type `<i32 as Trait>::Type`
30-
found type `usize`
31-
= help: consider constraining the associated type `<i32 as Trait>::Type` to `usize`
32-
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
33-
34-
error: aborting due to 3 previous errors
23+
error: aborting due to 2 previous errors
3524

36-
For more information about this error, try `rustc --explain E0308`.

‎tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
struct S<const L: usize>;
77

88
impl<const N: i32> Copy for S<N> {}
9-
//~^ ERROR: mismatched types
109
impl<const M: usize> Copy for S<M> {}
1110
//~^ ERROR: conflicting implementations of trait `Copy` for type `S<_>`
1211

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
error[E0119]: conflicting implementations of trait `Copy` for type `S<_>`
2-
--> $DIR/bad-const-wf-doesnt-specialize.rs:10:1
2+
--> $DIR/bad-const-wf-doesnt-specialize.rs:9:1
33
|
44
LL | impl<const N: i32> Copy for S<N> {}
55
| -------------------------------- first implementation here
6-
LL |
76
LL | impl<const M: usize> Copy for S<M> {}
87
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `S<_>`
98

10-
error[E0308]: mismatched types
11-
--> $DIR/bad-const-wf-doesnt-specialize.rs:8:31
12-
|
13-
LL | impl<const N: i32> Copy for S<N> {}
14-
| ^ expected `usize`, found `i32`
15-
16-
error: aborting due to 2 previous errors
9+
error: aborting due to 1 previous error
1710

18-
Some errors have detailed explanations: E0119, E0308.
19-
For more information about an error, try `rustc --explain E0119`.
11+
For more information about this error, try `rustc --explain E0119`.

‎tests/ui/transmutability/issue-101739-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod assert {
77
where
88
Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope
99
//~| the constant `ASSUME_ALIGNMENT` is not of type `Assume`
10-
//~| ERROR: mismatched types
1110
{
1211
}
1312
}

‎tests/ui/transmutability/issue-101739-1.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ LL | Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>,
1313
note: required by a const generic parameter in `TransmuteFrom`
1414
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
1515

16-
error[E0308]: mismatched types
17-
--> $DIR/issue-101739-1.rs:8:33
18-
|
19-
LL | Dst: TransmuteFrom<Src, ASSUME_ALIGNMENT>,
20-
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
21-
22-
error: aborting due to 3 previous errors
16+
error: aborting due to 2 previous errors
2317

24-
Some errors have detailed explanations: E0308, E0412.
25-
For more information about an error, try `rustc --explain E0308`.
18+
For more information about this error, try `rustc --explain E0412`.

‎tests/ui/transmutability/issue-101739-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod assert {
1717
Dst: TransmuteFrom<
1818
//~^ ERROR trait takes at most 2 generic arguments but 5 generic arguments were supplied
1919
Src,
20-
ASSUME_ALIGNMENT, //~ ERROR: mismatched types
20+
ASSUME_ALIGNMENT,
2121
ASSUME_LIFETIMES,
2222
ASSUME_VALIDITY,
2323
ASSUME_VISIBILITY,

‎tests/ui/transmutability/issue-101739-2.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ LL | | ASSUME_VALIDITY,
1111
LL | | ASSUME_VISIBILITY,
1212
| |_________________________________- help: remove the unnecessary generic arguments
1313

14-
error[E0308]: mismatched types
15-
--> $DIR/issue-101739-2.rs:20:17
16-
|
17-
LL | ASSUME_ALIGNMENT,
18-
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
19-
20-
error: aborting due to 2 previous errors
14+
error: aborting due to 1 previous error
2115

22-
Some errors have detailed explanations: E0107, E0308.
23-
For more information about an error, try `rustc --explain E0107`.
16+
For more information about this error, try `rustc --explain E0107`.

‎tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
trait Trait {
77
fn func<const N: u32>() -> [(); N];
88
//~^ ERROR: the constant `N` is not of type `usize`
9-
//~| ERROR: mismatched types
109
}
1110

1211
struct S {}
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/const-in-impl-fn-return-type.rs:16:39
2+
--> $DIR/const-in-impl-fn-return-type.rs:15:39
33
|
44
LL | fn func<const N: u32>() -> [(); { () }] {
55
| ^^ expected `usize`, found `()`
@@ -10,12 +10,6 @@ error: the constant `N` is not of type `usize`
1010
LL | fn func<const N: u32>() -> [(); N];
1111
| ^^^^^^^ expected `usize`, found `u32`
1212

13-
error[E0308]: mismatched types
14-
--> $DIR/const-in-impl-fn-return-type.rs:7:37
15-
|
16-
LL | fn func<const N: u32>() -> [(); N];
17-
| ^ expected `usize`, found `u32`
18-
19-
error: aborting due to 3 previous errors
13+
error: aborting due to 2 previous errors
2014

2115
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
Please sign in to comment.