Commit Graph

51956 Commits

Author SHA1 Message Date
Manish Goregaokar
75e3bc3bd8 Rollup merge of #35983 - GuillaumeGomez:e0060_bonus, r=jonathandturner
E0060 and E0061 improvement

Fixes #35290.

r? @jonathandturner
2016-09-05 14:53:08 +08:00
Manish Goregaokar
acf98d99f9 Rollup merge of #35845 - frewsxcv:result-into-iter, r=GuillaumeGomez
Indicate where `core::result::IntoIter` is created.

None
2016-09-05 14:53:08 +08:00
Jeffrey Seyfried
2c88b4b790 Load macros from extern crates in the InvocationCollector fold. 2016-09-05 04:53:35 +00:00
Jeffrey Seyfried
d986bbe674 Implement stackless expansion. 2016-09-05 04:53:34 +00:00
Jeffrey Seyfried
c07ff8d26a Add module ext::placeholders with placeholder() and PlaceholderExpander. 2016-09-05 04:53:33 +00:00
Jeffrey Seyfried
7a3ae576fa Refactor expand_invoc(.., fld) -> self.expand_invoc(..). 2016-09-05 04:53:33 +00:00
Jeffrey Seyfried
79fa9eb643 Refactor SyntaxEnv. 2016-09-05 04:53:32 +00:00
Jeffrey Seyfried
4ed2c0ea7c Refactor expand_* into expander.fold_*. 2016-09-05 04:53:30 +00:00
Jeffrey Seyfried
503a10b34a Clean up module processing. 2016-09-05 04:53:25 +00:00
Jeffrey Seyfried
2a83574c6a Refactor out expand_item (with better semantics than before). 2016-09-05 04:53:23 +00:00
Jeffrey Seyfried
8be8cf8540 Refactor away expand_item. 2016-09-05 04:53:22 +00:00
Jeffrey Seyfried
fca80c983d Generalize Invocation to include modifiers/decorators. 2016-09-05 04:53:21 +00:00
Jeffrey Seyfried
3cba93f993 Refactor with_exts_frame from a macro to a function. 2016-09-05 04:53:21 +00:00
Jeffrey Seyfried
de2e67836e Add Invocation and Expansion, remove MacroGenerable. 2016-09-05 04:53:20 +00:00
Jeffrey Seyfried
9b3bc7a9e9 Remove syntax::config::strip_unconfigured, add syntax::config::features. 2016-09-05 04:53:16 +00:00
Jeffrey Seyfried
234d68b7d3 Improve expand_type. 2016-09-05 04:52:50 +00:00
Jeffrey Seyfried
e1e5c14bad In Parser and ExtCtxt, replace fields filename and mod_path_stack
with a single field `directory: PathBuf`.
2016-09-05 04:52:48 +00:00
Andrew Cann
c9a340e546 Remove expr_ty method completely 2016-09-05 12:28:52 +08:00
Andrew Cann
7c8f5457d2 Undo unnecessary bookkeeping from last commit 2016-09-05 12:28:52 +08:00
Andrew Cann
180534f398 Remove use of expr_ty from coercions code 2016-09-05 12:28:52 +08:00
Andrew Cann
bd661481e7 Move write_ty to the bottom of check_pat 2016-09-05 12:28:52 +08:00
Andrew Cann
1749fda9c0 Factor write_ty out of more pattern-checking functions 2016-09-05 12:28:52 +08:00
Andrew Cann
c5ff28cd14 Factor write_ty out of pattern-matching functions 2016-09-05 12:26:41 +08:00
Andrew Cann
8c6086a0a3 check_block_with_expected returns the checked type 2016-09-05 12:26:41 +08:00
Andrew Cann
f54c47d34b Move check_expr match block into its own method 2016-09-05 12:26:41 +08:00
Andrew Cann
f120c71775 Tidy. Rename variables. 2016-09-05 12:26:41 +08:00
Andrew Cann
1c3e8b0a1c Tidy 2016-09-05 12:26:41 +08:00
Andrew Cann
adb19ff277 Add AdjustNeverToAny in check_expr 2016-09-05 12:26:41 +08:00
Andrew Cann
9cd8d7a24f Factor write_ty out of function checking functions 2016-09-05 12:26:41 +08:00
Andrew Cann
21720641dc Factor write_ty out of check_expr_closure 2016-09-05 12:26:41 +08:00
Andrew Cann
144b8cf5db Factor write_ty out of check_struct_expr 2016-09-05 12:26:41 +08:00
Andrew Cann
f22dd2e2d9 Factor write_ty out of field/indexing methods 2016-09-05 12:26:41 +08:00
Andrew Cann
91b39b5e65 Factor write_ty out of more checking functions 2016-09-05 12:19:07 +08:00
Andrew Cann
06ad8fe261 Factor write_ty out of check_binop* 2016-09-05 12:19:07 +08:00
Andrew Cann
c7ea3e8d13 Remove redundant error checking around ExprMethodCall 2016-09-05 12:19:07 +08:00
Andrew Cann
b93435fd79 Remove most uses of expr_ty 2016-09-05 12:19:07 +08:00
Andrew Cann
0ddf060b6d Make write_ty and friends return adjusted type 2016-09-05 12:19:07 +08:00
Andrew Paseltiner
e4784fc313
Remove mention of unsafe_no_drop_flag from Reference and Nomicon 2016-09-04 22:57:27 -04:00
bors
86995dc8c5 Auto merge of #36240 - leeopop:master, r=jseyfried
Allow CompilerControllers to access rustc_plugin::registry::Registry

