Commit Graph

14433 Commits

Author SHA1 Message Date
Matthias Krüger
4393eab9ea
Rollup merge of #123852 - kamaboko123:fix_typo_in_std_lib_rs, r=lqd
fix typo in library/std/src/lib.rs

I found typo in literal.
I got an error by this typo when build std.

```
salacia@Vega:~/fat12rs$ cargo build -Zbuild-std
   Compiling compiler_builtins v0.1.108
   Compiling core v0.0.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.153
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std)
   Compiling rustc-std-workspace-core v1.99.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v1.0.0
   Compiling unwind v0.0.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)
   Compiling adler v1.0.2
   Compiling rustc-demangle v0.1.23
   Compiling rustc-std-workspace-alloc v1.99.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling gimli v0.28.1
   Compiling object v0.32.2
   Compiling addr2line v0.21.0
   Compiling miniz_oxide v0.7.2
   Compiling std_detect v0.1.5 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling hashbrown v0.14.3
   Compiling panic_abort v0.0.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_abort)
   Compiling panic_unwind v0.0.0 (/home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_unwind)
error: expected `,`, found `.`
   --> /home/salacia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/lib.rs:224:78
    |
224 |             `#![no_std]` or overriding this warning by enabling this feature".
    |                                                                              ^ expected `,`

error: could not compile `std` (lib) due to 1 previous error
:224:78
    |
224 |             `#![no_std]` or overriding this warning by enabling this feature".
    |                                                                              ^ expected `,`

error: could not compile `std` (lib) due to 1 previous error
```
2024-04-12 17:41:36 +02:00
Matthias Krüger
be3ea1dfb0
Rollup merge of #123833 - dpaoliello:stdarch, r=Amanieu
Update stdarch submodule

`asm_experimental_arch` is required in `core` as we're now using unstable inline assembly when building Arm64EC.

Brings in the fix for <https://github.com/rust-lang/stdarch/issues/1555> (cc `@tslnc04).`

r? `@Amanieu`
2024-04-12 17:41:34 +02:00
Matthias Krüger
8c8692014b
Rollup merge of #123825 - saethlin:report-nounwind-panics, r=petrochenkov
Call the panic hook for non-unwind panics in proc-macros

As I suggested in https://github.com/rust-lang/rust/issues/123286#issuecomment-2030344815.

If a proc macro causes a non-unwinding panic, `proc_macro` isn't able to catch the unwind and report the panic as a compile error by passing control back to the compiler. Our only chance to produce any diagnostic is the panic hook, so we should call it.

This scenario has already existed, but has become a lot more interesting now that we're adding more UB-detecting panics to the standard library, and such panics do not unwind.
2024-04-12 17:41:34 +02:00
bors
bd71213cf0 Auto merge of #123846 - matthiaskrgr:rollup-85y28av, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #123796 (Remove unused cargo-platform dependency from tidy)
 - #123830 (Remove `From` impls for unstable types that break inference)
 - #123842 (fix typo in pin.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-12 13:13:50 +00:00
kamaboko123
47c3ffa5d4 fix typo in library/std/src/lib.rs 2024-04-12 22:02:08 +09:00
Matthias Krüger
e256d5f2ee
Rollup merge of #123842 - ShockYoungCHN:master, r=scottmcm
fix typo in pin.rs

correct "implemts" to "implements".
2024-04-12 13:35:31 +02:00
Matthias Krüger
bcf24d6467
Rollup merge of #123830 - tgross35:f16-f128-from-inference-fix, r=Nilstrieb
Remove `From` impls for unstable types that break inference

Adding additional `From` implementations that fit `f32::from(<unaffixed float>)` broke inference. Remove these for now.

I added a test to make sure this doesn't quietly change in the future, even though the behavior is not technically guaranteed https://github.com/rust-lang/rust/issues/123824#issuecomment-2050628184

Fixes: <https://github.com/rust-lang/rust/issues/123824>
2024-04-12 13:35:30 +02:00
bors
7bdae134cb Auto merge of #123783 - tgross35:f16-f128-debug-impl, r=Amanieu
Add a `Debug` impl and some basic functions to `f16` and `f128`

`compiler_builtins` uses some convenience functions like `is_nan` and `is_sign_positive`. Add these, as well as a temporary implementation for `Debug` that prints the bit representation.
2024-04-12 11:11:50 +00:00
bors
6bc9dcd7ec Auto merge of #123490 - niluxv:strict_prov_unwind_seh, r=Amanieu
Refactor `panic_unwind/seh.rs` pointer use

* `x86` now conforms to strict-provenance
* `x86_64` now uses the expose API (instead of `as` casts)
* changed `ptr_t` from a type alias to a `repr(transparent)` struct for some extra type-safety
* replaced the `ptr!` macro by methods on `ptr_t`, as there is now no reason (as far as I can see) anymore to use a macro

On `x86_64` pointers in SEH are represented by 32-bit offsets from `__ImageBase`, so we can't use a pointer type. It might be possible to leak the provenance into the FFI by using a `MaybeUninit<u32>` instead of a `u32`, but that is a bit more involved than using expose, and I'm not sure that would be worth it.
2024-04-12 06:38:26 +00:00
Yuanzhuo Yang
41ac5d93d6
fix pin.rs typo
correct "implemts" to "implements"
2024-04-12 01:28:58 -05:00
Matthias Krüger
3758e2ffa5
Rollup merge of #123826 - kornelski:one-in-a-quintillion, r=Amanieu
Move rare overflow error to a cold function

`scoped.spawn()` generates unnecessary inlined panic-formatting code for a branch that will never be taken.
2024-04-12 04:38:22 +02:00
bors
46961d2407 Auto merge of #120092 - zetanumbers:pin_in_static_allocator, r=Amanieu
Add `A: 'static` bound for `Arc/Rc::pin_in`

