about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2020-10-09remove ReadDir.end_of_stream on targets that don't use itJosh Stone-1/+18
2020-10-09unix/vxworks: make DirEntry slightly smallerJosh Stone-10/+8
`DirEntry` contains a `ReadDir` handle, which used to just be a wrapper on `Arc<InnerReadDir>`. Commit af75314ecdbc5 added `end_of_stream: bool` which is not needed by `DirEntry`, but adds 8 bytes after padding. We can let `DirEntry` have an `Arc<InnerReadDir>` directly to avoid that.
2020-10-08Rollup merge of #77660 - nilslice:patch-1, r=jyn514Jonas Schievink-1/+1
(docs): make mutex error comment consistent with codebase Although exceptionally minor, I found this stands out from other error reporting language used in doc comments. With the existence of the `failure` crate, I suppose this could be slightly ambiguous. In any case, this change brings the particular comment into a consistent state with other mentions of returning errors.
2020-10-08Rollup merge of #77449 - ssomers:btree_drain_filter_size_hint, r=Mark-SimulacrumJonas Schievink-0/+4
BTreeMap: comment why drain_filter's size_hint is somewhat pessimistic The `size_hint` of the `DrainFilter` iterator doesn't adjust as you iterate. This hardly seems important to me, but there has been a comparable PR #64383 in the past. I guess a scenario is that you first iterate half the map manually and keep most of the key/value pairs in the map, and then tell the predicate to drain most of the key/value pairs and `.collect` the iterator over the remaining half of the map. I am totally ambivalent whether this is better or not. r? @Mark-Simulacrum
2020-10-08Rollup merge of #76750 - camelid:dont-discourage-core-fmt-write, ↵Jonas Schievink-10/+6
r=Mark-Simulacrum Don't discourage implementing `core::fmt::Write` Fixes #76729. Explain when you should use it and when you should not.
2020-10-08Don't discourage implementing `core::fmt::Write`Camelid-10/+6
Explain when you should use it and when you should not.
2020-10-08Auto merge of #77346 - Caduser2020:master, r=Mark-Simulacrumbors-119/+170
`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgx This is part of #73904. Enclose unsafe operations in unsafe blocks in `libstd/sys/sgx`.
2020-10-08`#[deny(unsafe_op_in_unsafe_fn)]` in sys/sgxCaduser2020-119/+170
Run `./x.py` fmt Add reference link Fix reference link Apply review suggestions.
2020-10-07Bump to 1.48 bootstrap compilerMark Rousskov-15/+8
2020-10-07Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obkbors-0/+1
Give `impl Trait` in a `const fn` its own feature gate ...previously it was gated under `#![feature(const_fn)]`. I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer. cc #77463 r? `@oli-obk`
2020-10-07(docs): make mutex error comment consistent with codebaseSteve Manuel-1/+1
2020-10-07Auto merge of #77617 - AnthonyMikh:slice_windows_no_bounds_checking, r=lcnrbors-15/+17
Eliminate bounds checking in slice::Windows This is how `<core::slice::Windows as Iterator>::next` looks right now: ```rust fn next(&mut self) -> Option<&'a [T]> { if self.size > self.v.len() { None } else { let ret = Some(&self.v[..self.size]); self.v = &self.v[1..]; ret } } ``` The line with `self.v = &self.v[1..];` relies on assumption that `self.v` is definitely not empty at this point. Else branch is taken when `self.size <= self.v.len()`, so `self.v` can be empty if `self.size` is zero. In practice, since `Windows` is never created directly but rather trough `[T]::windows` which panics when `size` is zero, `self.size` is never zero. However, the compiler doesn't know about this check, so it keeps the code which checks bounds and panics. Using `NonZeroUsize` lets the compiler know about this invariant and reliably eliminate bounds checking without `unsafe` on `-O2`. Here is assembly of `Windows<'a, u32>::next` before and after this change ([goldbolt](https://godbolt.org/z/xrefzx)): <details> <summary>Before</summary> ``` example::next: push rax mov rcx, qword ptr [rdi + 8] mov rdx, qword ptr [rdi + 16] cmp rdx, rcx jbe .LBB0_2 xor eax, eax pop rcx ret .LBB0_2: test rcx, rcx je .LBB0_5 mov rax, qword ptr [rdi] mov rsi, rax add rsi, 4 add rcx, -1 mov qword ptr [rdi], rsi mov qword ptr [rdi + 8], rcx pop rcx ret .LBB0_5: lea rdx, [rip + .L__unnamed_1] mov edi, 1 xor esi, esi call qword ptr [rip + core::slice::slice_index_order_fail@GOTPCREL] ud2 .L__unnamed_2: .ascii "./example.rs" .L__unnamed_1: .quad .L__unnamed_2 .asciz "\f\000\000\000\000\000\000\000\016\000\000\000\027\000\000" ``` </details> <details> <summary>After</summary> ``` example::next: mov rcx, qword ptr [rdi + 8] mov rdx, qword ptr [rdi + 16] cmp rdx, rcx jbe .LBB0_2 xor eax, eax ret .LBB0_2: mov rax, qword ptr [rdi] lea rsi, [rax + 4] add rcx, -1 mov qword ptr [rdi], rsi mov qword ptr [rdi + 8], rcx ret ``` </details> Note the lack of call to `core::slice::slice_index_order_fail` in second snippet. #### Possible reasons _not_ to merge this PR: * this changes the error message on panic in `[T]::windows`. However, AFAIK this messages are not covered by backwards compatibility policy.
2020-10-07Auto merge of #77626 - tamird:parse-scope-id, r=dtolnaybors-13/+27
Parse SocketAddrV6::scope_id r? `@dtolnay`
2020-10-07Auto merge of #74194 - mbrubeck:slice-eq, r=sfacklerbors-1/+4
Add PartialEq impls for Vec <-> slice This is a follow-up to #71660 and rust-lang/rfcs#2917 to add two more missing vec/slice PartialEq impls: ``` impl<A, B> PartialEq<[B]> for Vec<A> where A: PartialEq<B> { .. } impl<A, B> PartialEq<Vec<B>> for [A] where A: PartialEq<B> { .. } ``` Since this is insta-stable, it should go through the `@rust-lang/libs` FCP process. Note that I used version 1.47.0 for the `stable` attribute because I assume this will not merge before the 1.46.0 branch is cut next week.
2020-10-06Auto merge of #77630 - Dylan-DPC:rollup-kfwl55z, r=Dylan-DPCbors-47/+65
Rollup of 11 pull requests Successful merges: - #76784 (Add some docs to rustdoc::clean::inline and def_id functions) - #76911 (fix VecDeque::iter_mut aliasing issues) - #77400 (Fix suggestions for x.py setup) - #77515 (Update to chalk 0.31) - #77568 (inliner: use caller param_env) - #77571 (Use matches! for core::char methods) - #77582 (Move `EarlyOtherwiseBranch` to mir-opt-level 2) - #77590 (Update RLS and Rustfmt) - #77605 (Fix rustc_def_path to show the full path and not the trimmed one) - #77614 (Let backends access span information) - #77624 (Add c as a shorthand check alternative for new options #77603) Failed merges: r? `@ghost`
2020-10-07Rollup merge of #77571 - pickfire:patch-6, r=cramertjDylan DPC-40/+10
Use matches! for core::char methods
2020-10-07Rollup merge of #76911 - RalfJung:vecdeque-aliasing, r=oli-obkDylan DPC-7/+55
fix VecDeque::iter_mut aliasing issues Fixes https://github.com/rust-lang/rust/issues/74029
2020-10-06Parse SocketAddrV6::scope_idTamir Duberstein-4/+15
2020-10-06Avoid unused returnTamir Duberstein-9/+12
2020-10-06Auto merge of #77386 - joshtriplett:static-glibc, r=petrochenkovbors-28/+13
Support static linking with glibc and target-feature=+crt-static With this change, it's possible to build on a linux-gnu target and pass RUSTFLAGS='-C target-feature=+crt-static' or the equivalent via a `.cargo/config.toml` file, and get a statically linked executable. Update to libc 0.2.78, which adds support for static linking with glibc. Add `crt_static_respected` to the `linux_base` target spec. Update `android_base` and `linux_musl_base` accordingly. Avoid enabling crt_static_respected on Android platforms, since that hasn't been tested. Closes https://github.com/rust-lang/rust/issues/65447.
2020-10-06Eliminate bounds checking in slice::WindowsAnthonyMikh-15/+17
2020-10-06Auto merge of #77594 - timvermeulen:chain_advance_by, r=scottmcmbors-12/+167
Implement advance_by, advance_back_by for iter::Chain Part of #77404. This PR does two things: - implement `Chain::advance[_back]_by` in terms of `advance[_back]_by` on `self.a` and `advance[_back]_by` on `self.b` - change `Chain::nth[_back]` to use `advance[_back]_by` on `self.a` and `nth[_back]` on `self.b` This ensures that `Chain::nth` can take advantage of an efficient `nth` implementation on the second iterator, in case it doesn't implement `advance_by`. cc `@scottmcm` in case you want to review this
2020-10-06avoid unnecessary intermediate reference and improve safety commentsRalf Jung-6/+11
2020-10-06Rollup merge of #77573 - pickfire:patch-7, r=jyn514Yuki Okushi-2/+2
Hint doc use convert::identity relative link r? @jyn514
2020-10-06Rollup merge of #77528 - tamird:avoid-cast-net-parser, r=dtolnayYuki Okushi-36/+48
Avoid unchecked casts in net parser Once this and #77426 are in, I'll send another PR adding scope id parsing. r? @dtolnay
2020-10-06Rollup merge of #77228 - GuillaumeGomez:maybeuninit-examples, r=pickfireYuki Okushi-2/+16
Add missing examples for MaybeUninit r? @Dylan-DPC
2020-10-06Rollup merge of #76388 - poliorcetics:system-time-document-panic, r=KodrAusYuki Okushi-0/+10
Add a note about the panic behavior of math operations on time objects Fixes #71226.
2020-10-05Remove `fn` from feature nameDylan MacKenzie-1/+1
2020-10-05Add requisite feature gates in the standard libraryDylan MacKenzie-0/+1
2020-10-06Test with non-fused iteratorsTim Vermeulen-4/+41
2020-10-05Add testsTim Vermeulen-0/+66
2020-10-05Implement iter::Chain::{advance_by, advance_back_by}Tim Vermeulen-12/+64
2020-10-05hint doc use intra-doc linksIvan Tham-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-05Hint doc use convert::identity relative linkIvan Tham-2/+2
2020-10-05Use matches! for core::char methodsIvan Tham-40/+10
2020-10-05Add missing examples for MaybeUninitGuillaume Gomez-2/+16
2020-10-05make IterMut Send/Sync againRalf Jung-0/+7
2020-10-05VecDeque: avoid more aliasing issues by working with raw pointers instead of ↵Ralf Jung-12/+31
references
2020-10-05VecDeque: fix incorrect &mut aliasing in IterMut::next/next_backRalf Jung-7/+24
2020-10-04Add comment explaining why libunwind doesn't need to link libgcc_ehJosh Triplett-0/+3
2020-10-04unwind: Move linux-gnu library linking to lib.rs and libcJosh Triplett-3/+5
This unifies it with the handling of `target-feature=+crt-static` on other platforms, and allows for supporting static glibc in the future.
2020-10-04Update libc to 0.2.79Josh Triplett-25/+5
This also fixes issues with inconsistent `unsafe` on functions.
2020-10-05Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebankDylan DPC-2/+4
Replace some once(x).chain(once(y)) with [x, y] IntoIter Now that we have by-value array iterators that are [already used](https://github.com/rust-lang/rust/blob/25c8c53dd994acb3f4f7c02fe6bb46076393f8b0/compiler/rustc_hir/src/def.rs#L305-L307)... For example, ```diff - once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it) + IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it) ```
2020-10-05Rollup merge of #77471 - ssomers:btree_cleanup_3, r=Mark-SimulacrumDylan DPC-7/+7
BTreeMap: refactoring around edges, missed spots Tweaks from #77244 (and more) that are really inconsistencies in #77005. r? @Mark-Simulacrum
2020-10-05Rollup merge of #77426 - tamird:sockaddr-scope-id, r=dtolnayDylan DPC-3/+19
Include scope id in SocketAddrV6::Display r? @tmandry I couldn't find any unit tests for these functions. cc @ghanan94 @brunowonka
2020-10-05Rollup merge of #77395 - ssomers:btree_love_the_leaf_edge_comments, ↵Dylan DPC-22/+12
r=Mark-Simulacrum BTreeMap: admit the existence of leaf edges in comments The btree code is ambiguous about leaf edges (i.e., edges within leaf nodes). Iteration relies on them heavily, but some of the comments suggest there are no leaf edges (extracted from #77025) r? @Mark-Simulacrum
2020-10-05Rollup merge of #77219 - mightyiam:issue_77100, r=jyn514Dylan DPC-0/+2
core::global_allocator docs link to std::alloc::GlobalAlloc Closes #77100
2020-10-05Rollup merge of #75853 - LeSeulArtichaut:core-intra-docs-3, r=jyn514Dylan DPC-3/+3
Use more intra-doc-links in `core::fmt` This is a follow-up to #75819, which encountered some broken links due to #75176, so this PR contains the links that are blocked on #75176. r? @jyn514
2020-10-04Auto merge of #77023 - HeroicKatora:len-missed-optimization, r=Mark-Simulacrumbors-3/+27
Hint the maximum length permitted by invariant of slices One of the safety invariants of references, and in particular of references to slices, is that they may not cover more than `isize::MAX` bytes. The unsafe `from_raw_parts` constructors of slices explicitly requires the caller to guarantee this fact. Violating it would also be UB with regards to the semantics of generated llvm code. This effectively bounds the length of a (non-ZST) slice from above by a compile time constant. But when the length is loaded from a function argument it appears llvm is not aware of this requirement. The additional value range assertions allow some further elision of code branches, including overflow checks, especially in the presence of artithmetic on the indices. This may have a performance impact, adding more code to a common method but allowing more optimization. I'm not quite sure, is the Rust side of const-prop strong enough to elide the irrelevant match branches? Fixes: #67186
2020-10-04Use more intra-doc-links in `core::fmt`LeSeulArtichaut-3/+3