bors [Fri, 10 Aug 2018 19:18:22 +0000 (19:18 +0000)]
Auto merge of #53177 - nikomatsakis:nll-redundant-borrows-and-escaping-values, r=pnkfelix
optimize redundant borrows and escaping paths in NLL
This builds on https://github.com/rust-lang/rust/pull/53168 and adds a commit that addresses https://github.com/rust-lang/rust/issues/53176 -- or at least I think it does. I marked this as WIP because I want to see the test results (and measure the performance). I also want to double check we're not adding in any unsoundness here.
bors [Fri, 10 Aug 2018 00:14:52 +0000 (00:14 +0000)]
Auto merge of #53073 - Mark-Simulacrum:data-structures, r=pnkfelix
Cleanup to librustc::session and related code
No functional changes, just some cleanup.
This also creates the `rustc_fs_util` crate, but I can remove that change if desired. It felt a little odd to force crates to depend on librustc for some fs utilities; and also seemed good to generally keep the size of librustc lower (for compile times); fs_util will compile in parallel with essentially the first crate since it has no dependencies beyond std.
With this change (just the `help` was added):
```
error[E0594]: cannot assign to immutable indexed content
--> index-error.rs:7:5
|
7 | map["peter"] = 27;
| ^^^^^^^^^^^^^^^^^ cannot borrow as mutable
|
= help: trait `IndexMut` is required to modify indexed content, but it is not implemented for std::collections::HashMap<&str, i32>
```
---
Yesterday I did some pair programming with a Rust-beginner. We created a type and implemented `Index` for it. Trying to modify the value returned by the index operation returns in a rather vague error that was not very clear for the Rust beginner. So I tried to improve the situation.
## Notes/questions for reviewers:
- Is the formulation OK like that? I'm fine with changing it.
- Can we be absolutely sure that `IndexMut` is actually not implemented in the case my `help` message is added? I'm fairly sure myself, but there could be some cases I didn't think of. Also, I don't know the compiler very well, so I don't know what exactly certain enum variants are used for.
- It would be nice to test if `IndexMut` is in fact not implemented for the type, but I couldn't figure out how to check that. If you think that additional check would be beneficial, could you tell me how to check if a trait is implemented?
- Do you think I should change the error message instead of only adding an additional help message?
bors [Thu, 9 Aug 2018 19:05:14 +0000 (19:05 +0000)]
Auto merge of #53216 - kennytm:rollup, r=kennytm
Rollup of 15 pull requests
Successful merges:
- #52773 (Avoid unnecessary pattern matching against Option and Result)
- #53082 (Fix doc link (again))
- #53094 (Automatically expand section if url id point to one of its component)
- #53106 (atomic ordering docs)
- #53110 (Account for --remap-path-prefix in save-analysis)
- #53116 (NetBSD: fix signedess of char)
- #53179 (Whitelist wasm32 simd128 target feature)
- #53183 (Suggest comma when missing in macro call)
- #53207 (Add individual docs for rotate_{left, right})
- #53211 ([nll] enable feature(nll) on various crates for bootstrap)
- #53214 ([nll] enable feature(nll) on various crates for bootstrap: part 2)
- #53215 (Slightly refactor syntax_ext/format)
- #53217 (inline some short functions)
- #53219 ([nll] enable feature(nll) on various crates for bootstrap: part 3)
- #53222 (A few cleanups for rustc_target)
kennytm [Thu, 9 Aug 2018 17:04:10 +0000 (01:04 +0800)]
Rollup merge of #53222 - ljedrz:cleanup_rustc_target, r=Mark-Simulacrum
A few cleanups for rustc_target
- remove redundant struct field names
- shorten a self-assignment
- prefer `unwrap_or_else` in case of function calls
- collapse an `if`
- collapse a double `map()`
- match on dereferenced objects
- consume `self` if it implements `Copy`
kennytm [Thu, 9 Aug 2018 17:03:45 +0000 (01:03 +0800)]
Rollup merge of #53215 - ljedrz:refactor_format, r=estebank
Slightly refactor syntax_ext/format
expand_preparsed_format_args:
- move a potential error `return` earlier in the processing
- pre-allocate some of the required space for `cx.pieces` and `cx.str_pieces`
- create `cx`-independent objects before `cx`
- build `pieces` and `errs` using `collect` instead of a `push` loop
describe_num_args:
- return `Cow<str>` instead of `String`
kennytm [Thu, 9 Aug 2018 08:58:49 +0000 (16:58 +0800)]
Rollup merge of #53183 - estebank:println-comma, r=oli-obk
Suggest comma when missing in macro call
When missing a comma in a macro call, suggest it, regardless of
position. When a macro call doesn't match any of the patterns, check
if the call's token stream could be missing a comma between two idents,
and if so, create a new token stream containing the comma and try to
match against the macro patterns. If successful, emit the suggestion.
This works on arbitrary macros, with no need of special support from
the macro writers.
```
error: no rules expected the token `d`
--> $DIR/missing-comma.rs:26:18
|
LL | foo!(a, b, c d, e);
| -^
| |
| help: missing comma here
```
Follow up to #52397.
bors [Thu, 9 Aug 2018 13:20:14 +0000 (13:20 +0000)]
Auto merge of #53031 - michaelwoerister:cross-lto, r=alexcrichton
Apply some fixes to cross-language LTO (especially when targeting MSVC)
This PR contains a few fixes that were needed in order to get Firefox compiling with Rust/C++ cross-language ThinLTO on Windows. The commits are self-contained and should be self-explanatory.
kennytm [Thu, 9 Aug 2018 08:58:42 +0000 (16:58 +0800)]
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
Account for --remap-path-prefix in save-analysis
Fixes #52549.
Didn't add a test since save-analysis is still unstable, only tested this locally. Should I add a test for that? If so, is run-make-fulldeps an appropriate format?
Session is already created with remapped working directory, so use that instead of the actual cwd.
This was the only place affected, since the rest of the paths in save-analysis are directly derived from files in spans from `sess.codemap()`, which already creates remapped ones.
bors [Thu, 9 Aug 2018 07:30:14 +0000 (07:30 +0000)]
Auto merge of #53108 - RalfJung:mutex, r=alexcrichton
clarify partially initialized Mutex issues
Using a `sys_common::mutex::Mutex` without calling `init` is dangerous, and yet there are some places that do this. I tried to find all of them and add an appropriate comment about reentrancy.
I found two places where (I think) reentrancy can actually occur, and was not able to come up with an argument for why this is okay. Someone who knows `io::lazy` and/or `sys_common::at_exit_imp` should have a careful look at this.
bors [Wed, 8 Aug 2018 12:48:32 +0000 (12:48 +0000)]
Auto merge of #53088 - matthewjasper:closure-region-spans, r=nikomatsakis
[NLL] Use span of the closure args in free region errors
Also adds a note when one of the free regions is BrEnv.
In a future PR I'll change these messages to say "return requires", which should improve them a bit more.
I just got a PR towards libc (https://github.com/rust-lang/libc/pull/1044) merged. With the new feature added in that PR it is now possible to create `in6_addr` instances as consts. This enables us to finally make the constructors of the IP structs const fns and to make the localhost/unspecified addresses associated constants, as agreed in the above mentioned tracking issue.
I also added a BROADCAST constant. Personally this is the well known address I tend to need the most often.
bors [Wed, 8 Aug 2018 08:37:56 +0000 (08:37 +0000)]
Auto merge of #53053 - petrochenkov:custattr, r=alexcrichton
resolve: Support custom attributes when macro modularization is enabled
Basically, if resolution of a single-segment attribute is a determined error, then we interpret it as a custom attribute.
Since custom attributes are integrated into general macro resolution, `feature(custom_attribute)` now requires and implicitly enables macro modularization (`feature(use_extern_macros)`).
Actually, a few other "advanced" macro features now implicitly enable macro modularization too (and one bug was found and fixed in process of enabling it).
The first two commits are preliminary cleanups/refactorings.
Esteban Küber [Wed, 8 Aug 2018 05:28:09 +0000 (22:28 -0700)]
Suggest comma when missing in macro call
When missing a comma in a macro call, suggest it, regardless of
position. When a macro call doesn't match any of the patterns, check
if the call's token stream could be missing a comma between two idents,
and if so, create a new token stream containing the comma and try to
match against the macro patterns. If successful, emit the suggestion.
bors [Wed, 8 Aug 2018 01:24:15 +0000 (01:24 +0000)]
Auto merge of #52993 - alexcrichton:fix-some-vis, r=michaelwoerister
rustc: Tweak visibility of some lang items
This commit tweaks the linker-level visibility of some lang items that rustc
uses and defines. Notably this means that `#[panic_implementation]` and
`#[alloc_error_handler]` functions are never marked as `internal`. It's up to
the linker to eliminate these, not rustc.
Additionally `#[global_allocator]` generated symbols are no longer forced to
`Default` visibility (fully exported), but rather they're relaxed to `Hidden`
visibility). This symbols are *not* needed across DLL boundaries, only as a
local implementation detail of the compiler-injected allocator symbols, so
`Hidden` should suffice.