fixes #36064

I chose to put ructc_plugin::registry::Registry structure
into CompilerState structure, instead of Session structure.
This will preserve dependencies among librustc, libructc_driver, and libructc_plugin.

@jseyfried @sanxiyn
2016-09-04 18:36:42 -07:00
Matt Ickstadt
b9a8c1a063 Fix incorrect LLVM Linkage enum
The `Linkage` enum in librustc_llvm got out of sync with the version in LLVM and it caused two variants of the #[linkage=""] attribute to break.

This adds the functions `LLVMRustGetLinkage` and `LLVMRustSetLinkage` which convert between the Rust Linkage enum and the LLVM one, which should stop this from breaking every time LLVM changes it.

Fixes #33992
2016-09-04 16:12:01 -05:00
bors
91f057de35 Auto merge of #36203 - petrochenkov:uvsdot, r=nrc
Replace `_, _` with `..` in patterns

This is how https://github.com/rust-lang/rust/issues/33627 looks in action.

Looks especially nice in leftmost/rightmost positions `(first, ..)`/`(.., last)`.
I haven't touched libsyntax intentionally because the feature is still unstable.
2016-09-04 14:03:01 -07:00
Cobrand
1aa777b51f Updated E0559 to new format
Refactored a method that printed one suggested field name,
into a method that returns an `Option` of a suggestion

Updated test cases accordingly
2016-09-04 22:21:32 +02:00
bors
9cc430d2cf Auto merge of #36144 - japaric:rustbuild-musl, r=alexcrichton
rustbuild: fix building std for musl targets

closes #36143

r? @alexcrichton
2016-09-04 10:22:26 -07:00
Andrew Paseltiner
8d3fd03855
Clean up thread-local storage docs
`std` no longer contains an implementation of scoped TLS.
2016-09-04 10:16:25 -04:00
Manish Goregaokar
55893f0da7 Rollup merge of #36234 - durka:disable-codegen-config, r=alexcrichton
rustbuild: add config.toml option to disable codegen tests

Fixes #36232.

I think it worked? Here's a build log where I tried to bootstrap, it crashed, then I added the setting to config.toml and it continued: https://gist.github.com/durka/cbf97cf04b8e065f1a2cfda4c1b6bf95

r? @alexcrichton
2016-09-04 21:01:00 +08:00
Manish Goregaokar
8ee0b6b6c1 Rollup merge of #36231 - durka:patch-29, r=alexcrichton
indicate where to copy config.toml.example

r? @alexcrichton
2016-09-04 21:01:00 +08:00
Manish Goregaokar
eac0ebe35a Rollup merge of #36225 - johnthagen:fix-nightly-docs, r=steveklabnik
Update nightly docs supported Windows versions to match Getting Started page

https://doc.rust-lang.org/book/getting-started.html#tier-1 shows that Windows 7+ is officially supported (implying, for example Windows 10), but the nightly page only listed 7, 8, and Server 2008 R2).
2016-09-04 21:01:00 +08:00
Manish Goregaokar
43440a4a6e Rollup merge of #36212 - razielgn:updated-e0493-to-new-format, r=jonathandturner
Updated e0493 to new format (+ bonus).

Part of #35233.
Fixes #35999.

r? @jonathandturner

I'm not satisfied with the bonus part, there has to be an easier way to reach into the `Drop`'s span implementation. I'm all ears. :)
2016-09-04 21:00:59 +08:00
Manish Goregaokar
8d64649982 Rollup merge of #36132 - nrc:save-std, r=@eddyb
Add --Zsave-analysis-api

This is a save-analysis variation which can be used with libraries distributed without their source (e.g., libstd). It will allow IDEs and other tools to get info about types and create URLs to docs and source, without the unnecessary clutter of internal-only save-analysis info. I'm sure we'll iterate somewhat on the design, but this is a first draft.
2016-09-04 18:02:53 +08:00
Manish Goregaokar
4b889154e1 Rollup merge of #36070 - gavinb:master, r=jonathandturner
Update error format for E0458, E0459

Fixes #35933, #35932
Part of #35233

r? @jonathandturner
2016-09-04 18:02:53 +08:00
bors
e77d86c142 Auto merge of #36132 - nrc:save-std, r=@eddyb
Add --Zsave-analysis-api

This is a save-analysis variation which can be used with libraries distributed without their source (e.g., libstd). It will allow IDEs and other tools to get info about types and create URLs to docs and source, without the unnecessary clutter of internal-only save-analysis info. I'm sure we'll iterate somewhat on the design, but this is a first draft.
2016-09-04 02:40:31 -07:00
Vadim Petrochenkov
e05e74ac83 Replace _, _ with .. 2016-09-04 12:30:33 +03:00
Vadim Petrochenkov
6f7e51e49b Replace _, _, _ with .. 2016-09-04 12:27:01 +03:00
Keunhong Lee
ca5dfd0c97 Allow CompilerControllers to access rustc_plugin::registry::Registry structure. 2016-09-04 03:22:56 +00:00
Jake Goldsborough
b66410043a adding a check to bootstrap script
and a check to the rust config script
2016-09-03 20:22:12 -07:00
bors
1ca1de6b26 Auto merge of #36124 - eddyb:fast-array-init, r=alexcrichton
Fix optimization regressions for operations on [x; n]-initialized arrays.

Fixes #35662 by using `!=` instead of `<` as the stop condition for `[x; n]` initialization loops.
Also included is cc2009f02d, a hack to run the GVN pass twice, another time after InstCombine.
This hack results in removal of redundant `memset` and `memcpy` calls (from loops over arrays).

cc @nrc Can we get performance numbers on this? Not sure if it regresses anything else.
2016-09-03 17:41:08 -07:00
Guillaume Gomez
1eda14e4c9 E0060 and E0061 improvement 2016-09-04 01:34:11 +02:00
Josh Triplett
fe8438d4a2 Fix "field is never used" warning to take unions into account
Rather than saying "struct or union" or adding logic to determine the
type of the item, just change the message to "field is never used",
dropping the "struct".

Update tests accordingly.
2016-09-03 15:29:16 -07:00
bors
70598e04f9 Auto merge of #36119 - arielb1:ctp-again, r=eddyb
fix broken type parameter indexing logic in wfcheck

r? @eddyb

Fixes #36075
2016-09-03 14:31:42 -07:00
Corey Farwell
5652b62a6b Indicate where core::result::IntoIter is created. 2016-09-03 16:56:22 -04:00
bors
49e9bfdbf2 Auto merge of #36104 - KiChjang:issue-35847, r=brson
Fix illegal instruction caused by overflow in channel cloning

Fixes #35847.

r? @alexcrichton
2016-09-03 11:24:01 -07:00
Alex Crichton
4ec715becf Add back feature accidentally removed
This feature was accidentally removed in
https://github.com/rust-lang/rust/pull/35957.
2016-09-03 10:23:40 -07:00
bors
d748fa6ecc Auto merge of #36016 - petrochenkov:union, r=nikomatsakis
Implement untagged unions (RFC 1444)

cc https://github.com/rust-lang/rust/issues/32836

Notes:
- The RFC doesn't talk about `#[packed]` unions, this implementation supports them, packing changes union's alignment to 1 and removes trailing padding.
- The RFC doesn't talk about dynamically sized unions, this implementation doesn't support them and rejects them during wf-checking (similarly, dynamically sized enums are not supported as well).
- The lint for drop fields in unions can't work precisely before monomorphization, so it works pessimistically - non-`Copy` generic fields are reported, types not implementing `Drop` directly, but having non-trivial drop code are reported.

    ```
    struct S(String); // Doesn't implement `Drop`
    union U<T> {
        a: S, // Reported
        b: T, // Reported
    }
    ```

- https://github.com/rust-lang/rust/pull/35764 was indeed helpful and landed timely, I didn't have to implement internal drop flags for unions.
- Unions are not permitted in constant patterns, because matching on union fields is unsafe, I didn't want unsafety checker to dig into all constants to uncover this possible unsafety.
- The RFC doesn't talk about `#[derive]`, generally trait impls cannot be derived for unions, but some of them can. I implemented only `#[derive(Copy)]` so far. In theory shallow `#[derive(Clone)]` can be derived as well if all union fields are `Copy`, I left it for later though, it requires changing how `Clone` impls are generated.
- Moving union fields is implemented as per https://github.com/rust-lang/rust/issues/32836#issuecomment-242511491.
- Testing strategy: union specific behavior is tested, sometimes very basically (e.g. debuginfo), behavior common for all ADTs (e.g. something like coherence
checks) is not generally tested.

r? @eddyb
2016-09-03 07:48:06 -07:00
Guillaume Gomez
216cf9c124 Add missing urls 2016-09-03 16:15:22 +02:00
bors
01b35d82e5 Auto merge of #36072 - arthurprs:binary_heap_opt, r=Aatch
Optimize BinaryHeap bounds checking

I was experimenting with d-ary binary heaps during the weekend (dead end) and I found that we could get some good improvements by removing bounds checking. Specially due to the panic-safe additional code, llvm can't really optimize them out.

```
 name                         d_ary_heap:: ns/iter  std___heap:: ns/iter  diff ns/iter  diff %
 bench_build_insert           148,610               236,960                     88,350  59.45%
 bench_from_vec               243,846               299,719                     55,873  22.91%
 bench_insert_2000_empty      4,512                 7,517                        3,005  66.60%
 bench_insert_2000_prefilled  28,665                32,605                       3,940  13.74%
 bench_pop_2000               111,515               128,005                     16,490  14.79%
 bench_pop_all                2,759,945             3,317,626                  557,681  20.21%
 peek_mut                     23,186                23,635                         449   1.94%
 pop_modify_push              41,573                43,822                       2,249   5.41%

test d_ary_heap::bench_build_insert          ... bench:     148,610 ns/iter (+/- 10,687)
test d_ary_heap::bench_from_vec              ... bench:     243,846 ns/iter (+/- 16,500)
test d_ary_heap::bench_insert_2000_empty     ... bench:       4,512 ns/iter (+/- 136)
test d_ary_heap::bench_insert_2000_prefilled ... bench:      28,665 ns/iter (+/- 1,347)
test d_ary_heap::bench_pop_2000              ... bench:     111,515 ns/iter (+/- 104,677)
test d_ary_heap::bench_pop_all               ... bench:   2,759,945 ns/iter (+/- 173,838)
test d_ary_heap::peek_mut                    ... bench:      23,186 ns/iter (+/- 106,254)
test d_ary_heap::pop_modify_push             ... bench:      41,573 ns/iter (+/- 3,313)
test std___heap::bench_build_insert          ... bench:     236,960 ns/iter (+/- 16,955)
test std___heap::bench_from_vec              ... bench:     299,719 ns/iter (+/- 6,354)
test std___heap::bench_insert_2000_empty     ... bench:       7,517 ns/iter (+/- 372)
test std___heap::bench_insert_2000_prefilled ... bench:      32,605 ns/iter (+/- 2,433)
test std___heap::bench_pop_2000              ... bench:     128,005 ns/iter (+/- 11,787)
test std___heap::bench_pop_all               ... bench:   3,317,626 ns/iter (+/- 238,968)
test std___heap::peek_mut                    ... bench:      23,635 ns/iter (+/- 1,420)
test std___heap::pop_modify_push             ... bench:      43,822 ns/iter (+/- 3,788)
```

