bors [Mon, 21 Oct 2019 04:01:37 +0000 (04:01 +0000)]
Auto merge of #65630 - ecstatic-morse:graphviz-tidy, r=Mark-Simulacrum
Check all files in `src/test` for `borrowck_graphviz_postflow`
This attribute causes DOT files to be generated in the top-level directory. It is intended to be used only temporarily and should never appear on master. This also tells git to ignore DOT files in the root or the `mir_dump` directory, which `-Z dump-mir` uses by default.
This will prevent #65071 from occurring again. It needs to be merged after #65629, otherwise `tidy` will start failing.
bors [Sun, 20 Oct 2019 23:40:12 +0000 (23:40 +0000)]
Auto merge of #65644 - Centril:rollup-gez1xhe, r=Centril
Rollup of 8 pull requests
Successful merges:
- #65314 (rustdoc: forward -Z options to rustc)
- #65592 (clarify const_prop ICE protection comment)
- #65603 (Avoid ICE when include! is used by stdin crate)
- #65614 (Improve error message for APIT with explicit generic arguments)
- #65629 (Remove `borrowck_graphviz_postflow` from test)
- #65633 (Remove leading :: from paths in doc examples)
- #65638 (Rename the default argument 'def' to 'default')
- #65639 (Fix parameter name in documentation)
Couldn't find an existing issue on this (then again, "::" makes for an annoying thing to search for) so if there is already something fixing this and/or there's a reason to not fix it, just close this PR.
(Also fixed indentation in the `process::exit()` docs)
Rollup merge of #65592 - RalfJung:const-prop-comment, r=wesleywiser
clarify const_prop ICE protection comment
This is based on discussion at https://github.com/rust-lang/rust/pull/64890/files#r334555787.
That said, why are function arguments the only unsized locals that could remain uninitialized? Couldn't we also fail to initialize some local but still go on with const_prop, and then hit a line that takes a reference to that? Cc @wesleywiser @oli-obk ; I don't know enough about const-prop to understand why this can happen only for function arguments.
~~The PR includes https://github.com/rust-lang/rust/pull/64890; the only new commit is 05e4e6ba0d5.~~
Rollup merge of #65314 - tmiasko:rustdoc-z, r=ollie27
rustdoc: forward -Z options to rustc
Currently rustdoc does not forward `-Z` options to rustc when building
test executables. This makes impossible to use rustdoc to run test
samples when crate under test is instrumented with one of sanitizers
`-Zsanitizer=...`, since the final linking step will not include
sanitizer runtime library.
Yuki Okushi [Sun, 20 Oct 2019 18:10:55 +0000 (03:10 +0900)]
Rollup merge of #65463 - nnethercote:rm-arena-allocation-from-expand_pattern, r=varkor
Avoid unnecessary arena allocations in `expand_pattern()`.
`expand_pattern()` has two callsites. One of them needs arena
allocation, but the other does not.
This commit moves the arena allocation out of the function. This avoids
the allocation of many 4 KiB page arena chunks that only hold a single
small allocation. It reduces the number of bytes allocated by up to 2%
for various benchmarks, albeit without only a very small improvement in
runtime.
Dylan MacKenzie [Sun, 20 Oct 2019 17:46:49 +0000 (10:46 -0700)]
Check all files in `src/test` for `borrowck_graphviz_postflow`
This attribute causes DOT files to be generated in the top-level
directory. It is intended to be used only temporarily and should never
appear on master.
Rollup merge of #65600 - integer32llc:bye-bye-ref, r=Centril
Remove unneeded `ref` from docs
Will reduce confusion like in https://users.rust-lang.org/t/help-understanding-the-ref-t-syntax/33779 since match ergonomics means you (almost) never have to say `ref` anymore!
There might be more like this, but I don't have a checkout on my computer right this second and I'm on slow wifi and GitHub search isn't powerful enough and that's my story.
Rollup merge of #65593 - RalfJung:non-const-fn, r=oli-obk
add test for calling non-const fn
The good news is that there is an error. But I expected to see [this error](https://github.com/rust-lang/rust/blob/9578272d681c8691ca2ff3f5c4230b491bc1c694/src/librustc_mir/const_eval.rs#L346) surface. @oli-obk any idea why that message is not shown anywhere?
Rollup merge of #65551 - sinkuu:cstring_spec, r=sfackler
Avoid realloc in `CString::new`
If `&[u8]` or `&str` is given, `CString::new` allocates a new `Vec` with the exact capacity, and then `CString::from_vec_unchecked` calls `.reserve_exact(1)` for nul byte. This PR avoids the reallocation by allocationg `len + 1` bytes beforehand. In microbenchmark this PR speeds up `CString::new(&[u8])` by 30%.
bors [Sun, 20 Oct 2019 10:11:10 +0000 (10:11 +0000)]
Auto merge of #65497 - choller:master, r=tmiasko
Avoid injecting sanitizer runtimes into staticlibs (#64629).
This fixes the remaining issue in `creader.rs` and also fixes the expected test failure. I have explicitly turned the `$(CC)` call into a negative check with the `!` to ensure that this command is really failing (if it is not, then either the runtime is attached to the lib or the lib has not been instrumented and both would be an error).
I've also borrowed `program.rs` and the additional `rustc` invocation from @tmiasko 's PR since he pointed out that using `-fsanitize=address` with `$(CC)` for linking could fail if the sanitizer runtimes on the system are incompatible.
With this toolchain I was able to compile Firefox locally without any linker errors. I am still seeing races with Rust in TSan but I assume that is because I did not build with `-Z build-std`.
bors [Sun, 20 Oct 2019 02:06:42 +0000 (02:06 +0000)]
Auto merge of #65302 - msizanoen1:fix-armv7-segfault, r=alexcrichton
Upgrade GCC to 8.3.0, glibc to 1.17.0 and crosstool-ng to 1.24.0 for dist-armv7-linux
#62896 was caused by the usage of the GCC 5.2.0 toolchain, which was released back in 2015 and may have bugs affecting LLVM 9.
This PR upgrade GCC to 8.3.0 from 5.2.0, glibc from 1.16.0 to 1.17.0 and crosstool-ng to 1.24.0 only for dist-armv7-linux.
Fixes #62896
bors [Sat, 19 Oct 2019 22:01:30 +0000 (22:01 +0000)]
Auto merge of #65094 - oxalica:linux-statx, r=alexcrichton
Prefer statx on linux if available
This PR make `metadata`-related functions try to invoke `statx` first on Linux if available,
making `std::fs::Metadata::created` work on Linux with `statx` supported.
It follows the discussion in #61386 , and will fix #59743
The implementation of this PR is simply converting `struct statx` into `struct stat64` with
extra fields for `btime` if `statx` succeeds, since other fields are not currently used.
---
I also did a separated benchmark for `fs::metadata`, `stat64`, `statx`, and `statx` with conversion to `stat64`.
It shows that `statx` with conversion is even more faster than pure `statx`.
I think it's due to `sizeof stat64 == 114` but `sizeof statx == 256`.
Anyway, the bare implementation of `statx` with conversion is only about 0.2% slower than the original impl (`stat64`-family).
With heap-allocation counted (~8.5% of total cost), the difference between `stat` and `statx` (with or without conversion) is just nothing.
Therefore, I think it is not urgent to use bare `struct statx` as underlying representation now.
There is no need to break `std::os::linux::fs::MetadataExt::as_raw_stat` (https://github.com/rust-lang/rust/pull/61386#issuecomment-538074018)
Will reduce confusion like in https://users.rust-lang.org/t/help-understanding-the-ref-t-syntax/33779 since match ergonomics means you (almost) never have to say `ref` anymore!
See https://github.com/rust-lang/rust/issues/64484. This does not yet edit `Arc` as I first wanted to be sure we agree on the terminology the way it actually ends up. "value" as a term appears a lot in this file, and sometimes it refers to the value stored inside the `RcBox` while sometimes it refers to the `RcBox` itself. I tried to properly tease these apart but may have made some mistakes. The former should now always be called "inner value" and the latter "allocation".
One area where I was very unsure of which terminology is dropping: the `value` field of the `RcBox` will get dropped *earlier* than the `RcBox` itself if there are weak references. I decided that "dropping the value stored in the allocation" refers to dropping the value field, while "destroying the allocation" refers to actually freeing its backing memory.
No scalability changes, but:
- Grew the cmp_opt function (shared by symmetric_difference & union) into a MergeIter, with less memory overhead than the pairs of Peekable iterators now, speeding up ~20% on my machine (not so clear on Travis though, I actually switched it off there because it wasn't consistent about identical code). Mainly meant to improve readability by sharing code, though it does end up using more lines of code. Extending and reusing the MergeIter in btree_map might be better, but I'm not sure that's possible or desirable. This MergeIter probably pretends to be more generic than it is, yet doesn't declare to be an iterator because there's no need to, it's only there to help construct genuine iterators SymmetricDifference & Union.
- Compact the code of #64820 by moving if/else into match guards.
Rollup merge of #65192 - estebank:restrict-bound, r=matthewjasper
Use structured suggestion for restricting bounds
When a trait bound is not met and restricting a type parameter would
make the restriction hold, use a structured suggestion pointing at an
appropriate place (type param in param list or `where` clause).
Account for opaque parameters where instead of suggesting extending
the `where` clause, we suggest appending the new restriction:
`fn foo(impl Trait + UnmetTrait)`. Fix #64565, fix #41817, fix #24354,
cc #26026, cc #37808, cc #24159, fix #37138, fix #24354, cc #20671.
bors [Sat, 19 Oct 2019 05:11:13 +0000 (05:11 +0000)]
Auto merge of #65588 - Centril:rollup-9k55k3t, r=Centril
Rollup of 6 pull requests
Successful merges:
- #65174 (Fix zero-size uninitialized boxes)
- #65252 (expand: Simplify expansion of derives)
- #65485 (Suppress ICE when validators disagree on `LiveDrop`s in presence of `&mut`)
- #65542 (Refer to "associated functions" instead of "static methods")
- #65545 (More symbol cleanups)
- #65576 (Don't add `argc` and `argv` arguments to `main` on WASI.)
Rollup merge of #65576 - sunfishcode:main-needs-argc-argv, r=alexcrichton
Don't add `argc` and `argv` arguments to `main` on WASI.
Add a target setting to allow targets to specify whether the generated
`main` function should be passed `argc` and `argv` arguments. Set it
to false on wasm32-wasi, since WASI's `args::args()` calls into the
WASI APIs itself. This will allow the WASI toolchain to avoid linking
and running command-line argument initialization code when the arguments
aren't actually needed.
Rollup merge of #65485 - ecstatic-morse:const-validation-mismatch-ugliness, r=eddyb
Suppress ICE when validators disagree on `LiveDrop`s in presence of `&mut`
Resolves #65394.
This hack disables the validator mismatch ICE in cases where a `MutBorrow` error has been emitted by both validators, but they don't agree on the number of `LiveDrop` errors.
The new validator is more conservative about whether a value is moved from in the presence of mutable borrows. For example, the new validator will emit a `LiveDrop` error on the following code.
```rust
const _: Vec<i32> = {
let mut x = Vec::new();
let px = &mut x as *mut _;
let y = x;
unsafe { ptr::write(px, Vec::new()); }
y
};
```
This code is not UB AFAIK (it passes MIRI at least). The current validator does not emit a `LiveDrop` error for `x` upon exit from the initializer. `x` is not actually dropped, so I think this is correct? A proper fix for this would require a new `MaybeInitializedLocals` dataflow analysis or maybe a relaxation of the existing `IndirectlyMutableLocals` one.
Rollup merge of #65252 - petrochenkov:deriveholders2, r=matthewjasper
expand: Simplify expansion of derives
And make it more uniform with other macros.
This is done by merging placeholders for future derives' outputs into the derive container's output fragment early (addressing FIXMEs from https://github.com/rust-lang/rust/pull/63667).
Also, macros with names starting with `_` are no longer reported as unused, in accordance with the usual behavior of `unused` lints.
bors [Sat, 19 Oct 2019 01:16:41 +0000 (01:16 +0000)]
Auto merge of #65570 - tmandry:rollup-hck39pf, r=tmandry
Rollup of 19 pull requests
Successful merges:
- #65016 (Always inline `mem::{size_of,align_of}` in debug builds)
- #65197 (Prepare `MutVisitor`s to handle interned projections)
- #65201 (Disable Go and OCaml bindings when building LLVM)
- #65334 (Add long error explanation for E0575)
- #65364 (Collect occurrences of empty blocks for mismatched braces diagnostic)
- #65455 (Avoid unnecessary `TokenTree` to `TokenStream` conversions)
- #65472 (Use a sharded dep node to dep node index map)
- #65480 (Speed up `LexicalResolve::expansion()`)
- #65493 (Add long error explanation for E0584)
- #65496 (properly document panics in div_euclid and rem_euclid)
- #65498 (Plugins deprecation: don’t suggest simply removing the attribute)
- #65508 (add option to ping llvm ice-breakers to triagebot)
- #65511 (save-analysis: Nest tables when processing impl block definitions)
- #65513 (reorder fmt docs for more clarity)
- #65532 (doc: make BitSet intro more short)
- #65535 (rustc: arena-allocate the slice in `ty::GenericsPredicate`, not the whole struct.)
- #65540 (show up some extra info when t!() fails)
- #65549 (Fix left/right shift typo in wrapping rotate docs)
- #65552 (Clarify diagnostics when using `~` as a unary op)
Failed merges:
- #65390 (Add long error explanation for E0576)
- #65434 (Add long error explanation for E0577)
- #65471 (Add long error explanation for E0578)
Tyler Mandry [Fri, 18 Oct 2019 20:48:34 +0000 (13:48 -0700)]
Rollup merge of #65535 - eddyb:sliced-predicates, r=nikomatsakis
rustc: arena-allocate the slice in `ty::GenericsPredicate`, not the whole struct.
While rebasing #59789 I noticed we can do this now. However, it doesn't help much without changing `inferred_outlives_of` to the same type, which I might try next.
Tyler Mandry [Fri, 18 Oct 2019 20:48:31 +0000 (13:48 -0700)]
Rollup merge of #65513 - RalfJung:fmt, r=Mark-Simulacrum
reorder fmt docs for more clarity
I adjusted these docs in https://github.com/rust-lang/rust/pull/65332 but wasn't happy with the result when seeing it in rustdoc. So this reorders the subsections in the "Formatting Parameters" section to be more logical (subsections that reference `width` come after the `width` subsection) and they also all have examples now.
Tyler Mandry [Fri, 18 Oct 2019 20:48:29 +0000 (13:48 -0700)]
Rollup merge of #65511 - Xanewok:sa-nest-in-impls, r=pnkfelix
save-analysis: Nest tables when processing impl block definitions
Similar to #65353 (which this PR should've been a part of), however in this case we didn't previously nest the tables when processing trait paths in impl block declarations.
Tyler Mandry [Fri, 18 Oct 2019 20:48:26 +0000 (13:48 -0700)]
Rollup merge of #65498 - SimonSapin:plugin-help, r=Centril
Plugins deprecation: don’t suggest simply removing the attribute
Building Servo with a recent Nightly produces:
```rust
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/issues/29597
--> components/script/lib.rs:14:1
|
14 | #![plugin(script_plugins)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
= note: `#[warn(deprecated)]` on by default
```
First, linking to https://github.com/rust-lang/rust/issues/29597 is not ideal since there is pretty much no discussion there of the deprecation and what can be used instead. This PR changes the link to the deprecation PR which does have more discussion.
Second, the “remove this attribute” suggestion is rather unhelpful. Just because a feature is deprecated doesn’t mean that simply removing its use without a replacement is acceptable.
In the case of custom lint, there is no replacement available. Prefixing a message with “help:” when telling users that they’re screwed honestly feels disrespectful.
This PR also changes the message to be more factual.
Tyler Mandry [Fri, 18 Oct 2019 20:48:22 +0000 (13:48 -0700)]
Rollup merge of #65480 - nnethercote:rm-iterate_until_fixed_size, r=nikomatsakis
Speed up `LexicalResolve::expansion()`
A couple of improvements that speed up `unicode_normalization` by about 4%. The first commit was enabled by the improvements to `BitSet` iteration in #65425.
Tyler Mandry [Fri, 18 Oct 2019 20:48:18 +0000 (13:48 -0700)]
Rollup merge of #65455 - nnethercote:avoid-unnecessary-TokenTree-to-TokenStream-conversions, r=petrochenkov
Avoid unnecessary `TokenTree` to `TokenStream` conversions
A `TokenStream` contains any number of `TokenTrees`. Therefore, a single `TokenTree` can be promoted to a `TokenStream`. But doing so costs two allocations: one for the single-element `Vec`, and one for the `Lrc`. (An `IsJoint` value also must be added; the default is `NonJoint`.)
The current code converts `TokenTree`s to `TokenStream`s unnecessarily in a few places. This PR removes some of these unnecessary conversions, both simplifying the code and speeding it up.
Tyler Mandry [Fri, 18 Oct 2019 20:48:11 +0000 (13:48 -0700)]
Rollup merge of #65197 - spastorino:place-mut-visitor-adjusts2, r=oli-obk
Prepare `MutVisitor`s to handle interned projections
The following are all the files where mir's `MutVisitor` is implemented. The `-` there stands for no changes, `visit_place` wasn't making any change on `Place`s. `x` stands for this file was changed to make `visit_place` do whatever it was doing with the base but avoid modifying the projection, instead just create a new one and assign to it.