Commit Graph

14145 Commits

Author SHA1 Message Date
bors
cdb683f6e4 Auto merge of #122024 - clubby789:remove-spec-option-pe, r=jhpratt
Remove SpecOptionPartialEq

With the recent LLVM bump, the specialization for Option::partial_eq on types with niches is no longer necessary. I kept the manual implementation as it still gives us better codegen than the derive (will look at this seperately).

Also implemented PartialOrd/Ord by hand as it _somewhat_ improves codegen for #49892: https://godbolt.org/z/vx5Y6oW4Y
2024-03-22 04:06:25 +00:00
Matthias Krüger
1757cb5871
Rollup merge of #122829 - ShoyuVanilla:gen-block-impl-fused-iter, r=compiler-errors
Implement `FusedIterator` for `gen` block

cc #117078
2024-03-22 01:07:31 +01:00
Matthias Krüger
fa99ebc7cf
Rollup merge of #122817 - ultrabear:ultrabear_btreedoc, r=Nilstrieb
Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order

This Doc-only PR adds text to the IntoIterator implementation and IntoIter type for both BTreeMap and BTreeSet that states that the returned items will be in sorted-by-key order, this is a guarantee that is made by the iter() and iter_mut() methods of BTreeMap/Set and BTreeMap respectively, but not on into_iter methods or types.

I don't know how the IntoIter iteration would not be sorted by key, and I would like to rely on that behavior for my prefix_array crate.

The text appended to IntoIter documentation is based on each types respective iter() method documentation, as is the text used in the IntoIterator documentation; they are slightly inconsistent between Set/Map, but they are consistent within their own types documentation.
2024-03-22 01:07:30 +01:00
Matthias Krüger
f0feebb270
Rollup merge of #121881 - devnexen:bsd_acceptfilter, r=Amanieu
std::net: adding acceptfilter feature for netbsd/freebsd.

similar to linux's ext deferaccept, to filter incoming connections before accept.
2024-03-22 01:07:30 +01:00
bors
0ad927c0c0 Auto merge of #122785 - the8472:const-select-specialized-impl, r=Amanieu
select Vec::from_iter impls in a const block to optimize compile times

Ignoring whitespace diffs should make this easier to review.

This relies on the trick from #122301
Split out from #120682
2024-03-21 21:19:19 +00:00
Shoyu Vanilla
ae4c5c891e Implement FusedIterator for gen block 2024-03-22 02:02:34 +09:00
Michael Goulet
2d633317f3 Implement macro-based deref!() syntax for deref patterns
Stop using `box PAT` syntax for deref patterns, as it's misleading and
also causes their semantics being tangled up.
2024-03-21 11:42:49 -04:00
Matthias Krüger
62e414d3af
Rollup merge of #122806 - compiler-errors:type-ascribe, r=fmease
Make `type_ascribe!` not a built-in

The only weird thing is the macro expansion note. I wonder if we should suppress these 🤔

r? ````@fmease```` since you told me about builtin# lol
2024-03-21 12:05:09 +01:00
ultrabear
beb0c22c09
document into_iter in top level docs iterator ordering guarantees 2024-03-21 02:07:46 -07:00
ultrabear
f8a093c8ea
document iteration ordering on into_iter method instead of IntoIterator implementation 2024-03-21 02:05:11 -07:00
ultrabear
f6f89dc202
BTree(Set|Map): Guarantee that IntoIter will iterate in sorted by key order 2024-03-21 00:54:50 -07:00
Michael Goulet
a015b90953 Make type_ascribe! not a built-in 2024-03-20 22:28:56 -04:00
Jacob Pratt
7a5ffccded
Rollup merge of #122765 - workingjubilee:test-for-vec-handling-usize-max, r=Nilstrieb
Add `usize::MAX` arg tests for Vec

Tests to prevent recurrence of the UB from the rust-lang/rust#122760 issue.

I skipped the `with_capacity`, `drain`, `reserve`, etc. APIs because they actually had a good assortment of tests earlier in the same file.

r? Nilstrieb
2024-03-20 20:29:46 -04:00
Jacob Pratt
43ad753adb
Rollup merge of #122729 - m-ou-se:relax, r=Amanieu
Relax SeqCst ordering in standard library.

Every single SeqCst in the standard library is unnecessary. In all cases, Relaxed or Release+Acquire was sufficient.

As I [wrote](https://marabos.nl/atomics/memory-ordering.html#common-misconceptions) in my book on atomics:

> [..] when reading code, SeqCst basically tells the reader: "this operation depends on the total order of every single SeqCst operation in the program," which is an incredibly far-reaching claim. The same code would likely be easier to review and verify if it used weaker memory ordering instead, if possible. For example, Release effectively tells the reader: "this relates to an acquire operation on the same variable," which involves far fewer considerations when forming an understanding of the code.
>
> It is advisable to see SeqCst as a warning sign. Seeing it in the wild often means that either something complicated is going on, or simply that the author did not take the time to analyze their memory ordering related assumptions, both of which are reasons for extra scrutiny.

r? ````@Amanieu```` ````@joboet````
2024-03-20 20:29:44 -04:00
bors
1388d7a069 Auto merge of #122761 - jwong101:fix/vec-insert, r=workingjubilee,Nilstrieb
fix OOB pointer formed in Vec::index

Move the length check to before using `index` with `ptr::add` to prevent an out of bounds pointer from being formed.

Fixes #122760
2024-03-20 21:37:30 +00:00
The 8472
3ff1e448e7 select Vec::from_iter impls in a const block to optimize compile times 2024-03-20 19:26:38 +01:00
David Carlier
19cb05fd78 std::net: adding acceptfilter feature for netbsd/freebsd.
similar to linux's ext deferaccept, to filter incoming connections
before accept.
2024-03-20 18:15:31 +00:00
Mara Bos
34621757ea SeqCst->Relaxed in condvar test.
Relaxed is enough here. Synchronization is done by the mutex.
2024-03-20 15:38:09 +01:00
Mara Bos
acddc55748 SeqCst->Relaxed in thread local test.
Relaxed memory ordering is fine because spawn()/join() already provides
all the synchronization we need.
2024-03-20 15:38:09 +01:00
Mara Bos
b45a725cbc SeqCst->Relaxed in std::net::test.
Relaxed is enough to have fetch_add(1) return each value only once
(until it wraps around).
2024-03-20 15:35:13 +01:00
Mara Bos
8b519f98e2 Use less restricted memory ordering in xous::thread_local_key.
SeqCst isn't necessary in any of these cases.
2024-03-20 15:35:11 +01:00
bors
a128516cf9 Auto merge of #122754 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68
Bump to 1.78 bootstrap compiler

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-03-20 13:43:41 +00:00
Mark Rousskov
02f1930595 step cfgs 2024-03-20 08:49:13 -04:00
bors
c86f3ac24f Auto merge of #120717 - compiler-errors:cap-closure-kind, r=oli-obk
For async closures, cap closure kind, get rid of `by_mut_body`

Right now we have three `AsyncFn*` traits, and three corresponding futures that are returned by the `call_*` functions for them. This is fine, but it is a bit excessive, since the future returned by `AsyncFn` and `AsyncFnMut` are identical. Really, the only distinction we need to make with these bodies is "by ref" and "by move".

This PR removes `AsyncFn::CallFuture` and renames `AsyncFnMut::CallMutFuture` to `AsyncFnMut::CallRefFuture`. This simplifies MIR building for async closures, since we don't need to build an extra "by mut" body, but just a "by move" body which is materially different.

We need to do a bit of delicate handling of the ClosureKind for async closures, since we need to "cap" it to `AsyncFnMut` in some cases when we only care about what body we're looking for.

This also fixes a bug where `<{async closure} as Fn>::call` was returning a body that takes the async-closure receiver *by move*.

This also helps align the `AsyncFn` traits to the `LendingFn` traits' eventual designs.
2024-03-20 11:40:45 +00:00
Jubilee Young
92f668c20b Add usize::MAX arg tests for Vec 2024-03-20 01:21:19 -07:00
Matthias Krüger
d7209bf858
Rollup merge of #122739 - Sky9x:insert-put, r=jhpratt
Add "put" as a confusable for insert on hash map/set

Already a confusable on btree map/set.

Java's `Map` calls the insert method `put`: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html#put(K,V)
2024-03-20 05:51:24 +01:00
Matthias Krüger
2cf93ac9c8
Rollup merge of #122730 - ferrocene:hoverbear/qnx-ucred-cfgs, r=Amanieu
Expose `ucred::peer_cred` on QNX targets to enable dist builds

After following https://doc.rust-lang.org/rustc/platform-support/nto-qnx.html I attempted to run the following `x.py` command:

```bash
export build_env='
    CC_aarch64-unknown-nto-qnx710=qcc
    CFLAGS_aarch64-unknown-nto-qnx710=-Vgcc_ntoaarch64le_cxx
    CXX_aarch64-unknown-nto-qnx710=qcc
    AR_aarch64_unknown_nto_qnx710=ntoaarch64-ar
    CC_x86_64-pc-nto-qnx710=qcc
    CFLAGS_x86_64-pc-nto-qnx710=-Vgcc_ntox86_64_cxx
    CXX_x86_64-pc-nto-qnx710=qcc
    AR_x86_64_pc_nto_qnx710=ntox86_64-ar'
env $build_env ./x.py --stage 2 dist rust-std  --target aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710,x86_64-unknown-linux-gnu
```

The result was the following error:

```
   Compiling object v0.32.2
   Compiling std_detect v0.1.5 (/home/ana/git/rust-lang/rust/library/stdarch/crates/std_detect)
   Compiling addr2line v0.21.0
error: function `peer_cred` is never used
  --> library/std/src/os/unix/net/ucred.rs:89:12
   |
89 |     pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
   |            ^^^^^^^^^
   |
   = note: `-D dead-code` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(dead_code)]`

error: could not compile `std` (lib) due to 1 previous error
Build completed unsuccessfully in 0:06:25
```

I contacted `@flba-eb` and `@gh-tr` over email and we confirmed that `peer_cred` here should be flagged on `nto` targets. This should enable the clean `x.py --stage 2 dist rust-std` command on these platforms.
2024-03-20 05:51:23 +01:00
Matthias Krüger
4f3050b85a
Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obk
various clippy fixes

We need to keep the order of the given clippy lint rules before passing them.
Since clap doesn't offer any useful interface for this purpose out of the box,
we have to handle it manually.

Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well.

Fixes #121481
cc `@matthiaskrgr`
2024-03-20 05:51:22 +01:00
Joshua Wong
37718f949f fix OOB pointer formed in Vec::index
Move the length check to before using `index` with `ptr::add` to prevent
an out of bounds pointer from being formed.

Fixes #122760
2024-03-19 22:47:35 -05:00
Mark Rousskov
4fb89c5056 branch 1.78: replace-version-placeholder 2024-03-19 19:27:24 -04:00
onur-ozkan
81d7d7aabd resolve clippy errors
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-20 00:12:00 +03:00
Michael Goulet
05116c5c30 Only split by-ref/by-move futures for async closures 2024-03-19 16:59:23 -04:00
Sky
49dd50f880
Add "put" as a confusable for insert on hash map/set 2024-03-19 14:28:01 -04:00
Matthias Krüger
f7731243d9
Rollup merge of #122720 - heisen-li:offset_of, r=workingjubilee
[doc]:fix error code example

fixs #122716
2024-03-19 18:03:53 +01:00
clubby789
f8fd23a2ad Manually implement PartialOrd/Ord for Option 2024-03-19 16:32:07 +00:00
clubby789
5f254d8b66 Remove SpecOptionPartialEq 2024-03-19 16:32:01 +00:00
Ana Hobden
d82d4196ac
Expose ucred::peer_cred on QNX targets to enable dist builds 2024-03-19 07:34:27 -07:00
Mara Bos
5a594f7bcd SeqCst->Relaxed for xous set_nonblocking.
The SeqCst wasn't synchronizing with anything. Relaxed is enough.
2024-03-19 15:27:11 +01:00
Mara Bos
69a4d77d67 SeqCst->{Release,Acquire} for xous DropLock.
SeqCst is unnecessary. Release+Acquire is the right ordering for a
mutex.
2024-03-19 15:27:11 +01:00
Mara Bos
60ad49005a SeqCst->Relaxed in pal::windows::pipe.
Relaxed is enough to ensure fetch_add(1) returns each integer exactly
once.
2024-03-19 15:27:11 +01:00
Mara Bos
46bb073423 SeqCst->{Release,Acquire} for wasm DropLock.
SeqCst is unnecessary. Release+Acquire is the right ordering for a
mutex.
2024-03-19 15:27:11 +01:00
Mara Bos
e43aef0ef9 SeqCst->{Release,Acquire} in sys_common::thread_local_key.
SeqCst is unnecessary here.
2024-03-19 15:27:11 +01:00
Mara Bos
516684c22e Use less restricted memory ordering in thread_parking::pthread.
SeqCst is unnecessary here.
2024-03-19 15:27:11 +01:00
Mara Bos
eb966983f2 SeqCst->{Release,Acquire} in xous mutex.
No need for SeqCst. Release+Acquire is the right memory ordering for a
mutex.
2024-03-19 15:27:11 +01:00
Mara Bos
9f25a04498 SeqCst->Relaxed for FIRST_PANIC.
Relaxed is enough to make sure this `swap` results in `true` only once.
2024-03-19 15:27:11 +01:00
Mara Bos
904fef0e24 SeqCst->{Release,Acquire} for alloc error hook.
SeqCst is unnecessary.
2024-03-19 15:27:11 +01:00
Mara Bos
bf3debe9d7 SeqCst->Relaxed for proc_macro bridge counter.
Relaxed is enough here.
2024-03-19 15:27:11 +01:00
Mara Bos
5e4cc6f694 SeqCst->Relaxed in panic_unwind/emcc.
SeqCst is unnecessary here.
2024-03-19 15:27:11 +01:00
Mara Bos
a2c74b8445 SeqCst->Relaxed in doc examples.
SeqCst is unnecessary here.
2024-03-19 15:27:11 +01:00
heisen-li
a370ed7644 [doc]:fix error code example 2024-03-19 17:18:10 +08:00