about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-03-31 18:13:44 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-03-31 18:59:46 -0700
commit683197975c119e4c03588fa729dee4f87902f534 (patch)
tree3f547b7f4bd572eda171dd378a455584e60eefed /src/rustllvm/RustWrapper.cpp
parentb8ef9fd9c9f642ce7b8aed82782a1ed745d08d64 (diff)
downloadrust-683197975c119e4c03588fa729dee4f87902f534.tar.gz
rust-683197975c119e4c03588fa729dee4f87902f534.zip
rustc: Switch tuple structs to have private fields
This is a continuation of the work done in #13184 to make struct fields private
by default. This commit finishes RFC 4 by making all tuple structs have private
fields by default. Note that enum variants are not affected.

A tuple struct having a private field means that it cannot be matched on in a
pattern match (both refutable and irrefutable), and it also cannot have a value
specified to be constructed. Similarly to private fields, switching the type of
a private field in a tuple struct should be able to be done in a backwards
compatible way.

The one snag that I ran into which wasn't mentioned in the RFC is that this
commit also forbids taking the value of a tuple struct constructor. For example,
this code now fails to compile:

    mod a {
        pub struct A(int);
    }

    let a: fn(int) -> a::A = a::A; //~ ERROR: first field is private

Although no fields are bound in this example, it exposes implementation details
through the type itself. For this reason, taking the value of a struct
constructor with private fields is forbidden (outside the containing module).

RFC: 0004-private-fields
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions