]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #95085 - ouz-a:master5, r=jackh726
Matthias Krüger [Mon, 21 Mar 2022 18:48:31 +0000 (19:48 +0100)]
Rollup merge of #95085 - ouz-a:master5, r=jackh726

Return err instead of ICE

Having `escaping_bound_vars` results in ICE when trying to create `ty::Binder::dummy`, to avoid it we return err like the line above. I think this requires a more sophisticated fix, I would love to investigate if mentorship is available 🤓

Fixes #95023 and #85350

2 years agoRollup merge of #95074 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesti...
Matthias Krüger [Mon, 21 Mar 2022 18:48:30 +0000 (19:48 +0100)]
Rollup merge of #95074 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesting-in-rustc-passes, r=lcnr

Refactor: use `format-args-capture` and remove unnecessary nested if blocks in some parts of `rust_passes`

2 years agoReturn err instead of ICE
ouz-a [Fri, 18 Mar 2022 19:04:01 +0000 (22:04 +0300)]
Return err instead of ICE

2 years agoAuto merge of #95169 - Smittyvb:union-test-ub, r=bjorn3
bors [Mon, 21 Mar 2022 15:17:08 +0000 (15:17 +0000)]
Auto merge of #95169 - Smittyvb:union-test-ub, r=bjorn3

Don't run UB in test suite

This splits `ui/unsafe/union.rs` to make it so only the non-UB parts are run. It also means we can do more testing of the location of error messages (which are a bit different with the THIR unsafety checker). `union-modification.rs` has no UB (according to Miri), and `union.rs` has errors (but would have UB if not for those errors).

Closes #95075.
r? `@bjorn3`

2 years agouse `format-args-capture` and remove unnecessary nested if blocks in some parts of...
Takayuki Maeda [Fri, 18 Mar 2022 13:48:21 +0000 (22:48 +0900)]
use `format-args-capture` and remove unnecessary nested if blocks in some parts of rustc_passes

break before the `&&`

Update compiler/rustc_passes/src/check_const.rs

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2 years agoDon't run UB in test suite
Smitty [Mon, 21 Mar 2022 13:32:26 +0000 (09:32 -0400)]
Don't run UB in test suite

This splits ui/unsafe/union.rs to make it so only the non-UB parts are
run. It also means we can do more testing of the location of error
messages.

2 years agoAuto merge of #95104 - compiler-errors:remove-ascription, r=davidtwco
bors [Mon, 21 Mar 2022 02:29:55 +0000 (02:29 +0000)]
Auto merge of #95104 - compiler-errors:remove-ascription, r=davidtwco

suggest removing type ascription in bad parsing position

Not sure how to test this with the non-nightly suggestion. Didn't add a new UI test because it already manifests in an existing UI test.

Fixes #95014

2 years agoAuto merge of #95156 - audunhalland:fix-rustc_const_eval_transform-comments, r=Dylan-DPC
bors [Mon, 21 Mar 2022 00:14:29 +0000 (00:14 +0000)]
Auto merge of #95156 - audunhalland:fix-rustc_const_eval_transform-comments, r=Dylan-DPC

fix two comments referring to moved code (now rustc_mir_transform::generator)

This caused me some confusion when trying to find the related code.

2 years agofix two comments referring to moved code (rustc_mir_transform::generator)
Audun Halland [Sun, 20 Mar 2022 22:31:04 +0000 (23:31 +0100)]
fix two comments referring to moved code (rustc_mir_transform::generator)

2 years agoAuto merge of #95148 - matthiaskrgr:rollup-jsb1ld9, r=matthiaskrgr
bors [Sun, 20 Mar 2022 21:36:57 +0000 (21:36 +0000)]
Auto merge of #95148 - matthiaskrgr:rollup-jsb1ld9, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #95114 (Skip a test if symlink creation is not possible)
 - #95131 (Fix docs for default rmeta filename.)
 - #95135 (Fix a not emitted unmatched angle bracket error)
 - #95145 (Fix typo interator->iterator)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #95145 - ChayimFriedman2:patch-1, r=Dylan-DPC
Matthias Krüger [Sun, 20 Mar 2022 19:42:46 +0000 (20:42 +0100)]
Rollup merge of #95145 - ChayimFriedman2:patch-1, r=Dylan-DPC

Fix typo interator->iterator

2 years agoRollup merge of #95135 - TaKO8Ki:fix-not-emitted-unmatched-angle-bracket-error, r...
Matthias Krüger [Sun, 20 Mar 2022 19:42:45 +0000 (20:42 +0100)]
Rollup merge of #95135 - TaKO8Ki:fix-not-emitted-unmatched-angle-bracket-error, r=Dylan-DPC

Fix a not emitted unmatched angle bracket error

closes #95128

2 years agoRollup merge of #95131 - ehuss:fix-metadata-filename, r=bjorn3
Matthias Krüger [Sun, 20 Mar 2022 19:42:44 +0000 (20:42 +0100)]
Rollup merge of #95131 - ehuss:fix-metadata-filename, r=bjorn3

Fix docs for default rmeta filename.

