bors [Mon, 3 Aug 2020 01:50:25 +0000 (01:50 +0000)]
Auto merge of #74969 - nnethercote:rm-GCX_PTR, r=Mark-Simulacrum
Remove `GCX_PTR`.
We store an `ImplicitCtxt` pointer in a thread-local value (TLV). This allows
implicit access to a `GlobalCtxt` and some other things.
We also store a `GlobalCtxt` pointer in `GCX_PTR`. This is always the same
`GlobalCtxt` as the one within the `ImplicitCtxt` pointer in TLV. `GCX_PTR`
is only used in the parallel compiler's `handle_deadlock()` function.
This commit does the following.
- It removes `GCX_PTR`.
- It also adds `ImplicitCtxt::new()`, which constructs an `ImplicitCtxt` from a
`GlobalCtxt`. `ImplicitCtxt::new()` + `tls::enter_context()` is now
equivalent to the old `tls::enter_global()`.
- Makes `tls::get_tlv()` public for the parallel compiler, because it's
now used in `handle_deadlock()`.
bors [Sun, 2 Aug 2020 23:55:12 +0000 (23:55 +0000)]
Auto merge of #74948 - lzutao:stalize-result-as-deref, r=dtolnay
Stabilize `Result::as_deref` and `as_deref_mut`
FCP completed in https://github.com/rust-lang/rust/issues/50264#issuecomment-645681400.
This PR stabilizes two new APIs for `std::result::Result`:
```rust
fn as_deref(&self) -> Result<&T::Target, &E> where T: Deref;
fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E> where T: DerefMut;
```
This PR also removes two rarely used unstable APIs from `Result`:
```rust
fn as_deref_err(&self) -> Result<&T, &E::Target> where E: Deref;
fn as_deref_mut_err(&mut self) -> Result<&mut T, &mut E::Target> where E: DerefMut;
```
We store an `ImplicitCtxt` pointer in a thread-local value (TLV). This allows
implicit access to a `GlobalCtxt` and some other things.
We also store a `GlobalCtxt` pointer in `GCX_PTR`. This is always the same
`GlobalCtxt` as the one within the `ImplicitCtxt` pointer in TLV. `GCX_PTR`
is only used in the parallel compiler's `handle_deadlock()` function.
This commit does the following.
- It removes `GCX_PTR`.
- It also adds `ImplicitCtxt::new()`, which constructs an `ImplicitCtxt` from a
`GlobalCtxt`. `ImplicitCtxt::new()` + `tls::enter_context()` is now
equivalent to the old `tls::enter_global()`.
- Makes `tls::get_tlv()` public for the parallel compiler, because it's
now used in `handle_deadlock()`.
bors [Sun, 2 Aug 2020 22:07:32 +0000 (22:07 +0000)]
Auto merge of #75070 - Manishearth:rollup-2kgcaw5, r=Manishearth
Rollup of 5 pull requests
Successful merges:
- #74980 (pprust: adjust mixed comment printing and add regression test for #74745)
- #75009 (Document the discrepancy in the mask type for _mm_shuffle_ps)
- #75031 (Do not trigger `unused_{braces,parens}` lints with `yield`)
- #75059 (fix typos)
- #75064 (compiletest: Support ignoring tests requiring missing LLVM components)
Rollup merge of #75064 - petrochenkov:llvmtarg, r=Mark-Simulacrum
compiletest: Support ignoring tests requiring missing LLVM components
This PR implements a more principled solution to the problem described in https://github.com/rust-lang/rust/pull/66084.
Builds of LLVM backends take a lot of time and disk space.
So it usually makes sense to build rustc with
```toml
[llvm]
targets = "X86"
experimental-targets = ""
```
unless you are working on some target-specific tasks.
A few tests, however, require non-x86 backends to be built.
A new test directive `// needs-llvm-components: component1 component2 component3` makes such tests to be automatically ignored if one of the listed components is missing in the provided LLVM (this is determined through `llvm-config --components`).
As a result, the test suite now fully passes with LLVM built only with the x86 backend. The component list in this case is
```
aggressiveinstcombine all all-targets analysis asmparser asmprinter binaryformat bitreader bitstreamreader bitwriter cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker engine executionengine frontendopenmp fuzzmutate globalisel instcombine instrumentation interpreter ipo irreader jitlink libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mirparser native nativecodegen objcarcopts object objectyaml option orcerror orcjit passes profiledata remarks runtimedyld scalaropts selectiondag support symbolize tablegen target textapi transformutils vectorize windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86utils xray
```
Rollup merge of #74980 - davidtwco:issue-74745-pprust-regression-test, r=petrochenkov
pprust: adjust mixed comment printing and add regression test for #74745
Fixes #74745.
This PR adds a regression test for #74745. While a `ignore-tidy-trailing-lines` header is required, this doesn't stop the test from reproducing, so long as there is no newline at the end of the file.
However, adding the header comments made the test fail due to a bug in pprust - so this PR also adjusts the pretty printing of mixed comments so that the initial zero-break isn't emitted at the beginning of the line. Through this, the `block-comment-wchar` test can have the `pp-exact` file removed, as it no longer converges from pretty printing of the source.
bors [Sun, 2 Aug 2020 18:01:27 +0000 (18:01 +0000)]
Auto merge of #74963 - JohnTitor:ptn-ice, r=petrochenkov
Fix ICEs with `@ ..` binding
This reverts #74557 and introduces an alternative fix while ensuring that #74954 is not broken.
The diagnostics are verbose though, it fixes three related issues.
cc #74954, #74539, and #74702
bors [Sun, 2 Aug 2020 16:06:54 +0000 (16:06 +0000)]
Auto merge of #75060 - JohnTitor:rollup-aq8sfxf, r=JohnTitor
Rollup of 10 pull requests
Successful merges:
- #74686 (BTreeMap: remove into_slices and its unsafe block)
- #74762 (BTreeMap::drain_filter should not touch the root during iteration)
- #74781 (Clean up E0733 explanation)
- #74874 (BTreeMap: define forget_type only when relevant)
- #74974 (Make tests faster in Miri)
- #75010 (Update elasticlunr-rs and ammonia transitive deps)
- #75041 (Replaced log with tracing crate)
- #75044 (Clean up E0744 explanation)
- #75054 (Rename rustc_middle::cstore::DepKind to CrateDepKind)
- #75057 (Avoid dumping rustc invocations to stdout)
Failed merges:
- #74827 (Move bulk of BTreeMap::insert method down to new method on handle)
Yuki Okushi [Sun, 2 Aug 2020 16:05:28 +0000 (01:05 +0900)]
Rollup merge of #75057 - Mark-Simulacrum:avoid-long-print, r=alexcrichton
Avoid dumping rustc invocations to stdout
These are quite long, usually, and in most cases not interesting. On smaller
terminals they can take up more than a full page of output, hiding the error
diagnostics emitted.
Yuki Okushi [Sun, 2 Aug 2020 16:05:18 +0000 (01:05 +0900)]
Rollup merge of #74874 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
BTreeMap: define forget_type only when relevant
Similar to `forget_node_type` for handles.
No effect on generated code, apart maybe from the superfluous calls that might not have been optimized away.
Yuki Okushi [Sun, 2 Aug 2020 16:05:13 +0000 (01:05 +0900)]
Rollup merge of #74762 - ssomers:btree_no_root_in_remove_kv_tracking, r=Mark-Simulacrum
BTreeMap::drain_filter should not touch the root during iteration
Although Miri doesn't point it out, I believe there is undefined behaviour using `drain_filter` when draining the 11th-last element from a tree that was larger. When this happens, the last remaining child nodes are merged, the root becomes empty and is popped from the tree. That last step establishes a mutable reference to the node elected root and writes a pointer in `node::Root`, while iteration continues to visit the same node.
This is mostly code from #74437, slightly adapted.
Mark Rousskov [Sun, 2 Aug 2020 14:54:13 +0000 (10:54 -0400)]
Avoid dumping rustc invocations to stdout
These are quite long, usually, and in most cases not interesting. On smaller
terminals they can take up more than a full page of output, hiding the error
diagnostics emitted.
David Wood [Sun, 2 Aug 2020 14:31:06 +0000 (15:31 +0100)]
compiletest: print diff for pretty tests
This commit modifies compiletest so that a diff of actual and expected
output is shown for pretty tests. This makes it far easier to work out
what has changed.
David Wood [Fri, 31 Jul 2020 13:53:44 +0000 (14:53 +0100)]
tests: add regression test for #74745
This commit adds a regression test for #74745. While a
`ignore-tidy-trailing-lines` header is required, this doesn't stop the
test from reproducing, so long as there is no newline at the end of the
file.
However, adding the header comments made the test fail due to a bug in
pprust, fixed in the previous commit.
David Wood [Sun, 2 Aug 2020 14:27:03 +0000 (15:27 +0100)]
pprust: adjust mixed comment printing
This commit adjusts the pretty printing of mixed comments so that the
initial zero-break isn't emitted at the beginning of the line. Through
this, the `block-comment-wchar` test can have the `pp-exact` file
removed, as it no longer converges from pretty printing of the source.
bors [Sun, 2 Aug 2020 12:20:09 +0000 (12:20 +0000)]
Auto merge of #74210 - estebank:type-ascriptomatic, r=petrochenkov
Deduplicate `::` -> `:` typo errors
Deduplicate errors caused by the same type ascription typo, including
ones suggested during parsing that would get reported again during
resolve. Fix #70382.
bors [Sun, 2 Aug 2020 09:41:17 +0000 (09:41 +0000)]
Auto merge of #74972 - second-state:wasi-right-fix, r=KodrAus
Fix std::fs::File::metadata permission on WASI target
Previously `std::fs::File::metadata` on wasm32-wasi would call `fd_filestat_get`
to get metadata associated with fd, but that fd is opened without
RIGHTS_FD_FILESTAT_GET right, so it will failed on correctly implemented WASI
environment.
This change instead to add the missing rights when opening an fd.
bors [Sat, 1 Aug 2020 20:43:12 +0000 (20:43 +0000)]
Auto merge of #74726 - oli-obk:tracing, r=Mark-Simulacrum
Move from `log` to `tracing`
The only visible change is that we now get timestamps in our logs:
```
Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: skipping replace of Rvalue::Use(const () because it is already a const
Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: propagated into _2
Jul 24 18:41:01.065 TRACE rustc_mir::transform::const_prop: visit_constant: const ()
```
This PR was explicitly designed to be as low-impact as possible. We can now move to using the name `tracing` insteads of `log` on a crate-by-crate basis and use any of the other tracing features where desirable.
As far as I can tell this will allow tools to seamlessly keep working (since they are using `rustc_driver::init_log...`).
This is the first half of step 1 of the accepted `tracing` MCP (https://github.com/rust-lang/compiler-team/issues/331)
bors [Sat, 1 Aug 2020 18:52:30 +0000 (18:52 +0000)]
Auto merge of #75016 - Manishearth:rollup-x553g7j, r=Manishearth
Rollup of 6 pull requests
Successful merges:
- #74977 (Clean up E0741 error explanation)
- #74981 (Some fixes for `plugin.md` in unstable-book)
- #74983 (Replace a recursive algorithm with an iterative one and a stack.)
- #74995 (Update the WASI libc build to LLVM 10.)
- #74996 (submodules: update cargo from 974eb438d to 2d5c2381e)
- #75007 (Clean up E0743 explanation)
Changes:
````
Use the same index location on nightly as beta
relax deprecated diagnostic message check
Don't print to raw stderr in test
Emit the `test` field in cargo metadata
````
r? @ehuss
Trying to get the fix to the registry-index-hash upstream soonish.
Rollup merge of #74995 - sunfishcode:update-llvm, r=alexcrichton
Update the WASI libc build to LLVM 10.
Among other things, this brings in [the `__main_argc_argv`] patch,
which simplifies the interaction between the compiler and WASI libc's
startup code, which will help work on reactor support.
Rollup merge of #74981 - giraffate:fix_sample_codes_in_unstable_book_plugin, r=GuilliameGomez
Some fixes for `plugin.md` in unstable-book
- sample codes not working
I referred to https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs and https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/lint-plugin.rs.
- broken link
https://github.com/rust-lang/rust/blob/master/src/librustc/lint/builtin.rs -> https://github.com/rust-lang/rust/blob/master/src/librustc_session/lint/builtin.rs
bors [Sat, 1 Aug 2020 04:34:05 +0000 (04:34 +0000)]
Auto merge of #74945 - dingxiangfei2009:promote-static-ref-deref, r=oli-obk
[mir] Special treatment for dereferencing a borrow to a static definition
Fix #70584.
As suggested by @oli-obk in this [comment](https://github.com/rust-lang/rust/issues/70584#issuecomment-626009260), one can chase the definition of the local variable being de-referenced and check if it is a true static variable. If that is the case, `validate_place` will admit the promotion.
This is my first time to contribute to `rustc`, and I have two questions.
1. A generalization to some extent is applied to decide if the promotion is possible in the static context. In case that there are more projection operations preceding the de-referencing, `validate_place` recursively decent into inner projection operations. I have put thoughts into its correctness but I am not totally sure about it.
2. I have a hard time to find a good place for the test case. This patch has to do with MIR, but this test case would look out of place compared to other tests in `src/test/ui/mir` or `src/test/ui/borrowck` because it does not generate errors while others do. It is tentatively placed in `src/test/ui/statics` for now.
bors [Sat, 1 Aug 2020 02:48:34 +0000 (02:48 +0000)]
Auto merge of #74717 - davidtwco:issue-74636-polymorphized-closures-inherited-params, r=oli-obk
mir: add `used_generic_parameters_needs_subst`
Fixes #74636.
This PR adds a `used_generic_parameters_needs_subst` helper function which checks whether a type needs substitution, but only for parameters that the `unused_generic_params` query considers used. This is used in the MIR interpreter to make the check for some pointer casts and for reflection intrinsics more precise.
I've opened this as a draft PR because this might not be the approach we want to fix this issue and we have to decide what to do about the reflection case.
Auto merge of #74994 - JohnTitor:rollup-eknaekv, r=JohnTitor
Rollup of 6 pull requests
Successful merges:
- #74644 (Remove `linked_list_extras` methods.)
- #74968 (Run all tests if have no specified tests)
- #74982 (1.45.2 release notes)
- #74984 (Miri: fix ICE when unwinding past topmost stack frame)
- #74986 (fix part of comparison that would always evaluate to "true", probably an oversight)
- #74991 (Fix Const-Generic Cycle ICE #74199)
Changes:
````
Use the same index location on nightly as beta
relax deprecated diagnostic message check
Don't print to raw stderr in test
Emit the `test` field in cargo metadata
````
Dan Gohman [Fri, 31 Jul 2020 23:07:08 +0000 (16:07 -0700)]
Update the WASI libc build to LLVM 10.
Among other things, this brings in [the `__main_argc_argv`] patch,
which simplifies the interaction between the compiler and WASI libc's
startup code, which will help work on reactor support.
Rollup merge of #74991 - JulianKnodt:74199, r=lcnr
Fix Const-Generic Cycle ICE #74199
This PR intends to fix the bug in Issue #74199 by following the suggestion provided of ignoring the error that causes the ICE.
This does not fix the underlying cycle detection issue, but fixes the ICE.
Also adds a test to check that it doesn't causes an ICE but returns a valid error for now.
r? @lcnr
Edit: Also it's funny how this PR number is an anagram of the issue number