Commit graph

4182 commits

Author SHA1 Message Date
Max Wase
01435fc83a no_run and ignore doc attributes 2021-06-18 14:17:21 +03:00
Max Wase
f3c1db311c
Update doc library/std/src/path.rs
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-06-06 22:42:29 +03:00
Max Wase
a0958df56f Review fixes + doc-features 2021-05-27 18:02:21 +03:00
Max Wase
2d88c52ab7 Tracking issue add. 2021-05-27 16:11:54 +03:00
Max Wase
89c0f50b09 Fix is_symlink() method for Path using added is_symlink() method for Metadata 2021-05-27 16:04:08 +03:00
Max Wase
e1cf38fa89 Add is_symlink() method for Path. 2021-05-27 15:20:36 +03:00
bors
9814e83094 Auto merge of #84124 - 12101111:libunwind, r=petrochenkov
libunwind fix and cleanup

Fix:

1. "system-llvm-libunwind" now only skip build-script for linux target
2. workaround from https://github.com/rust-lang/rust/pull/65972 is not needed, upstream fix it in 68c50708d1 ( LLVM 11 )
3. remove code for MSCV and Apple in `compile()`, as they are not used
4. fix https://github.com/rust-lang/rust/issues/69222 , compile c files and cpp files in different config
5. fix conditional compilation for musl target.
6. fix that x86_64-fortanix-unknown-sgx don't link libunwind built in build-script into rlib
2021-05-27 04:08:20 +00:00
Dylan DPC
955e0f42fc
Rollup merge of #85719 - elichai:cstring-into_inner-inline, r=m-ou-se
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-27 03:02:11 +02:00
Dylan DPC
de1d7dbd0f
Rollup merge of #85689 - m-ou-se:array-intoiter-3, r=estebank
Remove Iterator #[rustc_on_unimplemented]s that no longer apply.

Now that `IntoIterator` is implemented for arrays, all the `rustc_on_unimplemented` for arrays of ranges (e.g. `for _ in [1..3] {}`) no longer apply, since they are now valid Rust.

Separated these from #85670, because we should discuss a potential new (clippy?) lint for these.

Until Rust 1.52, `for _ in [1..3] {}` produced:

```
error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator
 --> src/main.rs:2:14
  |
2 |     for _ in [1..3] {}
  |              ^^^^^^ if you meant to iterate between two values, remove the square brackets
  |
  = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]`
  = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end`
  = note: required by `std::iter::IntoIterator::into_iter`
```

But in Rust 1.53 and later, it compiles fine. It iterates over the array by value, for one iteration with the element `1..3`.

This is probably a mistake, which is no longer caught. Should we have a lint for it? Should Clippy have a lint for it?

cc ```@estebank``` ```@flip1995```

cc https://github.com/rust-lang/rust/issues/84513
2021-05-27 03:02:10 +02:00
Dylan DPC
0c53acc6f8
Rollup merge of #85649 - ChrisDenton:update-cc, r=matthewjasper
Update cc

Recent commits have improved `cc`'s finding of MSVC tools on Windows. In particular it should help to address these issues: #83043 and #43468
2021-05-27 03:02:09 +02:00
bors
9111b8ae97 Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum
Add `TrustedRandomAccess` specialization for `Vec::extend()`

This should do roughly the same as the `TrustedLen` specialization but result in less IR by using `__iterator_get_unchecked`
instead of `Iterator::for_each`

Conflicting specializations are manually prioritized by grouping them under yet another helper trait.
2021-05-26 19:22:31 +00:00
Dylan DPC
9ee87c7e00
Rollup merge of #85712 - BlackHoleFox:fix-iter-typo, r=jyn514
Fix typo in core::array::IntoIter comment

Saw a small typo reading some internal comments and decided to just throw this up to fix it for future readers.
2021-05-26 13:32:12 +02:00
Dylan DPC
f3b10dd709
Rollup merge of #85679 - hch12907:master, r=Mark-Simulacrum
Remove num_as_ne_bytes feature

From the discussion in #76976, it is determined that eventual results of the safe transmute work as a more general mechanism will let these conversions happen in safe code without needing specialized methods.

Merging this PR closes #76976 and resolves #64464. Several T-libs members have raised their opinion that it doesn't pull its weight as a standalone method, and so we should not track it as a specific thing to add.
2021-05-26 13:32:11 +02:00
Dylan DPC
3c2a709620
Rollup merge of #85678 - lukas-code:matches2021, r=dtolnay
fix `matches!` and `assert_matches!` on edition 2021

Previously this code failed to compile on edition 2021. [(Playground)](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=53960f2f051f641777b9e458da747707)
```rust
fn main() {
    matches!((), ());
}
```
```
   Compiling playground v0.0.1 (/playground)
error: `$pattern:pat` may be followed by `|`, which is not allowed for `pat` fragments
    |
    = note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: aborting due to previous error

error: could not compile `playground`

To learn more, run the command again with --verbose.
```
2021-05-26 13:32:10 +02:00
Dylan DPC
12ab323d0e
Rollup merge of #85670 - m-ou-se:array-intoiter-1, r=scottmcm
Remove arrays/IntoIterator message from Iterator trait.

