Skip to content

Commit 9e0a27c

Browse files
committed
Emit error instead of delayed bug when meeting mismatch type for const tuple
1 parent ad04f76 commit 9e0a27c

3 files changed

Lines changed: 19 additions & 2 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
@@ -2502,11 +2502,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
25022502
let tcx = self.tcx();
25032503

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

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

25122513
let exprs = exprs
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+

0 commit comments

Comments
 (0)