Commit Graph

56629 Commits

Author SHA1 Message Date
Vadim Petrochenkov
93067ca089 Address comments and add requested tests 2016-09-03 13:39:35 +03:00
Vadim Petrochenkov
e67c2282af Fix rebase, fix some tests 2016-09-03 13:39:35 +03:00
Vadim Petrochenkov
5f975e969b Support unions in borrow checker
Add some more tests
2016-09-03 13:39:35 +03:00
Vadim Petrochenkov
59ccb7b6db Support deriving some traits for unions 2016-09-03 13:39:35 +03:00
Vadim Petrochenkov
079c390d50 Generate debuginfo for unions 2016-09-03 13:39:35 +03:00
Vadim Petrochenkov
d9b332bd69 Translate union constants
Fix alignment for packed unions
Add some missing privacy test
Get rid of `unimplemented_unions` macro
2016-09-03 13:39:35 +03:00
Vadim Petrochenkov
2dc2fc5fc5 Fix rebase 2016-09-03 13:39:35 +03:00
Vadim Petrochenkov
0cb19389b0 Fix buggy field access translation 2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
bea0b15935 Implement drop translation and add lint for unions with drop fields
Fix some typeck bugs blocking drop tests
2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
e88d4ca0e1 Make accesses to union fields unsafe 2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
f3b41c18a8 Check fields in union patters/expressions
Make parsing of union items backward compatible
Add some tests
2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
957971b63a Implement layout calculation and add more trans stubs 2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
c2ca1530db Fix rebase + address comments 2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
5f9ef3c8b2 Implement encoding/decoding unions in metadata
Add well-formedness check
Implement some more missing code
2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
6792bd99fe Support unions in rustdoc 2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
641d8e9e4c Some better support for unions through the compiler 2016-09-03 13:39:34 +03:00
Vadim Petrochenkov
a014323e45 Lower unions from AST to HIR and from HIR to types
Parse union items and add a feature for them
2016-09-03 13:39:33 +03:00
Vadim Petrochenkov
cbd912baba Add union types 2016-09-03 13:37:25 +03:00
Vadim Petrochenkov
35d52a003b Add unions to definition map 2016-09-03 13:37:25 +03:00
Vadim Petrochenkov
4001c039de Add unions to HIR 2016-09-03 13:37:25 +03:00
Vadim Petrochenkov
1db878fd38 Add unions to AST 2016-09-03 13:37:25 +03:00
bors
a029ea343f Auto merge of #35957 - alexcrichton:macros-1.1, r=nrc
rustc: Implement custom derive (macros 1.1)

This commit is an implementation of [RFC 1681] which adds support to the
compiler for first-class user-define custom `#[derive]` modes with a far more
stable API than plugins have today.

[RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md

The main features added by this commit are:

* A new `rustc-macro` crate-type. This crate type represents one which will
  provide custom `derive` implementations and perhaps eventually flower into the
  implementation of macros 2.0 as well.

* A new `rustc_macro` crate in the standard distribution. This crate will
  provide the runtime interface between macro crates and the compiler. The API
  here is particularly conservative right now but has quite a bit of room to
  expand into any manner of APIs required by macro authors.

* The ability to load new derive modes through the `#[macro_use]` annotations on
  other crates.

All support added here is gated behind the `rustc_macro` feature gate, both for
the library support (the `rustc_macro` crate) as well as the language features.

There are a few minor differences from the implementation outlined in the RFC,
such as the `rustc_macro` crate being available as a dylib and all symbols are
`dlsym`'d directly instead of having a shim compiled. These should only affect
the implementation, however, not the public interface.

This commit also ended up touching a lot of code related to `#[derive]`, making
a few notable changes:

* Recognized derive attributes are no longer desugared to `derive_Foo`. Wasn't
  sure how to keep this behavior and *not* expose it to custom derive.

* Derive attributes no longer have access to unstable features by default, they
  have to opt in on a granular level.

* The `derive(Copy,Clone)` optimization is now done through another "obscure
  attribute" which is just intended to ferry along in the compiler that such an
  optimization is possible. The `derive(PartialEq,Eq)` optimization was also
  updated to do something similar.

---

One part of this PR which needs to be improved before stabilizing are the errors
and exact interfaces here. The error messages are relatively poor quality and
there are surprising spects of this such as `#[derive(PartialEq, Eq, MyTrait)]`
not working by default. The custom attributes added by the compiler end up
becoming unstable again when going through a custom impl.

Hopefully though this is enough to start allowing experimentation on crates.io!
2016-09-03 00:11:18 -07:00
Alex Burka
0efc4bf387 rustbuild: add config.toml option to disable codegen tests 2016-09-03 06:04:03 +00:00
Alex Burka
a34485ff19 change wording 2016-09-03 02:02:03 -04:00
bors
d128e6bc74 Auto merge of #35856 - phimuemue:master, r=brson
Introduce max_by/min_by on iterators

See https://github.com/rust-lang/rfcs/issues/1722 for reference.

It seems that there is `min`, `max` (simple computation of min/max), `min_by_key`, `max_by_key` (min/max by comparing mapped values) but no `min_by` and `max_by` (min/max according to comparison function). However, e.g. on vectors or slices there is `sort`, `sort_by_key` and `sort_by`.
2016-09-02 21:02:41 -07:00
bors
100b309fd1 Auto merge of #36227 - jonathandturner:rollup, r=jonathandturner
Rollup of 12 pull requests

- Successful merges: #35754, #35793, #36099, #36160, #36171, #36178, #36180, #36190, #36198, #36205, #36210, #36223
- Failed merges:
2016-09-02 17:44:38 -07:00
Alex Burka
63520c1089 indicate where to copy config.toml.example 2016-09-02 19:54:02 -04:00
Jonathan Turner
c70149004a Rollup merge of #36223 - abhiQmar:e0558-formatting, r=jonathandturner
Update compiler error E0558 to use new error format

Fixes #36196 part of #35233

r? @jonathandturner
2016-09-02 15:28:52 -07:00
Jonathan Turner
5284bee03a Rollup merge of #36210 - EugeneGonzalez:E0529, r=jonathandturner
Fixed E0529's label and unit test

Fixes #36195 part of #35233.

This is ready for review, but will likely fail Travis due to #36138. I changed the wording of the label, so feedback on that would be appreciated.

r? @jonathandturner
2016-09-02 15:28:52 -07:00
Jonathan Turner
6736bad424 Rollup merge of #36205 - EugeneGonzalez:E0528, r=jonathandturner
Fixed E0528 label and unit test

Fixes #36194 part of #35233.

r? @jonathandturner
2016-09-02 15:28:52 -07:00
Jonathan Turner
b9996909ac Rollup merge of #36198 - alexcrichton:fix-travis, r=brson
test: Add a min-llvm-version directive

We've got tests which require a particular version of LLVM to run as they're
testing bug fixes. Our build system, however, supports multiple LLVM versions,
so we can't run these tests on all LLVM versions.

This adds a new `min-llvm-version` directive for tests so they can opt out of
being run on older versions of LLVM. This then namely applies that logic to the
`issue-36023.rs` test case and...

Closes #36138
2016-09-02 15:28:52 -07:00
Jonathan Turner
75fb28f6a0 Rollup merge of #36190 - 0xmohit:pr/issue-31216, r=alexcrichton
configure: check if any of the arguments contain --help

Currently it checks only the first argument.

Fixes #31216
2016-09-02 15:28:52 -07:00
Jonathan Turner
49125bd794 Rollup merge of #36180 - frewsxcv:patch-33, r=alexcrichton
Transition Travis CI to use rustbuild.
2016-09-02 15:28:51 -07:00
Jonathan Turner
fa95551b9b Rollup merge of #36178 - jonathandturner:windows_colors, r=nikomatsakis
Special case a few colors for Windows

As brought up on [this thread](https://github.com/rust-lang/rust/issues/33240#issuecomment-243310067) the colors used in error messages on Windows can be difficult to read because of the lack of bold.

This PR makes a few changes to improve readability, namely:
* Rather than using BRIGHT_BLUE, on Windows we now use BRIGHT_CYAN, which is easier to read on black when you do not have bold
* We used BRIGHT_YELLOW rather than YELLOW, for the same reason
* Titles will be BRIGHT_WHITE now, to give the illusion of being bold

Some examples:

![warning](https://cloud.githubusercontent.com/assets/547158/18148466/9aa9bbe2-6f8e-11e6-927f-d0eec53cac32.PNG)

![error](https://cloud.githubusercontent.com/assets/547158/18148488/ba9fb186-6f8e-11e6-8d8e-e93d569f61de.PNG)

r? @nikomatsakis

cc @retep998
2016-09-02 15:28:51 -07:00
Jonathan Turner
59c0ff6314 Rollup merge of #36171 - jonathandturner:temporary_value, r=nikomatsakis
Update lifetime errors to specifically note temporaries

This PR updates the error message we give in the case of a temporary value not living long enough.

Before:

<img width="497" alt="screen shot 2016-08-31 at 10 02 47 am" src="https://cloud.githubusercontent.com/assets/547158/18138551/27a06794-6f62-11e6-9ee2-bdf8bed75ca7.png">

Now:

<img width="488" alt="screen shot 2016-08-31 at 10 03 01 am" src="https://cloud.githubusercontent.com/assets/547158/18138557/2e5cf322-6f62-11e6-9047-4a78abf3d78c.png">

Specifically, it makes the following changes:

* Detects if a temporary is being used.  If so, it changes the labels to mention that a temporary value specifically is in question
* Simplifies wording of the existing labels to focus on lifetimes rather than values being valid
* Changes the help to a note, since the help+span wasn't as helpful (and sometimes more confusing) than just a note.

r? @nikomatsakis
2016-09-02 15:28:51 -07:00
Jonathan Turner
9327edd773 Rollup merge of #36160 - Aatch:normalize-closure-sig, r=eddyb
Normalize the function signature of closures

Previously we didn't normalize the function signatures used for
closures. This didn't cause a problem in most cases, but caused an ICE
in during MIR type checking.

Fixes #36139

r? @eddyb
2016-09-02 15:28:51 -07:00
Jonathan Turner
445fe52b72 Rollup merge of #36099 - skade:better-try-documentation, r=steveklabnik
Document try!'s error conversion behaviour

try!'s documentation currently doesn't document the error conversion behaviour of the macro. This patch extends the documentation.

Open questions:
* is it worthwhile to have seperate examples with and without wrapping behaviour? It's not immediately obvious that From<T> for T is always defined. Though this is necessary for the macro to work in any case, is this the place to expect that knowledge.
2016-09-02 15:28:51 -07:00
Jonathan Turner
c330376a4d Rollup merge of #35793 - matthew-piziak:add-rhs-example, r=steveklabnik
demonstrate `RHS != Self` use cases for `Add` and `Sub`
2016-09-02 15:28:50 -07:00
Jonathan Turner
dfe0f88de8 Rollup merge of #35754 - QuietMisdreavus:must-use-reference, r=Manishearth
Add `must_use` to the Reference

I'm a bit uncertain about the exact phrasing, but having it mentioned at all is probably better than before.
2016-09-02 15:28:50 -07:00
Abhishek Kumar
18434f9457 Update compiler error E0558 to use new error format
Fixes #36196 part of #35233
2016-09-03 02:17:45 +05:30
Alex Crichton
ecc6c39e87 rustc: Implement custom derive (macros 1.1)
This commit is an implementation of [RFC 1681] which adds support to the
compiler for first-class user-define custom `#[derive]` modes with a far more
stable API than plugins have today.

[RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md

The main features added by this commit are:

* A new `rustc-macro` crate-type. This crate type represents one which will
  provide custom `derive` implementations and perhaps eventually flower into the
  implementation of macros 2.0 as well.

* A new `rustc_macro` crate in the standard distribution. This crate will
  provide the runtime interface between macro crates and the compiler. The API
  here is particularly conservative right now but has quite a bit of room to
  expand into any manner of APIs required by macro authors.

* The ability to load new derive modes through the `#[macro_use]` annotations on
  other crates.

All support added here is gated behind the `rustc_macro` feature gate, both for
the library support (the `rustc_macro` crate) as well as the language features.

There are a few minor differences from the implementation outlined in the RFC,
such as the `rustc_macro` crate being available as a dylib and all symbols are
`dlsym`'d directly instead of having a shim compiled. These should only affect
the implementation, however, not the public interface.

This commit also ended up touching a lot of code related to `#[derive]`, making
a few notable changes:

* Recognized derive attributes are no longer desugared to `derive_Foo`. Wasn't
  sure how to keep this behavior and *not* expose it to custom derive.

* Derive attributes no longer have access to unstable features by default, they
  have to opt in on a granular level.

* The `derive(Copy,Clone)` optimization is now done through another "obscure
  attribute" which is just intended to ferry along in the compiler that such an
  optimization is possible. The `derive(PartialEq,Eq)` optimization was also
  updated to do something similar.

---

One part of this PR which needs to be improved before stabilizing are the errors
and exact interfaces here. The error messages are relatively poor quality and
there are surprising spects of this such as `#[derive(PartialEq, Eq, MyTrait)]`
not working by default. The custom attributes added by the compiler end up
becoming unstable again when going through a custom impl.

Hopefully though this is enough to start allowing experimentation on crates.io!

syntax-[breaking-change]
2016-09-02 12:52:56 -07:00
johnthagen
eb1c7161dd Update supported Windows versions to match Getting Started page. 2016-09-02 15:32:13 -04:00
Federico Ravasio
059094f3f2 Moved test on E0493 from compile-fail to ui. 2016-09-02 19:55:14 +02:00
Corey Farwell
3a96fe3275 Transition Travis CI to use rustbuild. 2016-09-02 12:48:55 -04:00
bors
ef9786ce0e Auto merge of #36084 - apasel422:counter, r=bluss
Address FIXME in libcollectionstest/btree/set.rs
2016-09-02 09:13:00 -07:00
bors
689c6c48ec Auto merge of #36024 - japaric:mips64, r=alexcrichton
add mips64-gnu and mips64el-gnu targets

With this commit one can build no_core (and probably no_std as well)
Rust programs for these targets. It's not yet possible to cross compile
std for these targets because rust-lang/libc doesn't know about the
mips64 architecture.

These targets have been tested by cross compiling the "smallest hello"
program (see code below) and then running it under QEMU.

``` rust

extern {
    fn puts(_: *const u8);
}

fn start(_: isize, _: *const *const u8) -> isize {
    unsafe {
        let msg = b"Hello, world!\0";
        puts(msg as *const _ as *const u8);
    }
    0
}

trait Copy {}

trait Sized {}
```

cc #36015
r? @alexcrichton
cc @brson

The cabi stuff is likely wrong. I just copied cabi_mips source and changed some `4`s to `8`s and `32`s to `64`s. It was enough to get libc's `puts` to work but I'd like someone familiar with this module to check it.
2016-09-02 03:01:48 -07:00
Federico Ravasio
ed5e5df596 E0493: showing a label where the destructor is defined. 2016-09-02 11:44:46 +02:00
Ahmed Charles
cd8f0aa7f2 Remove --{enable|disable}-orbit from configure.
Fixes #35956.
2016-09-02 01:57:31 -07:00
bors
022cb6d11d Auto merge of #35915 - llogiq:rfc-1623, r=nikomatsakis
implementing RFC 1623. This fixes #35897.

This is a work in progress. In particular, I want to add more tests,
especially the compile-fail test is very bare-bones.
2016-09-01 22:24:36 -07:00
Eugene R Gonzalez
7f95bb0dbd Fixed E0529's label and unit test 2016-09-01 22:35:25 -04:00