Mario Carneiro [Fri, 18 Feb 2022 04:27:53 +0000 (20:27 -0800)]
Optimize char_try_from_u32
The optimization was proposed by @falk-hueffner in https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Micro-optimizing.20char.3A.3Afrom_u32/near/272146171, and I simplified it a bit and added an explanation of why the optimization is correct.
bors [Thu, 17 Feb 2022 22:54:18 +0000 (22:54 +0000)]
Auto merge of #94103 - matthiaskrgr:rollup-cd70ofn, r=matthiaskrgr
Rollup of 9 pull requests
Successful merges:
- #93337 (Update tracking issue numbers for inline assembly sub-features)
- #93758 (Improve comments about type folding/visiting.)
- #93780 (Generate list instead of div items in sidebar)
- #93976 (Add MAIN_SEPARATOR_STR)
- #94011 (Even more let_else adoptions)
- #94041 (Add a `try_collect()` helper method to `Iterator`)
- #94043 (Fix ICE when using Box<T, A> with pointer sized A)
- #94082 (Remove CFG_PLATFORM)
- #94085 (Clippy: Don't lint `needless_borrow` in method receiver positions)
Matthias Krüger [Thu, 17 Feb 2022 22:01:01 +0000 (23:01 +0100)]
Rollup merge of #94043 - DrMeepster:box_alloc_ice, r=oli-obk
Fix ICE when using Box<T, A> with pointer sized A
Fixes #78459
Note that using `Box<T, A>` with a more than pointer sized `A` or using a pointer sized `A` with a Box of a DST will produce a different ICE (#92054) which is not fixed by this PR.
Matthias Krüger [Thu, 17 Feb 2022 22:01:00 +0000 (23:01 +0100)]
Rollup merge of #94041 - a-lafrance:try-collect, r=scottmcm
Add a `try_collect()` helper method to `Iterator`
Implement `Iterator::try_collect()` as a helper around `Iterator::collect()` as discussed [here](https://internals.rust-lang.org/t/idea-fallible-iterator-mapping-with-try-map/15715/5?u=a.lafrance).
First time contributor so definitely open to any feedback about my implementation! Specifically wondering if I should open a tracking issue for the unstable feature I introduced.
As the main participant in the internals discussion: r? `@scottmcm`
Matthias Krüger [Thu, 17 Feb 2022 22:00:55 +0000 (23:00 +0100)]
Rollup merge of #93758 - nnethercote:improve-folding-comments, r=BoxyUwU
Improve comments about type folding/visiting.
I have found this code confusing for years. I've always roughly
understood it, but never exactly. I just made my fourth(?) attempt and
finally cracked it.
This commit improves the comments. In particular, it explicitly
describes how you can't do a custom fold/visit of any type; there are
actually a handful of "types of interest" (e.g. `Ty`, `Predicate`,
`Region`, `Const`) that can be custom folded/visted, and all other types
just get a generic traversal. I think this was the part that eluded me
on all my prior attempts at understanding.
The commit also updates comments to account for some newer changes such
as the fallible/infallible folding distinction, does some minor
reorderings, and moves one `impl` to a better place.
Matthias Krüger [Thu, 17 Feb 2022 22:00:55 +0000 (23:00 +0100)]
Rollup merge of #93337 - Amanieu:asm_tracking, r=tmiasko
Update tracking issue numbers for inline assembly sub-features
The main tracking issue for inline assembly is [closed](https://github.com/rust-lang/rust/issues/72016#issuecomment-1022332954), further tracking of the remaining sub-features has been moved to separate tracking issues.
I have found this code confusing for years. I've always roughly
understood it, but never exactly. I just made my fourth(?) attempt and
finally cracked it.
This commit improves the comments. In particular, it explicitly
describes how you can't do a custom fold/visit of any type; there are
actually a handful of "types of interest" (e.g. `Ty`, `Predicate`,
`Region`, `Const`) that can be custom folded/visted, and all other types
just get a generic traversal. I think this was the part that eluded me
on all my prior attempts at understanding.
The commit also updates comments to account for some newer changes such
as the fallible/infallible folding distinction, does some minor
reorderings, and moves one `impl` to a better place.
bors [Thu, 17 Feb 2022 09:13:18 +0000 (09:13 +0000)]
Auto merge of #94072 - matthiaskrgr:rollup-7uu2286, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #89869 (Add documentation to more `From::from` implementations.)
- #93479 (Use `optflag` for `--report-time`)
- #93693 (Suggest deriving required supertraits)
- #93981 (Fix suggestion to slice if scurtinee is a reference to `Result` or `Option`)
- #93996 (Do not suggest "is a function" for free variables)
- #94030 (Correctly mark the span of captured arguments in `format_args!()`)
- #94031 ([diagnostics] Add mentions to `Copy` types being valid for `union` fields)
- #94064 (Update dist-x86_64-musl to Ubuntu 20.04)
Matthias Krüger [Thu, 17 Feb 2022 05:30:05 +0000 (06:30 +0100)]
Rollup merge of #94064 - nikic:update-musl-image, r=Mark-Simulacrum
Update dist-x86_64-musl to Ubuntu 20.04
This updates the dist-x86_64-musl image to use Ubuntu 20.04. The current Ubuntu 16.04 based image only works due to the Docker cache, it's not possible anymore to run it locally because of the usual certificate expiration issue.
I believe updating the OS here is relatively safe because this targets musl, so there are no concerns about raising the glibc baseline. There is some risk here in that it updates the compiler toolchain used to produce artifacts, though I'm not aware of any specific issues that could cause.
Matthias Krüger [Thu, 17 Feb 2022 05:30:03 +0000 (06:30 +0100)]
Rollup merge of #94031 - danielhenrymantilla:diagnostics/union-drop-suggest-copy-bound-alternative, r=davidtwco
[diagnostics] Add mentions to `Copy` types being valid for `union` fields
This came up from some user on Discord which was using a `T : PrimitiveInt` generic type, and they wanted to use in a `union`. Rather than adding a `Copy` bound, they started pondering about the `ManuallyDrop<T>` road, and how to correctly use `unsafe` to perform the drops.
<img width="648" alt="Screen Shot 2022-02-15 at 22 28 34" src="https://user-images.githubusercontent.com/9920355/154152496-8f9be74b-ad59-4724-8f9e-48b446774e06.png">
So, it seemed like the error message for types with potential drop glue on `union` fields could be improved to also mention the `Copy` alternative, since in many cases where `union`s are concerned, people are dealing with PODs / `Copy` types anyways 🙂
I chose to just hardcode handling for PartialOrd and PartialEq because that should be robust enough and I dont know how to go about doing it generically
Matthias Krüger [Thu, 17 Feb 2022 05:29:59 +0000 (06:29 +0100)]
Rollup merge of #93479 - smoelius:master, r=yaahc
Use `optflag` for `--report-time`
Essentially, what is described here:
https://github.com/rust-lang/rust/issues/64888#issuecomment-1008047228
There is one difference. The comment proposes to add a
`--report-time-color` option. This change instead uses libtest's
existing `--color` option for that purpose.
Matthias Krüger [Thu, 17 Feb 2022 05:29:57 +0000 (06:29 +0100)]
Rollup merge of #89869 - kpreid:from-doc, r=yaahc
Add documentation to more `From::from` implementations.
For users looking at documentation through IDE popups, this gives them relevant information rather than the generic trait documentation wording “Performs the conversion”. For users reading the documentation for a specific type for any reason, this informs them when the conversion may allocate or copy significant memory versus when it is always a move or cheap copy.
Notes on specific cases:
* The new documentation for `From<T> for T` explains that it is not a conversion at all.
* Also documented `impl<T, U> Into<U> for T where U: From<T>`, the other central blanket implementation of conversion.
* The new documentation for construction of maps and sets from arrays of keys mentions the handling of duplicates. Future work could be to do this for *all* code paths that convert an iterable to a map or set.
* I did not add documentation to conversions of a specific error type to a more general error type.
* I did not add documentation to unstable code.
This change was prepared by searching for the text "From<... for" and so may have missed some cases that for whatever reason did not match. I also looked for `Into` impls but did not find any worth documenting by the above criteria.
This keeps the cfg_target_has_atomic feature gate name since compiler-builtins otherwise depends on it and I'd rather not try to manage a bump across a crates.io published repository given the time-sensitivity here (we need to land this quickly to avoid a beta backport).
bors [Wed, 16 Feb 2022 22:11:22 +0000 (22:11 +0000)]
Auto merge of #91182 - ChrisDenton:command-broken-symlink, r=m-ou-se
Maintain broken symlink behaviour for the Windows exe resolver
When the resolver was updated to remove the current directory from the search path (see #87704), care was take to avoid unintentional changes that hadn't been discussed. However, I missed the broken symlink behaviour. This PR fixes that.
**Edit** This turned out to be more important than I first realised. There are some types of application stubs that will redirect to the actual process when run using `CreateProcessW`, but due to the way they're implemented they cannot be opened normally using a `File::open` that follows reparse points. So this doesn't work with our current `exists` and `try_exists` methods.
Matthias Krüger [Wed, 16 Feb 2022 17:59:35 +0000 (18:59 +0100)]
Rollup merge of #94045 - ehuss:update-books, r=ehuss
Update books
## nomicon
3 commits in 9493715a6280a1f74be759c7e1ef9999b5d13e6f..90993eeac93dbf9388992de92965f99cf6f29a03
2022-01-27 19:00:32 -0800 to 2022-02-13 12:44:12 +0900
- Fix a small typo in exception-safety.md (rust-lang/nomicon#341)
- Make `Vec::new` public in vec-alloc.md (rust-lang/nomicon#336)
- Fix a syntax error in leaking.md (rust-lang/nomicon#335)
## reference
6 commits in 411c2f0d5cebf48453ae2d136ad0c5e611d39aec..70fc73a6b908e08e66aa0306856c5211312f6c05
2022-01-30 12:46:37 -0800 to 2022-02-14 19:33:01 -0800
- Document pre-Rust-2021 special case for IntoIterator method lookup (rust-lang/reference#1154)
- Mention std::is_aarch64_feature_detected (rust-lang/reference#1061)
- Fix link to the Bastion of the Turbofish (rust-lang/reference#1161)
- Improve associated constant item CTFE timing section (rust-lang/reference#1147)
- document `#![feature(const_generics_defaults)]` (rust-lang/reference#1098)
- Update patterns allowed in @ patterns (rust-lang/reference#1158)
## book
6 commits in 98904efaa4fc968db8ff59cf2744d9f7ed158166..67b768c0b660a069a45f0e5d8ae2f679df1022ab
2022-01-29 21:22:31 -0500 to 2022-02-09 21:52:41 -0500
- Snapshot of ch18 for nostarch
- Remove mention of destructuring references as that's not covered currently
- Add note that exhaustiveness checking doesn't extend to match guards
- Change match guard example to actually be unexpressable with patterns alone
- Corrected listing number from 9-10 to 9-13
- Remove duplicate paragraph after No Starch related changes
## rustc-dev-guide
3 commits in 8763adb62c712df69b1d39ea3e692b6d696cc4d9..62f58394ba7b203f55ac35ddcc4c0b79578f5706
2022-01-26 14:01:40 -0800 to 2022-02-11 08:42:50 -0500
- Correction, building stage3 compiler (rust-lang/rustc-dev-guide#1298)
- Triage some date references (rust-lang/rustc-dev-guide#1293)
- mention test folders for cfg(bootstrap) (rust-lang/rustc-dev-guide#1294)
Matthias Krüger [Wed, 16 Feb 2022 17:59:34 +0000 (18:59 +0100)]
Rollup merge of #94037 - tmiasko:verbose, r=Mark-Simulacrum
Fix inconsistent symbol mangling with -Zverbose
Always skip arguments that are the defaults of their respective
parameters, to avoid generating inconsistent symbols for builds
with `-Zverbose` flag and without it.
Matthias Krüger [Wed, 16 Feb 2022 17:59:32 +0000 (18:59 +0100)]
Rollup merge of #94020 - tmiasko:pp, r=oli-obk
Support pretty printing of invalid constants
Make it possible to pretty print invalid constants by introducing a
fallible variant of `destructure_const` and falling back to debug
formatting when it fails.
Matthias Krüger [Wed, 16 Feb 2022 17:59:29 +0000 (18:59 +0100)]
Rollup merge of #93962 - joboet:branchless_slice_ord, r=Mark-Simulacrum
Make [u8]::cmp implementation branchless
The current implementation generates rather ugly assembly code, branching when the common parts are equal. By performing the comparison of the lengths upfront using a subtraction, the assembly gets much prettier: https://godbolt.org/z/4e5fnEKGd.
This will probably not impact speed too much, as the expensive part is in most cases the `memcmp`, but it sure looks better (I'm porting a sorting algorithm currently, and that branch just bothered me).
Matthias Krüger [Wed, 16 Feb 2022 17:59:27 +0000 (18:59 +0100)]
Rollup merge of #92366 - jhpratt:derive-default-enum, r=Mark-Simulacrum
Resolve concern of `derive_default_enum`
This resolves the concern in favor of prohibiting multiple instances of
the attribute. This is similar to non-helper attributes as introduced in
#88681.
Tomasz Miąsko [Wed, 16 Feb 2022 00:00:00 +0000 (00:00 +0000)]
Fix inconsistent symbol mangling with -Zverbose
Always skip arguments that are the defaults of their respective
parameters, to avoid generating inconsistent symbols for builds
with `-Zverbose` flag and without it.
Tomasz Miąsko [Tue, 15 Feb 2022 12:58:34 +0000 (13:58 +0100)]
Support pretty printing of invalid constants
Make it possible to pretty print invalid constants by introducing a
fallible variant of `destructure_const` and falling back to debug
formatting when it fails.
bors [Tue, 15 Feb 2022 21:20:49 +0000 (21:20 +0000)]
Auto merge of #93439 - abrown:cf-protection, r=nagisa
Add support for control-flow protection
This change adds a flag for configuring control-flow protection in the LLVM backend. In Clang, this flag is exposed as `-fcf-protection` with options `none|branch|return|full`. This convention is followed for `rustc`, though as a codegen option: `rustc -Z cf-protection=<none|branch|return|full>`. Tracking issue for future work is #93754.