diff options
| author | bors <bors@rust-lang.org> | 2017-06-28 01:12:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-06-28 01:12:12 +0000 |
| commit | 4079e6128f6cff3270ed2b0ebdc62fb6b1f4b5d7 (patch) | |
| tree | 6fd26e62bb4ec2af0808f61de8e67e12d2946ac1 /src/test/run-pass/thinlto | |
| parent | f590a44ce61888c78b9044817d8b798db5cd2ffd (diff) | |
| parent | 69076f3a786e0412510af925f38a2a7f78b8e6ef (diff) | |
| download | rust-4079e6128f6cff3270ed2b0ebdc62fb6b1f4b5d7.tar.gz rust-4079e6128f6cff3270ed2b0ebdc62fb6b1f4b5d7.zip | |
Auto merge of #42417 - eddyb:separate-fn-sig, r=nikomatsakis
Don't drag function signatures along function item types.
This PR separates the signature of a function from the "function item type" (`TyFnDef`), leaving only the `DefId` and parameter `Substs`, making them even more like (captureless) closure types.
The motivation for this change is reducing typesystem complexity, and its consequences:
* operating on the signature instead of just the parameters was less efficient
* specifically, signatures can easily add several levels of depth on top of the parameter types
* and the signatured were always substituted and normalized, so typically even more complex
* it was *the only* type that was *both* nominal (identity) and structural (signature)
* harder to model in Chalk than either a purely nominal or structural type
* subtyping worked on the signature but parameters were always invariant
* call type-checking was transforming signatures but keeping the nominal half intact
* the signature could therefore get out of sync during type inference in several ways
That last point comes with a `[breaking-change]`, because functions with `'static` in their return types will now *not* be as usable as if they were using lifetime parameters instead:
```rust
// Will cause lifetime mismatch in main after this PR.
fn bar() -> &'static str { "bar" }
// Will continue to work fine, as every use can choose its own lifetime.
fn bar<'a>() -> &'a str { "bar" }
fn main() {
let s = String::from("foo");
Some(&s[..]).unwrap_or_else(bar);
}
```
r? @nikomatsakis
Diffstat (limited to 'src/test/run-pass/thinlto')
0 files changed, 0 insertions, 0 deletions
