Commit Graph

13017 Commits

Author SHA1 Message Date
bors f688dd684f Auto merge of #119569 - matthiaskrgr:rollup-4packja, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #118521 (Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag)
 - #119026 (std::net::bind using -1 for openbsd which in turn sets it to somaxconn.)
 - #119195 (Make named_asm_labels lint not trigger on unicode and trigger on format args)
 - #119204 (macro_rules: Less hacky heuristic for using `tt` metavariable spans)
 - #119362 (Make `derive(Trait)` suggestion more accurate)
 - #119397 (Recover parentheses in range patterns)
 - #119417 (Uplift some miscellaneous coroutine-specific machinery into `check_closure`)
 - #119539 (Fix typos)
 - #119540 (Don't synthesize host effect args inside trait object types)
 - #119555 (Add codegen test for RVO on MaybeUninit)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-04 21:44:14 +00:00
Matthias Krüger e306cfb115
Rollup merge of #119532 - GKFX:offset-of-parse-expr, r=est31
Make offset_of field parsing use metavariable which handles any spacing

As discussed at and around comments https://github.com/rust-lang/rust/issues/106655#issuecomment-1793485081 and https://github.com/rust-lang/rust/issues/106655#issuecomment-1793774183, the current arguments to offset_of do not accept all the whitespace combinations: `0. 1.1.1` and `0.1.1. 1` are currently treated specially in `tests/ui/offset-of/offset-of-tuple-nested.rs`.

They also do not allow [forwarding individual fields as in](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=444cdf0ec02b99e8fd5fd8d8ecb312ca)
```rust
macro_rules! off {
    ($a:expr) => {
        offset_of!(m::S, 0. $a)
    }
}
```

This PR replaces the macro arguments with `($Container:ty, $($fields:expr)+ $(,)?)` which does allow any arrangement of whitespace that I could come up with and the forwarding of fields example above.

This also allows for array indexing in the future, which I think is the last future extension to the syntax suggested in the offset_of RFC.

Tracking issue for offset_of: #106655
``@rustbot`` label F-offset_of

``@est31``
2024-01-04 15:34:00 +01:00
Matthias Krüger 99a8c339f0
Rollup merge of #119475 - saethlin:remove-libtest-dylib, r=cuviper
Remove libtest's dylib

libtest.so is only used by rustdoc, and tests seem to pass locally with this change. I suppose if this is broken, the only way to find out is to make a PR.
2024-01-04 15:34:00 +01:00
Matthias Krüger a919d97aaa
Rollup merge of #119325 - RalfJung:custom-mir, r=compiler-errors
custom mir: make it clear what the return block is

Custom MIR recently got support for specifying the "unwind action", so now there's two things coming after the actual call part of `Call` terminators. That's not very self-explaining so I propose we change the syntax to imitate keyword arguments:
```
Call(popped = Vec::pop(v), ReturnTo(drop), UnwindContinue())
```

Also fix some outdated docs and add some docs to `Call` and `Drop`.
2024-01-04 15:33:58 +01:00
Matthias Krüger d134a4fe60
Rollup merge of #119026 - devnexen:listener_upd, r=Mark-Simulacrum
std::net::bind using -1 for openbsd which in turn sets it to somaxconn.

trusting platform's SOMAXCONN instead of hardcoding to 128 otherwise.
2024-01-04 08:33:22 +01:00
León Orell Valerian Liehr a79fccc288
Rollup merge of #119534 - tgross35:thread-local-example-updates, r=JohnTitor
Update `thread_local` examples to use `local_key_cell_methods`

`local_key_cell_methods` has been stable for a while and provides a much less clunky way to interface with thread-local

Additionaly add context to the documentation about why types with interior mutability are needed.

r? libs
2024-01-03 16:08:33 +01:00
León Orell Valerian Liehr 34ef194859
Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-Simulacrum
rc: Take *const T in is_dangling

It is not important which one is used since `is_dangling` does not access memory, but `*const` removes the needs of `*const T` -> `*mut T` casts in `from_raw_in`.
2024-01-03 16:08:25 +01:00
León Orell Valerian Liehr 4e265d9fe0
Rollup merge of #119319 - chfogelman:buffered-file-doc, r=the8472
Document that File does not buffer reads/writes

...and refer to `BufReader`/`BufWriter`.

This is a common source of efficiency issues in Rust programs written naively. Including this information with the `File` docs, and adding a link to the wrapper types, will help discoverability.
2024-01-03 16:08:25 +01:00
Trevor Gross 6f49080fa8 Update `thread_local` examples to use `local_key_cell_methods`
`local_key_cell_methods` has been stable for a while and provides a much less
clunky way to interface with thread-local variables.

Additionaly add context to the documentation about why types with interior
mutability are needed.
2024-01-02 22:24:26 -06:00
George Bateman 09bb07e38f
Make offset_of field parsing use metavariable which handles any spacing 2024-01-02 22:18:35 +00:00
Carter Hunt Fogelman 5cbe41ae9e Document that File does not buffer reads/writes, refer to BufReader/BufWriter 2023-12-31 16:33:46 -08:00
Ben Kimock c0fa85e9e1 Remove libtest's dylib 2023-12-31 11:18:25 -05:00
bors a2541e861e Auto merge of #119436 - semarie:openbsd-available_parallelism, r=Mark-Simulacrum
openbsd: available_parallelism: use the right API

use the standard `sysconf(_SC_NPROCESSORS_ONLN)` way to get the number of  available processors (capable of running processes), and fallback to `sysctl([CTL_HW, HW_NCPU])` (number of CPUs configured) only on error.

it permits to differenciate CPUs online (capable of running processes) vs CPUs configured (not necessary  capable of running processes).

while here, use the common code path for BSDs for doing that, and avoid code  duplication.

Problem initially reported to me by Jiri Navratil.
2023-12-30 15:37:26 +00:00
Matthias Krüger 19580d56c2
Rollup merge of #119424 - ojeda:send-sync, r=est31
Primitive docs: fix confusing `Send` in `&T`'s list

The two lists in this document describe what traits are implemented on references when their underlying `T` also implements them. However, while it is true that `T: Send + Sync` implies `&T: Send` (which is what the sentence is trying to explain), it is confusing to have `Send` in the list because `T: Send` is not needed for that. In particular, the "also require" part may be interpreted as "both `T: Send` and `T: Sync` are required".

Instead, move `Send` back to where it was before commit 7a477869b7 ("Makes docs for references a little less confusing"), i.e. to the `&mut` list (where no extra nota is needed, i.e. it fits naturally) and move the `Sync` definition/note to the bottom as something independent.
2023-12-30 11:42:04 +01:00
Matthias Krüger b594dfa456
Rollup merge of #119386 - Emilgardis:typo-ipaddr-canonical-doc, r=est31
fix typo in `IpAddr::to_canonical`
2023-12-30 11:42:03 +01:00
Matthias Krüger c67ab2e0b4
Rollup merge of #119158 - JohnTheCoolingFan:arc-weak-clone-pretty, r=cuviper
Clean up alloc::sync::Weak Clone implementation

Since both return points (tail and early return) return the same expression and the only difference is whether inner is available, the code that does the atomic operations and checks on inner was moved into the if body and the only return is at the tail. Original comments preserved.
2023-12-30 11:42:02 +01:00
Sebastien Marie 3633f8ba1c openbsd: available_parallelism: use the right API
use the standard sysconf(_SC_NPROCESSORS_ONLN) way to get the number of 
available processors (capable of running processes), and fallback to 
sysctl([CTL_HW, HW_NCPU]) (number of CPUs configured) only on error.

it permits to differenciate CPUs online vs CPUs configured (and not necessary 
capable of running processes).

while here, use the common code path for BSDs for doing that, and avoid code 
duplication.

Problem initially reported to me by Jiri Navratil.
2023-12-30 09:34:02 +00:00
Taiki Endo 2c23c06c32 rc: Take *const T in is_dangling
It is not important which one is used since `is_dangling` does not access
memory, but `*const` removes the needs of `*const T` -> `*mut T` casts
in `from_raw_in`.
2023-12-30 16:28:00 +09:00
Miguel Ojeda dd928c8f75 Primitive docs: fix confusing `Send` in `&T`'s list
The two lists in this document describe what traits are implemented on
references when their underlying `T` also implements them. However,
while it is true that `T: Send + Sync` implies `&T: Send` (which is
what the sentence is trying to explain), it is confusing to have `Send`
in the list because `T: Send` is not needed for that. In particular,
the "also require" part may be interpreted as "both `T: Send` and
`T: Sync` are required".

Instead, move `Send` back to where it was before commit 7a477869b7
("Makes docs for references a little less confusing"), i.e. to the `&mut`
list (where no extra nota is needed, i.e. it fits naturally) and move the
`Sync` definition/note to the bottom as something independent.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-12-29 22:26:23 +01:00
Gurinder Singh e3aca01343 Italicise "bytes" in the docs of some `Vec` methods
because on a cursory read it's easy to miss that the limit is
in terms of bytes not no. of elements. The italics should help
with that.
2023-12-29 09:53:29 +05:30
Emil Gardström 12dd5d1d0d
fix typo 2023-12-28 19:05:13 +01:00
Ralf Jung 4bf2794e59 custom mir: better type-checking 2023-12-26 20:15:35 +01:00
Ralf Jung 0f9baa8a31 custom mir: make it clear what the return block is 2023-12-26 20:15:26 +01:00
Michael Goulet 50e380c8f3
Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb
Add missing feature gate for sanitizer CFI cfgs

Found during the review of https://github.com/rust-lang/rust/pull/118494 in https://github.com/rust-lang/rust/pull/118494#discussion_r1416079288.

cc `@rcvalle`
2023-12-26 13:29:13 -05:00
bors e1fadb2c35 Auto merge of #119133 - scottmcm:assert-unchecked, r=thomcc
Add `hint::assert_unchecked`

Libs-API expressed interest, modulo bikeshedding, in https://github.com/rust-lang/libs-team/issues/315#issuecomment-1863159430

I think that means this is good for nightly, since we can always rename it before stabilization.

Tracking issue: https://github.com/rust-lang/rust/issues/119131
2023-12-26 15:31:44 +00:00
bors a815c3b69c Auto merge of #119313 - matthiaskrgr:rollup-41x48j6, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #119287 (Fix doc typo for read_exact_at)
 - #119294 (fix `./configure --set change-id`)
 - #119303 (Update sysinfo)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-26 08:22:57 +00:00
AlexBuz 3896f0bb9b
Fix doc typo for read_exact_at 2023-12-24 19:28:03 -06:00
lch361 c082c1c4c3 Documented unsafe blocks 2023-12-25 01:59:37 +03:00
lch361 b15e13760a Removed redundant bounds checking at Split's next and next_mut methods 2023-12-25 01:34:07 +03:00
Linus Färnstrand 98899b7131 Stabilize ip_in_core feature 2023-12-24 12:23:50 +01:00
David Carlier ce5af1c9bc std::net::bind using -1 for openbsd which in turn sets it to somaxconn.
trusting platform's SOMAXCONN instead of hardcoding to 128 otherwise.
2023-12-24 10:56:22 +00:00
Matthias Krüger 89c3236789
Rollup merge of #119205 - mumbleskates:vecdeque-comment-fix, r=Mark-Simulacrum
fix minor mistake in comments describing VecDeque resizing

Avoiding confusion where one of the items in the deque seems to disappear in two of the three cases
2023-12-24 01:08:09 +01:00
Matthias Krüger b136919ca6
Rollup merge of #119153 - rursprung:stabilize-file_create_new, r=dtolnay
stabilize `file_create_new`

closes #105135
2023-12-23 20:02:28 +01:00
Michael Goulet eef023c806
Rollup merge of #119222 - eholk:into-async-iterator, r=compiler-errors,dtolnay
Add `IntoAsyncIterator`

This introduces the `IntoAsyncIterator` trait and uses it in the desugaring of the unstable `for await` loop syntax. This is mostly added for symmetry with `Iterator` and `IntoIterator`.

r? `@compiler-errors`

cc `@rust-lang/libs-api,` `@rust-lang/wg-async`
2023-12-22 21:41:04 -05:00
bors 495203bf61 Auto merge of #119211 - rust-lang:pa-master-1.77, r=Mark-Simulacrum
Bump stage0 to 1.76 beta

r? `@Mark-Simulacrum`
2023-12-23 00:26:47 +00:00
Urgau c88b021782 Adjust the std library for sanitizer_cfi cfgs changes 2023-12-23 01:01:09 +01:00
Eric Holk acb6f17adf
Use `IntoAsyncIterator` in `for await` loop desugaring 2023-12-22 11:01:06 -08:00
Eric Holk 8e34391d6a
Add IntoAsyncIterator 2023-12-22 11:01:05 -08:00
bors 208dd2032b Auto merge of #118847 - eholk:for-await, r=compiler-errors
Add support for `for await` loops

This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library.

Given a loop like:
```rust
for await i in iter {
    ...
}
```
this is desugared to something like:
```rust
let mut iter = iter.into_async_iter();
while let Some(i) = loop {
    match core::pin::Pin::new(&mut iter).poll_next(cx) {
        Poll::Ready(i) => break i,
        Poll::Pending => yield,
    }
} {
    ...
}
```

This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this.

I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue.

r? `@compiler-errors`
2023-12-22 14:17:10 +00:00
Pietro Albini f9f5840eb4
update cfg(bootstrap)s 2023-12-22 11:14:11 +01:00
Pietro Albini c00486c9bb
update version placeholders 2023-12-22 11:01:42 +01:00
Kent Ross f2e711e4c2 fix minor mistake in comments describing VecDeque resizing 2023-12-21 15:20:14 -08:00
bors 5ac4c8a63e Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcm
do not allow ABI mismatches inside repr(C) types

In https://github.com/rust-lang/rust/pull/115476 we allowed ABI mismatches inside `repr(C)` types. This wasn't really discussed much; I added it because from how I understand calling conventions, this should actually be safe in practice. However I entirely forgot to actually allow this in Miri, and in the mean time I have learned that too much ABI compatibility can be a problem for CFI (it can reject fewer calls so that gives an attacker more room to play with).

So I propose we take back that part about ABI compatibility in `repr(C)`. It is anyway something that C and C++ do not allow, as far as I understand.

In the future we might want to introduce a class of ABI compatibilities where we say "this is a bug and it may lead to aborting the process, but it won't lead to arbitrary misbehavior -- worst case it'll just transmute the arguments from the caller type to the callee type". That would give CFI leeway to reject such calls without introducing the risk of arbitrary UB. (The UB can still happen if the transmute leads to bad results, of course, but it wouldn't be due to ABI weirdness.)

#115476 hasn't reached beta yet so if we land this before Dec 22nd we can just pretend this all never happened. ;)  Otherwise we should do a beta backport (of the docs change at least).

Cc `@rust-lang/opsem` `@rust-lang/types`
2023-12-20 18:04:40 +00:00
JohnTheCoolingFan 0453d5fe6f
Cleaned up alloc::sync::Weak Clone implementation
Since both return points (tail and early return) return the same
expression and the only difference is whether inner is available, the
code that does the atomic operations and checks on inner was moved into
the if body and the only return is at the tail. Original comments
preserved.
2023-12-20 12:13:34 +03:00
Ralph Ursprung 62d53211b0
stabilize `file_create_new`
closes #105135
2023-12-20 08:45:46 +01:00
bors 51c0db6a91 Auto merge of #106790 - the8472:rawvec-niche, r=scottmcm
add more niches to rawvec

Previously RawVec only had a single niche in its `NonNull` pointer. With this change it now has `isize::MAX` niches since half the value-space of the capacity field is never needed, we can't have a capacity larger than isize::MAX.
2023-12-20 02:19:10 +00:00
Scott McMurray 7556d6f61b Add `hint::assert_unchecked` 2023-12-19 13:56:50 -08:00
Eric Holk 97df0d3657
Desugar for await loops 2023-12-19 12:26:27 -08:00
bors 558ac1cfb7 Auto merge of #118853 - calebzulawski:simd-intrinsics, r=RalfJung
Add core::intrinsics::simd

Intended to close rust-lang/portable-simd#381.

r? ralfjung
2023-12-19 12:42:33 +00:00
Caleb Zulawski e61aaf91c8 Disable new intrinsics for bootstrap 2023-12-18 21:41:50 -05:00