Add #[derive(Clone, Copy)]
to anonymous adts
Fix the `AssertBoundIsClone` error for anonymous adts.
This commit is contained in:
parent
822d6dc5fd
commit
2b04ca94bb
5 changed files with 193 additions and 176 deletions
|
@ -110,7 +110,9 @@ fn cs_clone_simple(
|
|||
&& !seen_type_names.insert(name)
|
||||
{
|
||||
// Already produced an assertion for this type.
|
||||
} else {
|
||||
// Anonymous structs or unions must be eliminated as they cannot be
|
||||
// type parameters.
|
||||
} else if !field.ty.kind.is_anon_adt() {
|
||||
// let _: AssertParamIsClone<FieldTy>;
|
||||
super::assert_ty_bounds(
|
||||
cx,
|
||||
|
|
|
@ -123,6 +123,8 @@ fn assert_ty_bounds(
|
|||
span: Span,
|
||||
assert_path: &[Symbol],
|
||||
) {
|
||||
// Deny anonymous structs or unions to avoid wierd errors.
|
||||
assert!(!ty.kind.is_anon_adt(), "Anonymous structs or unions cannot be type parameters");
|
||||
// Generate statement `let _: assert_path<ty>;`.
|
||||
let span = cx.with_def_site_ctxt(span);
|
||||
let assert_path = cx.path_all(span, true, cx.std_path(assert_path), vec![GenericArg::Type(ty)]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue