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.
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.
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.
bors [Tue, 7 Aug 2018 19:10:17 +0000 (19:10 +0000)]
Auto merge of #52911 - Mark-Simulacrum:visibility-hirid, r=oli-obk
Add HirId to VisibilityKind::Restricted
I'm not confident that these changes are correct -- mostly just tried to copy previous PRs.
Specifically, it's unclear to me if/how to remove the NodeId now that we have HirIds in more structs; is that a all-at-once change that'll happen later?
bors [Tue, 7 Aug 2018 16:01:27 +0000 (16:01 +0000)]
Auto merge of #53109 - nikomatsakis:nll-escaping-into-return-revert, r=nikomatsakis
revert #52991
Reverts https://github.com/rust-lang/rust/pull/52991 which is flawed. I have an idea how to fix it but might as well revert first since it is so wildly flawed. That's what I get for opening PRs while on PTO =)
Alex Crichton [Thu, 2 Aug 2018 19:30:43 +0000 (12:30 -0700)]
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.
The previous iteration was a large `match` which was quite heavily indented,
making it slightly difficult to read and see what was going on. This iteration
is a refactoring (no functional change intended) to make it a bit easier on the
eyes and a bit easier to modify over time.
bors [Tue, 7 Aug 2018 13:14:37 +0000 (13:14 +0000)]
Auto merge of #51990 - oli-obk:unstable_union, r=nikomatsakis
Place unions, pointer casts and pointer derefs behind extra feature gates
To ensure we don't stabilize these things together with const fn stabilization (or any other stabilization)
This PR moves union field accesses inside `const fn` behind a feature gate. It was possible without a feature gate before, but since `const fn` was behind a feature gate we can do this change.
While "dereferencing raw pointers" and "casting raw pointers to usize" were hard errors before this PR, one could work around them by abusing unions:
```rust
// deref
union Foo<T> {
x: &'static T,
y: *const T,
}
const FOO: u32 = unsafe { *Foo { y: 42 as *const T }.x };
// as usize cast
union Bar<T> {
x: usize,
y: *const T,
}
const BAR: usize = unsafe { Bar { y: &1u8 }.x };
```
Make sure upstream object files are added to staticlibs when compiling
with ThinLTO and cross-lang-lto.
Normally, when compiling with whole-crate-graph ThinLTO, we expect
rustc's LTO step to "uplift" upstream object files/LLVM modules to
the current set of compilation artifacts. Therefore the staticlib
creation code skips this uplifting. However, when compiling with
"cross-language LTO" (i.e. defer LTO to the actual linker), the LTO
step in rustc is not performed, so we have to take care of copying
upstream object files during archive creation (like we already do
when compiling without any LTO).
bors [Tue, 7 Aug 2018 11:00:07 +0000 (11:00 +0000)]
Auto merge of #53150 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests
Successful merges:
- #52885 (Remove some unused method arguments from typeck)
- #52886 (cleanup: Remove `Def::GlobalAsm`)
- #53028 (Building librustc_codegen_llvm in a separate directory)
- #53052 (fixed broken links to char)
- #53060 (Change rustdoc style so fully qualified name does not overlap src link)
- #53068 (Rename Executor trait to Spawn)
- #53093 (Enable macros to pass $:literal to another macro)
- #53107 (Remove references to `StaticMutex` which got removed a while ago)
- #53135 (Rust 2018: Disable catch_expr, not targeted for 2018 edition)
- #53139 (set emit_debug_gdb_scripts: false for riscv32imac-unknown-none target)
kennytm [Tue, 7 Aug 2018 08:55:44 +0000 (16:55 +0800)]
Rollup merge of #53107 - RalfJung:static-mutex, r=alexcrichton
Remove references to `StaticMutex` which got removed a while ago
`StaticMutex` got removed two years ago with https://github.com/rust-lang/rust/pull/34705, but still got referenced in some comments and even an error explanation.
kennytm [Tue, 7 Aug 2018 08:55:41 +0000 (16:55 +0800)]
Rollup merge of #53060 - iliekturtles:rustdoc-style, r=GuillaumeGomez
Change rustdoc style so fully qualified name does not overlap src link
A type's fully qualified name will now wrap once it gets to the
`[-][src]` link aligned against the right edge of the content area.
Previously the two would overlap and the name would only wrap when
hitting the edge of the content area.
kennytm [Tue, 7 Aug 2018 08:55:38 +0000 (16:55 +0800)]
Rollup merge of #53028 - Mark-Simulacrum:split-out-codegen, r=alexcrichton
Building librustc_codegen_llvm in a separate directory
This allows clearing it out and building it separately from the
compiler. Since it's essentially a different and separate crate this
makes sense to do, each cargo invocation should generally happen in its
own directory.
bors [Mon, 6 Aug 2018 16:58:27 +0000 (16:58 +0000)]
Auto merge of #52644 - varkor:lib-feature-gate-2, r=withoutboats
Add errors for unknown, stable and duplicate feature attributes
- Adds an error for unknown (lang and lib) features.
- Extends the lint for unnecessary feature attributes for stable features to libs features (this already exists for lang features).
- Adds an error for duplicate (lang and lib) features.
Fixes #52053, fixes #53032 and address some of the problems noted in #44232 (though not unused features).
There are a few outstanding problems, that I haven't narrowed down yet:
- [x] Stability attributes on macros do not seem to be taken into account.
- [x] Stability attributes behind `cfg` attributes are not taken into account.
- [x] There are failing incremental tests.
bors [Mon, 6 Aug 2018 14:07:22 +0000 (14:07 +0000)]
Auto merge of #52990 - Aaron1011:fix/rustdoc-auto-trait-static, r=eddyb
Fix ICE when rustdoc encounters certain usages of HRTBs
Fixes #51236
Under certain circumstances, `AutoTraitFinder` could end up computing a `ParamEnv` involving two trait predicates that differed only in the region parameters involved. One of these parameters would be a HRTB, while the other would be a normal region parameter.
When this `ParamEnv` was later passed to `SelectionContext`, an `Ambiguity` error would occur, since the erased versions of these predicates would be identical. To solve the issue, we de-duplicate our list of predicates as we build it up. Whenever we encounter two predicates that differ only in their assignment of region parameters (a HRTB vs a normal lifetime parameter), we pick the HRTB. This corresponds to selecting a 'stricter' bound to display in the generated documentation: we're requiring that a particular type works for all possible lifetime parameters if it's going to implement a particular auto trait.
Mark Rousskov [Fri, 3 Aug 2018 13:22:42 +0000 (07:22 -0600)]
Building librustc_codegen_llvm in a separate directory
This allows clearing it out and building it separately from the
compiler. Since it's essentially a different and separate crate this
makes sense to do, each cargo invocation should generally happen in its
own directory.
bors [Mon, 6 Aug 2018 12:00:12 +0000 (12:00 +0000)]
Auto merge of #53045 - pnkfelix:issue-53026-migrate-never-looser-than-ast-borrowck, r=estebank
Fix NLL migration mode so that reports region errors when necessary.
The code here was trying to be clever, and say "lets not report diagnostics when we 'know' NLL will report an error about them in the future."
The problem is that in migration mode, when no error was reported here, the NLL error that we "knew" was coming was downgraded to a warning (!).
Thus causing #53026
(I hope it is the only instance of such a scenario, but we will see.)
Anyway, this PR fixes that by only doing the "clever" skipping of region error reporting when we are not in migration mode. As noted in the FIXME, I'm not really thrilled with this band-aid, but it is small enough to be back-ported easily if that is necessary.
Rather than make a separate test for issue 53026, I just took the test that uncovered this in a first place, and extended it (via our revisions system) to explicitly show all three modes in action: AST-borrowck, NLL, and NLL migration mode.
(To be honest I hope not to have to add such revisions to many tests. Instead I hope to adopt some sort of new `compare-mode` for either borrowck=migrate or for the 2018 edition as a whole.)