Matthias Krüger [Sat, 29 Jan 2022 13:46:30 +0000 (14:46 +0100)]
Rollup merge of #92274 - woppopo:const_deallocate, r=oli-obk
Add `intrinsics::const_deallocate`
Tracking issue: #79597
Related: #91884
This allows deallocation of a memory allocated by `intrinsics::const_allocate`. At the moment, this can be only used to reduce memory usage, but in the future this may be useful to detect memory leaks (If an allocated memory remains after evaluation, raise an error...?).
bors [Sat, 29 Jan 2022 09:01:01 +0000 (09:01 +0000)]
Auto merge of #93351 - anp:fuchsia-remove-dir-all, r=tmandry
Bump libc and fix remove_dir_all on Fuchsia after CVE fix
With the previous `is_dir` impl, we would attempt to unlink
a directory in the None branch, but Fuchsia supports returning
ENOTEMPTY from unlinkat() without the AT_REMOVEDIR flag because
we don't currently differentiate unlinking files and directories
by default.
On the Fuchsia side I've opened https://fxbug.dev/92273 to discuss
whether this is the correct behavior, but it doesn't seem like
addressing the error code is necessary to make our tests happy.
Depends on https://github.com/rust-lang/libc/pull/2654 since we
apparently haven't needed to reference DT_UNKNOWN before this.
bors [Fri, 28 Jan 2022 23:20:38 +0000 (23:20 +0000)]
Auto merge of #93427 - matthiaskrgr:rollup-esd3ixl, r=matthiaskrgr
Rollup of 10 pull requests
Successful merges:
- #92611 (Add links to the reference and rust by example for asm! docs and lints)
- #93158 (wasi: implement `sock_accept` and enable networking)
- #93239 (Add os::unix::net::SocketAddr::from_path)
- #93261 (Some unwinding related cg_ssa cleanups)
- #93295 (Avoid double panics when using `TempDir` in tests)
- #93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>)
- #93356 (Edit docs introduction for `std::cmp::PartialOrd`)
- #93375 (fix typo `documenation`)
- #93399 (rustbuild: Fix compiletest warning when building outside of root.)
- #93404 (Fix a typo from #92899)
Adam Perry [Wed, 26 Jan 2022 22:32:21 +0000 (22:32 +0000)]
Fix remove_dir_all on Fuchsia after CVE fix.
With the previous `is_dir` impl, we would attempt to unlink
a directory in the None branch, but Fuchsia supports returning
ENOTEMPTY from unlinkat() without the AT_REMOVEDIR flag because
we don't currently differentiate unlinking files and directories
by default.
On the Fuchsia side I've opened https://fxbug.dev/92273 to discuss
whether this is the correct behavior, but it doesn't seem like
addressing the error code is necessary to make our tests happy.
Updates std's libc crate to include DT_UNKNOWN for Fuchsia.
Matthias Krüger [Fri, 28 Jan 2022 14:20:29 +0000 (15:20 +0100)]
Rollup merge of #93399 - ehuss:fix-compiletest-path-relative, r=Mark-Simulacrum
rustbuild: Fix compiletest warning when building outside of root.
This fixes a warning that would happen when passing arguments to compiletest (like `x.py test src/test/ui`) when running `x.py` outside of the root source directory. For example, the CI builders do this, which causes a confusing warning message. This also fixes it so that passing a full path works (like `x.py test src/test/ui/hello.rs`) in the same scenario (previously it would just ignore the `hello.rs` part).
Matthias Krüger [Fri, 28 Jan 2022 14:20:27 +0000 (15:20 +0100)]
Rollup merge of #93356 - pierwill:partialord-headline, r=dtolnay
Edit docs introduction for `std::cmp::PartialOrd`
This makes `PartialOrd` consistent with the other three traits in this module, which all include links to their corresponding mathematical concepts on Wikipedia.
```rust
let mut value = Saturating(2u8);
value += 3u8;
value -= 1u8;
value *= 2u8;
value /= 2u8;
value %= 2u8;
value ^= 255u8;
value |= 123u8;
value &= 2u8;
```
See https://github.com/rust-lang/rust/pull/93208#issuecomment-1022564429
Matthias Krüger [Fri, 28 Jan 2022 14:20:25 +0000 (15:20 +0100)]
Rollup merge of #93295 - ChrisDenton:tempdir-double-panic, r=dtolnay
Avoid double panics when using `TempDir` in tests
`TempDir` could panic on drop if `remove_dir_all` returns an error. If this happens while already panicking, the test process would abort and therefore not show the test results.
Matthias Krüger [Fri, 28 Jan 2022 14:20:22 +0000 (15:20 +0100)]
Rollup merge of #93158 - haraldh:wasi_sock_accept, r=dtolnay
wasi: implement `sock_accept` and enable networking
With the addition of `sock_accept()` to snapshot1, simple networking via a passed `TcpListener` is possible. This PR implements the basics to make a simple server work.
See also:
* [wasmtime tracking issue](https://github.com/bytecodealliance/wasmtime/issues/3730)
* [wasmtime PR](https://github.com/bytecodealliance/wasmtime/pull/3711)
TODO:
* [ ] Discussion of `SocketAddr` return value for `::accept()`
```rust
Ok((
TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
// WASI has no concept of SocketAddr yet
// return an unspecified IPv4Addr
SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
))
```
bors [Fri, 28 Jan 2022 12:46:13 +0000 (12:46 +0000)]
Auto merge of #93006 - michaelwoerister:fix-unsized-ptr-debuginfo, r=davidtwco,oli-obk
Fix debuginfo for pointers/references to unsized types
This PR makes the compiler emit fat pointer debuginfo in all cases. Before, we sometimes got thin-pointer debuginfo, making it impossible to fully interpret the pointed to memory in debuggers. The code is actually cleaner now, especially around generation of trait object pointer debuginfo.
Harald Hoyer [Fri, 21 Jan 2022 13:19:48 +0000 (14:19 +0100)]
wasi: enable TcpListener and TcpStream
With the addition of `sock_accept()` to snapshot1, simple networking via
a passed `TcpListener` is possible. This patch implements the basics to
make a simple server work.
For more information about this error, try `rustc --explain E0061`.
```
With this change, `rustc` will now suggest parentheses when:
- The callee is expecting a single tuple argument
- The number of arguments passed matches the element count in the above tuple
- The arguments' types match the tuple's fields
```
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
--> b.rs:2:5
|
2 | Some(1, 2)
| ^^^^ - - supplied 2 arguments
|
help: use parentheses to construct a tuple
|
2 | Some((1, 2))
| + +
```
[debuginfo] Fix and unify handling of fat pointers in debuginfo: Don't mark fat pointer fields as artificial.
LLDB does not seem to see fields if they are marked with DW_AT_artificial
which breaks pretty printers that use these fields for decoding fat pointers.
pierwill [Thu, 27 Jan 2022 02:57:46 +0000 (20:57 -0600)]
Edit docs introduction for `std::cmp::PartialOrd`
This makes `PartialOrd` consistent with the other three traits in this
module, which all include links to their respective mathematical concepts
on Wikipedia.
bors [Thu, 27 Jan 2022 22:34:34 +0000 (22:34 +0000)]
Auto merge of #93390 - matthiaskrgr:rollup-4xeki5w, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #91641 (Define c_char using cfg_if rather than repeating 40-line cfg)
- #92899 (Mention std::iter::zip in Iterator::zip docs)
- #93193 (Add test for stable hash uniqueness of adjacent field values)
- #93325 (Introduce a limit to Levenshtein distance computation)
- #93339 (rustdoc: add test case for multiple traits and erased names)
- #93357 (Clarify the `usage-of-qualified-ty` error message.)
- #93363 (`#[rustc_pass_by_value]` cleanup)
- #93365 (More arena cleanups)
Matthias Krüger [Thu, 27 Jan 2022 21:32:24 +0000 (22:32 +0100)]
Rollup merge of #93193 - Kobzol:stable-hash-permutation-test, r=the8472
Add test for stable hash uniqueness of adjacent field values
This PR adds a simple test to check that stable hash will produce a different hash if the order of two values that have the same combined bit pattern changes.
Matthias Krüger [Thu, 27 Jan 2022 21:32:23 +0000 (22:32 +0100)]
Rollup merge of #91641 - dtolnay:cchar-if, r=Mark-Simulacrum
Define c_char using cfg_if rather than repeating 40-line cfg
Libstd has a 40-line cfg that defines the targets on which `c_char` is unsigned, and then repeats the same cfg with `not(…)` for the targets on which `c_char` is signed.
This PR replaces it with a `cfg_if!` in which an `else` takes care of the signed case.
I confirmed that `x.py doc library/std` inlines the type alias because c_char_definition is not a publicly accessible path:
It's simply a binary thing to allow different behaviour for `Copy` vs
`!Copy` types. The new code makes this much clearer; I was scratching my
head over the old code for some time.
bors [Thu, 27 Jan 2022 06:21:53 +0000 (06:21 +0000)]
Auto merge of #92889 - tmiasko:unbounded-recursion, r=ecstatic-morse
Ignore unwinding edges when checking for unconditional recursion
The unconditional recursion lint determines if all execution paths
eventually lead to a self-recursive call.
The implementation always follows unwinding edges which limits its
practical utility. For example, it would not lint function `f` because a
call to `g` might unwind. It also wouldn't lint function `h` because an
overflow check preceding the self-recursive call might unwind:
```rust
pub fn f() {
g();
f();
}
pub fn g() { /* ... */ }
pub fn h(a: usize) {
h(a + 1);
}
```
To avoid the issue, assume that terminators that might continue
execution along non-unwinding edges do so.
bors [Wed, 26 Jan 2022 22:54:26 +0000 (22:54 +0000)]
Auto merge of #93352 - matthiaskrgr:rollup-5peret4, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #90247 (Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa)
- #91861 (Replace iterator-based construction of collections by `Into<T>`)
- #92098 (add OpenBSD platform-support page)
- #92134 (Add x86_64-pc-windows-msvc linker-plugin-lto instructions)
- #92256 (Improve selection errors for `~const` trait bounds)
- #92778 (fs: Use readdir() instead of readdir_r() on Linux and Android)
- #93338 (Update minifier crate version to 0.0.42)
I had some trouble getting cross language LTO working for this target, in part because the very few links of documentation I could find were linux-centric and because of a few very specific errors I ran into. I'm not sure if this is the correct place to document this, but this is one of the first links I found when looking for documentation so it might be the best place for it.
Matthias Krüger [Wed, 26 Jan 2022 22:45:20 +0000 (23:45 +0100)]
Rollup merge of #92098 - semarie:openbsd-platform, r=pietroalbini
add OpenBSD platform-support page
It mentions x86_64, i686, aarch64 and sparc64 which are actively maintained and used on OpenBSD (binaries provided by standard package distribution on OpenBSD).
I volontary kept `powerpc-unknown-openbsd` unmentioned as it was added by `@Yn0ga` in #82733, and I am unaware if it is functional or not (I doubt as I added libc support only few days ago, and std `c_char` signess was wrong). `@Yn0ga` maybe you comment on your `powerpc-unknown-openbsd` usage ?
Matthias Krüger [Wed, 26 Jan 2022 22:45:18 +0000 (23:45 +0100)]
Rollup merge of #90247 - newpavlov:duration_float_fract, r=nagisa
Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa
Closes: #90225
The methods now implement direct processing of exponent and mantissa, which should result in the best possible conversion accuracy (modulo truncation, i.e. float value of 19.995 ns will be represented as 19 ns).
Tomasz Miąsko [Fri, 14 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Ignore unwinding edges when checking for unconditional recursion
The unconditional recursion lint determines if all execution paths
eventually lead to a self-recursive call.
The implementation always follows unwinding edges which limits its
practical utility. For example, it would not lint function `f` because a
call to `g` might unwind. It also wouldn't lint function `h` because an
overflow check preceding the self-recursive call might unwind:
```rust
pub fn f() {
g();
f();
}
pub fn g() { /* ... */ }
pub fn h(a: usize) {
h(a + 1);
}
```
To avoid the issue, assume that terminators that might continue
execution along non-unwinding edges do so.
bors [Wed, 26 Jan 2022 12:10:54 +0000 (12:10 +0000)]
Auto merge of #91840 - JakobDegen:fix_early_otherwise, r=oli-obk
Fix the unsoundness in the `early_otherwise_branch` mir opt pass
Closes #78496 .
This change is a significant rewrite of much of the pass. Exactly what it does is documented in the source file (with ascii art!), and all the changes that are made to the MIR that are not trivially sound are carefully documented. That being said, this is my first time touching MIR, so there are probably some invariants I did not know about that I broke.
This version of the optimization is also somewhat more flexible than the original; for example, we do not care how or where the value on which the parent is switching is computed. There is no requirement that any types be the same. This could be made even more flexible in the future by allowing a wider range of statements in the bodies of `BBC, BBD` (as long as they are all the same of course). This should be a good first step though.
Probably needs a perf run.
r? `@oli-obk` who reviewed things the last time this was touched