Commit Graph

16770 Commits

Author SHA1 Message Date
Ding Xiang Fei
fd36b3a4a8
s/SmartPointer/CoerceReferent/g
move derive_smart_pointer into removed set
2024-10-24 02:14:09 +08:00
Matthias Krüger
af356d6d73
Rollup merge of #132031 - slanterns:rc_default, r=ibraheemdev
Optimize `Rc<T>::default`

The missing piece of https://github.com/rust-lang/rust/pull/131460.

Also refactored `Arc<T>::default` by using a safe `NonNull::from(Box::leak(_))` to replace the unnecessarily unsafe call to `NonNull::new_unchecked(Box::into_raw(_))`. The remaining unsafety is coming from `[Rc|Arc]::from_inner`, which is safe from the construction of `[Rc|Arc]Inner`.
2024-10-23 06:51:25 +02:00
Matthias Krüger
38eaf608eb
Rollup merge of #131707 - clarfonthey:constify-core-tests, r=thomcc
Run most `core::num` tests in const context too

This adds some infrastructure for something I was going to use in #131566, but it felt worthwhile enough on its own to merge/discuss separately.

Essentially, right now we tend to rely on UI tests to ensure that things work in const context, rather than just using library tests. This uses a few simple macro tricks to make it *relatively* painless to execute tests in both runtime and compile-time context. And this only applies to the numeric tests, and not anything else.

Recommended to review without whitespace in the diff.

cc `@RalfJung`
2024-10-23 06:51:23 +02:00
bors
b13176595d Auto merge of #131929 - LaihoE:replace_default_capacity, r=joboet
better default capacity for str::replace

Adds smarter capacity for str::replace in cases where we know that the output will be at least as long as the original string.
2024-10-23 01:03:48 +00:00
Laiho
c8391802af better default capacity for str::replace 2024-10-22 19:53:33 +03:00
Slanterns
0a963ab2da
refactor Arc<T>::default 2024-10-22 02:25:48 -07:00
Slanterns
5b12d906bb
optimize Rc<T>::default 2024-10-22 01:37:53 -07:00
Jubilee
763fbf8a90
Rollup merge of #131697 - ShE3py:rt-arg-lifetimes, r=Amanieu
`rt::Argument`: elide lifetimes

`@rustbot` label +C-cleanup
2024-10-21 20:32:01 -07:00
Matthias Krüger
64f4aa6725
Rollup merge of #132003 - RalfJung:abi-compat-docs, r=traviscross
update ABI compatibility docs for new option-like rules

