Rollup merge of #152565 - Kivooeo:ctor-diag, r=BoxyUwU
fix missleading error for tuple ctor r? BoxyUwU fixes https://github.com/rust-lang/rust/issues/151414
This commit is contained in:
commit
d93a38a488
5 changed files with 12 additions and 5 deletions
|
|
@ -2465,7 +2465,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let parent_did = tcx.parent(*def_id);
|
||||
(tcx.adt_def(parent_did), fn_args, parent_did)
|
||||
}
|
||||
_ => return non_adt_or_variant_res(),
|
||||
_ => {
|
||||
let e = self.dcx().span_err(
|
||||
span,
|
||||
"complex const arguments must be placed inside of a `const` block",
|
||||
);
|
||||
return Const::new_error(tcx, e);
|
||||
}
|
||||
};
|
||||
|
||||
let variant_def = adt_def.variant_with_id(variant_did);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
fn foo<T>() {
|
||||
[0; size_of::<*mut T>()];
|
||||
//~^ ERROR: tuple constructor with invalid base path
|
||||
//~^ ERROR: complex const arguments must be placed inside of a `const` block
|
||||
[0; const { size_of::<*mut T>() }];
|
||||
//~^ ERROR: generic parameters may not be used in const operations
|
||||
[0; const { size_of::<*mut i32>() }];
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: tuple constructor with invalid base path
|
||||
error: complex const arguments must be placed inside of a `const` block
|
||||
--> $DIR/size-of-generic-ptr-in-array-len.rs:6:9
|
||||
|
|
||||
LL | [0; size_of::<*mut T>()];
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ fn test_errors<const N: usize>() {
|
|||
//~| ERROR tuple constructor with invalid base path
|
||||
|
||||
accepts_point::<{ non_ctor(N, N) }>();
|
||||
//~^ ERROR tuple constructor with invalid base path
|
||||
//~^ ERROR complex const arguments must be placed inside of a `const` block
|
||||
|
||||
accepts_point::<{ CONST_ITEM(N, N) }>();
|
||||
//~^ ERROR tuple constructor with invalid base path
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ error: tuple constructor with invalid base path
|
|||
LL | accepts_point::<{ UnresolvedIdent(N, N) }>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: tuple constructor with invalid base path
|
||||
error: complex const arguments must be placed inside of a `const` block
|
||||
--> $DIR/tuple_ctor_erroneous.rs:34:23
|
||||
|
|
||||
LL | accepts_point::<{ non_ctor(N, N) }>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue