about summary refs log tree commit diff
path: root/src/rt/sync/rust_thread.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-02 04:21:38 -0800
committerbors <bors@rust-lang.org>2013-03-02 04:21:38 -0800
commit5aca7d6aef2f5e18b640d918b243a71fc893a65b (patch)
tree01f7955c31e98292ddb8b73bdea107a853806d31 /src/rt/sync/rust_thread.cpp
parentd3b94f6f341e935910aff59ea187af7b34055be8 (diff)
parent95bc9ea26df56b29f74583317ab080fdc7b99757 (diff)
downloadrust-5aca7d6aef2f5e18b640d918b243a71fc893a65b.tar.gz
rust-5aca7d6aef2f5e18b640d918b243a71fc893a65b.zip
auto merge of #5137 : yjh0502/rust/empty_struct, r=nikomatsakis
The fix is straight-forward, but there are several changes
while fixing the issue.

1) disallow `mut` keyword when making a new struct

In code base, there are following code,

```rust
struct Foo { mut a: int };
let a = Foo { mut a: 1 };
```

This is because of structural record, which is
deprecated corrently (see issue #3089) In structural
record, `mut` keyword should be allowd to control
mutability. But without structural record, we don't
need to allow `mut` keyword while constructing struct.

2) disallow structural records in parser level
This is related to 1). With structural records, there
is an ambiguity between empty block and empty struct
To solve the problem, I change parser to stop parsing
structural records. I think this is not a problem,
because structural records are not compiled already.

Misc. issues

There is an ambiguity between empty struct vs. empty match stmt.
with following code,

```rust
match x{} {}
```

Two interpretation is possible, which is listed blow

```rust
match (x{}) {} //  matching with newly-constructed empty struct
(match x{}) {}  //  matching with empty enum(or struct) x
                //  and then empty block
```

It seems that there is no such code in rust code base, but
there is one test which uses empty match statement:
https://github.com/mozilla/rust/blob/incoming/src/test/run-pass/issue-3037.rs

All other cases could be distinguished with look-ahead,
but this can't be. One possible solution is wrapping with
parentheses when matching with an uninhabited type.

```rust
enum what { }
fn match_with_empty(x: what) -> ~str {
    match (x) { //use parentheses to remove the ambiguity
    }
}
```
Diffstat (limited to 'src/rt/sync/rust_thread.cpp')
0 files changed, 0 insertions, 0 deletions