Rollup merge of #62245 - RalfJung:miri-extra-fn, r=eddyb,zackmdavis
Miri engine: support extra function (pointer) values
We want to add basic support for `dlsym` in Miri (needed to run the latest version of `getrandom`). For that to work, `dlsym` needs to return *something* that can be stored in a function pointer and later called.
So we add a new `ExtraFnVal` type to the `Machine` trait, and enable Miri's memory to associate allocation IDs with such values, so that `create_fn_alloc` and `get_fn` can work on *both* `Instance` (this is used for "normal" function pointers) and `ExtraFnVal`.
Rollup merge of #62396 - RalfJung:miri-no-null, r=alexcrichton
remove Scalar::is_null_ptr
Comparing pointers should be done more carefully than that. With https://github.com/rust-lang/miri/pull/825, Miri does not need it any more and it is otherwise unused.
Rollup merge of #62380 - eddyb:x64-sysv-regs, r=nagisa
rustc_target: avoid negative register counts in the SysV x86_64 ABI.
Because `needed_{int,sse}` and `{int,sse}_regs` were only used with integer literals, they were inferred to `i32` and `{int,sse}_regs` could therefore be negative.
There was a check which prevented that, but *only* for aggregate arguments, not scalars.
Rollup merge of #62193 - matthewjasper:dynamic-drop-async, r=Centril
Create async version of the dynamic-drop test
Some of the tests in dynamic-drop have been cut:
* The tests that are just simpler versions of other tests - these tests are already fairly slow due to all of the unwinding and async functions have more control flow paths than normal functions.
* The union test - it's for an unstable feature that has an RFC to remove it.
* The generator test - there aren't async generators yet.
* The tests that show values being leaked - these can be added once the issue is fixed.
Rollup merge of #62168 - ljedrz:the_culmination_of_hiridification, r=Zoxc
The (almost) culmination of HirIdification
It's finally over.
This PR removes old `FIXME`s and renames some functions so that the `HirId` variant has the shorter name.
All that remains (and rightfully so) is stuff in `resolve`, `save_analysis` and (as far as I can tell) in a few places where we can't replace `NodeId` with `HirId`.
Rollup merge of #61545 - flip1995:internal_lints, r=oli-obk
Implement another internal lints
cc #49509
This adds ~~two~~ one internal lint~~s~~:
1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc #59669
2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in #49509~~
~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~
TODO (not directly relevant for review):
- [ ] https://github.com/rust-lang/rust/pull/59316#discussion_r280186517 (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) :thinking: cc @eddyb)
- [x] https://github.com/rust-lang/rust/pull/61735#discussion_r292389870
- [x] Check explicitly for the `{declare,impl}_lint_pass!` macros
Auto merge of #62407 - Centril:rollup-g0zmff7, r=Centril
Rollup of 10 pull requests
Successful merges:
- #62123 ( Remove needless lifetimes (std))
- #62150 (Implement mem::{zeroed,uninitialized} in terms of MaybeUninit.)
- #62169 (Derive which queries to save using the proc macro)
- #62238 (Fix code block information icon position)
- #62292 (Move `async || ...` closures into `#![feature(async_closure)]`)
- #62323 (Clarify unaligned fields in ptr::{read,write}_unaligned)
- #62324 (Reduce reliance on `await!(...)` macro)
- #62371 (Add tracking issue for Box::into_pin)
- #62383 (Improve error span for async type inference error)
- #62388 (Break out of the correct number of scopes in loops)
Rollup merge of #62388 - rust-lang:fix-loop-break-mir-generation, r=eddyb
Break out of the correct number of scopes in loops
We were incorrectly breaking out of one too many drop scopes when
generating MIR for loops and breakable blocks, resulting in use after
free and associated borrow checker warnings.
This wasn't noticed because the scope that we're breaking out of twice
is only used for temporaries that are created for adjustments applied to
the loop. Since loops generally propagate coercions to the `break`
expressions, the only case we see this is when the type of the loop is a
smart pointer to a trait object.
This is useful for getting the total compilation time at the end.
To do this, the patch changes `print_time_passes_entry` to not increment
the depth, which means that `print_time_passes_entry_internal` is no
longer needed.
Auto merge of #62153 - alexcrichton:parallel-compress, r=Mark-Simulacrum
Update the `rust-installer` submodule
This pulls in a commit which uses parallel xz encoding which should
hopefully help shave some time off the dist builders which spend an
inordinate amount of time compressing this data.
Matthew Jasper [Thu, 4 Jul 2019 20:53:46 +0000 (21:53 +0100)]
Break out of the correct number of scopes in loops
We were incorrectly breaking out of one too many drop scopes when
generating MIR for loops and breakable blocks, resulting in use after
free and associated borrow checker warnings.
This wasn't noticed because the scope that we're breaking out of twice
is only used for temporaries that are created for adjustments applied to
the loop. Since loops generally propagate coercions to the `break`
expressions, the only case we see this is when the type of the loop is a
smart pointer to a trait object.
Alex Crichton [Wed, 26 Jun 2019 15:24:43 +0000 (08:24 -0700)]
Update the `rust-installer` submodule
This pulls in a commit which uses parallel xz encoding which should
hopefully help shave some time off the dist builders which spend an
inordinate amount of time compressing this data.
Auto merge of #62355 - Centril:rollup-xnxtcgm, r=Centril
Rollup of 16 pull requests
Successful merges:
- #62039 (Remove needless lifetimes (rustc))
- #62173 (rename InterpretCx -> InterpCx)
- #62240 (wfcheck: resolve the type-vars in `AdtField` types)
- #62249 (Use mem::take instead of mem::replace with default)
- #62252 (Update mem::replace example to not be identical to mem::take)
- #62258 (syntax: Unsupport `foo! bar { ... }` macros in the parser)
- #62268 (Clean up inherent_impls)
- #62287 (Use link attributes on extern "C" blocks with llvm-libuwind)
- #62295 (miri realloc: do not require giving old size+align)
- #62297 (refactor check_for_substitution)
- #62316 (When possible without changing semantics, implement Iterator::last in terms of DoubleEndedIterator::next_back for types in liballoc and libcore.)
- #62317 (Migrate `compile-pass` annotations to `build-pass`)
- #62337 (Fix bucket in CPU usage script)
- #62344 (simplify Option::get_or_insert)
- #62346 (enable a few more tests in Miri and update the comment for others)
- #62351 (remove bogus example from drop_in_place)
Rollup merge of #62316 - khuey:efficient_last, r=sfackler
When possible without changing semantics, implement Iterator::last in terms of DoubleEndedIterator::next_back for types in liballoc and libcore.
Provided that the iterator has finite length and does not trigger user-provided code, this is safe.
What follows is a full list of the DoubleEndedIterators in liballoc/libcore and whether this optimization is safe, and if not, why not.
src/liballoc/boxed.rs
Box: Pass through to avoid defeating optimization of the underlying DoubleIterator implementation. This has no correctness impact.
src/liballoc/collections/binary_heap.rs
Iter: Pass through to avoid defeating optimizations on slice::Iter
IntoIter: Not safe, changes Drop order
Drain: Not safe, changes Drop order
src/liballoc/collections/btree/map.rs
Iter: Safe to call next_back, invokes no user defined code.
IterMut: ditto
IntoIter: Not safe, changes Drop order
Keys: Safe to call next_back, invokes no user defined code.
Values: ditto
ValuesMut: ditto
Range: ditto
RangeMut: ditto
src/liballoc/collections/btree/set.rs
Iter: Safe to call next_back, invokes no user defined code.
IntoIter: Not safe, changes Drop order
Range: Safe to call next_back, invokes no user defined code.
src/liballoc/collections/linked_list.rs
Iter: Safe to call next_back, invokes no user defined code.
IterMut: ditto
IntoIter: Not safe, changes Drop order
src/liballoc/collections/vec_deque.rs
Iter: Safe to call next_back, invokes no user defined code.
IterMut: ditto
IntoIter: Not safe, changes Drop order
Drain: ditto
src/liballoc/string.rs
Drain: Safe because return type is a primitive (char)
src/liballoc/vec.rs
IntoIter: Not safe, changes Drop order
Drain: ditto
Splice: ditto
src/libcore/ascii.rs
EscapeDefault: Safe because return type is a primitive (u8)
src/libcore/iter/adapters/chain.rs
Chain: Not safe, invokes user defined code (Iterator impl)
src/libcore/iter/adapters/flatten.rs
FlatMap: Not safe, invokes user defined code (Iterator impl)
Flatten: ditto
FlattenCompat: ditto
src/libcore/iter/adapters/mod.rs
Rev: Not safe, invokes user defined code (Iterator impl)
Copied: ditto
Cloned: Not safe, invokes user defined code (Iterator impl and T::clone)
Map: Not safe, invokes user defined code (Iterator impl + closure)
Filter: ditto
FilterMap: ditto
Enumerate: Not safe, invokes user defined code (Iterator impl)
Skip: ditto
Fuse: ditto
Inspect: ditto
src/libcore/iter/adapters/zip.rs
Zip: Not safe, invokes user defined code (Iterator impl)
src/libcore/iter/range.rs
ops::Range: Not safe, changes Drop order, but ALREADY HAS SPECIALIZATION
ops::RangeInclusive: ditto
src/libcore/iter/sources.rs
Repeat: Not safe, calling last should iloop.
Empty: No point, iterator is at most one item long.
Once: ditto
OnceWith: ditto
src/libcore/option.rs
Item: No point, iterator is at most one item long.
Iter: ditto
IterMut: ditto
IntoIter: ditto
src/libcore/result.rs
Iter: No point, iterator is at most one item long
IterMut: ditto
IntoIter: ditto
src/libcore/slice/mod.rs
Split: Not safe, invokes user defined closure
SplitMut: ditto
RSplit: ditto
RSplitMut: ditto
Windows: Safe, already has specialization
Chunks: ditto
ChunksMut: ditto
ChunksExact: ditto
ChunksExactMut: ditto
RChunks: ditto
RChunksMut: ditto
RChunksExact: ditto
RChunksExactMut: ditto
src/libcore/str/mod.rs
Chars: Safe, already has specialization
CharIndices: ditto
Bytes: ditto
Lines: Safe to call next_back, invokes no user defined code.
LinesAny: Deprecated
Everything that is generic over P: Pattern: Not safe because Pattern invokes user defined code.
SplitWhitespace: Safe to call next_back, invokes no user defined code.
SplitAsciiWhitespace: ditto
Rollup merge of #62287 - petrhosek:libunwind-link-attribute, r=tmandry
Use link attributes on extern "C" blocks with llvm-libuwind
When llvm-libunwind feature is enabled, we need to use link attribute on
extern "C" blocks to make sure that symbols provided by LLVM's libunwind
that's built as part of Rust's libunwind crate are re-exported.
Rollup merge of #62258 - petrochenkov:idclean, r=Centril
syntax: Unsupport `foo! bar { ... }` macros in the parser
Their support in expansion was removed in https://github.com/rust-lang/rust/pull/61606.
Also un-reserve `macro_rules` as a macro name, there's no ambiguity between `macro_rules` definitions and macro calls (it also wasn't reserved correctly).
cc https://github.com/rust-lang-nursery/wg-grammar/issues/51
Rollup merge of #62240 - arielb1:resolve-wf-fields, r=pnkfelix
wfcheck: resolve the type-vars in `AdtField` types
Normalization can leave some type-vars unresolved in its return type.
Make sure to resolve them so we have an infcx-independent type that can
be used with `needs_drop`.
Auto merge of #62335 - Mark-Simulacrum:rollup-0pcaz5a, r=Mark-Simulacrum
Rollup of 15 pull requests
Successful merges:
- #62021 (MSVC link output improve)
- #62064 (nth_back for chunks_exact)
- #62128 (Adjust warning of -C extra-filename with -o.)
- #62161 (Add missing links for TryFrom docs)
- #62183 (std: Move a process test out of libstd)
- #62186 (Add missing type urls in Into trait)
- #62196 (Add Vec::leak)
- #62199 (import gdb for explicit access to gdb.current_objfile())
- #62229 (Enable intptrcast for explicit casts)
- #62250 (Improve box clone doctests to ensure the documentation is valid)
- #62255 (Switch tracking issue for `#![feature(slice_patterns)]`)
- #62285 (Fix michaelwoerister's mailmap)
- #62304 (HashMap is UnwindSafe)
- #62319 (Fix mismatching Kleene operators)
- #62327 (Fixed document bug, those replaced each other)
Mark Rousskov [Wed, 3 Jul 2019 13:59:28 +0000 (09:59 -0400)]
Rollup merge of #62304 - SimonSapin:safe, r=eddyb
HashMap is UnwindSafe
Fixes https://github.com/rust-lang/rust/issues/62301, a regression in 1.36.0-pre which was caused by hashbrown using `NonZero<T>` where the older hashmap used `Unique<T>`.