Skip to content

Commit 11a6497

Browse files
authored
Unrolled build for #152565
Rollup merge of #152565 - Kivooeo:ctor-diag, r=BoxyUwU fix missleading error for tuple ctor r? BoxyUwU fixes #151414
2 parents a423f68 + f63007c commit 11a6497

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2465,7 +2465,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24652465
let parent_did = tcx.parent(*def_id);
24662466
(tcx.adt_def(parent_did), fn_args, parent_did)
24672467
}
2468-
_ => return non_adt_or_variant_res(),
2468+
_ => {
2469+
let e = self.dcx().span_err(
2470+
span,
2471+
"complex const arguments must be placed inside of a `const` block",
2472+
);
2473+
return Const::new_error(tcx, e);
2474+
}
24692475
};
24702476

24712477
let variant_def = adt_def.variant_with_id(variant_did);

tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
fn foo<T>() {
66
[0; size_of::<*mut T>()];
7-
//~^ ERROR: tuple constructor with invalid base path
7+
//~^ ERROR: complex const arguments must be placed inside of a `const` block
88
[0; const { size_of::<*mut T>() }];
99
//~^ ERROR: generic parameters may not be used in const operations
10+
[0; const { size_of::<*mut i32>() }];
1011
}
1112

1213
fn main() {}

tests/ui/const-generics/mgca/size-of-generic-ptr-in-array-len.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: tuple constructor with invalid base path
1+
error: complex const arguments must be placed inside of a `const` block
22
--> $DIR/size-of-generic-ptr-in-array-len.rs:6:9
33
|
44
LL | [0; size_of::<*mut T>()];

tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn test_errors<const N: usize>() {
3232
//~| ERROR tuple constructor with invalid base path
3333

3434
accepts_point::<{ non_ctor(N, N) }>();
35-
//~^ ERROR tuple constructor with invalid base path
35+
//~^ ERROR complex const arguments must be placed inside of a `const` block
3636

3737
accepts_point::<{ CONST_ITEM(N, N) }>();
3838
//~^ ERROR tuple constructor with invalid base path

tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ error: tuple constructor with invalid base path
2727
LL | accepts_point::<{ UnresolvedIdent(N, N) }>();
2828
| ^^^^^^^^^^^^^^^^^^^^^
2929

30-
error: tuple constructor with invalid base path
30+
error: complex const arguments must be placed inside of a `const` block
3131
--> $DIR/tuple_ctor_erroneous.rs:34:23
3232
|
3333
LL | accepts_point::<{ non_ctor(N, N) }>();

0 commit comments

Comments
 (0)