Skip to content

RFC: changes to implicit copyability #9098

Closed
@metajack

Description

@metajack

Right now any struct that contains only implicitly copyable types is implicitly copyable and there is no way to turn this off.

We need a way to annotate that a struct should not be implicitly copyable at the very least.

I think a better solution would to make the default not to have structs be implicitly copyable unless annotated specifically that they are. That is, the default would be reversed.

This is an issue for things like Option where T is implicitly copyable. It completely changes the semantics of functions like unwrap(). Depending on the type of T, this may move or copy.

This recently caused a Servo bug where the different between unwrap() and with_mut_ref() caused an infinite loop:

sammykim/servo@7a1493a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions