about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2021-08-02Rollup merge of #86936 - CDirkx:ipv6-multicast, r=JohnTitorYuki Okushi-1/+43
Add documentation for `Ipv6MulticastScope` Adds basic documentation to the unstable `Ipv6MulticastScope`, as well as marking it `#[non_exhaustive]` because future IETF RFCs may introduce additional scopes. The documentation mentions this in a section "Stability Guarantees": > /// Not all possible values for a multicast scope have been assigned. /// Future RFCs may introduce new scopes, which will be added as variants to this enum; /// because of this the enum is marked as `#[non_exhaustive]`.
2021-08-02Rollup merge of #86593 - jhpratt:stabilize-const_slice_first_last, r=m-ou-seYuki Okushi-4/+4
Partially stabilize `const_slice_first_last` This stabilizes the non-`mut` methods of `const_slice_first_last` as `const`. These methods are trivial to implement and have no blockers that I am aware of. `@rustbot` label +A-const-fn +S-waiting-on-review +T-libs-api
2021-08-02Rollup merge of #86509 - CDirkx:os_str, r=m-ou-seYuki Okushi-14/+12
Move `os_str_bytes` to `sys::unix` Followup to #84967, with `OsStrExt` and `OsStringExt` moved out of `sys_common`, there is no reason anymore for `os_str_bytes` to live in `sys_common` and not in sys. This pr moves it to the location `sys::unix::os_str` and reuses the code on other platforms via `#[path]` (as is common in `sys`) instead of importing.
2021-08-02Rollup merge of #86439 - CDirkx:ip-protocol-assignment, r=m-ou-seYuki Okushi-51/+6
Remove `Ipv4Addr::is_ietf_protocol_assignment` This PR removes the unstable method `Ipv4Addr::is_ietf_protocol_assignment`, as I suggested in https://github.com/rust-lang/rust/issues/85612#issuecomment-847863404. The method was added in #60145, as far as I can tell primarily for the implementation of `Ipv4Addr::is_global` (addresses reserved for IETF protocol assignment are not globally reachable unless otherwise specified). The method was added in 2019, but I haven't been able to find any open-source code using this method so far. I'm also having a hard time coming up with a usecase for specifically this method; knowing that an address is reserved for future protocols doesn't allow you to do much with it, especially since now some of those addresses are indeed assigned to a protocol and have their own behaviour (and might even be defined to be globally reachable, so if that is what you care about it is always more accurate to call `!is_global()`, instead of `is_ietf_protocol_assignment()`). Because of these reasons, I propose removing the method (or alternatively make it a private helper for `is_global`) and also not introduce `Ipv6Addr::is_ietf_protocol_assignment` and `IpAddr::is_ietf_protocol_assignment` in the future.
2021-08-02Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-seYuki Okushi-52/+38
Change environment variable getters to error recoverably This PR changes the standard library environment variable getter functions to error recoverably (i.e. not panic) when given an invalid value. On some platforms, it is invalid for environment variable names to contain `'\0'` or `'='`, or for their values to contain `'\0'`. Currently, the standard library panics when manipulating environment variables with names or values that violate these invariants. However, this behavior doesn't make a lot of sense, at least in the case of getters. If the environment variable is missing, the standard library just returns an error value, rather than panicking. It doesn't make sense to treat the case where the variable is invalid any differently from that. See the [internals thread](https://internals.rust-lang.org/t/why-should-std-var-panic/14847) for discussion. Thus, this PR changes the functions to error recoverably in this case as well. If desired, I could change the functions that manipulate environment variables in other ways as well. I didn't do that here because it wasn't entirely clear what to change them to. Should they error silently or do something else? If someone tells me how to change them, I'm happy to implement the changes. This fixes #86082, an ICE that arises from the current behavior. It also adds a regression test to make sure the ICE does not occur again in the future. `@rustbot` label +T-libs r? `@joshtriplett`
2021-08-01Auto merge of #86031 - ssomers:btree_lazy_iterator, r=Mark-Simulacrumbors-68/+171
BTree: lazily locate leaves in rangeless iterators BTree iterators always locate both the first and last leaf edge and often only need either one, i.e., whenever they are traversed in a single direction, like in for-loops and in the common use of `iter().next()` or `iter().next_back()` to retrieve the first or last key/value-pair (#62924). It's fairly easy to avoid because the iterators with this disadvantage already are quite separate from other iterators. r? `@Mark-Simulacrum`
2021-08-01Auto merge of #87622 - pietroalbini:bump-bootstrap, r=Mark-Simulacrumbors-24/+6
Bump bootstrap compiler to 1.55 Changing the cfgs for stdarch is missing, but my understanding is that we don't need to do it as part of this PR? r? `@Mark-Simulacrum`
2021-08-01Auto merge of #81825 - voidc:pidfd, r=joshtriplettbors-11/+410
Add Linux-specific pidfd process extensions (take 2) Continuation of #77168. I addressed the following concerns from the original PR: - make `CommandExt` and `ChildExt` sealed traits - wrap file descriptors in `PidFd` struct representing ownership over the fd - add `take_pidfd` to take the fd out of `Child` - close fd when dropped Tracking Issue: #82971
2021-08-01Update const_slice_first_last_not_mut stable version.Mara Bos-4/+4
2021-08-01bump bootstrap compiler to 1.55Pietro Albini-24/+6
2021-08-01Auto merge of #87664 - devnexen:netbsd_sanitizers_support, r=nagisabors-1/+6
netbsd x86_64 arch enable supported sanitizers.
2021-08-01Auto merge of #87546 - rusticstuff:issue87450-take-two, r=davidtwcobors-1/+48
Bail on any found recursion when expanding opaque types Fixes #87450. More of a bandaid because it does not fix the exponential complexity of the type folding used for opaque type expansion.
2021-08-01Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisabors-51/+44
more clippy::complexity fixes (also a couple of clippy::perf fixes)
2021-08-01Check whether clone3 syscall exists in pidfd testDominik Stolz-1/+19
2021-08-01Add dummy FileDesc struct for doc targetDominik Stolz-0/+4
2021-08-01Do not call getpid wrapper after fork in testsDominik Stolz-7/+35
The test calls libc::getpid() in the pre_exec hook and asserts that the returned value is different from the PID of the parent. However, libc::getpid() returns the wrong value. Before version 2.25, glibc caches the PID of the current process with the goal of avoiding additional syscalls. The cached value is only updated when the wrapper functions for fork or clone are called. In PR #81825 we switch to directly using the clone3 syscall. Thus, the cache is not updated and getpid returns the PID of the parent. source: https://man7.org/linux/man-pages/man2/getpid.2.html#NOTES
2021-08-01Auto merge of #84662 - dtolnay:unwindsafe, r=Amanieubors-638/+662
Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to core They were previously only available in std::panic, not core::panic. - https://doc.rust-lang.org/1.51.0/std/panic/trait.UnwindSafe.html - https://doc.rust-lang.org/1.51.0/std/panic/trait.RefUnwindSafe.html - https://doc.rust-lang.org/1.51.0/std/panic/struct.AssertUnwindSafe.html Where this is relevant: trait objects! Inside a `#![no_std]` library it's otherwise impossible to have a struct holding a trait object, and at the same time can be used from downstream std crates in a way that doesn't interfere with catch_unwind. ```rust // common library #![no_std] pub struct Thing { pub(crate) x: &'static (dyn SomeTrait + Send + Sync), } pub(crate) trait SomeTrait {...} ``` ```rust // downstream application fn main() { let thing: library::Thing = ...; let _ = std::panic::catch_unwind(|| { let _ = thing; }); // does not work :( } ``` See https://github.com/dtolnay/colorous/blob/a4131708e2f05d2377964981896ff62dbc9b027b/src/gradient.rs#L7-L15 for a real life example of needing to work around this problem. In particular that workaround would not even be viable if implementors of the trait were provided externally by a caller, as the `feature = "std"` would become non-additive in that case. What happens without the UnwindSafe constraints: ```rust fn main() { let gradient = colorous::VIRIDIS; let _ = std::panic::catch_unwind(|| { let _ = gradient; }); } ``` ```console error[E0277]: the type `(dyn colorous::gradient::EvalGradient + Send + Sync + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary --> src/main.rs:3:13 | 3 | let _ = std::panic::catch_unwind(|| { let _ = gradient; }); | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn colorous::gradient::EvalGradient + Send + Sync + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | ::: .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:430:40 | 430 | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> { | ---------- required by this bound in `catch_unwind` | = help: within `Gradient`, the trait `RefUnwindSafe` is not implemented for `(dyn colorous::gradient::EvalGradient + Send + Sync + 'static)` = note: required because it appears within the type `&'static (dyn colorous::gradient::EvalGradient + Send + Sync + 'static)` = note: required because it appears within the type `Gradient` = note: required because of the requirements on the impl of `UnwindSafe` for `&Gradient` = note: required because it appears within the type `[closure@src/main.rs:3:38: 3:62]` ```
2021-07-31Fix unused sync::atomic import on targets without atomicsDavid Tolnay-15/+14
2021-08-01Auto merge of #85782 - badboy:build-ios-sim-target, r=Mark-Simulacrumbors-2/+2
Build aarch64-apple-ios-sim as part of the full macOS build Part of the [MCP 428](https://github.com/rust-lang/compiler-team/issues/428) to promote this target to Tier 2. This adds the aarch64-apple-ios-sim target as a tier 2 target, currently cross-compiled from our x86_64 apple builders. The compiler team has approved the addition per the MCP noted above, and the infrastructure team has not raised concerns with this addition at this time (as the CI time impact is expected to be minimal; this is only building std).
2021-07-31Auto merge of #87662 - FabianWolff:rb-string, r=estebankbors-3/+41
Suggest `br` if the unknown string prefix `rb` is found Currently, for the following code: ```rust fn main() { rb"abc"; } ``` we issue the following suggestion: ``` help: consider inserting whitespace here | 2 | rb "abc"; | -- ``` With my changes (only in edition 2021, where unknown prefixes became an error), I get: ``` help: use `br` for a raw byte string | 2 | br"abc"; | ^^ ```
2021-07-31Auto merge of #87610 - Aaron1011:bump-llvm-bugfix, r=cuviperbors-6/+2
Bump LLVM for RegAllocFast bugfix Fixes #83854 cc `@cuviper`
2021-07-31netbsd x86_64 arch enable supported sanitizers.David Carlier-1/+6
2021-07-31Auto merge of #87607 - JohnTitor:help-to-unused-must-use-op, r=estebankbors-143/+325
Add a hint that the expressions produce a value Fixes #85913 The second commit is semi-_unrelated_ but it allows us to run the related tests just on `src/test/ui/lint`.
2021-07-31Suggest `br` if the unknown string prefix `rb` is foundFabian Wolff-3/+41
2021-07-31Relocate Arc and Rc UnwindSafe implsDavid Tolnay-12/+8
2021-07-31Auto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakisbors-27/+504
Trait upcasting coercion (part1) This revives the first part of earlier PR #60900 . It's not very clear to me which parts of that pr was design decisions, so i decide to cut it into pieces and land them incrementally. This allows more eyes on the details. This is the first part, it adds feature gates, adds feature gates tests, and implemented the unsize conversion part. (I hope i have dealt with the `ExistentialTraitRef` values correctly...) The next part will be implementing the pointer casting.
2021-07-31Auto merge of #87387 - the8472:slice-iter-advance_by, r=scottmcmbors-0/+57
Implement advance_by, advance_back_by for slice::{Iter, IterMut} Part of #77404. Picking up where #77633 was closed. I have addressed https://github.com/rust-lang/rust/pull/77633#issuecomment-771842599 by restoring `nth` and `nth_back`. So according to that comment this should already be r=m-ou-se, but it has been sitting for a while.
2021-07-31Auto merge of #87488 - kornelski:track-remove, r=dtolnaybors-0/+2
Track caller of Vec::remove() `vec.remove(invalid)` doesn't print a helpful source position: > thread 'main' panicked at 'removal index (is 99) should be < len (is 1)', **library/alloc/src/vec/mod.rs:1379:13**
2021-07-31Add more tests to cover more corner cases of type-checking.Charles Lew-0/+342
2021-07-30Auto merge of #86754 - estebank:use-multispans-more, r=varkorbors-442/+661
Use `multipart_suggestions` more Built on top of #86532
2021-07-31Apply review suggestionYuki Okushi-70/+157
2021-07-31Move the `unused` dir to `lint`s subdirYuki Okushi-0/+0
2021-07-31Add a hint that the expressions produce a valueYuki Okushi-30/+125
2021-07-30Auto merge of #87640 - JohnTitor:rollup-yq24nq5, r=JohnTitorbors-94/+577
Rollup of 9 pull requests Successful merges: - #86072 (Cross compiling rustc_llvm on Darwin requires zlib.) - #87385 (Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default) - #87547 (Add missing examples for NonNull) - #87557 (Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic) - #87559 (Tweak borrowing suggestion in `for` loop) - #87596 (Add warning when whitespace is not skipped after an escaped newline) - #87606 (Add some TAIT-related regression tests) - #87609 (Add docs about performance and `Iterator::map` to `[T; N]::map`) - #87616 (Fix missing word in rustdoc book) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-07-31Rollup merge of #87616 - Wilfred:patch-1, r=jyn514Yuki Okushi-1/+1
Fix missing word in rustdoc book
2021-07-31Rollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-seYuki Okushi-0/+22
Add docs about performance and `Iterator::map` to `[T; N]::map` This suboptimal code gen for some usages of array::map got a bit of attention by multiple people throughout the community. Some cases: - https://github.com/rust-lang/rust/issues/75243#issuecomment-866051086 - https://github.com/rust-lang/rust/issues/75243#issuecomment-874732134 - https://www.reddit.com/r/rust/comments/oeqqf7/unexpected_high_stack_usage/ My *guess* is that this gets the attention it gets because in JavaScript (and potentially other languages), a `map` function on arrays is very commonly used since in those languages, arrays basically take the role of Rust's iterator. I considered explicitly naming JavaScript in the first paragraph I added, but I couldn't find precedence of mentioning other languages in standard library doc, so I didn't add it. When array::map was stabilized, we still wanted to add docs, but that somehow did not happen in time. So here we are. Not sure if this sounds crazy but maybe it is worth considering beta backporting this? Only if it's not a lot of work, of course! But yeah, stabilized array::map is already in beta and if this problem is really as big as it sometimes seems, might be worth having the docs in place when 1.55 is released. CC ``@CryZe`` r? ``@m-ou-se`` (since you were involved in that discussion and the stabilization)
2021-07-31Rollup merge of #87606 - JohnTitor:tait-tests, r=oli-obkYuki Okushi-0/+53
Add some TAIT-related regression tests Closes #74280, closes #77179. r? ``@oli-obk``
2021-07-31Rollup merge of #87596 - jesyspa:issue-87318-hidden-whitespace, r=estebankYuki Okushi-8/+75
Add warning when whitespace is not skipped after an escaped newline Fixes issue #87318, also simplifies issue #87319. * Add support to the lexer to emit warnings as well as errors. * Emit a warning when a string literal contains an escaped newline, but when (some of) the whitespace on the next line is not skipped due to it being non-ASCII.
2021-07-31Rollup merge of #87559 - estebank:consider-borrowing, r=oli-obkYuki Okushi-44/+76
Tweak borrowing suggestion in `for` loop
2021-07-31Rollup merge of #87557 - rylev:fix-invalid-prelude-collision-error, ↵Yuki Okushi-3/+126
r=nikomatsakis Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic Fixes #86940 The test cases and associated issue should make it clear what specifically this is meant to fix. The fix is slightly hacky in that we check against the literal source code of the call site for the presence of `<` in order to determine if the user has included the generics for the struct (meaning we don't need to include them for them). r? ``@nikomatsakis``
2021-07-31Rollup merge of #87547 - GuillaumeGomez:nonnull-examples, r=kennytmYuki Okushi-0/+88
Add missing examples for NonNull
2021-07-31Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkovYuki Okushi-37/+135
Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default This PR makes the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint warn by default. To avoid showing a large number of un-actionable warnings to users, we only enable the lint for macros defined in the same crate. This ensures that users will be able to fix the warning by simply removing a semicolon. In the future, I'd like to enable this lint unconditionally, and eventually make it into a hard error in a future edition. This PR is a step towards that goal.
2021-07-31Rollup merge of #86072 - MarcusCalhoun-Lopez:llvm_cross, r=nagisaYuki Okushi-1/+1
Cross compiling rustc_llvm on Darwin requires zlib.
2021-07-30Add regression test for issue #87450.Hans Kratz-0/+43
2021-07-30Fix some broken rustdoc links in core::panic documentationDavid Tolnay-0/+6
2021-07-30Fix comment referring to formerly-above codeDavid Tolnay-1/+1
2021-07-30Fix undocumented unsafe in AssertUnwindSafe implsDavid Tolnay-0/+2
2021-07-30Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to coreDavid Tolnay-309/+319
2021-07-30Fix separation of public vs internal parts of LocationDavid Tolnay-12/+12
2021-07-30Split core::panic module to subdirectoryDavid Tolnay-329/+340