Analogous to https://github.com/rust-lang/rust/pull/79327
Needed to preserve pin's [drop guarantee](https://doc.rust-lang.org/std/pin/index.html#drop-guarantee)
2024-04-12 00:03:43 +00:00
Daniel Paoliello
8a6ec2eadd Update stdarch submodule 2024-04-11 16:26:02 -07:00
Trevor Gross
9bcc98818c Remove From impls for unstable types that break inference
Adding additional `From` implementations that fit `f32::from(<unaffixed
float>)` broke inference. Remove these for now.

Fixes: <https://github.com/rust-lang/rust/issues/123824>
2024-04-11 18:04:31 -04:00
bors
a07f3eb43a Auto merge of #123823 - matthiaskrgr:rollup-8zdtggx, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #122882 (Avoid a panic in `set_output_capture` in the default panic handler)
 - #123523 (Account for trait/impl difference when suggesting changing argument from ref to mut ref)
 - #123744 (Silence `unused_imports` for redundant imports)
 - #123784 (Replace `document.write` with `document.head.insertAdjacent`)
 - #123798 (Avoid invalid socket address in length calculation)
 - #123804 (Stop using `HirId` for fn-like parents since closures are not `OwnerNode`s)
 - #123806 (Panic on overflow in `BorrowedCursor::advance`)
 - #123820 (Add my former address to .mailmap)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-11 21:56:11 +00:00
Ben Kimock
d8dc28b93e Call the panic hook for non-unwind panics in proc-macros 2024-04-11 17:46:12 -04:00
Kornel
1170d73007 Move rare overflow error to a cold function 2024-04-11 22:23:49 +01:00
Matthias Krüger
d8ae975c02
Rollup merge of #123806 - joboet:advanced_overflow, r=Amanieu
Panic on overflow in `BorrowedCursor::advance`

Passing `usize::MAX` to `advance` clearly isn't correct, but the current assertion fails to detect this when overflow checks are disabled. This isn't unsound, but should probably be fixed regardless.
2024-04-11 22:38:56 +02:00
Matthias Krüger
f361026ebd
Rollup merge of #123798 - tniessen:patch-1, r=workingjubilee
Avoid invalid socket address in length calculation

This has no effect on the lengths of these constants, but since the IP address portion of the socket addresses was intentionally chosen to be the largest valid value, it seems appropriate to also use the largest valid value for the other components (as opposed to invalid values exceeding the possible ranges).
2024-04-11 22:38:55 +02:00
Matthias Krüger
1e99af514b
Rollup merge of #122882 - Zoxc:panic-output-panic, r=Amanieu
Avoid a panic in `set_output_capture` in the default panic handler

This avoid a panic in the default panic handler by not using `set_output_capture` as `OUTPUT_CAPTURE.with` may panic once `OUTPUT_CAPTURE` is dropped.

A new non-panicking `try_set_output_capture` variant of `set_output_capture` is added for use in the default panic handler.
2024-04-11 22:38:53 +02:00
bors
616a8f85f1 Auto merge of #123814 - matthiaskrgr:rollup-lxn0t4t, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #123459 (Correctly handle inlining of doc hidden foreign items)
 - #123740 (Reduce Size of `ModifierInfo`)
 - #123770 (Correct broken link in core::pin doc)
 - #123777 (Deduplicate some function implementations between the parser and AST/HIR)
 - #123808 (codegen tests: Tolerate `nuw` `nsw` on `trunc`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-11 19:52:22 +00:00
Trevor Gross
5159ecd922 Add a Debug impl and some basic functions to f16 and f128
`compiler_builtins` uses some convenience functions like `is_nan` and
`is_sign_positive`. Add these, as well as a temporary implementation for
`Debug` that prints the bit representation.
2024-04-11 15:31:10 -04:00
niluxv
f63d5d1dcd
Refactor panic_unwind/seh.rs pointer use; x86 now conforms to strict-provenance 2024-04-11 20:47:52 +02:00
bors
aa6a697a1c Auto merge of #123732 - a1phyr:io_error_factor, r=cuviper
Factor some common `io::Error` constants
2024-04-11 17:49:04 +00:00
joboet
91fe6f9343
core: panic on overflow in BorrowedCursor 2024-04-11 18:33:46 +02:00
Tobias Nießen
e1972c0061
Avoid invalid socket address in length calculation 2024-04-11 17:27:23 +02:00
Benoît du Garreau
9c64068ddb Factor some common io::Error constants 2024-04-11 09:55:15 +02:00
Tomoki Nakagawa
68914f2095 Correct broken link in core::pin doc 2024-04-11 15:02:49 +09:00
León Orell Valerian Liehr
b24d2ad300
Rollup merge of #123756 - lukas-code:file-sync, r=jhpratt
clean up docs for `File::sync_*`

* Clarify that `sync_all` also writes data and not just metadata.
* Clarify that dropping a file is not equivalent to calling `sync_all` and ignoring the result. `sync_all` the still the recommended way to detect errors before closing, because we don't have a dedicated method for that.
* Add a link from `sync_all` to `sync_data`, because that's what the user might want to use instead.
* Add doc aliases for `fsync` -> `sync_all` and `fdatasync` -> `sync_data`. Those are the POSIX standard names for these functions. I was trying to find out what we call `fsync` in Rust and had to search through the source code to find it, so this alias should help with that in the future.
2024-04-11 01:56:26 +02:00
León Orell Valerian Liehr
d7d5be0c40
Rollup merge of #123661 - tgross35:stabilize-cstr_count_bytes, r=dtolnay
Stabilize `cstr_count_bytes`

Newly stable API:

```rust
impl CStr {
    pub fn count_bytes(&self) -> usize;
}
```

Const stabilization has not yet been decided, so that will continue to be gated under <https://github.com/rust-lang/rust/issues/113219>.

FCP finished at https://github.com/rust-lang/rust/issues/114441#issuecomment-2016942573.

Fixes: <https://github.com/rust-lang/rust/issues/114441>
2024-04-11 01:56:25 +02:00
León Orell Valerian Liehr
084d27b120
Rollup merge of #123360 - adamgemmell:dev/adagem01/restricted-std, r=ehuss
Document restricted_std

