From 8e577a5d286f242f1e00df2efc83278b94c48fa2 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 18 Dec 2025 12:26:28 -0500 Subject: [PATCH] Prevent accidental copies of TypeStructure (#6519) The TypeStructure is pretty large, with multiple vectors inside, and we don't want to do a bunch of mallocs for no reason. There is no need for a copy ever at this time. Based on #6517 --- toolchain/check/type_structure.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/toolchain/check/type_structure.h b/toolchain/check/type_structure.h index 1ff87154de5a..7b82a4c45909 100644 --- a/toolchain/check/type_structure.h +++ b/toolchain/check/type_structure.h @@ -24,6 +24,11 @@ namespace Carbon::Check { // better, more specified, match. class TypeStructure : public Printable { public: + // TypeStructure is a pretty heavy data structure, avoid accidental copies. + // TODO: Add a Clone() method if we want to make a copy of this in the future. + TypeStructure(TypeStructure&&) noexcept = default; + auto operator=(TypeStructure&&) noexcept -> TypeStructure& = default; + enum class CompareTest { // Test whether `this` has the same structure as `other`, or `this` is // strictly more specific (has more concrete values) than `other` while