Documents the rules decided [here](https://github.com/rust-lang/rust/pull/130628#issuecomment-2402761599) for our ABI compatibility rules.

Long-term this should be moved to the reference, but for now this is what we got.

Cc `@rust-lang/lang` `@rust-lang/opsem`
2024-10-21 18:11:23 +02:00
Matthias Krüger
20b1dadf92
Rollup merge of #130350 - RalfJung:strict-provenance, r=dtolnay
stabilize Strict Provenance and Exposed Provenance APIs

Given that [RFC 3559](https://rust-lang.github.io/rfcs/3559-rust-has-provenance.html) has been accepted, t-lang has approved the concept of provenance to exist in the language. So I think it's time that we stabilize the strict provenance and exposed provenance APIs, and discuss provenance explicitly in the docs:
```rust
// core::ptr
pub const fn without_provenance<T>(addr: usize) -> *const T;
pub const fn dangling<T>() -> *const T;
pub const fn without_provenance_mut<T>(addr: usize) -> *mut T;
pub const fn dangling_mut<T>() -> *mut T;
pub fn with_exposed_provenance<T>(addr: usize) -> *const T;
pub fn with_exposed_provenance_mut<T>(addr: usize) -> *mut T;

impl<T: ?Sized> *const T {
    pub fn addr(self) -> usize;
    pub fn expose_provenance(self) -> usize;
    pub fn with_addr(self, addr: usize) -> Self;
    pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self;
}

impl<T: ?Sized> *mut T {
    pub fn addr(self) -> usize;
    pub fn expose_provenance(self) -> usize;
    pub fn with_addr(self, addr: usize) -> Self;
    pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self;
}

impl<T: ?Sized> NonNull<T> {
    pub fn addr(self) -> NonZero<usize>;
    pub fn with_addr(self, addr: NonZero<usize>) -> Self;
    pub fn map_addr(self, f: impl FnOnce(NonZero<usize>) -> NonZero<usize>) -> Self;
}
```

I also did a pass over the docs to adjust them, because this is no longer an "experiment". The `ptr` docs now discuss the concept of provenance in general, and then they go into the two families of APIs for dealing with provenance: Strict Provenance and Exposed Provenance. I removed the discussion of how pointers also have an associated "address space" -- that is not actually tracked in the pointer value, it is tracked in the type, so IMO it just distracts from the core point of provenance. I also adjusted the docs for `with_exposed_provenance` to make it clear that we cannot guarantee much about this function, it's all best-effort.

There are two unstable lints associated with the strict_provenance feature gate; I moved them to a new [strict_provenance_lints](https://github.com/rust-lang/rust/issues/130351) feature since I didn't want this PR to have an even bigger FCP. ;)

`@rust-lang/opsem` Would be great to get some feedback on the docs here. :)
Nominating for `@rust-lang/libs-api.`

Part of https://github.com/rust-lang/rust/issues/95228.

[FCP comment](https://github.com/rust-lang/rust/pull/130350#issuecomment-2395114536)
2024-10-21 18:11:19 +02:00
Ralf Jung
75cadc09f2 update ABI compatibility docs for new option-like rules 2024-10-21 16:25:32 +01:00
Ralf Jung
56ee492a6e move strict provenance lints to new feature gate, remove old feature gates 2024-10-21 15:22:17 +01:00
Ralf Jung
c3e928d8dd stabilize Strict Provenance and Exposed Provenance
This comes with a big docs rewrite.
2024-10-21 15:05:35 +01:00
klensy
2920ed0999 fix docs 2024-10-20 18:25:38 +03:00
klensy
8abe67c949 replace FindFirstFileW with FindFirstFileExW and apply optimization 2024-10-20 18:24:55 +03:00
klensy
22a9a8b76e replace FindFirstFileW with FindFirstFileExW and regenerate bindings 2024-10-20 16:05:49 +03:00
bors
b596184f3b Auto merge of #131948 - matthiaskrgr:rollup-c9rvzu6, r=matthiaskrgr
Rollup of 12 pull requests

Successful merges:

 - #116863 (warn less about non-exhaustive in ffi)
 - #127675 (Remove invalid help diagnostics for const pointer)
 - #131772 (Remove `const_refs_to_static` TODO in proc_macro)
 - #131789 (Make sure that outer opaques capture inner opaques's lifetimes even with precise capturing syntax)
 - #131795 (Stop inverting expectation in normalization errors)
 - #131920 (Add codegen test for branchy bool match)
 - #131921 (replace STATX_ALL with (STATX_BASIC_STATS | STATX_BTIME) as former is deprecated)
 - #131925 (Warn on redundant `--cfg` directive when revisions are used)
 - #131931 (Remove unnecessary constness from `lower_generic_args_of_path`)
 - #131932 (use tracked_path in rustc_fluent_macro)
 - #131936 (feat(rustdoc-json-types): introduce rustc-hash feature)
 - #131939 (Get rid of `OnlySelfBounds`)

Failed merges:

 - #131181 (Compiletest: Custom differ)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-19 22:33:42 +00:00
Matthias Krüger
d881cc6723
Rollup merge of #131921 - klensy:statx_all, r=ChrisDenton
replace STATX_ALL with (STATX_BASIC_STATS | STATX_BTIME) as former is deprecated

STATX_ALL was deprecated in 581701b7ef and suggested to use equivalent (STATX_BASIC_STATS | STATX_BTIME) combination, to prevent future surprises.
2024-10-19 22:00:58 +02:00
Matthias Krüger
e0b8e787c1
Rollup merge of #131772 - GnomedDev:remove-proc_macro-todo, r=petrochenkov
Remove `const_refs_to_static` TODO in proc_macro

Noticed this TODO, and with `const_refs_to_static` being stable now we can sort it out.
2024-10-19 22:00:56 +02:00
bors
da935398d5 Auto merge of #131907 - saethlin:update-compiler-builtins, r=tgross35
Update `compiler-builtins` to 0.1.134

I'm modeling this PR after https://github.com/rust-lang/rust/pull/131314.

This pulls in https://github.com/rust-lang/compiler-builtins/pull/713 which should mitigate the problem reported and discussed in https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Hello.20World.20on.20sparc-unknown-none-elf.20crashes
2024-10-19 20:00:08 +00:00
Ben Kimock
5aeb662045 Update compiler-builtins to 0.1.134 2024-10-19 11:47:43 -04:00
Matthias Krüger
7a6d4368b7
Rollup merge of #131919 - RalfJung:zero-sized-accesses, r=jhpratt
zero-sized accesses are fine on null pointers

We entirely forgot to update all the function docs when changing the central docs. That's the problem with helpfully repeating shared definitions in tons of places...
2024-10-19 17:25:36 +02:00
Matthias Krüger
1cc036d18b
Rollup merge of #131890 - printfn:precise-capturing-docs, r=traviscross
Update `use` keyword docs to describe precise capturing

I noticed that the standard library keyword docs for the `use` keyword haven't been updated yet to describe the new precise capturing syntax.
2024-10-19 17:25:34 +02:00
Matthias Krüger
5a3ecd53e4
Rollup merge of #127462 - Ayush1325:uefi-env, r=joboet
std: uefi: Add basic Env variables

- Implement environment variable functions
- Using EFI Shell protocol.
2024-10-19 17:25:33 +02:00
bors
c926476d01 Auto merge of #131816 - Zalathar:profiler-feature, r=Kobzol
Make `profiler_builtins` an optional dependency of sysroot, not std

This avoids unnecessary rebuilds of std (and the compiler) when `build.profiler` is toggled off or on.

Fixes #131812.

---

Background: The `profiler_builtins` crate has been an optional dependency of std (behind a cargo feature) ever since it was added back in #42433. But as far as I can tell that has only ever been a convenient way to force the crate to be built, not a genuine dependency.

The side-effect of this false dependency is that toggling `build.profiler` causes a rebuild of std and the compiler, which shouldn't be necessary. This PR therefore makes `profiler_builtins` an optional dependency of the dummy sysroot crate (#108865), rather than a dependency of std.

What makes this change so small is that all of the necessary infrastructure already exists. Previously, bootstrap would enable the `profiler` feature on the sysroot crate, which would forward that feature to std. Now, enabling that feature directly enables sysroot's `profiler_builtins` dependency instead.

---

I believe this is more of a bootstrap change than a libs change, so tentatively:
r? bootstrap
2024-10-19 10:55:40 +00:00
klensy
d84114690b replace STATX_ALL with (STATX_BASIC_STATS | STATX_BTIME) as former is deprecated 2024-10-19 13:05:42 +03:00
Ralf Jung
1b11ba87ae zero-sized accesses are fine on null pointers 2024-10-19 11:36:14 +02:00
printfn
be984c1889 Update use keyword docs to describe precise capturing 2024-10-18 21:17:08 +00:00
Ayush Singh
753536aba8
std: uefi: Use common function for UEFI shell
- Since in almost all cases, there will only be 1 UEFI shell, share the
  shell handle between all functions that require it.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2024-10-18 22:56:15 +05:30
Ayush Singh
588bfb4d50
std: uefi: Add basic Env variables
- Implement environment variable functions
- Using EFI Shell protocol.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2024-10-18 22:56:08 +05:30
bors
f7b5e5471b Auto merge of #131895 - jieyouxu:rollup-jyt3pic, r=jieyouxu
Rollup of 3 pull requests

Successful merges:

 - #126207 (std::unix::stack_overflow::drop_handler addressing todo through libc …)
 - #131864 (Never emit `vptr` for empty/auto traits)
 - #131870 (compiletest: Store test collection context/state in two structs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-18 17:23:35 +00:00
许杰友 Jieyou Xu (Joe)
39af44dae9
Rollup merge of #126207 - devnexen:stack_overflow_libc_upd, r=joboet
std::unix::stack_overflow::drop_handler addressing todo through libc …

…update
2024-10-18 14:52:25 +01:00
bors
b0c2d2e5b0 Auto merge of #131841 - paulmenage:futex-abstraction, r=joboet
Abstract the state type for futexes

In the same way that we expose `SmallAtomic` and `SmallPrimitive` to allow Windows to use a value other than an `AtomicU32` for its futex state, switch the primary futex state type from `AtomicU32` to `futex::Futex`.  The `futex::Futex` type should be usable as an atomic value with underlying primitive type equal to `futex::Primitive`. (`SmallAtomic` is also renamed to `SmallFutex`).

This allows supporting the futex API on systems where the underlying kernel futex implementation requires more user state than simply an `AtomicU32`.

All in-tree futex implementations simply define {`Futex`,`Primitive`} directly as {`AtomicU32`,`u32`}.
2024-10-18 13:43:57 +00:00
许杰友 Jieyou Xu (Joe)
af85d5280a
Rollup merge of #131866 - jieyouxu:thread_local, r=jhpratt
Avoid use imports in `thread_local_inner!`

Previously, the use imports in `thread_local_inner!` can shadow user-provided types or type aliases of the names `Storage`, `EagerStorage`, `LocalStorage` and `LocalKey`. This PR fixes that by dropping the use imports and instead refer to the std-internal types via fully qualified paths. A basic test is added to ensure `thread_local!`s with static decls with type names that match the aforementioned std-internal type names can successfully compile.

Fixes #131863.
2024-10-18 12:00:53 +01:00
许杰友 Jieyou Xu (Joe)
64bf99b476
Rollup merge of #131858 - AnthonyMikh:AnthonyMikh/repeat_n-is-not-that-special-anymore, r=jhpratt
Remove outdated documentation for `repeat_n`

After #106943, which made `Take<Repeat<I>>` implement `ExactSizeIterator`, part of documentation about difference from `repeat(x).take(n)` is no longer valid.

````@rustbot```` labels: +A-docs, +A-iterators
2024-10-18 12:00:52 +01:00
许杰友 Jieyou Xu (Joe)
759820e631
Rollup merge of #131809 - collinoc:fix-retain-mut-docs, r=jhpratt
Fix predicate signatures in retain_mut docs

This is my first PR here so let me know if I'm doing anything wrong.

The docs for `retain_mut` in `LinkedList` and `VecDeque` say the predicate takes `&e`, but it should be `&mut e` to match the actual signature. `Vec` [has it documented](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.retain_mut) correctly already.
2024-10-18 12:00:52 +01:00
许杰友 Jieyou Xu (Joe)
951c0cd6f3
Rollup merge of #131774 - thesummer:rtems-add-getentropy, r=joboet
Add getentropy for RTEMS

RTEMS provides the `getentropy` function.
Use this for providing random data.

This PR enables the `getentropy` function for the RTEMS operating system to get random data.
It is exposed via libc  (see https://github.com/rust-lang/libc/pull/3975).
2024-10-18 12:00:51 +01:00
许杰友 Jieyou Xu (Joe)
dae3076fa2
Rollup merge of #130136 - GKFX:stabilize-const-pin, r=dtolnay
Partially stabilize const_pin

Tracking issue #76654.

Eight of these methods can be made const-stable. The remainder are blocked on #73255.
2024-10-18 12:00:50 +01:00
Jan Sommer
e20636a786 Add entropy source for RTEMS 2024-10-18 10:26:59 +02:00
Matthias Krüger
b25d266bef
Rollup merge of #131850 - lexeyOK:master, r=compiler-errors
Missing parenthesis

the line was missing closing parenthesis
2024-10-18 06:59:07 +02:00
Matthias Krüger
4e9901faa9
Rollup merge of #131823 - thesummer:bump-libc-0.2.160, r=workingjubilee
Bump libc to 0.2.161

Bumps libc to the latest release version 0.2.161 which
- includes libc support for the tier 3 RTEMS target
- fixes segfaults on 32-bit FreeBSD targets
- gets musl's `posix_spawn_file_actions_addchdir_np` for some spawn opts
2024-10-18 06:59:06 +02:00
Matthias Krüger
994bdbb23f
Rollup merge of #131654 - betrusted-io:xous-various-fixes, r=thomcc
Various fixes for Xous

This patchset includes several fixes for Xous that have crept in over the last few months:

* The `adjust_process()` syscall was incorrect
* Warnings have started appearing in `alloc` -- adopt the same approach as wasm, until wasm figures out a workaround
* Dead code warnings have appeared in the networking code. Add `allow(dead_code)` as these structs are used as IPC values
* Add support for `args` and `env`, which have been useful for running tests
* Update `unwinding` to `0.2.3` which fixes the recent regression due to changes in `asm!()` code
2024-10-18 06:59:05 +02:00
许杰友 Jieyou Xu (Joe)
7b2320c3df Avoid shadowing user provided types or type aliases in thread_local!
By using qualified imports, i.e. `$crate::...::LocalKey`.
2024-10-18 10:27:41 +08:00
AnthonyMikh
cdacdae01f
remove outdated documentation for repeat_n
After rust/#106943 the part about `ExactSizeIterator` is no longer valid
2024-10-18 02:47:24 +04:00
bors
d9c4b8d475 Auto merge of #131572 - cuviper:ub-index_range, r=thomcc
Avoid superfluous UB checks in `IndexRange`

`IndexRange::len` is justified as an overall invariant, and
`take_prefix` and `take_suffix` are justified by local branch
conditions. A few more UB-checked calls remain in cases that are only
supported locally by `debug_assert!`, which won't do anything in
distributed builds, so those UB checks may still be useful.

We generally expect core's `#![rustc_preserve_ub_checks]` to optimize
away in user's release builds, but the mere presence of that extra code
can sometimes inhibit optimization, as seen in #131563.
2024-10-17 22:18:24 +00:00
Jan Sommer
a09c54d4d3 Bump libc to 0.2.161 2024-10-17 23:11:45 +02:00
David Carlier
e569c5c92f
std::unix::stack_overflow::drop_handler addressing todo through libc update 2024-10-17 21:34:51 +01:00
lexx
4ab307f9e8
Missing parenthesis
the line was missing closing parenthesis
2024-10-18 01:04:01 +05:00
Paul Menage
cf7ff15a0d Abstract the state type for futexes
In the same way that we expose SmallAtomic and SmallPrimitive to allow
Windows to use a value other than an AtomicU32 for its futex state, this
patch switches the primary futex state type from AtomicU32 to
futex::Atomic.  The futex::Atomic type should be usable as an atomic
value with underlying primitive type equal to futex::Primitive.

This allows supporting the futex API on systems where the underlying
kernel futex implementation requires more state than simply an
AtomicU32.

All in-tree futex implementations simply define {Atomic,Primitive}
directly as {AtomicU32,u32}.
2024-10-17 12:21:53 -07:00
Matthias Krüger
e46d52ccda
Rollup merge of #131835 - ferrocene:amanjeev/add-missing-attribute-unwind, r=Noratrieb
Do not run test where it cannot run

This was seen on Ferrocene, where we have a custom test target that does not have unwind support
2024-10-17 20:47:32 +02:00