bors [Sat, 6 Oct 2018 10:44:11 +0000 (10:44 +0000)]
Auto merge of #54766 - alexcrichton:wasm-all-symbols, r=michaelwoerister
wasm: Explicitly export all symbols with LLD
This commit fixes an oddity on the wasm target where LTO can produce
working executables but plain old optimizations doesn't. The compiler
already knows what set of symbols it would like to export, but LLD only
discovers this list transitively through symbol visibilities. LLD may
not, however, always find all the symbols that we'd like to export.
For example if you depend on an rlib with a `#[no_mangle]` symbol, then
if you don't actually use anything from the rlib then the symbol won't
appear in the final artifact! It will appear, however, with LTO. This
commit attempts to rectify this situation by ensuring that all symbols
rustc would otherwise preserve through LTO are also preserved through
the linking process with LLD by default.
bors [Sat, 6 Oct 2018 00:44:11 +0000 (00:44 +0000)]
Auto merge of #54859 - pietroalbini:rollup, r=pietroalbini
Rollup of 11 pull requests
Successful merges:
- #54078 (Expand the documentation for the `std::sync` module)
- #54717 (Cleanup rustc/ty part 1)
- #54781 (Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs)
- #54787 (Only warn about unused `mut` in user-written code)
- #54804 (add suggestion for inverted function parameters)
- #54812 (Regression test for #32382.)
- #54833 (make `Parser::parse_foreign_item()` return a foreign item or error)
- #54834 (rustdoc: overflow:auto doesn't work nicely on small screens)
- #54838 (Fix typo in src/libsyntax/parse/parser.rs)
- #54851 (Fix a regression in 1.30 by reverting #53564)
- #54853 (Remove unneccessary error from test, revealing NLL error.)
Pietro Albini [Fri, 5 Oct 2018 20:33:21 +0000 (22:33 +0200)]
Rollup merge of #54851 - alexcrichton:revert-optimize, r=sfackler
Fix a regression in 1.30 by reverting #53564
Investigation on #54477 revealed https://github.com/rust-lang/rust/pull/53564 as the culprit in the regression for that crate. I've reproduced the regression with the [detailed test cases provided](https://github.com/rust-lang/rust/issues/54477#issuecomment-427398456). While we figure out how to fix the regression this commit reverts the current culprit.
Pietro Albini [Fri, 5 Oct 2018 20:33:17 +0000 (22:33 +0200)]
Rollup merge of #54833 - abonander:issue-54441, r=petrochenkov
make `Parser::parse_foreign_item()` return a foreign item or error
Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter.
This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`.
Pietro Albini [Fri, 5 Oct 2018 20:33:11 +0000 (22:33 +0200)]
Rollup merge of #54717 - ljedrz:cleanup_ty_p1, r=davidtwco
Cleanup rustc/ty part 1
Part 2 will follow soon; I wouldn't want these changes to rot too quickly.
- improve stack shifting and remove related allocations
- move a faster early return up
- improve allocations
- use Cow<str> where applicable
- simplify common patterns
- whitespace fixes
Pietro Albini [Fri, 5 Oct 2018 20:33:10 +0000 (22:33 +0200)]
Rollup merge of #54078 - GabrielMajeri:expand-sync-docs, r=steveklabnik
Expand the documentation for the `std::sync` module
I've tried to expand the documentation for Rust's synchronization primitives. The module level documentation explains why synchronization is required when working with a multiprocessor system,
and then links to the appropiate structure in this module.
Fixes #29377, since this should be the last item on the checklist (documentation for `Atomic*` was fixed in #44854, but not ticked off the checklist).
bors [Fri, 5 Oct 2018 19:32:14 +0000 (19:32 +0000)]
Auto merge of #54743 - ljedrz:cleanup_ty_p2, r=zackmdavis
Cleanup rustc/ty part 2
The second part of cleanups and minor improvements for rustc/ty.
- improve allocations
- calculate span after a possible early continue
- simplify some patterns
- mark a comment as FIXME
- whitespace fixes
bors [Fri, 5 Oct 2018 12:52:53 +0000 (12:52 +0000)]
Auto merge of #54336 - petrochenkov:preuni, r=alexcrichton
resolve: Some refactorings in preparation for uniform paths 2.0
The main result is that in-scope resolution performed during macro expansion / import resolution is now consolidated in a single function (`fn early_resolve_ident_in_lexical_scope`), which can now be used for resolving first import segments as well when uniform paths are enabled.
bors [Fri, 5 Oct 2018 10:08:01 +0000 (10:08 +0000)]
Auto merge of #52121 - jebrosen:macros2_feature, r=petrochenkov
Merge `proc_macro_` expansion feature gates as `proc_macro_hygiene`
Merges `proc_macro_mod`, `proc_macro_expr`, `proc_macro_non_items`, and `proc_macro_gen` into a single feature: `proc_macro_hygiene`. These features are not all blocked on implementing macro hygiene *per se*, but rather on interactions with hygiene that have not been entirely resolved.
expansion: Remove restriction on use of macro attributes with test/bench
The restrictions were introduced in https://github.com/rust-lang/rust/pull/54277 and no longer necessary now because legacy plugins are now expanded in usual left-to-right order
bors [Fri, 5 Oct 2018 01:57:01 +0000 (01:57 +0000)]
Auto merge of #54017 - alexcrichton:wasm-atomics2, r=sfackler
std: Start implementing wasm32 atomics
This commit is an initial start at implementing the standard library for
wasm32-unknown-unknown with the experimental `atomics` feature enabled. None of
these changes will be visible to users of the wasm32-unknown-unknown target
because they all require recompiling the standard library. The hope with this is
that we can get this support into the standard library and start iterating on it
in-tree to enable experimentation.
Currently there's a few components in this PR:
* Atomic fences are disabled on wasm as there's no corresponding atomic op and
it's not clear yet what the convention should be, but this will change in the
future!
* Implementations of `Mutex`, `Condvar`, and `RwLock` were all added based on
the atomic intrinsics that wasm has.
* The `ReentrantMutex` and thread-local-storage implementations panic currently
as there's no great way to get a handle on the current thread's "id" yet.
Right now the wasm32 target with atomics is unfortunately pretty unusable,
requiring a lot of manual things here and there to actually get it operational.
This will likely continue to evolve as the story for atomics and wasm unfolds,
but we also need more LLVM support for some operations like custom `global`
directives for this to work best.
bors [Thu, 4 Oct 2018 20:28:57 +0000 (20:28 +0000)]
Auto merge of #54649 - nikomatsakis:universes-refactor-1, r=scalexm
adopt "placeholders" to represent universally quantified regions
This does a few preliminary refactorings that lay some groundwork for moving towards universe integration. Two things, primarily:
- Rename from "skolemized" to "placeholder"
- When instantiating `for<'a, 'b, 'c>`, just create one universe for all 3 regions, and distinguish them from one another using the `BoundRegion`.
- This is more accurate, and I think that in general we'll be moving towards a model of separating "binder" (universe, debruijn index) from "index within binder" in a number of places.
- In principle, it feels the current setup of making lots of universes could lead to us doing the wrong thing, but I've actually not been able to come up with an example where this is so.
bors [Thu, 4 Oct 2018 16:34:27 +0000 (16:34 +0000)]
Auto merge of #54666 - matthewjasper:mir-function-spans, r=pnkfelix
[NLL] Improve "borrow later used here" messages
* In the case of two conflicting borrows, the later used message says which borrow it's referring to
* If the later use is a function call (from the users point of view) say that the later use is for the call. Point just to the function.
bors [Thu, 4 Oct 2018 11:39:50 +0000 (11:39 +0000)]
Auto merge of #54809 - pietroalbini:rollup, r=pietroalbini
Rollup of 10 pull requests
Successful merges:
- #53523 (Add doc for impl From for Std Error)
- #54746 (simplify some unused lints code)
- #54761 (Make spec_extend use for_each())
- #54769 (Fix typo in CONTRIBUTING.md)
- #54773 (Update a FIXME in memory.rs)
- #54777 (abolish ICE when pretty-printing async block)
- #54780 (Remove duplicate predicates in `explicit_predicates_of`)
- #54788 (A handful of cleanups for rustc/mir)
- #54789 (Introduce `TyKind::UnnormalizedProjection`)
- #54795 (remove padding from multiline format string label)
Pietro Albini [Thu, 4 Oct 2018 10:20:15 +0000 (12:20 +0200)]
Rollup merge of #54788 - ljedrz:cleanup_rustc_mir, r=oli-obk
A handful of cleanups for rustc/mir
- use the "regular" `into()` instead of `graphviz::IntoCow` in `mod.rs`
- `format!("{}", x)` > `x.to_string()`
- remove one unnecessary `String` allocation
- shorten the logic of one loop
- `assert!(x == y)` > `assert_eq!(x, y)`
- whitespace & formatting fixes
Pietro Albini [Thu, 4 Oct 2018 10:20:13 +0000 (12:20 +0200)]
Rollup merge of #54780 - scalexm:dup-predicates, r=nikomatsakis
Remove duplicate predicates in `explicit_predicates_of`
I took a more brutal approach than described in #52187. I could have used the `linked_hash_map` crate but this seems overkill, especially as we need a vec storage in the end.
Pietro Albini [Thu, 4 Oct 2018 10:20:12 +0000 (12:20 +0200)]
Rollup merge of #54777 - zackmdavis:async_pretty_ice, r=cramertj
abolish ICE when pretty-printing async block
@jnetterf reported an ICE when the unused-parentheses lint triggered around an async block (#54752). In order to compose an autofixable suggestion, the lint invokes the pretty-printer on the unnecessarily-parenthesized expression. (One wonders why the lint doesn't just use `SourceMap::span_to_snippet` instead, to preserve the formatting of the original source?—but to answer that, you'd have to ask the author of 5c9f806d.)
But then the pretty-printer panics when trying to call `<pprust::State as PrintState>::end` when `State.boxes` is empty. Empirically, the problem would seem to be solved if we start some "boxes" beforehand in the `ast::ExprKind::Async` arm of the big match in `print_expr_outer_attr_style`, exactly like we do in the immediately-preceding match arm for `ast::ExprKind::Block`—it would seem pretty ("pretty") reasonable for the pretty-printing of async blocks to work a lot like the pretty-printing of ordinary non-async blocks, right??
Of course, it would be shamefully cargo-culty to commit code on the basis of this kind of mere reasoning-by-analogy (in contrast to understanding the design of the pretty-printer in such detail that the correctness of the patch is comprehended with all the lucid certainty of mathematical proof, rather than being merely surmised by intuition). But maybe we care more about fixing the bug with high probability today, than with certainty in some indefinite hypothetical future? Maybe the effort is worth [a fifth of a shirt](https://hacktoberfest.digitalocean.com/stats/zackmdavis)??
Pietro Albini [Thu, 4 Oct 2018 10:20:11 +0000 (12:20 +0200)]
Rollup merge of #54773 - rust-lang:wesleywiser-patch-1, r=oli-obk
Update a FIXME in memory.rs
In #51833, I improved the performance of `copy_undef_mask()`. As such, the old FIXME wasn't appropriate anymore. The main remaining thing left to do is to implement a fast path for non-overlapping copies (per @oli-obk).
Pietro Albini [Thu, 4 Oct 2018 10:20:08 +0000 (12:20 +0200)]
Rollup merge of #54761 - Lucretiel:patch-1, r=cramertj
Make spec_extend use for_each()
`for_each` will use an iterator's own implementation of `try_fold`, which I understand to be generally preferable (because nested iterator adapter's will use each other's `try_fold` and be designed for the specific adaptation in a way that promotes performance and inlining.
bors [Thu, 4 Oct 2018 06:48:13 +0000 (06:48 +0000)]
Auto merge of #53851 - oli-obk:local_promotion, r=eddyb
Limit the promotion of const fns to the libstd and the `rustc_promotable` attribute
There are so many questions around promoting const fn calls... it seems saner to try to limit automatic promotion to const fns which were explicitly opted in for promotion.
I added the attribute to all public stable const fns that were already promotable (e.g. not Cell::new) in order to not cause any breakage
bors [Thu, 4 Oct 2018 03:08:22 +0000 (03:08 +0000)]
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
handle outlives predicates in trait evaluation
This handles higher-ranked outlives predicates in trait evaluation the same way they are handled in projection.
Fixes #54302. I think this is a more correct fix than #54401 because it fixes the root case in evaluation instead of making evaluation used in less cases. However, we might want to go to a direction closer to @nikomatsakis's solution with Chalk.
bors [Wed, 3 Oct 2018 21:46:21 +0000 (21:46 +0000)]
Auto merge of #54391 - davidtwco:issue-54230, r=petrochenkov
suggest `crate::...` for "local" paths in 2018
Fixes #54230.
This commit adds suggestions for unresolved imports in the cases where
there could be a missing `crate::`, `super::`, `self::` or a missing
external crate name before an import.
Matthew Jasper [Sat, 29 Sep 2018 10:47:47 +0000 (11:47 +0100)]
Clearer later use messages for calls
Give a special message when the later use is from a call. Use the span
of the callee instead of the whole expression. For conflicting borrow
messages say that the later use is of the first borrow.
bors [Wed, 3 Oct 2018 18:12:22 +0000 (18:12 +0000)]
Auto merge of #54605 - petrochenkov:mambig, r=alexcrichton
resolve: Disambiguate a subset of conflicts "macro_rules" vs "macro name in module"
Currently if macro name may refer to both a `macro_rules` macro definition and a macro defined/imported into module we conservatively report an ambiguity error.
Unfortunately, these errors became a source of regressions when macro modularization was enabled - see issue https://github.com/rust-lang/rust/issues/54472.
This PR disambiguates such conflicts in favor of `macro_rules` if both the `macro_rules` item and in-module macro name are defined in the same normal (named) module and `macro_rules` is closer in scope to the point of use (see the tests for examples).
This is a subset of more general approach described in https://github.com/rust-lang/rust/issues/54472#issuecomment-424666659.
The subset is enough to fix all the regressions from https://github.com/rust-lang/rust/issues/54472, but it can be extended to apply to all "macro_rules" vs "macro name in module" conflicts in the future.
To give an analogy, this is equivalent to scoping rules for `let` variables and items defined in blocks (`macro_rules` behaves like "`let` at module level" in general).
```rust
{ // beginning of the block
use xxx::m; // (1)
// Starting from the beginning of the block and until here m!() refers to (1)
macro_rules! m { ... } // (2)
// Starting from here and until the end of the block m!() refers to (2)
} // end of the block
```
More complex examples with `use` and `macro_rules` from different modules still report ambiguity errors, even if equivalent examples with `let` are legal.
David Wood [Wed, 3 Oct 2018 13:20:20 +0000 (15:20 +0200)]
Deterministic external crate suggestion.
This commit ensures that the external crate suggestion is deterministic
by using a `BTreeMap` rather than a `FxHashMap`. This is particularly
useful as `std` and `core` will often contain the same items and
therefore the suggestion would previously suggest either for any given
error - in this case, the suggestion will always prefer `std` now.
David Wood [Fri, 28 Sep 2018 09:30:55 +0000 (11:30 +0200)]
Removed hardcoded crate.
Previously, `meta` crate was hardcoded as attempting to resolve a path
with it would ICE. Now, we attempt to load each extern crate first so
that resolving a path involving that crate doesn't error.
David Wood [Thu, 20 Sep 2018 15:15:52 +0000 (17:15 +0200)]
Add suggestions for unresolved imports.
This commit adds suggestions for unresolved imports in the cases where
there could be a missing `crate::`, `super::`, `self::` or a missing
external crate name before an import.
bors [Wed, 3 Oct 2018 10:49:27 +0000 (10:49 +0000)]
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
NLL fails to suggest "try removing `&mut` here"
Fixes #51191.
This PR adds ``try removing `&mut` here`` suggestions to functions where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`. This PR also enables the suggestion for adding a `mut` pattern to by-value implicit self arguments without `mut` patterns already.