Arrays implement IntoIterator since 1.53.

cc https://github.com/rust-lang/rust/issues/84513
2021-05-26 13:32:09 +02:00
Dylan DPC
27899e3887
Rollup merge of #85625 - SkiFire13:fix-85613-vec-dedup-drop-panics, r=nagisa
Prevent double drop in `Vec::dedup_by` if a destructor panics

Fixes #85613
2021-05-26 13:32:06 +02:00
12101111
52a33655be
cleanup and fix compiling of libunwind
fix conditional compiling of llvm-libunwind feaure for musl target.
update document of llvm-libunwind feature.
2021-05-26 19:22:58 +08:00
Elichai Turkel
45099e6cf6 Add inline attr to private CString::into_inner 2021-05-26 13:12:54 +03:00
BlackHoleFox
d1b69cf89b Fix typo in core::array::IntoIter comment 2021-05-26 02:37:39 -05:00
Yuki Okushi
7caf93fa1b
Rollup merge of #85672 - CDirkx:ip, r=Mark-Simulacrum
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-26 13:31:07 +09:00
Yuki Okushi
e87bc66fca
Rollup merge of #85666 - fee1-dead:document-shared-from-cow, r=dtolnay
Document shared_from_cow functions
2021-05-26 13:31:04 +09:00
Yuki Okushi
587de8e5f9
Rollup merge of #85645 - scottmcm:demote-from-into-try, r=yaahc
Demote `ControlFlow::{from|into}_try` to `pub(crate)`

