bors [Wed, 19 Aug 2020 10:54:44 +0000 (10:54 +0000)]
Auto merge of #75600 - nagisa:improve_align_offset, r=KodrAus
Improve codegen for `align_offset`
In this PR the `align_offset` implementation is changed/improved to produce better code in certain scenarios such as when pointer type is has a stride of 1 or when building for low optimisation levels.
While these changes do not achieve the "ideal" codegen referenced in #75579, it gets significantly closer to it. I’m not actually sure if the codegen can actually be much better with this function returning the offset, rather than the aligned pointer.
See the descriptions for separate commits for further information.
bors [Wed, 19 Aug 2020 06:59:13 +0000 (06:59 +0000)]
Auto merge of #75692 - JohnTitor:rollup-8gr04ah, r=JohnTitor
Rollup of 9 pull requests
Successful merges:
- #75038 (See also X-Link mem::{swap, take, replace})
- #75049 (docs(marker/copy): provide example for `&T` being `Copy`)
- #75499 (Fix documentation error)
- #75554 (Fix clashing_extern_declarations stack overflow for recursive types.)
- #75646 (Move to intra doc links for keyword documentation)
- #75652 (Resolve true and false as booleans)
- #75658 (Don't emit "is not a logical operator" error outside of associative expressions)
- #75665 (Add doc examples coverage)
- #75685 (Switch to intra-doc links in /src/sys/unix/ext/*.rs)
These two links are not resolving to either `crate::fs::File...` or `fs::File...`
```
# unix/ext/fs.rs
27: /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read
Yuki Okushi [Wed, 19 Aug 2020 06:54:35 +0000 (15:54 +0900)]
Rollup merge of #75658 - tgnottingham:issue-75599, r=estebank
Don't emit "is not a logical operator" error outside of associative expressions
Avoid showing this error where it doesn't make sense by not assuming
"and" and "or" were intended to mean "&&" and "||" until after we decide
to continue parsing input as an associative expression.
Note that the decision of whether or not to continue parsing input as an
associative expression doesn't actually depend on this assumption.
Fixes #75599
---
First time contributor! Let me know if there are any conventions or policies I should be following that I missed here. Thanks :)
Yuki Okushi [Wed, 19 Aug 2020 06:54:30 +0000 (15:54 +0900)]
Rollup merge of #75554 - jumbatm:fix-clashing-extern-decl-overflow, r=lcnr
Fix clashing_extern_declarations stack overflow for recursive types.
Fixes #75512.
Adds a seen set to `structurally_same_type` to avoid recursing indefinitely for types which contain values of the same type through a pointer or reference.
Yuki Okushi [Wed, 19 Aug 2020 06:54:26 +0000 (15:54 +0900)]
Rollup merge of #75049 - janriemer:patch-1, r=poliorcetics
docs(marker/copy): provide example for `&T` being `Copy`
### Edited 2020-08-16 (most recent)
In the current documentation about the `Copy` marker trait, there is a section
with examples of structs that can implement `Copy`. Currently there is no example for
showing that shared references (`&T`) are also `Copy`.
It is worth to have a dedicated example for `&T` being `Copy`, because shared
references are an integral part of the language and it being `Copy` is not as
intuitive as other types that share this behaviour like `i32` or `bool`.
The example picks up on the previous non-`Copy` struct and shows that
structs can be `Copy`, even when they hold a shared reference to a non-`Copy` type.
-----------------------------------------
### Edited 2020-08-02, 3:28 p.m.
I've just realized that it says "in addition to the **implementors listed below**", which makes this PR kind of "wrong", because `&T` is indeed in the "implementors listed below".
Maybe we can instead show an example with `&T` in the [When can my type be Copy](https://doc.rust-lang.org/std/marker/trait.Copy.html#when-can-my-type-be-copy) section.
What I really want to achieve is that it becomes more obvious that `&T` is also `Copy`, because, I think, it is very valuable to know and it wasn't obvious for me, until I read something about it in a forum post.
What do you think? I would create another PR for that.
**Please feel free to close this PR.**
-----------------------------------
### Original post
In the current documentation about the `Copy` marker trait, there is a section
about "additional implementors", which list additional implementors of the `Copy` trait.
The fact that shared references are also `Copy` is mixed with another point,
which makes it hard to recognize and make it seem not as important.
This clarifies the fact that shared references are also `Copy`, by mentioning it as a
separate item in the list of "additional implementors".
Yuki Okushi [Wed, 19 Aug 2020 06:54:24 +0000 (15:54 +0900)]
Rollup merge of #75038 - rust-lang:Havvy-patch-1, r=steveklabnik
See also X-Link mem::{swap, take, replace}
Since it's easy to end up at one of these functions when you really wanted the other one, cross link them with descriptions of why you'd want to use them.
bors [Wed, 19 Aug 2020 02:56:59 +0000 (02:56 +0000)]
Auto merge of #75677 - cuviper:shrink-towel, r=Mark-Simulacrum
Don't panic in Vec::shrink_to_fit
We can help the compiler see that `Vec::shrink_to_fit` will never reach the panic case in `RawVec::shrink_to_fit`, just by guarding the call only for cases where the capacity is strictly greater. A capacity less than the length is only possible through an unsafe call to `set_len`, which would break the `Vec` invariants, so `shrink_to_fit` can just ignore that.
This removes the panicking code from the examples in both #71861 and #75636.
bors [Wed, 19 Aug 2020 01:02:19 +0000 (01:02 +0000)]
Auto merge of #75555 - workingjubilee:update-everything, r=Mark-Simulacrum
Cargo update (almost) all the things!
This runs `cargo update` on our dependency tree, bumping numerous crates. See details in the first commit of this PR.
Several updates were held back intentionally; version_check in particular landed a change in behavior in 0.9.2 (arguably a bug fix, but still will be split into a separate PR).
bors [Tue, 18 Aug 2020 20:51:22 +0000 (20:51 +0000)]
Auto merge of #75516 - matklad:remove-deprecation, r=petrochenkov
Promote missing_fragment_specifier to hard error
It has been deny_by_default since 2017 (and warned for some time
before that), so it seems reasonable to promote it.
The specific technical motivation to do this now is to remove a field
from `ParseSess` -- it is a global state, and global state makes
extracting libraries annoying.
Tomasz Miąsko [Tue, 18 Aug 2020 19:55:54 +0000 (12:55 -0700)]
Fix asm compiler flags change from cmake 0.1.44
cmake-rs@8141f0e changed the logic for handling asm compiler flags.
This change was pulled in with the cmake 0.1.42 -> 0.1.44 update.
This introduced two new flags to the LLVM build, breaking it:
"-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64"
"-DCMAKE_ASM_COMPILER=/usr/bin/cc"
This patch should resolve the breakage by handling it in bootstrap.
Tyson Nottingham [Tue, 18 Aug 2020 02:15:51 +0000 (19:15 -0700)]
Don't emit "is not a logical operator" error outside of associative expressions
Avoid showing this error where it doesn't make sense by not assuming
"and" and "or" were intended to mean "&&" and "||" until after we decide
to continue parsing input as an associative expression.
Note that the decision of whether or not to continue parsing input as an
associative expression doesn't actually depend on this assumption.
Jubilee Young [Mon, 17 Aug 2020 23:07:09 +0000 (16:07 -0700)]
Resolve licensing by updating tinyvec 0.3.3 -> 0.3.4
Per https://github.com/rust-lang/rust/pull/75555#issuecomment-675090858
Zlib license might be OK. "OR Apache-2.0 OR MIT" definitely is.
unicode-normalization depends on this and rustc_parse, clippy,
and many other things depend on unicode-normalization.
Aleksey Kladov [Sat, 15 Aug 2020 12:12:51 +0000 (14:12 +0200)]
Remove broken clap versions from cargotest
treeify depends on an outdated version of clap, which will fail to compile
when we promote missing_fragment_specifier future compat lint to
error (ie, old clap contains code that shouldn't have compiled in the
first place).
Additionally, this crate seem tiny relative to other crates we are
testing here, so it seems like it doesn't provide that much additional
confidence.
The same happens with tokei project, but it is an actively maintained
one, so we can just upgrade it to a version from 2018, where clap was
upgraded.
Aleksey Kladov [Fri, 14 Aug 2020 09:24:01 +0000 (11:24 +0200)]
Promote missing_fragment_specifier to hard error
It has been deny_by_default since 2017 (and warned for some time
before that), so it seems reasonable to promote it.
The specific technical motivation to do this now is to remove a field
from `ParseSess` -- it is a global state, and global state makes
extracting libraries annoying.
Tyler Mandry [Tue, 18 Aug 2020 03:20:29 +0000 (20:20 -0700)]
Rollup merge of #75637 - ctaggart:wasm32build, r=Mark-Simulacrum
update stacker to 0.1.11 to unbreak build for wasm32-unknown-unknown
Like #72079, this updates stacker. The related problem is stacker is here https://github.com/rust-lang/stacker/issues/42. It was fixed by switching from `libc::c_void` to `std::ffi::c_void` https://github.com/rust-lang/stacker/pull/43/files.
Make sure to test file types against the non-canonicalized name to
avoid detecting the wrong type. Some systems save build artifacts
into associate file stores that do not preserve extensions, and
then link to those using conventionally-named symbolic links, that
are the arguments to `rustc` et al. If we canonicalize before
testing the type, we resolve the symlink, the extension is
lost and we might treat rlibs and rmetas as dylibs.
The fix is to tntroduce a temporary to hold the canonicalized name,
compare against the non-canonical name, and add a comment
explaining what's going on for the would-be mainter who sees a
potential cleanup.
bors [Tue, 18 Aug 2020 01:11:43 +0000 (01:11 +0000)]
Auto merge of #75653 - JohnTitor:rollup-0ejtdfo, r=JohnTitor
Rollup of 8 pull requests
Successful merges:
- #75389 (attempt to improve span_label docs)
- #75392 (Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods)
- #75464 (Move to intra doc links for ascii.rs and panic.rs)
- #75578 (Allowing raw ptr dereference in const fn)
- #75613 (Add explanation for `&mut self` method call when expecting `-> Self`)
- #75626 (Clean up E0754 explanation)
- #75629 (Use intra-doc links in `std::env`, `std::alloc` and `std::error`)
- #75634 (Mark x86_64-linux-kernel as *)
Yuki Okushi [Tue, 18 Aug 2020 00:27:47 +0000 (09:27 +0900)]
Rollup merge of #75613 - estebank:explain-mut-method, r=petrochenkov
Add explanation for `&mut self` method call when expecting `-> Self`
When a user tries to use a method as if it returned a new value of the
same type as its receiver, we will emit a type error. Try to detect this
and provide extra explanation that the method modifies the receiver
in-place.
This has confused people in the wild, like in
https://users.rust-lang.org/t/newbie-why-the-commented-line-stops-the-snippet-from-compiling/47322
Yuki Okushi [Tue, 18 Aug 2020 00:27:45 +0000 (09:27 +0900)]
Rollup merge of #75578 - 5M1Sec:master, r=oli-obk
Allowing raw ptr dereference in const fn
Reflect on issue #75340
Discussion in previous PR #75425
## Updates
Change `UnsafetyViolationKind::General` to `UnsafetyViolationKind::GeneralAndConstFn` in check_unsafety.rs
Remove `unsafe` in min_const_fn_unsafe_bad.rs
Bless min_const_fn
Add the test case from issue 75340
***
Sorry for the chaos. I messed up and ended up deleting the repo in the last PR. I have to create a new PR for the new repo. I will make a feature branch next time. I will edit the old PR once I receive the commends.
@RalfJung Thank you all for your replies. They are helpful!
Yuki Okushi [Tue, 18 Aug 2020 00:27:42 +0000 (09:27 +0900)]
Rollup merge of #75392 - TimDiekmann:non-null-uninit-slice, r=RalfJung
Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods
This adds a convenient method to retrieve a `&(mut) [MaybeUninit<T>]` from slice pointers (`*const [T]`, `*mut [T]`, `NonNull<[T]>`). See also https://github.com/rust-lang/wg-allocators/issues/66#issuecomment-671789105.
~I'll add a tracking issue as soon as it's reviewed and CI passed.~
Tracking Issue: #75402
Yuki Okushi [Tue, 18 Aug 2020 00:27:39 +0000 (09:27 +0900)]
Rollup merge of #75389 - RalfJung:span_label, r=davidtwco
attempt to improve span_label docs
I was still confused by the `span_label` docs, so I did some more digging. However, this needs careful checking as I have no idea if any of this is correct.
bors [Mon, 17 Aug 2020 20:51:59 +0000 (20:51 +0000)]
Auto merge of #75145 - davidtwco:issue-60607-preallocate-defid-for-lang-items, r=petrochenkov
Reference lang items during AST lowering
Fixes #60607 and fixes #61019.
This PR introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols:
- Credit for much of this work goes to @matthewjasper, I basically just [rebased their earlier work](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#diff-c0f791ead38d2d02916faaad0f56f41d).
- ~~Changes to Clippy might not be correct, they compile but attempting to run tests through `./x.py` produced failures which appeared spurious, so I didn't run any clippy tests.~~
- Changes to save analysis might not be correct - tests pass but I don't have a lot of confidence in those changes being correct.
- I've used `GenericBounds::LangItemTrait` rather than changing `PolyTraitRef`, as suggested by @matthewjasper [in this comment](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#r40107992) but I'd prefer that be left for a follow-up.
- I've split things into smaller commits fairly arbitrarily to make the diff easier to review, each commit should compile but might not pass tests until the final commit.
bors [Mon, 17 Aug 2020 18:33:24 +0000 (18:33 +0000)]
Auto merge of #74748 - simonvandel:simplify-discriminant-arm, r=wesleywiser
MIR-OPT: Make SimplifyBranchSame able to remove identity match with fieldless variant
Modifies SimplifyBranchSame so that it can see that the statements can be considered equal in the following example
`_0 = _1` and `discriminant(_0) = discriminant(0)` are considered equal if 0 is a fieldless variant of an enum.
Make sure to test for file types against the non-canonicalized name
to avoid detecting the wrong type. Some systems save build artifacts
into associative file stores that do not preserve extensions, and
then link to those using conventionally-named symbolic links that
are the arguments to `rustc` et al. If we canonicalize before
testing the type, we resolve the symlink, the extension is lost and
we might treat rlibs and rmetas as dylibs.
The fix is to introduce a temporary to hold the canonicalized name,
compare against the non-canonical name, and add a comment
explaining what's going on for the would-be maintainer who sees a
potential cleanup.
jumbatm [Sun, 16 Aug 2020 01:01:14 +0000 (11:01 +1000)]
Don't memoize seen types.
That cache is unlikely to be particularly useful within a single
invocation of structurally_same_type, especially compared to memoizing
results across _all_ invocations of that function.