Skip to content

tuple structs with all-public fields can not be instantiated if one of the fields has an external attribute #66555

Closed
@DarkKirb

Description

@DarkKirb

In current nightly (2019-11-18 and also 2019-11-16) and stable (1.39.0), tuple structs can not be instantiated from an outside module directly if

  • all of the members are public
  • at least one of the struct members has an attribute (like #[serde(rename = "some_name")])

Example code that is broken:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7108f99f96b03247b7d44bdf47091a1a

In the same module the code works:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a896f6f28a050228c4e91d9e3bcc5557

Same with normal structs:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=2083f2cae68b7378652bd239bb122d20

The broken code works in 1.38.0:

https://godbolt.org/z/_8KX6P

Meta

One of the affected installations:

rustc 1.41.0-nightly (5c5b8afd8 2019-11-16)
binary: rustc
commit-hash: 5c5b8afd80e6fa1d24632153cb2257c686041d41
commit-date: 2019-11-16
host: x86_64-apple-darwin
release: 1.41.0-nightly
LLVM version: 9.0

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-visibilityArea: Visibility / privacyC-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions