Skip to content

[moveOnly] Add an @_noImplicitCopy decl attribute and allow it to be only attached to local lets. #39927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gottesmm
Copy link
Contributor

Some notes:

  1. This is not actually wired up to any part of codegen. Instead, this PR just
    has the code necessary to parse the attribute and to ensure that we use it only
    on local lets. The rest will come in subsequent commits.

  2. I am allowing for the attribute to be attached to generic things in Sema
    since we do not have enough information in the TypeChecker to distinguish in
    between structs with a type parameter but that have all non-generic stored vars
    from one with generic stored vars. We can only support the later with opaque
    values but the former we can support without opaque values (and is one of the
    use cases we are interested in).

rdar://83957088

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

…only attached to local lets.

Some notes:

1. This is not actually wired up to any part of codegen. Instead, this PR just
has the code necessary to parse the attribute and to ensure that we use it only
on local lets. The rest will come in subsequent commits.

2. I am allowing for the attribute to be attached to generic things in Sema
since we do not have enough information in the TypeChecker to distinguish in
between structs with a type parameter but that have all non-generic stored vars
from one with generic stored vars. We can only support the later with opaque
values but the former we can support without opaque values (and is one of the
use cases we are interested in).

rdar://83957088
@gottesmm gottesmm requested a review from DougGregor October 26, 2021 20:02
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test


if (vd->hasStorage()) {
// We do not support fields of nominal types now.
if (isa<NominalTypeDecl>(dc)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want !dc->isLocalContext() here. It should be able to subsume this check and the one below as well. (You'll likely want a separate check for static).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll do that in a subsequent PR.

@gottesmm gottesmm merged commit 8aef84c into swiftlang:main Oct 26, 2021
@gottesmm gottesmm deleted the pr-7b7eae43b3c94f52f927ce574f94861e33da7f4a branch October 26, 2021 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants