Commit Graph

9669 Commits

Author SHA1 Message Date
Guillaume Gomez
ed38562d76
Rollup merge of #104139 - ferrocene:pa-channel-licensing, r=pnkfelix
Clarify licensing situation of MPSC and SPSC queue

Originally, these two files were licensed under the `BSD-2-Clause` license, as they were based off sample code on a blog licensing those snippets under that license:

* `library/std/src/sync/mpsc/mpsc_queue.rs`
* `library/std/src/sync/mpsc/spsc_queue.rs`

In 2017 though, the author of that blog agreed to relicense their code under the standard `MIT OR Apache-2.0` license in https://github.com/rust-lang/rust/pull/42149. This PR clarifies the situation in the files by expanding the comment at the top of the file.

r? ``@pnkfelix``
2022-11-08 20:40:53 +01:00
Guillaume Gomez
02db37a18a
Rollup merge of #104113 - ink-feather-org:fix_const_fn_ref_impls, r=compiler-errors
Fix `const_fn_trait_ref_impl`, add test for it

#99943 broke `#[feature(const_fn_trait_ref_impl)]`, this PR fixes this and adds a test for it.

r? ````@fee1-dead````
2022-11-08 20:40:51 +01:00
Guillaume Gomez
c39cf7acaa
Rollup merge of #104109 - yancyribbens:add-mutable-to-comment-for-align-to-mut, r=thomcc
rustdoc: Add mutable to the description