Test code: https://github.com/arthurprs/heap-experiments
2016-09-03 04:40:38 -07:00
Vadim Petrochenkov
436cfe5653 Fix type encoding/decoding for unions
Fix union debuginfo test on lldb
2016-09-03 13:39:35 +03:00
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
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
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
Andrea Corradi
63671c495b Update E0496 to new format 2016-09-02 22:28:26 +02:00
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
Jared Roesch
9510add6a3 Remove illegal bound from doc test 2016-09-02 11:58:02 -07:00
Jared Roesch
6eb06e6770 Forget to update tests to use new error message 2016-09-02 11:58:02 -07:00
Jared Roesch
ed5843bcc6 Address feedback on secondary changes 2016-09-02 11:58:02 -07:00
Jared Roesch
90d1a53551 Address feedback, and remove invalid tests 2016-09-02 11:58:02 -07:00
Jared Roesch
352fac95ad Reject certain auto trait declarations
Fixes #29859
2016-09-02 11:58:02 -07:00
Jared Roesch
f18c99072e Add tests for #29859 2016-09-02 11:58:02 -07: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
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
bors
8aeb15acc7 Auto merge of #35894 - jseyfried:new_import_semantics, r=nrc
Implement RFC 1560 behind `#![feature(item_like_imports)]`

This implements https://github.com/rust-lang/rfcs/pull/1560 (cc #35120) behind the `item_like_imports` feature gate.

