A class defines a destructor but neither declares nor deletes its copy constructor and copy assignment

tx0/cpp:destructor-without-copy-operationsstrictwarningreliability/object-contractsdepth fastbug

What it finds

A class that needs a destructor usually owns a resource, and the copy operations the compiler generates copy the handle, so two objects free it. Declaring the copy constructor and copy assignment, as defined, defaulted or deleted, states what copying means. Classes with base classes or macros among their members are left alone, since those may take care of copying.

From the rule's source, destructor_without_copy_operations.rs.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:destructor-without-copy-operations" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/cpp:destructor-without-copy-operations] reason="..."

tx0 explain tx0/cpp:destructor-without-copy-operations shows the same in the terminal. Found a false positive? Report it.