about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2021-10-07Remove untracked vtable-const-allocation cache from tcxMichael Woerister-15/+29
2021-10-04Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obkbors-8/+52
Fix unsound optimization with explicit variant discriminants Fixes #89485.
2021-10-04Auto merge of #89512 - Manishearth:rollup-meh9x7r, r=Manishearthbors-135/+251
Rollup of 14 pull requests Successful merges: - #86434 (Add `Ipv6Addr::is_benchmarking`) - #86828 (const fn for option copied, take & replace) - #87679 (BTree: refine some comments) - #87910 (Mark unsafe methods NonZero*::unchecked_(add|mul) as const.) - #88286 (Remove unnecessary unsafe block in `process_unix`) - #88305 (Manual Debug for Unix ExitCode ExitStatus ExitStatusError) - #88353 (Partially stabilize `array_methods`) - #88370 (Add missing `# Panics` section to `Vec` method) - #88481 (Remove some feature gates) - #89138 (Fix link in Ipv6Addr::to_ipv4 docs) - #89401 (Add truncate note to Vec::resize) - #89467 (Fix typos in rustdoc/lints) - #89472 (Only register `WSACleanup` if `WSAStartup` is actually ever called) - #89505 (Add regression test for spurious const error with NLL) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-10-03Rollup merge of #89505 - Aaron1011:nll-const-test, r=Mark-SimulacrumManish Goregaokar-0/+20
Add regression test for spurious const error with NLL Fixes #55825
2021-10-03Rollup merge of #89472 - nagisa:nagisa/wsa-cleanup, r=dtolnayManish Goregaokar-6/+21
Only register `WSACleanup` if `WSAStartup` is actually ever called See https://github.com/rust-lang/rust/pull/85595 Fixes #85441
2021-10-03Rollup merge of #89467 - tniessen:rustdoc-unecessary, r=jyn514Manish Goregaokar-3/+3
Fix typos in rustdoc/lints This PR merely fixes a few typos in a recently introduced change :) Refs: https://github.com/rust-lang/rust/pull/85223
2021-10-03Rollup merge of #89401 - owengage:master, r=joshtriplettManish Goregaokar-0/+1
Add truncate note to Vec::resize A very minor addition to the `Vec::resize` documentation to point out the `truncate` method. When I was searching for something matching `truncate` I managed to miss it, along with some colleagues. We later found it by chance. We did find `resize` however, so I was hoping to point it out in the documentation.
2021-10-03Rollup merge of #89138 - newpavlov:patch-2, r=dtolnayManish Goregaokar-1/+1
Fix link in Ipv6Addr::to_ipv4 docs
2021-10-03Rollup merge of #88481 - bjorn3:remove_feature_gates, r=cjgillotManish Goregaokar-65/+31
Remove some feature gates The first commit removes various feature gates that are unused. The second commit replaces some `Fn` implementations with `Iterator` implementations, which is much cleaner IMO. The third commit replaces an unboxed_closures feature gate with min_specialization. For some reason the unboxed_closures feature gate suppresses the min_specialization feature gate from triggering on an `TrustedStep` impl. The last comment just turns a regular comment into a doc comment as drive by cleanup. I can move it to a separate PR if preferred.
2021-10-03Rollup merge of #88370 - Seppel3210:master, r=dtolnayManish Goregaokar-1/+6
Add missing `# Panics` section to `Vec` method namely `Vec::extend_from_within`
2021-10-03Rollup merge of #88353 - jhpratt:stabilize-array-as-ref, r=joshtriplettManish Goregaokar-3/+3
Partially stabilize `array_methods` This stabilizes `<[T; N]>::as_slice` and `<[T; N]>::as_mut_slice`, which is forms part of the `array_methods` feature: #76118. This also makes `<[T; N]>::as_slice` const due to its trivial nature.
2021-10-03Rollup merge of #88305 - ijackson:exitstatus-debug, r=dtolnayManish Goregaokar-3/+21
Manual Debug for Unix ExitCode ExitStatus ExitStatusError These structs have misleading names. An ExitStatus[Error] is actually a Unix wait status; an ExitCode is actually an exit status. These misleading names appear in the `Debug` output. The `Display` impls on Unix have been improved, but the `Debug` impls are still misleading, as reported in #74832. Fix this by pretending that these internal structs are called `unix_exit_status` and `unix_wait_status` as applicable. (We can't actually rename the structs because of the way that the cross-platform machinery works: the names are cross-platform.) After this change, this program ``` #![feature(exit_status_error)] fn main(){ let x = std::process::Command::new("false").status().unwrap(); dbg!(x.exit_ok()); eprintln!("x={:?}",x); } ``` produces this output ``` [src/main.rs:4] x.exit_ok() = Err( ExitStatusError( unix_wait_status( 256, ), ), ) x=ExitStatus(unix_wait_status(256)) ``` Closes #74832
2021-10-03Rollup merge of #88286 - LeSeulArtichaut:unnecessary-unsafe-block-std, r=dtolnayManish Goregaokar-2/+1
Remove unnecessary unsafe block in `process_unix` Because it's nested under this unsafe fn! This block isn't detected as unnecessary because of a bug in the compiler: #88260.
2021-10-03Rollup merge of #87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, ↵Manish Goregaokar-2/+2
r=joshtriplett Mark unsafe methods NonZero*::unchecked_(add|mul) as const. Now that https://github.com/rust-lang/rfcs/pull/3016 has landed, these two unstable `std` function can be marked `const`, according to this detail of #84186.
2021-10-03Rollup merge of #87679 - ssomers:btree_comments, r=joshtriplettManish Goregaokar-10/+8
BTree: refine some comments
2021-10-03Rollup merge of #86828 - lambinoo:67441-const-fn-copied-take-replace, ↵Manish Goregaokar-7/+30
r=joshtriplett const fn for option copied, take & replace Tracking issue: [#67441](https://github.com/rust-lang/rust/issues/67441) Adding const fn for the copied, take and replace method of Option. Also adding necessary unit test. It's my first contribution so I am pretty sure I don't know what I'm doing but there's a first for everything!
2021-10-03Rollup merge of #86434 - CDirkx:ipv6-benchmarking, r=joshtriplettManish Goregaokar-32/+103
Add `Ipv6Addr::is_benchmarking` This PR adds the unstable method `Ipv6Addr::is_benchmarking`. This method is added for parity with `Ipv4Addr::is_benchmarking`, and I intend to use it in a future rework of `Ipv6Addr::is_global` (edit: #86634) to more accurately follow the [IANA Special Address Registry](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml) (like is done in `Ipv4Addr::is_global`). With `Ipv6Addr::is_benchmarking` and `Ipv4Addr::is_benchmarking` now both existing, `IpAddr::is_benchmarking` is also added.
2021-10-04Auto merge of #89165 - jkugelman:read-to-end-overallocation, r=joshtriplettbors-41/+37
Fix read_to_end to not grow an exact size buffer If you know how much data to expect and use `Vec::with_capacity` to pre-allocate a buffer of that capacity, `Read::read_to_end` will still double its capacity. It needs some space to perform a read, even though that read ends up returning `0`. It's a bummer to carefully pre-allocate 1GB to read a 1GB file into memory and end up using 2GB. This fixes that behavior by special casing a full buffer and reading into a small "probe" buffer instead. If that read returns `0` then it's confirmed that the buffer was the perfect size. If it doesn't, the probe buffer is appended to the normal buffer and the read loop continues. Fixing this allows several workarounds in the standard library to be removed: - `Take` no longer needs to override `Read::read_to_end`. - The `reservation_size` callback that allowed `Take` to inhibit the previous over-allocation behavior isn't needed. - `fs::read` doesn't need to reserve an extra byte in `initial_buffer_size`. Curiously, there was a unit test that specifically checked that `Read::read_to_end` *does* over-allocate. I removed that test, too.
2021-10-03Add regression test for spurious const error with NLLAaron Hill-0/+20
Fixes #55825
2021-10-03Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearthbors-24/+28
Add expansion to while desugar spans In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name. The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop. r? `@Manishearth`
2021-10-03Disable `SimplifyBranchSame` optimization for nowFabian Wolff-0/+6
2021-10-03Update commentsFabian Wolff-8/+18
2021-10-03Auto merge of #89486 - rusticstuff:docker_letsencrypt_ca_update, ↵bors-0/+41
r=Mark-Simulacrum Update Let's Encrypt ROOT CA certificate in dist-(i686|x86_64)-linux docker images The DST Root CA X3 used by Let's Encrypt has expired ([Let's Encrypt announcement](https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/)). This patch installs the new root certificate (ISRG Root X1) and disables the old one. Disabling the old one is necessary because otherwise curl still fails to download from servers with Let's Encrypt certs even though they are cross-signed. Fixes #89484.
2021-10-03Auto merge of #88086 - ssomers:btree_clone_testing, r=dtolnaybors-25/+32
BTree: toughen panicky test of clone() Test did not cover the second half of `clone_subtree` and why this clones key & value first.
2021-10-03Replace Fn impls with RPIT impls in rustc_indexbjorn3-50/+23
This is cleaner and removes an unstable feature usage
2021-10-03Fix unsound optimization with explicit variant discriminantsFabian Wolff-4/+32
2021-10-03Auto merge of #87870 - WaffleLapkin:pub_split_at_unchecked, r=dtolnaybors-4/+4
Make `<[T]>::split_at_unchecked` and `<[T]>::split_at_mut_unchecked` public The methods were originally added in https://github.com/rust-lang/rust/pull/75936 (https://github.com/sdroege/rust/commit/30dc32b10eb53e4a92c61a42062983db58838217), but for some reason as private. Nevertheless, the methods have documentation and even a [tracking issue](https://github.com/rust-lang/rust/issues/76014). It's very weird to have a tracking issue for private methods and these methods may be useful outside of the standard library. As such, this PR makes the methods public.
2021-10-03Auto merge of #89459 - tspiteri:idiv-overflow-bitand, r=kennytmbors-8/+16
Use bitand when checking for signed integer division overflow For `self == Self::MIN && rhs == -1`, LLVM does not realize that this is the same check made by `self / rhs`, so the code generated may have some unnecessary duplication. For `(self == Self::MIN) & (rhs == -1)`, LLVM realizes it is the same check.
2021-10-03Update Let's Encrypt ROOT CA certificate in dist-(i686|x86_64)-linux docker ↵Hans Kratz-0/+41
images
2021-10-03Auto merge of #88060 - TennyZhuang:optimize-vec-retain, r=dtolnaybors-3/+39
Optimize unnecessary check in Vec::retain The function `vec::Vec::retain` only have two stages: 1. Nothing was deleted. 2. Some elements were deleted. Here is an unnecessary check `if g.deleted_cnt > 0` in the loop, and it's difficult for compiler to optimize it. I split the loop into two stages manully and keep the code clean using const generics. I write a special but common bench case for this optimization. I call retain on vec but keep all elements. Before and after this optimization: ``` test vec::bench_retain_whole_100000 ... bench: 84,803 ns/iter (+/- 17,314) ``` ``` test vec::bench_retain_whole_100000 ... bench: 42,638 ns/iter (+/- 16,910) ``` The result is expected, there are two `if`s before the optimization and one `if` after.
2021-10-03Auto merge of #89479 - camsteffen:diag-naming, r=Manishearthbors-248/+244
Make diangostic item naming consistent Right now there is about a 50/50 split of naming diagnostic items as `vec_type` vs `Vec`. So it is hard to guess a diagnostic item name with confidence. I know it's not great to change these retroactively, but I think it will be much easier to maintain consistency after consistency is established.
2021-10-03Auto merge of #84267 - dtolnay:ptrunit, r=nagisabors-45/+69
Make *const (), *mut () okay for FFI Pointer-to-() is used occasionally in the standard library to mean "pointer to none-of-your-business". Examples: - `RawWakerVTable::new` https://doc.rust-lang.org/1.51.0/std/task/struct.RawWakerVTable.html#method.new - `<*const T>::to_raw_parts` https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.to_raw_parts I believe it's useful for the same purpose in FFI signatures, even while `()` itself is not FFI safe. The following should be allowed: ```rust extern "C" { fn demo(pc: *const (), pm: *mut ()); } ``` Prior to this PR, those pointers were not considered okay for an extern signature. ```console warning: `extern` block uses type `()`, which is not FFI-safe --> src/main.rs:2:17 | 2 | fn demo(pc: *const (), pm: *mut ()); | ^^^^^^^^^ not FFI-safe | = note: `#[warn(improper_ctypes)]` on by default = help: consider using a struct instead = note: tuples have unspecified layout warning: `extern` block uses type `()`, which is not FFI-safe --> src/main.rs:2:32 | 2 | fn demo(pc: *const (), pm: *mut ()); | ^^^^^^^ not FFI-safe | = help: consider using a struct instead = note: tuples have unspecified layout ```
2021-10-02Make diangostic item names consistentCameron Steffen-248/+244
2021-10-02Add desugaring mark to while loopCameron Steffen-24/+28
2021-10-02Auto merge of #89345 - jackh726:89333, r=estebankbors-16/+42
Don't lose binders when printing trait bound suggestion Fixes #89333
2021-10-02Run the #85441 regression test on MSVC onlySimonas Kazlauskas-4/+4
On MinGW toolchains the various features (such as function sections) necessary to eliminate dead function references are disabled due to various bugs. This means that the windows sockets library will most likely remain linked to any mingw toolchain built program that also utilizes libstd. That said, I made an attempt to also enable `function-sections` and `--gc-sections` during my experiments, but the symbol references remained, sadly.
2021-10-02Add test for checking if WS2_32.dll is linkedChristiaan Dirkx-0/+10
2021-10-02Only register `WSACleanup` if `WSAStartup` is actually ever calledChristiaan Dirkx-6/+11
2021-10-02Auto merge of #89341 - ↵bors-10/+79
audunhalland:derive-type-params-with-bound-generic-params, r=jackh726 Deriving: Include bound generic params in type parameters for where clause Fixes #89188. The `derive` macro ignored the `for<'s>` needed with the `Fn` trait in that code example. edit: I'm unsure if this might cause regressions. I'm not an experienced compiler developer so I'm not used to thinking about unwanted side effects code changes like this might have.
2021-10-02Turn a module non-doc comment into a doc commentbjorn3-7/+7
2021-10-02Swap out unboxed_closures feature gate for min_specializationbjorn3-1/+1
For some reason unboxed_closures supresses the feature gate for min_specialization when implementing TrustedStep. min_specialization is the true feature that is used.
2021-10-02Remove various unused feature gatesbjorn3-7/+0
2021-10-02Fix typos in rustdoc/lintsTobias Nießen-3/+3
Refs: https://github.com/rust-lang/rust/pull/85223
2021-10-02Auto merge of #89239 - petrochenkov:modcache, r=cjgillotbors-44/+93
resolve: Cache module loading for all foreign modules It was previously cached for modules loaded from `fn get_module`, but not for modules loaded from `fn build_reduced_graph_for_external_crate_res`. This also makes all foreign modules use their real parent, span and expansion instead of possibly a parent/span/expansion of their reexport. Modules are also often compared using referential equality (`ptr::eq`), this change makes such comparisons correct in all cases. An ICE happening on attempt to decode expansions for foreign enums and traits is avoided. Also local enums and traits are now added to the module map. Follow up to https://github.com/rust-lang/rust/pull/88872. r? `@cjgillot`
2021-10-02rustc_span: Make hygiene debug printing reproducibleVadim Petrochenkov-1/+4
2021-10-02resolve: Avoid comparing modules by optional def-idVadim Petrochenkov-15/+19
It makes all block modules identical during comparison
2021-10-02resolve: Cache module loading for all foreign modulesVadim Petrochenkov-29/+71
It was previously cached for modules loaded from `fn get_module`, but not for modules loaded from `fn build_reduced_graph_for_external_crate_res`. This also makes all foreign modules use their real parent, span and expansion instead of possibly a parent/span/expansion of their reexport. An ICE happening on attempt to decode expansions for foreign enums and traits is avoided. Also local enums and traits are now added to the module map.
2021-10-02Auto merge of #89408 - Mark-Simulacrum:fix-query-nondet, r=petrochenkovbors-2/+23
Avoid nondeterminism in trimmed_def_paths Previously this query depended on the global interning order of Symbols, which meant that irrelevant changes could influence the query and cause recompilations. This commit ensures that the return set is stable and will not be affected by the global order by deterministically (in lexicographic order) choosing a name to use if there are multiple names for a single DefId. This should fix the cause of the [regressions] in #83343. [regressions]: https://perf.rust-lang.org/compare.html?start=9620f3a84b079decfdc2e557be007580b097fe43&end=addb4da686a97da46159f0123cb6cdc2ce3d7fdb
2021-10-02Auto merge of #89405 - GuillaumeGomez:fix-clippy-lints, r=cjgillotbors-508/+460
Fix clippy lints I'm currently working on allowing clippy to run on librustdoc after a discussion I had with `@Mark-Simulacrum.` So in the meantime, I fixed a few lints on the compiler crates.
2021-10-02Use bitand when checking for signed integer division overflowTrevor Spiteri-8/+16
For `self == Self::MIN && rhs == -1`, LLVM does not realize that this is the same check made by `self / rhs`, so the code generated may have some unnecessary duplication. For `(self == Self::MIN) & (rhs == -1)`, LLVM realizes it is the same check.