They have mediocre names and non-obvious semantics, so personally I don't think they're worth trying to stabilize, and thus might as well just be internal (they're used for convenience in iterator adapters), not something shown in the rustdocs.

I don't think anyone actually wanted to use them outside `core` -- they just got made public-but-unstable along with the whole type in https://github.com/rust-lang/rust/pull/76204 that promoted `LoopState` from an internal type to the exposed `ControlFlow` type.

cc https://github.com/rust-lang/rust/issues/75744, the tracking issue they mention.
cc https://github.com/rust-lang/rust/pull/85608, the PR where I'm proposing stabilizing the type.
2021-05-26 13:31:02 +09:00
Yuki Okushi
b7b9ce3df8
Rollup merge of #85610 - SkiFire13:fix-copy-within-provenance, r=oli-obk
Fix pointer provenance in <[T]>::copy_within

Previously the `self.as_mut_ptr()` invalidated the pointer created by the first `self.as_ptr()`. This also triggered miri when run with `-Zmiri-track-raw-pointers`
2021-05-26 13:31:00 +09:00
Yuki Okushi
ae6a1a7043
Rollup merge of #85529 - tlyu:trylock-errors, r=JohnTitor
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-26 13:30:58 +09:00
bors
47a90f4520 Auto merge of #85535 - dtolnay:weakdangle, r=kennytm
Weak's type parameter may dangle on drop

Way back in 34076bc0c9, #\[may_dangle\] was added to Rc\<T\> and Arc\<T\>'s Drop impls. That appears to have been because a test added in #28929 used Arc and Rc with dangling references at drop time. However, Weak was not covered by that test, and therefore no #\[may_dangle\] was forced to be added at the time.

As far as dropping, Weak has *even less need* to interact with the T than Rc and Arc do. Roughly speaking #\[may_dangle\] describes generic parameters that the outer type's Drop impl does not interact with except by possibly dropping them; no other interaction (such as trait method calls on the generic type) is permissible. It's clear this applies to Rc's and Arc's drop impl, which sometimes drop T but otherwise do not interact with one. It applies *even more* to Weak. Dropping a Weak cannot ever cause T's drop impl to run. Either there are strong references still in existence, in which case better not drop the T. Or there are no strong references still in existence, in which case the T would already have been dropped previously by the drop of the last strong count.
2021-05-26 01:17:02 +00:00
Mara Bos
caf6faf951 Remove Iterator #[rustc_on_unimplemented]s that no longer apply. 2021-05-25 20:20:05 +02:00
Hoe Hao Cheng
0baf89810f Remove num_as_ne_bytes feature 2021-05-25 22:48:08 +08:00
Lukas Markeffsky
3ed90e2424 fix matches! and assert_matches! on edition 2021 2021-05-25 16:44:20 +02:00
Christiaan Dirkx
87cf2d4726 Move stability attribute for methods under the ip feature from the module to the methods themselves 2021-05-25 15:57:27 +02:00
Mara Bos
8d954fa589 Remove arrays/IntoIterator message from Iterator trait. 2021-05-25 15:48:14 +02:00
Deadbeef
37588e9e1b
Document shared_from_cow functions 2021-05-25 20:06:02 +08:00
Guillaume Gomez
46615598a9
Rollup merge of #85644 - tialaramex:master, r=dtolnay
Better English for documenting when to use unimplemented!()

I don't think "plan of using" is correct here. I considered "plan on using" but eventually decided "plan to use" is better.
2021-05-25 13:05:15 +02:00
bors
a7890c7952 Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrum
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-25 05:48:00 +00:00
Chris Denton
e238ee31d4
Update cc
Recent commits to cc have helped to address #83043 and #43468
2021-05-24 23:34:12 +01:00
Scott McMurray
b63f7f9965 Demote ControlFlow::{from|into}_try to pub(crate) 2021-05-24 14:29:44 -07:00
Nick Lamb
54ccf95af2 Better English for documenting when to use unimplemented!() 2021-05-24 22:21:05 +01:00
bors
126561cb31 Auto merge of #85639 - GuillaumeGomez:rollup-modinsi, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #85271 (Fix indentation in move keyword documentation)
 - #85551 (Fix search results display)
 - #85621 (Restore sans-serif font for module items.)
 - #85628 (Replace more "NULL" with "null")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-24 18:05:35 +00:00
Guillaume Gomez
2a8eeafa9d
Rollup merge of #85271 - th1000s:master, r=JohnTitor
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-24 18:53:29 +02:00
bors
ef0ec303fa Auto merge of #85596 - scottmcm:more-on-unimplemented, r=estebank
Extend `rustc_on_implemented` to improve more `?` error messages

`_Self` could match the generic definition; this adds that functionality for matching the generic definition of type parameters too.

Your advice welcome on the wording of all these messages, and which things belong in the message/label/note.

r? `@estebank`
2021-05-24 15:24:38 +00:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
Taylor Yu
0e4f8cb661 minor rewording after review
Use "the `WouldBlock` error" instead of "the error `WouldBlock`", etc.
2021-05-24 09:24:35 -05:00
Giacomo Stevanato
c9595faa28 Make Vec::dedup panicking test actually detect double panics 2021-05-24 12:42:04 +02:00
Giacomo Stevanato
e0c9719672 Avoid a double drop in Vec::dedup if a destructor panics 2021-05-24 12:41:13 +02:00
bors
6f6919231e Auto merge of #85601 - klensy:padint-example-fix, r=dtolnay
fix pad_integral example

pad_integral's parameter `is_nonnegative - whether the original integer was either positive or zero`, but in example it checked as `self.nb > 0`, so it previously printed `-0` for `format!("{}", Foo::new(0)`, what is wrong.
2021-05-24 10:02:55 +00:00
Giacomo Stevanato
d7341f3c4b Don't reborrow self when computing the dest pointer in <[T]>::copy_within 2021-05-23 22:00:32 +02:00
bstrie
ed75d62fd5
Update std::array module doc header
Extremely outdated; not only are traits implemented on arrays of arbitrary length, those implementations are documented on the primitive type, not in this module.
2021-05-23 15:55:27 -04:00
Scott McMurray
8be67998a1 Extend rustc_on_implemented to improve a ?-on-ControlFlow error message 2021-05-23 07:18:02 -07:00
klensy
7c0db6f0f1 fix pad_integral example 2021-05-23 14:48:16 +03:00
bors
6e92fb4098 Auto merge of #85490 - CDirkx:fix-vxworks, r=dtolnay
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-23 05:40:18 +00:00
Dylan DPC
75edb76937
Rollup merge of #85571 - workingjubilee:reverse-prepend, r=Amanieu
Remove surplus prepend LinkedList fn

This nightly library feature provides a function on `LinkedList<T>` that is identical to `fn append` with a reversed order of arguments. Observe this diff against the `fn append` doctest:
```diff
+#![feature(linked_list_prepend)]
 fn main() {
    use std::collections::LinkedList;
    let mut list1 = LinkedList::new();
    list1.push_back('a');
    let mut list2 = LinkedList::new();
    list2.push_back('b');
    list2.push_back('c');

-    list1.append(&mut list2);
+    list2.prepend(&mut list1);

-    let mut iter = list1.iter();
+    let mut iter = list2.iter();
     assert_eq!(iter.next(), Some(&'a'));
     assert_eq!(iter.next(), Some(&'b'));
     assert_eq!(iter.next(), Some(&'c'));
     assert!(iter.next().is_none());

-    assert!(list2.is_empty());
+    assert!(list1.is_empty());
 }
```

As this has received no obvious request to stabilize it, nor does it have a tracking issue, and was left on nightly and the consensus seems to have been to deprecate it in this pre-1.0 PR in 2014, https://github.com/rust-lang/rust/pull/20356, I propose simply removing it.
2021-05-23 03:23:47 +02:00