The docs for the default filename for `--emit=metadata` was wrong, it was missing the `lib` prefix.  The current implementation for that default is [here](https://github.com/rust-lang/rust/blob/f2661cfe341f88bea919daf52a07015dceaf7a6a/compiler/rustc_session/src/output.rs#L140).  Perhaps somewhat confusing, but `lib` is used for all crate types.

cc https://github.com/rust-lang/rust/issues/68839#issuecomment-1073118716

2 years agoRollup merge of #95114 - ChrisDenton:symlink-test, r=the8472
Matthias Krüger [Sun, 20 Mar 2022 19:42:43 +0000 (20:42 +0100)]
Rollup merge of #95114 - ChrisDenton:symlink-test, r=the8472

Skip a test if symlink creation is not possible

If someone running tests on Windows does not have Developer Mode enabled then creating symlinks will fail which in turn would cause this test to fail. This can be a stumbling block for contributors.

2 years agoAuto merge of #95144 - RalfJung:miri, r=RalfJung
bors [Sun, 20 Mar 2022 19:10:06 +0000 (19:10 +0000)]
Auto merge of #95144 - RalfJung:miri, r=RalfJung

update Miri

2 years agoFix typo interator->iterator
Chayim Refael Friedman [Sun, 20 Mar 2022 18:52:22 +0000 (20:52 +0200)]
Fix typo interator->iterator

2 years agoupdate Miri
Ralf Jung [Sun, 20 Mar 2022 18:30:40 +0000 (14:30 -0400)]
update Miri

2 years agoAuto merge of #95142 - bjorn3:sync_cg_clif-2022-03-20, r=bjorn3
bors [Sun, 20 Mar 2022 16:29:16 +0000 (16:29 +0000)]
Auto merge of #95142 - bjorn3:sync_cg_clif-2022-03-20, r=bjorn3

Sync rustc_codegen_cranelift

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

2 years agoAdd once_cell as allowed cg_clif dependency
bjorn3 [Sun, 20 Mar 2022 16:01:32 +0000 (17:01 +0100)]
Add once_cell as allowed cg_clif dependency

2 years agoMerge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_clif-2022-03-20
bjorn3 [Sun, 20 Mar 2022 15:55:21 +0000 (16:55 +0100)]
Merge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_clif-2022-03-20

2 years agoAuto merge of #95071 - RalfJung:arbitrary-self-dyn, r=oli-obk
bors [Sun, 20 Mar 2022 13:48:23 +0000 (13:48 +0000)]
Auto merge of #95071 - RalfJung:arbitrary-self-dyn, r=oli-obk

Miri: implement arbitrary-self dyn receivers

Roughly follows the [codegen logic](https://github.com/rust-lang/rust/blob/851fcc7a54262748b1aa9e16de91453998d896f3/compiler/rustc_codegen_ssa/src/mir/block.rs#L809).

Fixes https://github.com/rust-lang/miri/issues/1038
r? `@oli-obk` Cc `@eddyb`

2 years agofix a not emitted unmatched angle bracket error
Takayuki Maeda [Sun, 20 Mar 2022 13:39:15 +0000 (22:39 +0900)]
fix a not emitted unmatched angle bracket error

2 years agoAuto merge of #92962 - frank-king:btree_entry_no_insert, r=Amanieu
bors [Sun, 20 Mar 2022 11:20:26 +0000 (11:20 +0000)]
Auto merge of #92962 - frank-king:btree_entry_no_insert, r=Amanieu

BTreeMap::entry: Avoid allocating if no insertion

This PR allows the `VacantEntry` to borrow from an empty tree with no root, and to lazily allocate a new root node when the user calls `.insert(value)`.

2 years agoRun part of the simd test suite
bjorn3 [Sat, 19 Mar 2022 15:32:07 +0000 (16:32 +0100)]
Run part of the simd test suite

2 years agoIgnore rustc tests with needs-unwind directive
bjorn3 [Sat, 19 Mar 2022 15:11:53 +0000 (16:11 +0100)]
Ignore rustc tests with needs-unwind directive

2 years agoMove test and clarify problem of some other tests
bjorn3 [Sat, 19 Mar 2022 14:48:19 +0000 (15:48 +0100)]
Move test and clarify problem of some other tests

2 years agoWrap write_mir_fn call in with_no_trimmed_paths!()
bjorn3 [Sat, 19 Mar 2022 15:54:51 +0000 (16:54 +0100)]
Wrap write_mir_fn call in with_no_trimmed_paths!()

2 years agoAuto merge of #95133 - matthiaskrgr:rollup-4q0u804, r=matthiaskrgr
bors [Sun, 20 Mar 2022 08:35:40 +0000 (08:35 +0000)]
Auto merge of #95133 - matthiaskrgr:rollup-4q0u804, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #94749 (remove_dir_all: use fallback implementation on Miri)
 - #94948 (Fix diagnostics for `#![feature(deprecated_suggestion)]`)
 - #94989 (Add Stream alias for AsyncIterator)
 - #95108 (Give more details in `Display` for `hir::Target`)
 - #95110 (Provide more useful documentation of conversion methods)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #95110 - wmstack:patch-1, r=Dylan-DPC
Matthias Krüger [Sun, 20 Mar 2022 08:15:01 +0000 (09:15 +0100)]
Rollup merge of #95110 - wmstack:patch-1, r=Dylan-DPC

Provide more useful documentation of conversion methods

I thought that the documentation for these methods needed to be a bit more explanatory for new users. For advanced users, the comments are relatively unnecessary. I think it would be useful to explain precisely what the method does. As a new user, when you see the `into` method, where the type is inferred, if you are new you don't even know what you convert to, because it is implicit. I believe this can help new users understand.

2 years agoRollup merge of #95108 - scottmcm:more-in-target-display, r=Dylan-DPC
Matthias Krüger [Sun, 20 Mar 2022 08:15:00 +0000 (09:15 +0100)]
Rollup merge of #95108 - scottmcm:more-in-target-display, r=Dylan-DPC

Give more details in `Display` for `hir::Target`

Made because I was making a code change and got a very confusing "should be applied to a method, not a method" error.

```
error[E0718]: `into_try_type` language item must be applied to a method
   --> library\core\src\ops\try_trait.rs:352:32
    |
352 |     #[cfg_attr(not(bootstrap), lang = "into_try_type")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a method, not a method
```

With this change the error is more actionable

```
error[E0718]: `into_try_type` language item must be applied to a required trait method
   --> library\core\src\ops\try_trait.rs:352:32
    |
352 |     #[cfg_attr(not(bootstrap), lang = "into_try_type")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a required trait method, not a provided trait method
```

2 years agoRollup merge of #94989 - compiler-errors:stream-alias, r=Dylan-DPC
Matthias Krüger [Sun, 20 Mar 2022 08:15:00 +0000 (09:15 +0100)]
Rollup merge of #94989 - compiler-errors:stream-alias, r=Dylan-DPC

Add Stream alias for AsyncIterator

Fixes #94965

2 years agoRollup merge of #94948 - jhpratt:rustc_deprecated, r=Dylan-DPC
Matthias Krüger [Sun, 20 Mar 2022 08:14:59 +0000 (09:14 +0100)]
Rollup merge of #94948 - jhpratt:rustc_deprecated, r=Dylan-DPC

Fix diagnostics for `#![feature(deprecated_suggestion)]`

Follow up from #94635, where I missed a couple things.

2 years agoRollup merge of #94749 - RalfJung:remove-dir-all-miri, r=cuviper
Matthias Krüger [Sun, 20 Mar 2022 08:14:58 +0000 (09:14 +0100)]
Rollup merge of #94749 - RalfJung:remove-dir-all-miri, r=cuviper

remove_dir_all: use fallback implementation on Miri

Fixes https://github.com/rust-lang/miri/issues/1966

The new implementation requires `openat`, `unlinkat`, and `fdopendir`. These cannot easily be shimmed in Miri since libstd does not expose APIs corresponding to them. So for now it is probably easiest to just use the fallback code in Miri. Nobody should run Miri as root anyway...

2 years agoAuto merge of #95063 - tromey:fix-94458-gdb-char, r=Mark-Simulacrum
bors [Sun, 20 Mar 2022 04:31:23 +0000 (04:31 +0000)]
Auto merge of #95063 - tromey:fix-94458-gdb-char, r=Mark-Simulacrum

Fix debuginfo tests with GDB 11.2

GDB 11.2 added support for DW_ATE_UTF, which caused some test
failures.  This fixes these tests by changing the format that is used,
and adds a new test to verify that characters are emitted as something
that GDB can print in a char-like way.

Fixes #94458

2 years agoFix docs for default rmeta filename.
Eric Huss [Sun, 20 Mar 2022 04:05:31 +0000 (21:05 -0700)]
Fix docs for default rmeta filename.

2 years agoAuto merge of #94976 - jclulow:solaris-festival, r=Mark-Simulacrum
bors [Sun, 20 Mar 2022 01:50:36 +0000 (01:50 +0000)]
Auto merge of #94976 - jclulow:solaris-festival, r=Mark-Simulacrum

solaris build environment should include libsendfile/liblgrp

As of version 0.2.120 of the libc crate, the solaris target now requires
some additional libraries to be present in the sysroot.  Note that the
solaris target doesn't really build against files from Solaris, but
rather against some files from DilOS (a platform similar to both Solaris
and illumos).  Pull in the extra libraries and their compilation links
from that apt repository.

This aims to assist with rust-lang/rust#94052.

2 years agoAuto merge of #94372 - erikdesjardins:asrefinl, r=dtolnay
bors [Sat, 19 Mar 2022 22:32:28 +0000 (22:32 +0000)]
Auto merge of #94372 - erikdesjardins:asrefinl, r=dtolnay

Add #[inline] to trivial AsRef/AsMut impls

These appeared uninlined in some perf runs, but they're trivial.

r? `@ghost`

2 years agoAuto merge of #95103 - ehuss:update-cargo, r=ehuss
bors [Sat, 19 Mar 2022 19:41:10 +0000 (19:41 +0000)]
Auto merge of #95103 - ehuss:update-cargo, r=ehuss

Update cargo

9 commits in 65c82664263feddc5fe2d424be0993c28d46377a..109bfbd055325ef87a6e7f63d67da7e838f8300b
2022-03-09 02:32:56 +0000 to 2022-03-17 21:43:09 +0000
- Refactor RegistryData::load to handle management of the index cache (rust-lang/cargo#10482)
- Separate VCS command paths with "--" (rust-lang/cargo#10483)
- Fix panic when artifact target is used for `[target.'cfg(&lt;target&gt;)'.dependencies` (rust-lang/cargo#10433)
- Bump git2@0.14.2 and libgit2-sys@0.13.2 (rust-lang/cargo#10479)
- vendor: Don't allow multiple values for --sync (rust-lang/cargo#10448)
- Use types to make clere (credential process || token) (rust-lang/cargo#10471)
- Warning on conflicting keys (rust-lang/cargo#10316)
- Registry functions return Poll to enable parallel fetching of index data (rust-lang/cargo#10064)
- Refine the contributor guide (rust-lang/cargo#10468)

2 years agoAuto merge of #95112 - Dylan-DPC:rollup-0jo0loj, r=Dylan-DPC
bors [Sat, 19 Mar 2022 17:00:15 +0000 (17:00 +0000)]
Auto merge of #95112 - Dylan-DPC:rollup-0jo0loj, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #93858 (Add a `process_group` method to UNIX `CommandExt`)
 - #94650 (Relax tests for Windows dos device names)
 - #94991 (Make Weak::new const)
 - #95072 (Re-enable parallel debuginfo tests)
 - #95109 (Extend --check-cfg tests to all predicate inside all/any)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoSkip a test if symlink creation is not possible
Chris Denton [Sat, 19 Mar 2022 14:55:59 +0000 (14:55 +0000)]
Skip a test if symlink creation is not possible

2 years agoRollup merge of #95109 - Urgau:check-cfg-all-any, r=petrochenkov
Dylan DPC [Sat, 19 Mar 2022 13:50:27 +0000 (14:50 +0100)]
Rollup merge of #95109 - Urgau:check-cfg-all-any, r=petrochenkov

Extend --check-cfg tests to all predicate inside all/any

Now that https://github.com/rust-lang/rust/pull/94295 is merged it's time to add more tests to check that all predicate inside `all` and `any` are always checked.

r? `@petrochenkov`

2 years agoRollup merge of #95072 - tromey:parallel-debug-tests, r=tmiasko
Dylan DPC [Sat, 19 Mar 2022 13:50:26 +0000 (14:50 +0100)]
Rollup merge of #95072 - tromey:parallel-debug-tests, r=tmiasko

Re-enable parallel debuginfo tests

Debuginfo tests are serialized due to some older version of LLDB.
However, that comment was last touched in 2014, so presumably these
older versions are long since obsolete.

Partially fixes bug #72719.

2 years agoRollup merge of #94991 - CAD97:const-weak-new, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 13:50:25 +0000 (14:50 +0100)]
Rollup merge of #94991 - CAD97:const-weak-new, r=dtolnay

Make Weak::new const

Simple enough. This is const creation of an allocating container, but no actual allocation is done, because it's defined to.

2 years agoRollup merge of #94650 - ChrisDenton:windows-absolute-fix, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 13:50:24 +0000 (14:50 +0100)]
Rollup merge of #94650 - ChrisDenton:windows-absolute-fix, r=dtolnay

Relax tests for Windows dos device names

Windows 11 no longer turn paths ending with dos device names into device paths.

E.g. `C:\path\to\COM1.txt` used to get turned into `\\.\COM1`. Whereas now this path is left as is.

Note though that if the given path is an exact (case-insensitive) match for the string `COM1` then it'll still be converted to `\\.\COM1`.

2 years agoRollup merge of #93858 - krallin:process-process_group, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 13:50:24 +0000 (14:50 +0100)]
Rollup merge of #93858 - krallin:process-process_group, r=dtolnay

Add a `process_group` method to UNIX `CommandExt`

- Tracking issue: #93857
- RFC: https://github.com/rust-lang/rfcs/pull/3228

Add a `process_group` method to `std::os::unix::process::CommandExt` that
allows setting the process group id (i.e. calling `setpgid`) in the child, thus
enabling users to set process groups while leveraging the `posix_spawn` fast
path.

2 years agoRustup to rustc 1.61.0-nightly (1bfe40d11 2022-03-18)
bjorn3 [Sat, 19 Mar 2022 12:36:25 +0000 (13:36 +0100)]
Rustup to rustc 1.61.0-nightly (1bfe40d11 2022-03-18)

2 years agoSync from rust 31535841701e0bf7ef33998024376f2cedd8b3e3
bjorn3 [Sat, 19 Mar 2022 12:28:22 +0000 (13:28 +0100)]
Sync from rust 31535841701e0bf7ef33998024376f2cedd8b3e3

2 years agoCodegen 128bit atomic loads and stores for compiler builtins as trap
bjorn3 [Sat, 19 Mar 2022 09:44:56 +0000 (10:44 +0100)]
Codegen 128bit atomic loads and stores for compiler builtins as trap

128bit atomics are unstable and only enabled on AArch64 and x86_64 macOS.
Cranelift doesn't support 128bit atomics yet.

2 years agoExtend --check-cfg tests to all predicate inside all/any
Loïc BRANSTETT [Sat, 19 Mar 2022 09:23:09 +0000 (10:23 +0100)]
Extend --check-cfg tests to all predicate inside all/any

2 years agoGive more details in `Display` for `hir::Target`
Scott McMurray [Sat, 19 Mar 2022 09:03:37 +0000 (02:03 -0700)]
Give more details in `Display` for `hir::Target`

Made because I was making a code change and got a very confusing "should be applied to a method, not a method" error.

```
error[E0718]: `into_try_type` language item must be applied to a method
   --> library\core\src\ops\try_trait.rs:352:32
    |
352 |     #[cfg_attr(not(bootstrap), lang = "into_try_type")]
    |                                ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a method, not a method
```

2 years agoProvide more useful documentation of conversion methods
Waleed Dahshan [Sat, 19 Mar 2022 07:52:30 +0000 (18:52 +1100)]
Provide more useful documentation of conversion methods

I thought that the documentation for these methods needed to be a bit more explanatory for new users. For advanced users, the comments are relatively unnecessary. I think it would be useful to explain precisely what the method does. As a new user, when you see the `into` method, where the type is inferred, if you are new you don't even know what you convert to, because it is implicit. I believe this can help new users understand.

2 years agosuggest removing type ascription in bad position
Michael Goulet [Sat, 19 Mar 2022 03:45:15 +0000 (20:45 -0700)]
suggest removing type ascription in bad position

2 years agoUpdate cargo
Eric Huss [Sat, 19 Mar 2022 03:06:56 +0000 (20:06 -0700)]
Update cargo

2 years agoAuto merge of #95101 - Dylan-DPC:rollup-r1f1v9t, r=Dylan-DPC
bors [Sat, 19 Mar 2022 02:16:00 +0000 (02:16 +0000)]
Auto merge of #95101 - Dylan-DPC:rollup-r1f1v9t, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #92519 (Use verbatim paths for `process::Command` if necessary)
 - #92612 (Update stdlib for the l4re target)
 - #92663 (Implement `Write for Cursor<[u8; N]>`, plus `A: Allocator` cursor support)
 - #93263 (Consistently present absent stdio handles on Windows as NULL handles.)
 - #93692 (keyword_docs: document use of `in` with `pub` keyword)
 - #94984 (add `CStr` method that accepts any slice containing a nul-terminated string)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #94984 - ericseppanen:cstr_from_bytes, r=Mark-Simulacrum
Dylan DPC [Sat, 19 Mar 2022 01:02:02 +0000 (02:02 +0100)]
Rollup merge of #94984 - ericseppanen:cstr_from_bytes, r=Mark-Simulacrum

add `CStr` method that accepts any slice containing a nul-terminated string

I haven't created an issue (tracking or otherwise) for this yet; apologies if my approach isn't correct. This is my first code contribution.

This change adds a member fn that converts a slice into a `CStr`; it is intended to be safer than `from_ptr` (which is unsafe and may read out of bounds), and more useful than `from_bytes_with_nul` (which requires that the caller already know where the nul byte is).

The reason I find this useful is for situations like this:
```rust
let mut buffer = [0u8; 32];
unsafe {
    some_c_function(buffer.as_mut_ptr(), buffer.len());
}
let result = CStr::from_bytes_with_nul(&buffer).unwrap();
```

This code above returns an error with `kind = InteriorNul`, because `from_bytes_with_nul` expects that the caller has passed in a slice with the NUL byte at the end of the slice. But if I just got back a nul-terminated string from some FFI function, I probably don't know where the NUL byte is.

I would wish for a `CStr` constructor with the following properties:
- Accept `&[u8]` as input
- Scan for the first NUL byte and return the `CStr` that spans the correct sub-slice (see [future note below](https://github.com/rust-lang/rust/pull/94984#issuecomment-1070754281)).
- Return an error if no NUL byte is found within the input slice

I asked on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/CStr.20from.20.26.5Bu8.5D.20without.20knowing.20the.20NUL.20location.3F) whether this sounded like a good idea, and got a couple of positive-sounding responses from ``@joshtriplett`` and ``@AzureMarker.``

This is my first draft, so feedback is welcome.

A few issues that definitely need feedback:

1. Naming. ``@joshtriplett`` called this `from_bytes_with_internal_nul` on Zulip, but after staring at all of the available methods, I believe that this function is probably what end users want (rather than the existing fn `from_bytes_with_nul`). Giving it a simpler name (**`from_bytes`**) implies that this should be their first choice.
2. Should I add a similar method on `CString` that accepts `Vec<u8>`? I'd assume the answer is probably yes, but I figured I'd try to get early feedback before making this change bigger.
3. What should the error type look like? I made a unit struct since `CStr::from_bytes` can only fail in one obvious way, but if I need to do this for `CString` as well then that one may want to return `FromVecWithNulError`. And maybe that should dictate the shape of the `CStr` error type also?

Also, cc ``@poliorcetics`` who wrote #73139 containing similar fns.

2 years agoRollup merge of #93692 - mfrw:mfrw/document-keyword-in, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 01:02:02 +0000 (02:02 +0100)]
Rollup merge of #93692 - mfrw:mfrw/document-keyword-in, r=dtolnay

keyword_docs: document use of `in` with `pub` keyword

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Fixes: #93609
2 years agoRollup merge of #93263 - sunfishcode:sunfishcode/detatched-console-handle, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 01:02:01 +0000 (02:02 +0100)]
Rollup merge of #93263 - sunfishcode:sunfishcode/detatched-console-handle, r=dtolnay

Consistently present absent stdio handles on Windows as NULL handles.

This addresses #90964 by making the std API consistent about presenting
absent stdio handles on Windows as NULL handles. Stdio handles may be
absent due to `#![windows_subsystem = "windows"]`, due to the console
being detached, or due to a child process having been launched from a
parent where stdio handles are absent.

Specifically, this fixes the case of child processes of parents with absent
stdio, which previously ended up with `stdin().as_raw_handle()` returning
`INVALID_HANDLE_VALUE`, which was surprising, and which overlapped with an
unrelated valid handle value. With this patch, `stdin().as_raw_handle()`
now returns null in these situation, which is consistent with what it
does in the parent process.

And, document this in the "Windows Portability Considerations" sections of
the relevant documentation.

2 years agoRollup merge of #92663 - cuviper:generic-write-cursor, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 01:02:00 +0000 (02:02 +0100)]
Rollup merge of #92663 - cuviper:generic-write-cursor, r=dtolnay

Implement `Write for Cursor<[u8; N]>`, plus `A: Allocator` cursor support

This implements `Write for Cursor<[u8; N]>`, and also adds support for generic `A: Allocator` in `Box` and `Vec` cursors.

This was inspired by a user questioning why they couldn't write a `Cursor<[u8; N]>`:
https://users.rust-lang.org/t/why-vec-and-not-u8-makes-cursor-have-write/68210

Related history:
- #27197 switched `AsRef<[u8]>` for reading and seeking
- #67415 tried to use `AsMut<[u8]>` for writing, but did not specialize `Vec`.

2 years agoRollup merge of #92612 - atopia:update-lib-l4re, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 01:01:59 +0000 (02:01 +0100)]
Rollup merge of #92612 - atopia:update-lib-l4re, r=dtolnay

Update stdlib for the l4re target

This PR contains the work by ``@humenda`` and myself to update standard library support for the x86_64-unknown-l4re-uclibc tier 3 target, split out from  humenda/rust as requested in #85967. The changes have been rebased on current master and updated in follow up commits by myself. The publishing of the changes is authorized and preferred by the original author. To preserve attribution, when standard library changes were introduced as part of other changes to the compiler, I have kept the changes concerning the standard library and altered the commit messages as indicated. Any incompatibilities have been remedied in follow up commits, so that the PR as a whole should result in a clean update of the target.

2 years agoRollup merge of #92519 - ChrisDenton:command-maybe-verbatim, r=dtolnay
Dylan DPC [Sat, 19 Mar 2022 01:01:59 +0000 (02:01 +0100)]
Rollup merge of #92519 - ChrisDenton:command-maybe-verbatim, r=dtolnay

Use verbatim paths for `process::Command` if necessary

In #89174, the standard library started using verbatim paths so longer paths are usable by default. However, `Command` was originally left out because of the way `CreateProcessW` was being called. This was changed as a side effect of #87704 so now `Command` paths can be converted to verbatim too (if necessary).

2 years agoMake Weak::new const
CAD97 [Wed, 16 Mar 2022 04:58:18 +0000 (23:58 -0500)]
Make Weak::new const

2 years agoadd CStr::from_bytes_until_nul
Eric Seppanen [Tue, 15 Mar 2022 23:47:26 +0000 (16:47 -0700)]
add CStr::from_bytes_until_nul

This adds a member fn that converts a slice into a CStr; it is intended
to be safer than from_ptr (which is unsafe and may read out of bounds),
and more useful than from_bytes_with_nul (which requires that the caller
already know where the nul byte is).

feature gate: cstr_from_bytes_until_nul

Also add an error type FromBytesUntilNulError for this fn.

2 years agoAuto merge of #95090 - matthiaskrgr:rollup-pho6x6s, r=matthiaskrgr
bors [Fri, 18 Mar 2022 22:10:55 +0000 (22:10 +0000)]
Auto merge of #95090 - matthiaskrgr:rollup-pho6x6s, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #94115 (Let `try_collect` take advantage of `try_fold` overrides)
 - #94295 (Always evaluate all cfg predicate in all() and any())
 - #94848 (Compare installed browser-ui-test version to the one used in CI)
 - #94993 (Add test for >65535 hashes in lexing raw string)
 - #95017 (Derive Eq for std::cmp::Ordering, instead of using manual impl.)
 - #95058 (Add use of bool::then in sys/unix/process)
 - #95083 (Document that `Option<extern "abi" fn>` discriminant elision applies for any ABI)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoBump impl Write for Cursor<[u8; N]> to 1.61
David Tolnay [Fri, 18 Mar 2022 22:04:37 +0000 (15:04 -0700)]
Bump impl Write for Cursor<[u8; N]> to 1.61

2 years agoRollup merge of #95083 - danielhenrymantilla:patch-2, r=RalfJung
Matthias Krüger [Fri, 18 Mar 2022 20:50:50 +0000 (21:50 +0100)]
Rollup merge of #95083 - danielhenrymantilla:patch-2, r=RalfJung

Document that `Option<extern "abi" fn>` discriminant elision applies for any ABI

The current phrasing was not very clear on that aspect.

r? `@RalfJung`

`@rustbot` modify labels: A-docs A-ffi

2 years agoRollup merge of #95058 - wcampbell0x2a:use-then-in-unix-process, r=dtolnay
Matthias Krüger [Fri, 18 Mar 2022 20:50:49 +0000 (21:50 +0100)]
Rollup merge of #95058 - wcampbell0x2a:use-then-in-unix-process, r=dtolnay

Add use of bool::then in sys/unix/process

Remove `else { None }` in favor of using `bool::then()`

2 years agoRollup merge of #95017 - zachs18:cmp_ordering_derive_eq, r=Dylan-DPC
Matthias Krüger [Fri, 18 Mar 2022 20:50:48 +0000 (21:50 +0100)]
Rollup merge of #95017 - zachs18:cmp_ordering_derive_eq, r=Dylan-DPC

Derive Eq for std::cmp::Ordering, instead of using manual impl.

This allows consts of type Ordering to be used in patterns, and with feature(adt_const_params) allows using `Ordering` as a const generic parameter.

Currently, `std::cmp::Ordering` implements `Eq` using a manually written `impl Eq for Ordering {}`, instead of `derive(Eq)`. This means that it does not implement `StructuralEq`.

This commit removes the manually written impl, and adds `derive(Eq)` to `Ordering`, so that it will implement `StructuralEq`.

2 years agoRollup merge of #94993 - GrishaVar:too-many-hashes-test, r=Dylan-DPC
Matthias Krüger [Fri, 18 Mar 2022 20:50:48 +0000 (21:50 +0100)]
Rollup merge of #94993 - GrishaVar:too-many-hashes-test, r=Dylan-DPC

Add test for >65535 hashes in lexing raw string

2 years agoRollup merge of #94848 - GuillaumeGomez:browser-ui-test-version, r=Mark-Simulacrum
Matthias Krüger [Fri, 18 Mar 2022 20:50:47 +0000 (21:50 +0100)]
Rollup merge of #94848 - GuillaumeGomez:browser-ui-test-version, r=Mark-Simulacrum

Compare installed browser-ui-test version to the one used in CI

I happened a few times to run into (local) rustdoc GUI tests errors because I forgot to update my browser-ui-test version. I know at least two others who encountered the same problem so I think emitting a warning to let us know about this version mismatch would make it easier to figure out.

So now, I'm not too sure that this PR is the right approach because it requires to parse a Dockerfile, which feels pretty bad. I had the idea to instead store the browser-ui-test version into a docker ARG like:

```docker
ARG BROWSER_UI_TEST_VERSION=0.8.0
```

And then use it as such in the command to make the parsing more reliable.

Or we could store this version into a file and import this file into the Dockerfile and read it from the builder.

Any preference or maybe another solution?

r? ``@Mark-Simulacrum``

2 years agoRollup merge of #94295 - Urgau:cfg-always-eval-all-predicate, r=petrochenkov
Matthias Krüger [Fri, 18 Mar 2022 20:50:46 +0000 (21:50 +0100)]
Rollup merge of #94295 - Urgau:cfg-always-eval-all-predicate, r=petrochenkov

Always evaluate all cfg predicate in all() and any()

This pull-request adjust the handling of the `all()` and `any()` to always evaluate every cfg predicate because not doing so result in accepting incorrect `cfg`:

```rust
#[cfg(any(unix, foo::bar))] // Should error on foo::bar, but does not on unix platform (but does on non unix platform)
fn foo1() {}

#[cfg(all(foo, foo::bar))] // Should error on foo::bar, but does not
fn foo2() {}

#[cfg(all(foo::bar, foo))] // Correctly error on foo::bar
fn foo3() {}

#[cfg(any(foo::bar, foo))] // Correctly error on foo::bar
fn foo4() {}
```
This pull-request take the side to directly turn it into a hard error instead of having a future incompatibility lint because the combination to get this incorrect behavior is unusual and highly probable that some code have this without noticing.

A [search](https://cs.github.com/?scopeName=All+repos&scope=&q=lang%3Arust+%2Fany%5C%28%5Ba-zA-Z%5D%2C+%5Ba-zA-Z%5D%2B%3A%3A%5Ba-zA-Z%5D%2B%2F) on Github reveal no such instance nevertheless a Crater run should probably be done before merging this.

This was discover in https://github.com/rust-lang/rust/pull/94175 when trying to lint on the second predicate. Also note that this seems to have being introduce with Rust 1.27.0: https://rust.godbolt.org/z/KnfqKv15f.

r? `@petrochenkov`

2 years agoRollup merge of #94115 - scottmcm:iter-process-by-ref, r=yaahc
Matthias Krüger [Fri, 18 Mar 2022 20:50:44 +0000 (21:50 +0100)]
Rollup merge of #94115 - scottmcm:iter-process-by-ref, r=yaahc

Let `try_collect` take advantage of `try_fold` overrides

No public API changes.

With this change, `try_collect` (#94047) is no longer going through the `impl Iterator for &mut impl Iterator`, and thus will be able to use `try_fold` overrides instead of being forced through `next` for every element.

Here's the test added, to see that it fails before this PR (once a new enough nightly is out): https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=462f2896f2fed2c238ee63ca1a7e7c56

This might as well go to the same person as my last `try_process` PR  (#93572), so
r? ``@yaahc``

2 years agoEnable rand based libcore tests
bjorn3 [Fri, 18 Mar 2022 20:19:37 +0000 (21:19 +0100)]
Enable rand based libcore tests

Part of #806

2 years agoCleanup rand test disable patch
bjorn3 [Fri, 18 Mar 2022 19:59:51 +0000 (20:59 +0100)]
Cleanup rand test disable patch

2 years agoRemove no longer necessary rand patch
bjorn3 [Fri, 18 Mar 2022 19:51:53 +0000 (20:51 +0100)]
Remove no longer necessary rand patch

2 years agoMerge pull request #1221 from bjorn3/run_more_rustc_tests
bjorn3 [Fri, 18 Mar 2022 18:32:45 +0000 (19:32 +0100)]
Merge pull request #1221 from bjorn3/run_more_rustc_tests

Run more rustc tests

2 years agoDocument that `Option<extern "abi" fn>` discriminant elision applies for any ABI
Daniel Henry-Mantilla [Fri, 18 Mar 2022 17:14:34 +0000 (18:14 +0100)]
Document that `Option<extern "abi" fn>` discriminant elision applies for any ABI

The current phrasing was not very clear on that aspect.

2 years agoReorganize test list
bjorn3 [Fri, 18 Mar 2022 15:38:28 +0000 (16:38 +0100)]
Reorganize test list

2 years agoAuto merge of #95068 - TaKO8Ki:use-create-snapshot-for-diagnostic, r=davidtwco
bors [Fri, 18 Mar 2022 14:50:29 +0000 (14:50 +0000)]
Auto merge of #95068 - TaKO8Ki:use-create-snapshot-for-diagnostic, r=davidtwco

Use `Parser.create_snapshot_for_diagnostic` instead of `Parser.clone()`

Use [`create_snapshot_for_diagnostic`](https://github.com/rust-lang/rust/blob/cd119057160cedea245aa2679add56723f3dc784/compiler/rustc_parse/src/parser/diagnostics.rs#L214-L223) I implemented in https://github.com/rust-lang/rust/pull/94731 instead of `self.clone()` to avoid duplicate unclosed delims errors being emitted when the `Parser` is dropped.

2 years agoRun tests with warnings
bjorn3 [Fri, 18 Mar 2022 14:38:58 +0000 (15:38 +0100)]
Run tests with warnings

2 years agoRe-enable fixed tests
bjorn3 [Thu, 17 Mar 2022 20:16:26 +0000 (21:16 +0100)]
Re-enable fixed tests

2 years agoRe-enable parallel debuginfo tests
Tom Tromey [Fri, 18 Mar 2022 03:22:35 +0000 (21:22 -0600)]
Re-enable parallel debuginfo tests

Debuginfo tests are serialized due to some older version of LLDB.
However, that comment was last touched in 2014, so presumably these
older versions are long since obsolete.

Partially fixes bug #72719.

2 years agoMiri: implement arbitrary-self dyn receivers
Ralf Jung [Fri, 18 Mar 2022 12:48:34 +0000 (08:48 -0400)]
Miri: implement arbitrary-self dyn receivers

2 years agoAuto merge of #95067 - nnethercote:parse_tt-more-refactoring, r=petrochenkov
bors [Fri, 18 Mar 2022 12:34:05 +0000 (12:34 +0000)]
Auto merge of #95067 - nnethercote:parse_tt-more-refactoring, r=petrochenkov

Still more refactoring of `parse_tt`

r? `@petrochenkov`

2 years agoRun rustdoc GUI tests when browser-ui-test version is updated
Guillaume Gomez [Fri, 18 Mar 2022 09:50:53 +0000 (10:50 +0100)]
Run rustdoc GUI tests when browser-ui-test version is updated

2 years agoCompare installed browser-ui-test version to the one used in CI
Guillaume Gomez [Fri, 11 Mar 2022 14:29:11 +0000 (15:29 +0100)]
Compare installed browser-ui-test version to the one used in CI

2 years agouse `self.create_snapshot_for_diagnostic` instead of `self.clone()`
Takayuki Maeda [Fri, 18 Mar 2022 07:56:43 +0000 (16:56 +0900)]
use `self.create_snapshot_for_diagnostic` instead of `self.clone()`

2 years agoRename `TtSeq` as `TtSlice`.
Nicholas Nethercote [Fri, 18 Mar 2022 06:39:13 +0000 (17:39 +1100)]
Rename `TtSeq` as `TtSlice`.

It's a better name because (a) it holds a slice, and (b) "sequence" has
other meanings in this file.

2 years agoTweak a bunch of comments.
Nicholas Nethercote [Fri, 18 Mar 2022 06:13:41 +0000 (17:13 +1100)]
Tweak a bunch of comments.

I've been staring at these enough lately that they're annoying me, let's
make them better.

2 years agoAuto merge of #95065 - matthiaskrgr:rollup-75i6oz5, r=matthiaskrgr
bors [Fri, 18 Mar 2022 05:26:14 +0000 (05:26 +0000)]
Auto merge of #95065 - matthiaskrgr:rollup-75i6oz5, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #95013 (Update browser-ui-test version to 0.8.2)
 - #95039 (Make negative coherence work when there's impl negative on super predicates)
 - #95047 (Refactor: remove an unnecessary pattern for ignoring all parts)
 - #95048 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #95048 - RalfJung:miri, r=RalfJung
Matthias Krüger [Fri, 18 Mar 2022 04:21:57 +0000 (05:21 +0100)]
Rollup merge of #95048 - RalfJung:miri, r=RalfJung

update Miri

Let's get those SIMD intrinsics out there. :)
r? `@ghost`

2 years agoRollup merge of #95047 - TaKO8Ki:remove-unnecessary-pattern-for-ignoring-all-parts...
Matthias Krüger [Fri, 18 Mar 2022 04:21:56 +0000 (05:21 +0100)]
Rollup merge of #95047 - TaKO8Ki:remove-unnecessary-pattern-for-ignoring-all-parts, r=wesleywiser

Refactor: remove an unnecessary pattern for ignoring all parts

2 years agoRollup merge of #95039 - spastorino:overlap-super-predicates, r=nikomatsakis
Matthias Krüger [Fri, 18 Mar 2022 04:21:55 +0000 (05:21 +0100)]
Rollup merge of #95039 - spastorino:overlap-super-predicates, r=nikomatsakis

Make negative coherence work when there's impl negative on super predicates

r? `@nikomatsakis`

2 years agoRollup merge of #95013 - GuillaumeGomez:browser-ui-test-v, r=notriddle
Matthias Krüger [Fri, 18 Mar 2022 04:21:54 +0000 (05:21 +0100)]
Rollup merge of #95013 - GuillaumeGomez:browser-ui-test-v, r=notriddle

Update browser-ui-test version to 0.8.2

It brings mostly debugging improvements: it doesn't stop at the first failing command but rather at the first "fatal error".

r? `@notriddle`

2 years agoReorder cases in `parse_tt_inner`.
Nicholas Nethercote [Fri, 18 Mar 2022 03:16:45 +0000 (14:16 +1100)]
Reorder cases in `parse_tt_inner`.

I find the new order easier to read: within a matcher; past the end of a
repetition; at end of input. It also reduces the indentation level by
one for

2 years agoOnly modify `eof_items` if `token == Eof`.
Nicholas Nethercote [Fri, 18 Mar 2022 03:11:01 +0000 (14:11 +1100)]
Only modify `eof_items` if `token == Eof`.

Because that's the condition under which `eof_items` is used.

2 years agoFactor out some code into `MatcherPos::repetition`.
Nicholas Nethercote [Fri, 18 Mar 2022 03:09:02 +0000 (14:09 +1100)]
Factor out some code into `MatcherPos::repetition`.

Also move `create_matches` within `impl MatcherPos`, because it's only
used within that impl block.

2 years agoAuto merge of #88098 - Amanieu:oom_panic, r=nagisa
bors [Fri, 18 Mar 2022 03:01:46 +0000 (03:01 +0000)]
Auto merge of #88098 - Amanieu:oom_panic, r=nagisa

Implement -Z oom=panic

This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue #43596).

Perf and binary size tests show negligible impact.

2 years agoAuto merge of #88098 - Amanieu:oom_panic, r=nagisa
bors [Fri, 18 Mar 2022 03:01:46 +0000 (03:01 +0000)]
Auto merge of #88098 - Amanieu:oom_panic, r=nagisa

Implement -Z oom=panic

This PR removes the `#[rustc_allocator_nounwind]` attribute on `alloc_error_handler` which allows it to unwind with a panic instead of always aborting. This is then used to implement `-Z oom=panic` as per RFC 2116 (tracking issue #43596).

Perf and binary size tests show negligible impact.

2 years agoAdd two useful assertions.
Nicholas Nethercote [Fri, 18 Mar 2022 01:51:01 +0000 (12:51 +1100)]
Add two useful assertions.

2 years agoFix debuginfo tests with GDB 11.2
Tom Tromey [Fri, 18 Mar 2022 02:19:10 +0000 (20:19 -0600)]
Fix debuginfo tests with GDB 11.2

GDB 11.2 added support for DW_ATE_UTF, which caused some test
failures.  This fixes these tests by changing the format that is used,
and adds a new test to verify that characters are emitted as something
that GDB can print in a char-like way.

Fixes #94458