Skip to content

Commit 417f15b

Browse files
authored
Rollup merge of rust-lang#150869 - fix/150841, r=BoxyUwU
Emit error instead of delayed bug when meeting mismatch type for const tuple And rename some tests Fixes rust-lang#150841 r? @BoxyUwU
2 parents 776517c + 2f35424 commit 417f15b

6 files changed

Lines changed: 23 additions & 6 deletions

File tree

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,11 +2533,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
25332533
let tcx = self.tcx();
25342534

25352535
let FeedConstTy::WithTy(ty) = feed else {
2536-
return Const::new_error_with_message(tcx, span, "unsupported const tuple");
2536+
return Const::new_error_with_message(tcx, span, "const tuple lack type information");
25372537
};
25382538

25392539
let ty::Tuple(tys) = ty.kind() else {
2540-
return Const::new_error_with_message(tcx, span, "const tuple must have a tuple type");
2540+
let e = tcx.dcx().span_err(span, format!("expected `{}`, found const tuple", ty));
2541+
return Const::new_error(tcx, e);
25412542
};
25422543

25432544
let exprs = exprs

tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_complex.rs renamed to tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs

File renamed without changes.

tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_complex.stderr renamed to tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: complex const arguments must be placed inside of a `const` block
2-
--> $DIR/adt_expr_arg_tuple_expr_complex.rs:13:25
2+
--> $DIR/tuple_expr_arg_complex.rs:13:25
33
|
44
LL | takes_tuple::<{ (N, N + 1) }>();
55
| ^^^^^
66

77
error: complex const arguments must be placed inside of a `const` block
8-
--> $DIR/adt_expr_arg_tuple_expr_complex.rs:14:25
8+
--> $DIR/tuple_expr_arg_complex.rs:14:25
99
|
1010
LL | takes_tuple::<{ (N, T::ASSOC + 1) }>();
1111
| ^^^^^^^^^^^^
1212

1313
error: complex const arguments must be placed inside of a `const` block
14-
--> $DIR/adt_expr_arg_tuple_expr_complex.rs:16:36
14+
--> $DIR/tuple_expr_arg_complex.rs:16:36
1515
|
1616
LL | takes_nested_tuple::<{ (N, (N, N + 1)) }>();
1717
| ^^^^^
1818

1919
error: generic parameters may not be used in const operations
20-
--> $DIR/adt_expr_arg_tuple_expr_complex.rs:17:44
20+
--> $DIR/tuple_expr_arg_complex.rs:17:44
2121
|
2222
LL | takes_nested_tuple::<{ (N, (N, const { N + 1 })) }>();
2323
| ^
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(min_generic_const_args)]
2+
#![expect(incomplete_features)]
3+
4+
pub fn takes_nested_tuple<const N: u32>() {
5+
takes_nested_tuple::<{ () }> //~ ERROR expected `u32`, found const tuple
6+
}
7+
8+
fn main() {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected `u32`, found const tuple
2+
--> $DIR/tuple_expr_arg_mismatch_type.rs:5:28
3+
|
4+
LL | takes_nested_tuple::<{ () }>
5+
| ^^
6+
7+
error: aborting due to 1 previous error
8+

tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_simple.rs renamed to tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs

File renamed without changes.

0 commit comments

Comments
 (0)