BTreeSet symmetric_difference & union optimized
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.
r? @bluss
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.
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.
More symbol cleanups
Some minor improvements, mostly aimed at reducing unimportant differences between `Symbol` and `InternedString`. Helps a little with #60869.
r? @petrochenkov
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.
r? @RalfJung
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.
r? @matthewjasper or @mark-i-m
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)
r? @ghost
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.
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.
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.
Closes#65411
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.
properly document panics in div_euclid and rem_euclid
For signed numbers, document that `div_euclid` and `rem_euclid` panic not just when `rhs` is 0, but also when the division overflows.
For unsigned numbers, document that `div_euclid` and `rem_euclid` panic when `rhs` is 0.
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.
r? @nikomatsakis
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.
r? @petrochenkov
Disable Go and OCaml bindings when building LLVM
Instead of instaling OCaml bindings in a location where installation
will not fail, don't build them in the first place.
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.
```
[-] src/librustc_mir/transform/no_landing_pads.rs
[x] src/librustc_mir/transform/promote_consts.rs
[x] src/librustc_mir/transform/generator.rs
[x] src/librustc_mir/transform/erase_regions.rs
[-] src/librustc_mir/transform/instcombine.rs
[x] src/librustc_mir/transform/inline.rs
[x] src/librustc_mir/transform/simplify.rs
[x] src/librustc_mir/util/def_use.rs
[-] src/librustc_mir/transform/const_prop.rs
[-] src/librustc_mir/transform/cleanup_post_borrowck.rs
[x] src/librustc_mir/borrow_check/nll/renumber.rs
[-] src/librustc_mir/transform/copy_prop.rs
```
There is some code repetition, just created the PR so we can start discussing it.
/cc @oli-obk @nikomatsakis
Always inline `mem::{size_of,align_of}` in debug builds
Those two are const fn and do not have any arguments. Inlining
helps reducing generated code size in debug builds.
See also #64996.