mir-opt: Make SimplifyCfg collapse goto chains starting from bb0
`SimplifyCfg` pass was not able to collapse goto chains starting from bb0, leaving MIR like this:
```
bb0: {
goto -> bb1;
}
```
Bump minimum required LLVM version to 6.0
Based on the discussion in #55842, while the overall position of Rust wrt LLVM continues to be contentious, there does seem to be a consensus that there is no need for continued support of LLVM 5. This PR bumps our version requirement to LLVM 6.0 and makes Travis run against that.
I hope that this is going to unblock #52694. If I understand correctly, while this issue still exists in LLVM 6, Ubuntu has backported the relevant patch.
r? @alexcrichton
Rollup of 20 pull requests
Successful merges:
- #53506 (Documentation for impl From for AtomicBool and other Atomic types)
- #56343 (Remove not used mod)
- #56439 (Clearer error message for dead assign)
- #56640 (Add FreeBSD unsigned char platforms to std::os::raw)
- #56648 (Fix BTreeMap UB)
- #56672 (Document time of back operations of a Linked List)
- #56706 (Make `const unsafe fn` bodies `unsafe`)
- #56742 (infer: remove Box from a returned Iterator)
- #56761 (Suggest using `.display()` when trying to print a `Path`)
- #56781 (Update LLVM submodule)
- #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)
- #56790 (Make RValue::Discriminant a normal Shallow read)
- #56793 (rustdoc: look for comments when scraping attributes/crates from doctests)
- #56826 (rustc: Add the `cmpxchg16b` target feature on x86/x86_64)
- #56832 (std: Use `rustc_demangle` from crates.io)
- #56844 (Improve CSS rule)
- #56850 (Fixed issue with using `Self` ctor in typedefs)
- #56855 (Remove u8 cttz hack)
- #56857 (Fix a small mistake regarding NaNs in a deprecation message)
- #56858 (Fix doc of `std::fs::canonicalize`)
Failed merges:
- #56741 (treat ref-to-raw cast like a reborrow: do a special kind of retag)
r? @ghost
Fix doc of `std::fs::canonicalize`
Point out that the final component of the path name might be a filename
(and not a directory name). Previously, the doc said that all components
of the path must be directory names, when it actually only ment all but
the final one.
Fixes#54056.
Remove u8 cttz hack
This issue has since been fixed in LLVM: 1886c8e29a
Furthermore this code doesn't actually work, because the 8 literal does not match the $BITS provided from the macro invocation, so effectively this was just dead code. Ref #43024.
What LLVM does is still not ideal for CPUs that only have bsf but not tzcnt, will create a patch for that later.
r? @nagisa
std: Use `rustc_demangle` from crates.io
No more need to duplicate the demangling routine between crates.io and
the standard library, we can use the exact same one!
rustc: Add the `cmpxchg16b` target feature on x86/x86_64
This appears to be called `cx16` in LLVM and a few other locations, but
the Intel Intrinsic Guide doesn't have a name for this and the CPU
manual from Intel only mentions `cmpxchg16b`, so that's the name chosen
here.
rustdoc: look for comments when scraping attributes/crates from doctests
Fixes https://github.com/rust-lang/rust/issues/56727
When scraping out crate-level attributes and `extern crate` statements, we wouldn't look for comments, so any presence of comments would shunt it and everything after it into "everything else". This could cause parsing issues when looking for `fn main` and `extern crate my_crate` later on, which would in turn cause rustdoc to incorrectly wrap a test with `fn main` when it already had one declared.
I took the opportunity to clean up the logic a little bit, but it would still benefit from a libsyntax-based loop like the `fn main` detection.
Make RValue::Discriminant a normal Shallow read
Enum layout optimizations mean that the discriminant of an enum may not be stored in a tag disjoint from the rest of the fields of the enum. Stop borrow checking as though they are.
Run with MIRI to see why this is needed: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=09a3236685a06b6096e2e2e3968b852c.
This issue exists with the lexical borrow checker as well (see #45045) so migrate mode should prevent this from being immediately breaking.
r? @nikomatsakis
Fixes#56797
rustc: Add an unstable `simd_select_bitmask` intrinsic
This is going to be required for binding a number of AVX-512 intrinsics
in the `stdsimd` repository, and this intrinsic is the same as
`simd_select` except that it takes a bitmask as the first argument
instead of a SIMD vector. This bitmask is then transmuted into a `<NN x
i8>` argument, depending on how many bits it is.
cc rust-lang-nursery/stdsimd#310
Document time of back operations of a Linked List
Popping and pushing from the end of a linked list is constant time. This
documentation is already there for popping and pushing from the front.
@bors: r+ 38fe8d2 rollup
Fix BTreeMap UB
BTreeMap currently causes UB by created a shared reference to a too-small allocation. This PR fixes that by introducing a `NodeHeader` type and using that until we really need access to the key/value arrays. Avoiding run-time checks in `into_key_slice` was somewhat tricky, see the comments embedded in the code.
I also adjusted `as_leaf_mut` to return a raw pointer, because creating a mutable reference asserts that there are no aliases to the pointee, but that's not always correct: We use `as_leaf_mut` twice to create two mutable slices for keys and values; the second call overlaps with the first slice and hence is not a unique pointer.
Fixes https://github.com/rust-lang/rust/issues/54957
Cc @nikomatsakis @Gankro
Clearer error message for dead assign
I'm not that this is the right place for this (if it needs an RFC or not).
I had the problem where I misunderstood the compiler lint message https://github.com/rust-lang/rust/issues/56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.
I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.
I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.
If this is the wrong place for this sort of thing I'll happily delete/move it.
Documentation for impl From for AtomicBool and other Atomic types
As part of issue #51430 (cc @skade).
The impl is very simple, so not sure if we need to go into any details.
Point out that the final component of the path name might be a filename
(and not a directory name). Previously, the doc said that all components
of the path must be directory names, when it actually only ment all but
the final one.
Fixes#54056.
Rollup of 7 pull requests
Successful merges:
- #56677 (#[must_use] on traits in stdlib)
- #56679 (overhaul external doc attribute diagnostics)
- #56682 (Update the stdsimd submodule)
- #56691 (fix install broken link)
- #56710 (Always set the RDRAND and RDSEED features on SGX)
- #56713 (Test capacity of ZST vector)
- #56841 (Add some unit tests to compiletest)
Failed merges:
r? @ghost
This issue has since been fixed in LLVM:
1886c8e29a
Furthermore this doesn't actually work, because the "8" literal does
not match the $BITS provided from the macro invocation, so effectively
this code was not being used anyway...
Add some unit tests to compiletest
Based on #56792, otherwise the tests won't be executed on CI.
Just a small start, I would like to add more testing to compiletest in the future but that will require some refactoring first.
cc #47606
Test capacity of ZST vector
Initially, #50233 accidentally changed the capacity of empty ZST. This was pointed out during code review. This commit adds a test to prevent capacity of ZST vectors from accidentally changing to prevent that from happening again.
Always set the RDRAND and RDSEED features on SGX
Not sure if this is 100% correct.
This [Intel article](https://software.intel.com/en-us/articles/intel-software-guard-extensions-tutorial-part-5-enclave-development) goes in great depth regarding using (untrusted) CPUID to see whether RDRAND/RDSEED is supported, and explains what happens to the enclave if the CPUID result is faked.
I'd say that an implementation of SGX that doesn't make RDRAND available to the enclave is so severely limited/broken that it's ok if you get #UD in that case. The case is less clear for RDSEED, but it so far every processor released by Intel with SGX support also has RDSEED (including Gemini Lake).
cc @briansmith
overhaul external doc attribute diagnostics
This PR improves the error handling and spans for the external doc attribute. Many cases that silently failed before now emit errors, spans are tightened, and the errors have help and suggestions.
I tried to address all the cases that users ran into in the tracking issue.
cc #44732
r? @QuietMisdreavus
#[must_use] on traits in stdlib
Based on #55506.
Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`
There may be other traits that should have the attribute, but I couldn't find/think of any.