`mutable` is missing from the description.  Currently the description for [align_to](https://github.com/rust-lang/rust/blob/master/library/core/src/slice/mod.rs#L3498) is the same as [align_to_mut](https://github.com/rust-lang/rust/blob/master/library/core/src/slice/mod.rs#L3559)
2022-11-08 20:40:51 +01:00
Guillaume Gomez
53b6a894ca
Rollup merge of #104097 - RalfJung:miri-alloc-benches, r=thomcc
run alloc benchmarks in Miri and fix UB

Miri since recently has a "fake monotonic clock" that works even with isolation. Its measurements are not very meaningful but it means we can run these benches and check them for UB.

And that's a good thing since there was UB here: fixes https://github.com/rust-lang/rust/issues/104096.

r? ``@thomcc``
2022-11-08 20:40:50 +01:00
Guillaume Gomez
afaba1997d
Rollup merge of #104093 - RalfJung:test-sizes, r=thomcc
disable btree size tests on Miri

Seems fine not to run these in Miri, they can't have UB anyway. And this lets us do layout randomization in Miri.

r? ``@thomcc``
2022-11-08 20:40:49 +01:00
Pietro Albini
807a7bfcee
clarify licensing situation of mpsc and spsc queue 2022-11-08 09:36:08 +01:00
Dylan DPC
b695ed3f20
Rollup merge of #103446 - the8472:tra-array-chunks, r=Mark-Simulacrum
Specialize `iter::ArrayChunks::fold` for TrustedRandomAccess iterators

```
OLD:
test iter::bench_trusted_random_access_chunks                      ... bench:         368 ns/iter (+/- 4)
NEW:
test iter::bench_trusted_random_access_chunks                      ... bench:          30 ns/iter (+/- 0)
```

The resulting assembly is similar to #103166 but the specialization kicks in under different (partially overlapping) conditions compared to that PR. They're complementary.

In principle a TRA-based specialization could be applied to all `ArrayChunks` methods, including `next()` as we do for `Zip` but that would have all the same hazards as the Zip specialization. Only doing it for `fold` is far less hazardous. The downside is that it only helps with internal, exhaustive iteration. I.e. `for _ in` or `try_fold` will not benefit.

Note that the regular, `try_fold`-based and the specialized `fold()` impl have observably slightly different behavior. Namely the specialized variant does not fetch the remainder elements from the underlying iterator. We do have a few other places in the standard library where beyond-the-end-of-iteration side-effects are being elided under some circumstances but not others.

Inspired by https://old.reddit.com/r/rust/comments/yaft60/zerocost_iterator_abstractionsnot_so_zerocost/
2022-11-08 11:23:50 +05:30
The 8472
3925fc0c8e document and improve array Guard type
The type is unsafe and now exposed to the whole crate.
Document it properly and add an unsafe method so the
caller can make it visible that something unsafe is happening.
2022-11-08 00:13:26 +01:00
The 8472
43c353fff7 simplification: do not process the ArrayChunks remainder in fold() 2022-11-07 21:44:25 +01:00
The 8472
cfcce8e684 specialize iter::ArrayChunks::fold for TrustedRandomAccess iters
This is fairly safe use of TRA since it consumes the iterator so
no struct in an unsafe state will be left exposed to user code
2022-11-07 21:44:25 +01:00
The 8472
eb3f001d37 make the array initialization guard available to other modules 2022-11-07 21:44:25 +01:00
The 8472
b00666ed09 add benchmark for iter::ArrayChunks::fold specialization
This also updates the existing iter::Copied::next_chunk benchmark so
that the thing it benches doesn't get masked by the ArrayChunks specialization
2022-11-07 21:44:24 +01:00
bors
73c9eaf214 Auto merge of #103934 - notriddle:notriddle/backtrace-deps, r=Mark-Simulacrum
std: sync "Dependencies of the `backtrace` crate" with `backtrace`

Compare:

07872f28cd/Cargo.toml (L43)

160b194295/library/std/Cargo.toml (L26)
2022-11-07 20:05:09 +00:00
onestacked
0c9896bfaa Fix const_fn_trait_ref_impl, add test for it 2022-11-07 17:41:58 +01:00
yancy
d62582f92a rustdoc: Add mutable to the description 2022-11-07 16:51:23 +01:00
Ralf Jung
29d451ccb3 fmt 2022-11-07 15:24:49 +01:00
Dylan DPC
81b8db2675
Rollup merge of #104090 - wanghaha-dev:master, r=Dylan-DPC
Modify comment syntax error

Modify comment syntax error
2022-11-07 18:35:26 +05:30
Ralf Jung
780952f922 run alloc benchmarks in Miri and fix UB 2022-11-07 10:34:04 +01:00
Ralf Jung
17044c1d00 disable btree size tests on Miri 2022-11-07 09:29:14 +01:00
wanghaha-dev
009f80b987 Modify comment syntax error 2022-11-07 14:33:33 +08:00
Yuki Okushi
7ca833efe0
Rollup merge of #104074 - yancyribbens:add-example-to-round, r=Mark-Simulacrum
rustdoc: Add an example for round that is different from truncate

The current examples for [round](https://github.com/rust-lang/rust/blob/master/library/std/src/f64.rs#L75) would have the same results as the example for [truncate](https://github.com/rust-lang/rust/blob/master/library/std/src/f64.rs#L95).  This PR adds one more example to `round` that will have a different result from `truncate`.
2022-11-07 09:46:29 +09:00
Yuki Okushi
57daec5989
Rollup merge of #104056 - ripytide:patch-1, r=Mark-Simulacrum
Vec: IntoIterator signature consistency

Also makes the code dryer.
2022-11-07 09:46:26 +09:00
yancy
a398e09e42 rustdoc: Add an example for round that is different from truncate 2022-11-06 23:05:16 +01:00
bors
7eef946fc0 Auto merge of #99943 - compiler-errors:tuple-trait, r=jackh726
Implement `std::marker::Tuple`, use it in `extern "rust-call"` and `Fn`-family traits

Implements rust-lang/compiler-team#537

I made a few opinionated decisions in this implementation, specifically:
1. Enforcing `extern "rust-call"` on fn items during wfcheck,
2. Enforcing this for all functions (not just ones that have bodies),
3. Gating this `Tuple` marker trait behind its own feature, instead of grouping it into (e.g.) `unboxed_closures`.

Still needing to be done:
1. Enforce that `extern "rust-call"` `fn`-ptrs are well-formed only if they have 1/2 args and the second one implements `Tuple`. (Doing this would fix ICE in #66696.)
2. Deny all explicit/user `impl`s of the `Tuple` trait, kinda like `Sized`.
3. Fixing `Tuple` trait built-in impl for chalk, so that chalkification tests are un-broken.

Open questions:
1. Does this need t-lang or t-libs signoff?

Fixes #99820
2022-11-06 17:48:33 +00:00
ripytide
743726e352
Vec: IntoIterator signature consistency
Also makes the code dryer.
2022-11-06 15:25:00 +00:00
Matthias Krüger
d93b5200d5
Rollup merge of #104002 - RalfJung:unsafecell-new, r=JohnTitor
fix a comment in UnsafeCell::new

There are several safe methods that access the inner value: `into_inner` has existed since forever and `get_mut` also exists since recently. So this comment seems just wrong. But `&self` methods return raw pointers and thus require unsafe code (though the methods themselves are still safe).
2022-11-06 08:35:27 +01:00
Michael Goulet
d9891563d3 Merge conflicts and rebase onto master 2022-11-05 18:05:44 +00:00
Michael Goulet
2786acce98 Enforce Tuple trait on Fn traits 2022-11-05 17:34:47 +00:00
Ralf Jung
dad327090a fix a comment in UnsafeCell::new 2022-11-05 12:27:43 +01:00
Dylan DPC
47e6304e32
Rollup merge of #103995 - SUPERCILEX:typos, r=Dylan-DPC
Small round of typo fixes
2022-11-05 11:31:30 +05:30
Alex Saveau
849d89b031
Small round of typo fixes
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-04 20:06:18 -07:00
Matthias Krüger
c38ee06b62
Rollup merge of #103681 - RalfJung:libtest-thread, r=thomcc
libtest: run all tests in their own thread, if supported by the host

This reverts the threading changes of https://github.com/rust-lang/rust/pull/56243, which made it so that with `-j1`, the test harness does not spawn any threads. Those changes were done to enable Miri to run the test harness, but Miri supports threads nowadays, so this is no longer needed. Using a thread for each test is useful because the thread's name can be set to the test's name which makes panic messages consistent between `-j1` and `-j2` runs and also a bit more readable.

I did not revert the HashMap changes of https://github.com/rust-lang/rust/pull/56243; using a deterministic map seems fine for the test harness and the more deterministic testing is the better.

Fixes https://github.com/rust-lang/rust/issues/59122
Fixes https://github.com/rust-lang/rust/issues/70492
2022-11-04 18:52:26 +01:00
Matthias Krüger
dabb6c6bd7
Rollup merge of #103367 - chbaker0:update-std-getrandom, r=thomcc
Remove std's transitive dependency on cfg-if 0.1

After https://github.com/rust-lang/rust/pull/101946 this completes the move to cfg-if 1.0 by:
* Updating getrandom 0.1.14->0.1.16
* Updating panic_abort's and unwind's dep to cfg-if 1.0

Fixes https://github.com/rust-lang/rust/issues/103365
2022-11-04 18:52:25 +01:00
Matthias Krüger
9398676635
Rollup merge of #103941 - douweschulte:patch-1, r=jyn514
Fixed typos

Fixed a typo that has been found on two locations in comments.
2022-11-04 12:18:02 +01:00
Matthias Krüger
428dd011ca
Rollup merge of #103680 - RalfJung:cstr-links, r=JohnTitor
CStr: add some doc links
2022-11-04 12:18:00 +01:00
Douwe Schulte
f65cb6868d
Fixed typos
Fixed a typo that has been found on two locations in comments.
2022-11-03 21:19:02 +00:00
Michael Howell
cf83a1d81b std: sync "Dependencies of the backtrace crate" with backtrace
Compare:

07872f28cd/Cargo.toml (L43)

160b194295/library/std/Cargo.toml (L26)
2022-11-03 10:10:15 -07:00
Collin Baker
dfab01b6e0 Remove std's transitive dependency on cfg-if 0.1
After rust-lang/rust#101946 this completes the move to cfg-if 1.0 by:
* Updating getrandom 0.1.14->0.1.16
* Updating panic_abort, panic_unwind, and unwind to cfg-if 1.0
2022-11-02 18:01:20 -04:00
Dylan DPC
68db106366
Rollup merge of #103807 - H4x5:string-extend-from-within-tracking-issue, r=Dylan-DPC
Add tracking issue for `string_extend_from_within`

Tracking issue: #103806

The original PR didn't create a tracking issue.
2022-11-02 22:32:04 +05:30
Dylan DPC
bbd3a10663
Rollup merge of #103774 - compiler-errors:dyn-trait-in-type-name, r=eholk
Format `dyn Trait` better in `type_name` intrinsic

Noticed this in #103764 (though not related to that PR at all!)

```rust
trait Foo {
    type Bar;
}

fn main() {
    println!(
        "`dyn Fn(i32, i32) -> i32` => `{}`",
        std::any::type_name::<dyn Fn(i32, i32) -> i32>()
    );
    println!(
        "`dyn Foo<Bar = i32> + Send + Sync` => `{}`",
        std::any::type_name::<dyn Foo<Bar = i32> + Send + Sync>()
    );
}
```

```
`dyn Fn(i32, i32) -> i32` => `dyn core::ops::function::Fn<(i32, i32)>+Output = i32`
`dyn Foo<Bar = i32> + Send + Sync` => `dyn playground::Foo+Bar = i32+core::marker::Sync+core::marker::Send`
```

Just reuse `pretty_print_dyn_existential` which already makes an attempt to make its output stable.
2022-11-02 22:32:03 +05:30
Manish Goregaokar
65d63caf8d
Rollup merge of #103637 - ChrisDenton:stdio-uwp, r=thomcc
Use stdio in UWP apps

Fixes #103233

This has been supported since Windows 10.0.16299. See https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-console-l1-1-0dll
2022-11-01 20:00:38 -04:00
Manish Goregaokar
d4bd794f5e
Rollup merge of #103084 - inquisitivecrystal:control-flow, r=scottmcm
Derive `Eq` and `Hash` for `ControlFlow`

There's really no reason for `ControlFlow` not to derive these traits. This is the part of #96416 that no one objected to, but that PR seems stale. The `Eq` derive was also [requested](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60ControlFlow.3A.20Eq.60/near/303610659) by `@lcnr` on Zulip to allow for pattern matching.

This change requires an FCP because it's insta-stable.

Closes #96416.
2022-11-01 20:00:37 -04:00
Michael Goulet
e24df2778f Format dyn Trait better in type_name intrinsic 2022-11-01 20:41:47 +00:00
Dylan DPC
5d30bfc431
Rollup merge of #103809 - tyggja:patch-1, r=JohnTitor
Fix a typo in std::net mod doc comment

net-doc syntax
2022-11-01 14:12:27 +05:30
Dylan DPC
20528baac4
Rollup merge of #103729 - RalfJung:align-of-val-packed, r=oli-obk
interpret: fix align_of_val on packed types

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

r? `@oli-obk`
2022-11-01 14:12:26 +05:30
Dylan DPC
43634675f6
Rollup merge of #103061 - Amanieu:rewrite_alloc_error_handler, r=bjorn3
Rewrite implementation of `#[alloc_error_handler]`

The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called.

This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-11-01 14:12:25 +05:30
bors
95a3a7277b Auto merge of #103795 - thomcc:untest, r=Mark-Simulacrum
Include both benchmarks and tests in the numbers given to `TeFiltered{,Out}`

Fixes #103794

`#[bench]` is broken on nightly without this, sadly. It apparently has no test coverage. In addition to manually testing, I've added a run-make smokecheck for this (which would have caught the issue), but it would be nice to have a better way to test, err, libtest. For now we should get this in ASAP IMO
2022-10-31 18:50:06 +00:00
Amanieu d'Antras
56074b5231 Rewrite implementation of #[alloc_error_handler]
The new implementation doesn't use weak lang items and instead changes
`#[alloc_error_handler]` to an attribute macro just like
`#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by
the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom`
function is defined in any crate then the compiler shim will call
`__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with
`default_alloc_error_handler`: `__rg_oom` was previously defined in the
alloc crate and would attempt to reference the `oom` lang item, even if
it didn't exist. This worked as long as `__rg_oom` was excluded from
linking since it was not called.

This is a prerequisite for the stabilization of
`default_alloc_error_handler` (#102318).
2022-10-31 16:32:57 +00:00
tyggja
7fe1622b71
Update mod.rs 2022-10-31 12:17:30 -04:00
Sky
3e23d60a32
Add tracking issue for string_extend_from_within 2022-10-31 12:01:20 -04:00