This PR aims to pin down exactly what restricted_std is meant to achieve and what it isn't.

This commit fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/87 by explaining why the error appears and what the choices the user has. The error describes how std cannot function without knowing about some form of OS/platform support. Any features of std that work without an OS should be moved to core/alloc (see https://github.com/rust-lang/rust/issues/27242 https://github.com/rust-lang/rust/issues/103765).

Note that the message says "platform" and "environment" because, since https://github.com/rust-lang/rust/pull/120232, libstd can be built for some JSON targets. This is still unsupported (all JSON targets probably should be unstable https://github.com/rust-lang/wg-cargo-std-aware/issues/90), but a JSON target with the right configuration should hopefully have some partial libstd support.

I propose closing https://github.com/rust-lang/wg-cargo-std-aware/issues/69 as "Won't fix" since any support of std without properly configured os, vendor or env fields is very fragile considering future upgrades of Rust or dependencies. In addition there's no likely path to it being fixed long term (making std buildable for all targets being the only solution). This is distinct from tier 3 platforms with limited std support implemented (and as such aren't restricted_std) because these platforms can conceptually work in the future and std support should mainly improve over time.

The alternative to closing https://github.com/rust-lang/wg-cargo-std-aware/issues/69 is a new crate feature for std which escapes the restricted_std mechanism in build.rs. It could be used with the -Zbuild-std-features flag if we keep it permanently unstable, which I hope we can do anyway. A minor side-effect in this scenario is that std wouldn't be marked as unstable if documentation for it were generated with build-std.

cc ```@ehuss```
2024-04-11 01:56:25 +02:00
León Orell Valerian Liehr
aac3f24054
Rollup merge of #122470 - tgross35:f16-f128-step4-libs-min, r=Amanieu
`f16` and `f128` step 4: basic library support

This is the next step after https://github.com/rust-lang/rust/pull/121926, another portion of https://github.com/rust-lang/rust/pull/114607

Tracking issue: https://github.com/rust-lang/rust/issues/116909

This PR adds the most basic operations to `f16` and `f128` that get lowered as LLVM intrinsics. This is a very small step but it seemed reasonable enough to add unopinionated basic operations before the larger modules that are built on top of them.

r? ```@Amanieu``` since you were pretty involved in the RFC
cc ```@compiler-errors```
```@rustbot``` label +T-libs-api +S-blocked +F-f16_and_f128
2024-04-11 01:56:23 +02:00
Lukas Markeffsky
f0fd5ad5d7 clean up docs for File::sync_* 2024-04-10 23:02:12 +02:00
Trevor Gross
311ad55c32 Add primitive documentation for f16 and f128 2024-04-10 13:50:27 -04:00
Trevor Gross
143ecc3202 Add basic f16 and f128 modules
Create empty modules so `rustdoc` has someplace to link to for these
types.
2024-04-10 13:50:27 -04:00
Trevor Gross
454de78ea3 Add basic library support for f16 and f128
Implement basic operation traits that get lowered to intrinsics. This
includes codegen tests for implemented operations.
2024-04-10 13:50:27 -04:00
Trevor Gross
88bcc79f31 Revert "Put basic impls for f16 and f128 behind cfg(not(bootstrap))"
This reverts commit 049a917535.

The resolution to <https://github.com/rust-lang/rust/issues/123282> is
that the `f16`/`f128` regression in the beta compiler was fixable
without a revert, so the commit adding `#[cfg(not(bootstrap))]` is no
longer useful (added in
<https://github.com/rust-lang/rust/pull/123390>).

Revert this commit because not having these basic impls bootstrap-gated
simplifies everything else that uses them.
2024-04-10 13:50:27 -04:00
bors
5974fe87c4 Auto merge of #123725 - GuillaumeGomez:rollup-gk2bbrg, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #118391 (Add `REDUNDANT_LIFETIMES` lint to detect lifetimes which are semantically redundant)
 - #123534 (Windows: set main thread name without re-encoding)
 - #123659 (Add support to intrinsics fallback body)
 - #123689 (Add const generics support for pattern types)
 - #123701 (Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place)
 - #123702 (Further cleanup cfgs in the UI test suite)
 - #123706 (rustdoc: reduce per-page HTML overhead)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-10 14:28:52 +00:00
Guillaume Gomez
38af5f9ee8
Rollup merge of #123534 - ChrisDenton:name, r=workingjubilee
Windows: set main thread name without re-encoding

As a minor optimization, we can skip the runtime UTF-8 to UTF-16 conversion.
2024-04-10 16:15:23 +02:00
bors
e908cfd125 Auto merge of #122393 - a1phyr:specialize_read_buf_exact, r=joboet
Specialize many implementations of `Read::read_buf_exact`

This makes all implementations of `Read` that have a specialized `read_exact` implementation also have one for `read_buf_exact`.
2024-04-10 11:38:15 +00:00
bors
b14d8b2ef2 Auto merge of #122812 - dtolnay:mode, r=workingjubilee
Show mode_t as octal in std::fs Debug impls

Example:

```rust
fn main() {
    println!("{:?}", std::fs::metadata("Cargo.toml").unwrap().permissions());
}
```

- Before: `Permissions(FilePermissions { mode: 33204 })`

- ~~After: `Permissions(FilePermissions { mode: 0o100664 })`~~

- After: `Permissions(FilePermissions { mode: 0o100664 (-rw-rw-r--) })`

~~I thought about using the format from `ls -l` (`-rw-rw-r--`, `drwxrwxr-x`) but I am not sure how transferable the meaning of the higher bits between different unix systems, and anyway starting the value with a leading negative-sign seems objectionable.~~
2024-04-10 04:47:56 +00:00
Matthias Krüger
a3f10a47d9
Rollup merge of #123633 - bjorn3:unsupported_command_data, r=jhpratt
Store all args in the unsupported Command implementation

This allows printing them in the Debug impl as well as getting them again using the get_args() method. This allows programs that would normally spawn another process to more easily show which program they would have spawned if not for the fact that the target doesn't support spawning child processes without requiring intrusive changes to keep the args. For example rustc compiled to wasi will show the full linker invocation that would have been done.
2024-04-10 04:27:40 +02:00
David Tolnay
caf3766eaf
Show mode_t as octal in std::fs Debug impls 2024-04-09 18:12:41 -07:00
Chris Denton
19f04a7d68
Add comment on UTF-16 surrogates 2024-04-09 20:20:32 +00:00
Chris Denton
952d432666
Windows: set main thread name without reencoding 2024-04-09 20:20:31 +00:00
Chris Denton
b48e7e5496
Add const UTF-8 to UTF-16 conversion macros
`wide_str!` creates a null terminated UTF-16 string whereas `utf16!` just creates a UTF-16 string without adding a null.
2024-04-09 20:20:19 +00:00
bors
8b2459c1f2 Auto merge of #123683 - pietroalbini:pa-cve-2024-24576-nightly, r=pietroalbini
Backport fix of CVE-2024-24576

See https://blog.rust-lang.org/2024/04/09/cve-2024-24576.html

r? `@ghost`
2024-04-09 19:56:18 +00:00
bors
033becf83c Auto merge of #123485 - madsmtm:use-libc-copyfile, r=joboet
macOS: Use `libc` definitions for copyfile

`COPYFILE_ALL` is not yet exposed in `libc`, but the rest of what we need is, so use those definitions instead of manually defining them.

The definitions were added in https://github.com/rust-lang/libc/pull/2667 and https://github.com/rust-lang/libc/pull/3346.
2024-04-09 14:15:09 +00:00
bjorn3
b4a395bcce Fix dead code warning 2024-04-09 13:44:53 +00:00
Guillaume Gomez
4f563a16f2
Rollup merge of #123665 - Jules-Bertholet:patch-1, r=lqd
Fix typo in `Future::poll()` docs

``@rustbot`` label A-docs
2024-04-09 13:39:24 +02:00