about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2021-06-06A few lerp testsltdk-0/+43
2021-06-06Default panic message should print Box<dyn Any>Reagan McFarland-1/+1
Prior to this patch, the default panic message (resulting from calling `panic_any(42);` for example), would print the following error message: ``` thread 'main' panicked at 'Box<Any>', ... ``` However, this should be `Box<dyn Any>` instead.
2021-06-06Update doc library/std/src/path.rsMax Wase-1/+0
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-06-05Updated code examples and wordingerer1243-11/+9
2021-06-05Rollup merge of #85974 - GuillaumeGomez:td-align, r=jshaGuillaume Gomez-2/+2
td align attribute This is a follow-up of #85972. I have put this one on its own because it changes the display: ![Screenshot from 2021-06-03 21-49-11](https://user-images.githubusercontent.com/3050060/120703622-d533d280-c4b5-11eb-9519-ea1131a40bee.png) Without align: ![Screenshot from 2021-06-03 21-49-15](https://user-images.githubusercontent.com/3050060/120703623-d5cc6900-c4b5-11eb-95f9-878d3915c7fb.png) I also opened an issue about it: raphlinus/pulldown-cmark#533. However, I'm not sure if this is the right course of action... Should we instead ignore the warning? r? ``@jsha``
2021-06-05Rollup merge of #85760 - ChrisDenton:path-doc-platform-specific, r=m-ou-seGuillaume Gomez-9/+9
Possible errors when accessing file metadata are platform specific In particular the `is_dir`, `is_file` and `exists` functions suggests that querying a file requires querying the directory. On Windows this is not normally true. r? `@m-ou-se`
2021-06-05Rollup merge of #85710 - fee1-dead:document-path, r=m-ou-seGuillaume Gomez-0/+24
Document `From` impls in path.rs
2021-06-05Implement `Cursor::{remaining, is_empty}`Sören Meier-4/+59
2021-06-05Rename IoSlice(Mut)::advance_slice to advance_slicesThomas de Zeeuw-24/+24
2021-06-05Rollup merge of #84942 - jyn514:channel-replace, r=ManishearthYuki Okushi-1/+0
rustdoc: link to stable/beta docs consistently in documentation This is an alternative to https://github.com/rust-lang/rust/pull/84941 which fixes the problem consistently by linking to stable/beta for *all* items, not just for primitives. ## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel cc Mark-Simulacrum - I know [you were dubious about this in the past](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/231223124), but I'm not quite sure why? I see this as "just a bugfix", I don't know why rustdoc should unconditionally link to nightly. cc dtolnay who commented in https://github.com/rust-lang/rust/issues/30693: > I would welcome a PR to solve this permanently if anyone has ideas for how. I don't believe we need an RFC. Fixes https://github.com/rust-lang/rust/issues/30693 (note that issue is marked as feature-accepted, although I don't see where it was discussed).
2021-06-04rustdoc: link to stable/beta docs consistently in documentationJoshua Nelson-1/+0
## User-facing changes - Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as). - Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels). - Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links. Note that "links" includes both intra-doc links and rustdoc's own automatically generated hyperlinks. ## Implementation changes - Update the testsuite to allow linking to /beta and /1.52.1 in docs - Use an html_root_url for the standard library that's dependent on the channel This avoids linking to nightly docs on stable. - Update rustdoc to use channel-dependent links for primitives from an unknown crate - Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync - Include doc.rust-lang.org in the channel
2021-06-04Auto merge of #85806 - ATiltedTree:android-ndk-beta, r=petrochenkovbors-2/+1
Support Android ndk versions `r23-beta3` and up Since android ndk version `r23-beta3`, `libgcc` has been replaced with `libunwind`. This moves the linking of `libgcc`/`libunwind` into the `unwind` crate where we check if the system compiler can find `libunwind` and fall back to `libgcc` if needed.
2021-06-04Fix invalid align attribute generation on <td> elementsGuillaume Gomez-2/+2
2021-06-01Add lerp methodltdk-0/+56
2021-06-02Auto merge of #85687 - m-ou-se:new-prelude, r=yaahcbors-7/+7
New prelude RFC: rust-lang/rfcs#3114 Tracking issue: https://github.com/rust-lang/rust/issues/85684
2021-06-01Support Android ndk versions `r23-beta3` and upTilmann Meyer-1/+0
Since android ndk version `r23-beta3`, `libgcc` has been replaced with `libunwind`. This moves the linking of `libgcc`/`libunwind` into the `unwind` crate where we check if the system compiler can find `libunwind` and fall back to `libgcc` if needed.
2021-06-01Update `compiler_builtins` to 0.1.44Tilmann Meyer-1/+1
2021-06-01Multiple improvements to RwLocksBenoît du Garreau-133/+111
- Split `sys_common::RWLock` between `StaticRWLock` and `MovableRWLock` - Unbox `RwLock` on some platforms (Windows, Wasm and unsupported) - Simplify `RwLock::into_inner`
2021-05-31Use `is_unicast` instead of ``!is_multicast`Christiaan Dirkx-1/+1
2021-05-31Add `Ipv6Addr::is_unicast`Christiaan Dirkx-0/+28
2021-05-30Remove `is_unicast_link_local_strict`Christiaan Dirkx-101/+27
2021-05-29Add has_data_left() to BufReadYuhanLiin-0/+41
2021-05-29Add IoSlice(Mut)::advanceThomas de Zeeuw-2/+54
Advance the internal cursor of a single slice.
2021-05-29Rename IoSlice(Mut)::advance to advance_sliceThomas de Zeeuw-28/+27
To make way for a new IoSlice(Mut)::advance function that advances a single slice. Also changes the signature to accept a `&mut &mut [IoSlice]`, not returning anything. This will better match the future IoSlice::advance function.
2021-05-28Refactor windows sockets impl methodsMichael-133/+173
2021-05-28Auto merge of #85745 - veber-alex:panic_any, r=m-ou-sebors-0/+1
Add #[track_caller] to panic_any Report the panic location from the user code. ```rust use std::panic; use std::panic::panic_any; fn main() { panic::set_hook(Box::new(|panic_info| { if let Some(location) = panic_info.location() { println!( "panic occurred in file '{}' at line {}", location.file(), location.line(), ); } else { println!("panic occurred but can't get location information..."); } })); panic_any(42); } ```` Before: `panic occurred in file '/rustc/ff2c947c00f867b9f012e28ba88cecfbe556f904/library/std/src/panic.rs' at line 59` After: `panic occurred in file 'src/main.rs' at line 17`
2021-05-27Possible errors when reading file metadata are platform specificChris Denton-9/+9
In particular the `is_dir`, `is_file` and `exists` functions says that querying a file requires querying the directory. On Windows this is not normally true.
2021-05-27Review fixes + doc-featuresMax Wase-6/+8
2021-05-27Document `From` impls in path.rsDeadbeef-0/+24
2021-05-27Tracking issue add.Max Wase-2/+2
2021-05-27Fix `is_symlink()` method for `Path` using added `is_symlink()` method for ↵Max Wase-3/+26
`Metadata`
2021-05-27Add `is_symlink()` method for `Path`.Max Wase-0/+26
2021-05-27Add #[track_caller] to panic_anyAlex Veber-0/+1
2021-05-26Rename opensbd to openbsdAlbert Ford-3/+3
2021-05-27Rollup merge of #85719 - elichai:cstring-into_inner-inline, r=m-ou-seDylan DPC-0/+1
Add inline attr to CString::into_inner so it can optimize out NonNull checks It seems that currently if you convert any of the standard library's container to a pointer and then to a NonNull pointer, all will optimize out the NULL check except `CString`(https://godbolt.org/z/YPKW9G5xn), because for some reason `CString::into_inner` isn't inlined even though it's a private function that should compile into a simple `mov` instruction. Adding a simple `#[inline]` attribute solves this, code example: ```rust use std::ffi::CString; use std::ptr::NonNull; pub fn cstring_nonull(mut n: CString) -> NonNull<i8> { NonNull::new(CString::into_raw(n)).unwrap() } ``` assembly before: ```asm __ZN3wat14cstring_nonull17h371c755bcad76294E: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset %rbp, -16 movq %rsp, %rbp .cfi_def_cfa_register %rbp callq __ZN3std3ffi5c_str7CString10into_inner17h28ece07b276e2878E testq %rax, %rax je LBB0_2 popq %rbp retq LBB0_2: leaq l___unnamed_1(%rip), %rdi leaq l___unnamed_2(%rip), %rdx movl $43, %esi callq __ZN4core9panicking5panic17h92a83fa9085a8f73E .cfi_endproc .section __TEXT,__const l___unnamed_1: .ascii "called `Option::unwrap()` on a `None` value" l___unnamed_3: .ascii "wat.rs" .section __DATA,__const .p2align 3 l___unnamed_2: .quad l___unnamed_3 .asciz "\006\000\000\000\000\000\000\000\006\000\000\000(\000\000" ``` Assembly after: ```asm __ZN3wat14cstring_nonull17h9645eb9341fb25d7E: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset %rbp, -16 movq %rsp, %rbp .cfi_def_cfa_register %rbp movq %rdi, %rax popq %rbp retq .cfi_endproc ``` (Related discussion on zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/NonNull.20From.3CBox.3CT.3E.3E)
2021-05-26Add inline attr to private CString::into_innerElichai Turkel-0/+1
2021-05-26Rollup merge of #85672 - CDirkx:ip, r=Mark-SimulacrumYuki Okushi-8/+17
Move stability attribute for items under the `ip` feature The `#[unstable]` attribute for items under the `ip` feature is currently located on the `std::net::ip` module itself. This is unusual, and less readable. This has sidetracked discussion about these items numerous times (https://github.com/rust-lang/rust/pull/60145#issuecomment-498016572, https://github.com/rust-lang/rust/pull/76098#discussion_r530463543, https://github.com/rust-lang/rust/pull/76098#discussion_r558067755, https://github.com/rust-lang/rust/pull/75019#discussion_r467464300, https://github.com/rust-lang/rust/pull/75019#issuecomment-672888727) and lead to incorrect assumptions about which items are actually stable (https://github.com/rust-lang/rust/pull/60145#issuecomment-485970669, https://github.com/rust-lang/rust/pull/76098#discussion_r530444275). This PR moves the attribute from the module to the items themselves.
2021-05-26Rollup merge of #85529 - tlyu:trylock-errors, r=JohnTitorYuki Okushi-9/+28
doc: clarify Mutex::try_lock, etc. errors Clarify error returns from Mutex::try_lock, RwLock::try_read, RwLock::try_write to make it more obvious that both poisoning and the lock being already locked are possible errors.
2021-05-25Add tracking issue for edition-specific preludes.Mara Bos-7/+7
2021-05-25Fix documentation style inconsistenciesChristiaan Dirkx-26/+26
2021-05-25Move stability attribute for methods under the `ip` feature from the module ↵Christiaan Dirkx-8/+17
to the methods themselves
2021-05-25Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrumbors-13/+6
Bump bootstrap compiler to beta 1.53.0 This PR bumps the bootstrap compiler to version 1.53.0 beta, as part of our usual release process (this was supposed to be Wednesday's step, but creating the beta release took longer than expected). The PR also includes the "Bootstrap: skip rustdoc fingerprint for building docs" commit, see the reasoning [on Zulip](https://zulip-archive.rust-lang.org/241545trelease/88450153betabootstrap.html). r? `@Mark-Simulacrum`
2021-05-24Rollup merge of #85271 - th1000s:master, r=JohnTitorGuillaume Gomez-2/+2
Fix indentation in move keyword documentation See (at the time of writing) the second example code block with `create_fn()` at https://doc.rust-lang.org/std/keyword.move.html
2021-05-24remove cfg(bootstrap)Pietro Albini-13/+6
2021-05-24minor rewording after reviewTaylor Yu-6/+6
Use "the `WouldBlock` error" instead of "the error `WouldBlock`", etc.
2021-05-23Auto merge of #85490 - CDirkx:fix-vxworks, r=dtolnaybors-5/+31
Fix `vxworks` Some PRs made the `vxworks` target not build anymore. This PR fixes that: - #82973: copy `ExitStatusError` implementation from `unix`. - #84716: no `libc::chroot` available on `vxworks`, so for now don't implement `os::unix::fs::chroot`.
2021-05-23Rollup merge of #85334 - r00ster91:patch-8, r=dtolnayDylan DPC-0/+3
Add doc aliases to `unit` I think it makes sense for `unit` to have the same doc aliases as `tuple` does.
2021-05-23Rollup merge of #85288 - Geal:clarify-std-io-read, r=dtolnayDylan DPC-1/+7
add an example to explain std::io::Read::read returning 0 in some cases I have always found the explanation about `Read::read` returning 0 to indicate EOF but not indefinitely, so here's more info using Linux as example. I can also add example code if necessary
2021-05-23Rollup merge of #84758 - ChrisDenton:dllimport, r=dtolnayDylan DPC-166/+168
MSVC: Avoid using jmp stubs for dll function imports Windows import libraries contain two symbols for every function: `__imp_FunctionName` and `FunctionName` (where `FunctionName` is the name of the function to be imported). `__imp_FunctionName` contains the address of the imported function. This will be filled in by the Windows executable loader at runtime. `FunctionName` contains a jmp stub that simply jumps to the address given by `__imp_FunctionName`. E.g. it's a function that solely contains a single jmp instruction: ```asm jmp __imp_FunctionName ``` When using an external DLL function in Rust, by default the linker will link to FunctionName, causing a bit of indirection at runtime. In Microsoft's C++ it's possible to instead tell it to insert calls to the address in `__imp_FunctionName` by using the `__declspec(dllimport)` attribute. In Rust it's possible to get effectively the same behaviour using the `#[link]` attribute on `extern` blocks. ---- The second commit also merges multiple `extern` blocks into one block. This is because otherwise Rust will currently create duplicate linker arguments for each block. In this case having duplicates shouldn't matter much other than the noise when displaying the linker command.
2021-05-21Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStrAaron Rennow-0/+42
DirEntryExt2 is a new trait with the same purpose as DirEntryExt, but sealed