Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2502,11 +2502,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let tcx = self.tcx();

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

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

let exprs = exprs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: complex const arguments must be placed inside of a `const` block
--> $DIR/adt_expr_arg_tuple_expr_complex.rs:13:25
--> $DIR/tuple_expr_arg_complex.rs:13:25
|
LL | takes_tuple::<{ (N, N + 1) }>();
| ^^^^^

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

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

error: generic parameters may not be used in const operations
--> $DIR/adt_expr_arg_tuple_expr_complex.rs:17:44
--> $DIR/tuple_expr_arg_complex.rs:17:44
|
LL | takes_nested_tuple::<{ (N, (N, const { N + 1 })) }>();
| ^
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(min_generic_const_args)]
#![expect(incomplete_features)]

pub fn takes_nested_tuple<const N: u32>() {
takes_nested_tuple::<{ () }> //~ ERROR expected `u32`, found const tuple
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected `u32`, found const tuple
--> $DIR/tuple_expr_arg_mismatch_type.rs:5:28
|
LL | takes_nested_tuple::<{ () }>
| ^^

error: aborting due to 1 previous error

Loading