bors [Sun, 30 Jan 2022 18:12:08 +0000 (18:12 +0000)]
Auto merge of #93482 - ehuss:rollup-qjyppci, r=ehuss
Rollup of 5 pull requests
Successful merges:
- #92887 (Bootstrap compiler update)
- #92908 (Render more readable macro matcher tokens in rustdoc)
- #93183 (rustdoc: mobile nav fixes)
- #93192 (Add VS 2022 into error message)
- #93475 (Add test to ensure that theme is applied correctly when going back in history)
Eric Huss [Sun, 30 Jan 2022 16:37:47 +0000 (08:37 -0800)]
Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomez
Render more readable macro matcher tokens in rustdoc
Follow-up to #92334.
This PR lifts some of the token rendering logic from https://github.com/dtolnay/prettyplease into rustdoc so that even the matchers for which a source code snippet is not available (because they are macro-generated, or any other reason) follow some baseline good assumptions about where the tokens in the macro matcher are appropriate to space.
The below screenshots show an example of the difference using one of the gnarliest macros I could find. Some things to notice:
- In the **before**, notice how a couple places break in between `$(....)`↵`*`, which is just about the worst possible place that it could break.
- In the **before**, the lines that wrapped are weirdly indented by 1 space of indentation relative to column 0. In the **after**, we use the typical way of block indenting in Rust syntax which is put the open/close delimiters on their own line and indent their contents by 4 spaces relative to the previous line (so 8 spaces relative to column 0, because the matcher itself is indented by 4 relative to the `macro_rules` header).
- In the **after**, macro_rules metavariables like `$tokens:tt` are kept together, which is how just about everybody writing Rust today writes them.
bors [Sun, 30 Jan 2022 10:30:42 +0000 (10:30 +0000)]
Auto merge of #93468 - matthiaskrgr:rollup-vxullvd, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #93256 (Make `join!` description more accurate)
- #93358 (Add note suggesting that predicate may be satisfied, but is not `const`)
- #93362 (Do not register infer var for GAT projection in RPIT)
- #93391 (rustdoc: remove tooltip from source link)
- #93414 (Move unstable is_{arch}_feature_detected! macros to std::arch)
- #93441 (rustdoc: load the set of in-scope traits for modules with no docstring)
- #93459 (fs: Don't copy d_name from struct dirent)
- #93463 (Rename _args -> args in format_args expansion)
Matthias Krüger [Sat, 29 Jan 2022 23:04:17 +0000 (00:04 +0100)]
Rollup merge of #93463 - dtolnay:_args, r=cjgillot
Rename _args -> args in format_args expansion
As observed in https://github.com/rust-lang/rust/pull/91359#discussion_r786058960, prior to that PR this variable was sometimes never used, such as in the case of:
```rust
println!("");
// used to expand to:
::std::io::_print(
::core::fmt::Arguments::new_v1(
&["\n"],
&match () {
_args => [],
},
),
);
```
so the leading underscore in `_args` was used to suppress an unused variable lint. However after #91359 the variable is always used when present, as the unused case would instead expand to:
Matthias Krüger [Sat, 29 Jan 2022 23:04:16 +0000 (00:04 +0100)]
Rollup merge of #93459 - tavianator:dirent-copy-only-reclen, r=cuviper
fs: Don't copy d_name from struct dirent
The dirent returned from readdir() is only guaranteed to be valid for
d_reclen bytes on common platforms. Since we copy the name separately
anyway, we can copy everything except d_name into DirEntry::entry.
Matthias Krüger [Sat, 29 Jan 2022 23:04:15 +0000 (00:04 +0100)]
Rollup merge of #93441 - notriddle:notriddle/collect-crate-doc-links-very-early, r=petrochenkov
rustdoc: load the set of in-scope traits for modules with no docstring
Fixes #93428
This fix is a response to a couple of special cases related to the `module_id`, which is eventually used for trait candidates:
* The module id is always set to the current crate, when checking `crate::`.
Normally, the set of in-scope traits would be set in `load_links_in_attrs`, but if there are no doc comments, then that loop will never run.
* the module id is set to the parent module, when resolving a module that is spelled like this:
// Notice how we use an outlined doc comment here!
// [`Test::my_fn`]
mod something {
}
As with the above problem with `crate::`, we need to make sure the module gets its traits in scope resolved, even if it has no doc comments of its own.
Matthias Krüger [Sat, 29 Jan 2022 23:04:11 +0000 (00:04 +0100)]
Rollup merge of #93358 - compiler-errors:is-not-const, r=fee1-dead
Add note suggesting that predicate may be satisfied, but is not `const`
Not sure if we should be printing this in addition to, or perhaps _instead_ of the help message:
```
help: the trait `~const Add` is not implemented for `NonConstAdd`
```
Also added `ParamEnv::is_const` and `PolyTraitPredicate::is_const_if_const` and, in a separate commit, used those in other places instead of `== hir::Constness::Const`, etc.
Tavian Barnes [Sat, 29 Jan 2022 16:23:28 +0000 (11:23 -0500)]
fs: Don't copy d_name from struct dirent
The dirent returned from readdir() is only guaranteed to be valid for
d_reclen bytes on common platforms. Since we copy the name separately
anyway, we can copy everything except d_name into DirEntry::entry.
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.
Michael Howell [Fri, 28 Jan 2022 19:12:17 +0000 (12:12 -0700)]
rustdoc: load the set of in-scope traits for modules with no docstring
Fixes #93428
This fix is a response to a couple of special cases related to the
`module_id`, which is eventually used for trait candidates:
* The module id is always set to the current crate, when checking `crate::`.
Normally, the set of in-scope traits would be set in `load_links_in_attrs`,
but if there are no doc comments, then that loop will never run.
* the module id is set to the parent module, when resolving a module
that is spelled like this:
// Notice how we use an outlined doc comment here!
// [`Test::my_fn`]
mod something {
}
As with the above problem with `crate::`, we need to make sure the
module gets its traits in scope resolved, even if it has no doc comments
of its own.
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.