The [RFC text](https://github.com/rust-lang/rfcs/blob/master/text/1560-name-resolution.md#changes-to-name-resolution-rules) describes the changes to name resolution enabled by `#![feature(item_like_imports)` in detail. To summarize,
 - Items and named imports shadow glob imports.
 - Multiple globs can import the same name if the name is unused or the imports are shadowed.
 - Multiple globs can import the same name if the imports are of the same item (following re-exports).
  - The visibility of such a name is the maximum visibility of the imports.
  - Equivalently, adding a glob import will never reduce the visibility of a name, nor will removing one increase it.
 - Non-prelude private imports can be used wherever we currently allow private items to be used.
  - Prelude-imported names are unaffected, i.e. they continue to be usable only in lexical scopes.
 - Globs import all visible names, not just public names.
  - Equivalently, glob importing from an ancestor module imports all of the ancestor's names, and glob importing from other modules is unchanged.

r? @nrc
2016-09-01 19:03:27 -07:00
Jeffrey Seyfried
90ce504c1c Address comments. 2016-09-02 00:35:16 +00:00
Alex Crichton
96283fc083 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-01 16:14:17 -07:00
Eugene R Gonzalez
7cd4e7ff0b Fixed E0528 label and unit test 2016-09-01 19:08:07 -04:00
Jeffrey Seyfried
4f5616e3c4 Avoid cascading name resolution errors caused by an ambiguous module. 2016-09-01 22:30:29 +00:00
Jeffrey Seyfried
32a0cfeb48 Avoid reporting multiple ambiguity errors for a single use of a name. 2016-09-01 22:30:28 +00:00
Jeffrey Seyfried
681a14f29b item_like_imports: Allow unused ambiguous glob imports. 2016-09-01 22:30:27 +00:00
Jeffrey Seyfried
f582fa327e item_like_imports: Allow multiple glob imports of the same item. 2016-09-01 22:30:26 +00:00
Jeffrey Seyfried
245a0c5530 item_like_imports: Make all visible items glob importable. 2016-09-01 22:30:26 +00:00
Jeffrey Seyfried
097b6d62fc item_like_imports: Allow glob imports with a given visibility
to reexport some (but not all) names with less visibility.
2016-09-01 22:30:25 +00:00
Jeffrey Seyfried
c56a5afd4d item_like_imports: Allow single imports with a given visibility
to reexport some (but not all) namespaces with less visibility.
2016-09-01 22:30:24 +00:00
Jeffrey Seyfried
aad1f3cbf3 item_like_imports: Allow glob imports to be shadowed by items and single imports. 2016-09-01 22:30:24 +00:00
Jeffrey Seyfried
efc0bea687 item_like_imports: Treat private imports like private items. 2016-09-01 22:30:21 +00:00
Jeffrey Seyfried
5ba22c0ed6 Add item_like_imports feature. 2016-09-01 22:29:50 +00:00
Jeffrey Seyfried
513e955a18 Add field dummy_binding to Resolver. 2016-09-01 22:29:30 +00:00
Jeffrey Seyfried
95528d1a98 Refactor away resolver.current_vis and add module.normal_ancestor_id. 2016-09-01 22:29:29 +00:00
Jeffrey Seyfried
1e4c8173e1 Improve diagnostics and remove dead code. 2016-09-01 22:29:28 +00:00
Jeffrey Seyfried
87ae68c1d6 Refactor binding.def() to return a Def instead of an Option<Def>. 2016-09-01 22:29:27 +00:00
Jeffrey Seyfried
691d10c3c9 Rename new_binding -> binding. 2016-09-01 22:29:27 +00:00
Jeffrey Seyfried
5dc1196191 Refactor away binding.is_pseudo_public(). 2016-09-01 22:29:26 +00:00
Jeffrey Seyfried
48a435a90f Fix test compile-fail/task-rng-isnt-sendable.rs. 2016-09-01 22:29:25 +00:00
bors
497d67d708 Auto merge of #35761 - nikomatsakis:faster-trans-fulfill-obligation, r=eddyb
Cache projections in trans

This introduces a cache for the results of projection and normalization in trans. This is in addition to the existing cache that is per-inference-context. Trans is an easy place to put the cache because we are guaranteed not to have type parameters and also we don't expect any failures or inference variables, so there is no need to cache or follow-up on obligations that come along with.  (As evidenced by the fact that this particular code would panic if any error occurred.)

That said, I am not sure this is 100% the best place for it; I sort of wanted a cache like we have in the fulfillment context for global names; but that cache only triggers when all subsequent obligations are satisfied, and since projections don't have an entry in the obligation jungle there is no easy place to put it. I considered caching both the result and obligations globally, but haven't really tried implementing it. It might be a good next step.

Regardless, this cache seems to have no real effect on bootstrap time (maybe a slight improvement), but on [the futures.rs test case I was looking at](https://github.com/rust-lang-nursery/rustc-benchmarks/pull/6), it improves performance quite a bit:

| phase | before | after |
| ----- | ------ | ----- |
| collection | 0.79s | 0.46s |
| translation | 6.8s | 3.2s |
| total | 11.92s | 7.15s |

r? @arielb1
2016-09-01 15:25:58 -07:00
bors
933f471710 Auto merge of #34494 - CensoredUsername:allow_sysV64_abi, r=nagisa
Allow specification of the system V AMD64 ABI constraint.

This can be specified using `extern "sysV64" fn` on all platforms.

This ABI is used as the C ABI on unix platforms, but can only be specified there using extern "C". It was impossible to specify on other platforms. Meanwhile the win64 ABI, which was the extern "C" ABI on the windows platform could be specified on other platforms using extern "win64".

This pull request adds the the "sysV64" ABI constraint which exposes this calling convention on platforms where it is not the C ABI.
2016-09-01 11:56:51 -07:00
Michael Woerister
7310a8ffea ICH: Adapt to changes in the MetaItem AST representation. 2016-09-01 14:39:31 -04:00
Florian Gilcher
0f8eb81011 Document try!'s error conversion behaviour 2016-09-01 19:16:19 +02:00
Michael Woerister
8cbd6fe331 ICH: Share codemap cache between subsequent runs of the ICH visitor. 2016-09-01 09:43:44 -04:00
Michael Woerister
2faca22bd3 ICH: Fix codemap lookup caching. 2016-09-01 09:43:44 -04:00
Michael Woerister
a142d2ff02 ICH: Fix bug in hash_discriminant() and visit_vis(). 2016-09-01 09:43:44 -04:00
Michael Woerister
0310e3444b ICH: Take CaptureClause of closure expressions into account. 2016-09-01 09:43:44 -04:00
Michael Woerister
500ab357c2 ICH: Cleanup some comments. 2016-09-01 09:43:44 -04:00