diff options
| author | bors <bors@rust-lang.org> | 2014-10-01 11:27:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-01 11:27:23 +0000 |
| commit | 8ab6fce95e9b8a4ed27ecb7bee69784a02610e1d (patch) | |
| tree | 1fba572bb05c2be5fd0dbe66dd74967b1e2958a9 /src/test | |
| parent | ff2616e847ddf913e007d715732b5669b0f22672 (diff) | |
| parent | 065a5b0424221b246d59fd068d4e6eb5d1ae5be1 (diff) | |
| download | rust-8ab6fce95e9b8a4ed27ecb7bee69784a02610e1d.tar.gz rust-8ab6fce95e9b8a4ed27ecb7bee69784a02610e1d.zip | |
auto merge of #17653 : kaini/rust/master, r=alexcrichton
Fixes that unit-like structs cannot be used if they are re-exported and used in another crate. (ICE)
The relevant changes are in `rustc::metadata::{decoder, encoder}` and `rustc::middle::ty`.
A test case is included.
The problem is that the expressoin `UnitStruct` is an `ExprPath` to an `DefFn`, which is of expr kind `RvalueDatumExpr`, but for unit-struct ctors the expr kind should be `RvalueDpsExpr`. I fixed this (in a I guess clean way) by introducing `CtorFn` in the metadata and including a `is_ctor` flag in `DefFn`.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/auxiliary/issue-12660-aux.rs | 21 | ||||
| -rw-r--r-- | src/test/run-pass/issue-12660.rs | 21 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/test/auxiliary/issue-12660-aux.rs b/src/test/auxiliary/issue-12660-aux.rs new file mode 100644 index 00000000000..9f2bd5d0e93 --- /dev/null +++ b/src/test/auxiliary/issue-12660-aux.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +#![crate_name="issue12660aux"] + +pub use my_mod::{MyStruct, my_fn}; + +mod my_mod { + pub struct MyStruct; + + pub fn my_fn(my_struct: MyStruct) { + } +} diff --git a/src/test/run-pass/issue-12660.rs b/src/test/run-pass/issue-12660.rs new file mode 100644 index 00000000000..6b3fa587bc5 --- /dev/null +++ b/src/test/run-pass/issue-12660.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-12660-aux.rs + +extern crate issue12660aux; + +use issue12660aux::{my_fn, MyStruct}; + +#[allow(path_statement)] +fn main() { + my_fn(MyStruct); + MyStruct; +} |
