Commit Graph

7072 Commits

Author SHA1 Message Date
Matthias Krüger
4cd289550f
Rollup merge of #133420 - thesummer:rtems-unwind, r=workingjubilee
Switch rtems target to panic unwind

Switch the RTEMS target to `panic_unwind`.

Relates to https://github.com/rust-lang/backtrace-rs/pull/682
2025-01-03 22:12:41 +01:00
bors
319f5292a1 Auto merge of #135059 - matthiaskrgr:rollup-0ka9o3h, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #131729 (Make the `test` cfg a userspace check-cfg)
 - #134241 (more concrete source url of std docs [V2])
 - #135042 (taint fcx on selection errors during unsizing)
 - #135049 (Remove unused fields from RepeatElementCopy obligation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-03 09:34:23 +00:00
Matthias Krüger
e11d5f88a2
Rollup merge of #134241 - liigo:patch-16, r=dtolnay
more concrete source url of std docs [V2]

r? jhpratt
since you have reivewed https://github.com/rust-lang/rust/pull/134193

> If someone is looking to contribute, they will want the repository as a whole, not the lib.rs for std.

Now the repository url is reserved, I just add another concrete url as an example, to help people finding target page more quickly&easily.
2025-01-03 07:57:25 +01:00
bors
ac00fe89a1 Auto merge of #134692 - GrigorenkoPV:sync_poision, r=tgross35
Move some things to `std::sync::poison` and reexport them in `std::sync`

Tracking issue: #134646

r? `@tgross35`

I've used `sync_poison_mod` feature flag instead, because `sync_poison` had already been used back in 1.2.

try-job: x86_64-msvc
2025-01-03 06:40:28 +00:00
bors
ab3924b298 Auto merge of #122565 - Zoxc:atomic-panic-msg, r=the8472
Try to write the panic message with a single `write_all` call

This writes the panic message to a buffer before writing to stderr. This allows it to be printed with a single `write_all` call, preventing it from being interleaved with other outputs. It also adds newlines before and after the message ensuring that only the panic message will have its own lines.

Before:
```
thread 'thread 'thread 'thread 'thread '<unnamed>thread 'thread 'thread 'thread '<unnamed><unnamed>thread '<unnamed>' panicked at ' panicked at <unnamed><unnamed><unnamed><unnamed><unnamed>' panicked at <unnamed>' panicked at src\heap.rssrc\heap.rs'
panicked at ' panicked at ' panicked at ' panicked at ' panicked at src\heap.rs' panicked at src\heap.rs::src\heap.rssrc\heap.rssrc\heap.rssrc\heap.rssrc\heap.rs:src\heap.rs:455455:::::455:455::455455455455455:455:99:::::9:9:
:
999:
999:
assertion failed: size <= (*queue).block_size:
:
assertion failed: size <= (*queue).block_size:
assertion failed: size <= (*queue).block_size:
:
:
assertion failed: size <= (*queue).block_sizeassertion failed: size <= (*queue).block_sizeassertion failed: size <= (*queue).block_size

assertion failed: size <= (*queue).block_size
assertion failed: size <= (*queue).block_sizeassertion failed: size <= (*queue).block_sizeerror: process didn't exit successfully: `target\debug\direct_test.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
```
After:
```

thread '<unnamed>' panicked at src\heap.rs:455:9:
assertion failed: size <= (*queue).block_size

thread '<unnamed>' panicked at src\heap.rs:455:9:
assertion failed: size <= (*queue).block_size

thread '<unnamed>' panicked at src\heap.rs:455:9:
assertion failed: size <= (*queue).block_size

error: process didn't exit successfully: `target\debug\direct_test.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
```

---

try-jobs: x86_64-gnu-llvm-18
2025-01-02 22:06:09 +00:00
Liigo Zhuang
862fc62208 path in detail 2025-01-02 22:30:56 +08:00
Pavel Grigorenko
ee2ad4dfb1 Move some things to std::sync::poison and reexport them in std::sync 2025-01-02 15:21:41 +03:00
John Kåre Alsaker
4bf85c25ec Try to write the panic message with a single write_all call 2025-01-01 15:58:29 +01:00
Kleis Auke Wolthuizen
b6af0c4836 std::fs::DirEntry.metadata(): prefer use of lstat() on Emscripten
Align it with musl, which also prefers using lstat() here.
2025-01-01 13:21:19 +01:00
Kleis Auke Wolthuizen
ef58e8b989 Avoid use of LFS64 symbols on Emscripten
Since Emscripten uses musl libc internally.

Non-functional change: all LFS64 symbols were aliased to their non-LFS64
counterparts in rust-lang/libc@7c952dceaa.
2025-01-01 13:21:19 +01:00
bors
7a0cde96f8 Auto merge of #134620 - ChrisDenton:line-writer, r=tgross35
Avoid short writes in LineWriter

If the bytes written to `LineWriter` contains at least one new line but doesn't end in a new line (e.g. `"abc\ndef"`) then we:

- write up to the last new line direct to the underlying `Writer`.
- copy as many of the remaining bytes as will fit into our internal buffer.

That last step is inefficient if the remaining bytes are larger than our buffer. It will needlessly split the bytes in two, requiring at least two writes to the underlying `Writer` (one to flush the buffer, one more to write the rest). This PR skips the extra buffering if the remaining bytes are larger than the buffer.
2024-12-31 13:21:27 +00:00
Matthias Krüger
344a61e69b
Rollup merge of #134884 - calciumbe:patch1, r=jieyouxu
Fix typos

Hello, I fix some typos in docs and comments. Thank you very much.
2024-12-29 21:18:07 +01:00
calciumbe
4f8bebd6b5
fix: typos
Signed-off-by: calciumbe <192480234+calciumbe@users.noreply.github.com>
2024-12-29 21:35:02 +08:00
bors
3c1e750364 Auto merge of #134547 - SUPERCILEX:unify-copy, r=thomcc
Unify fs::copy and io::copy on Linux

Currently, `fs::copy` first tries a regular file copy (via copy_file_range) and then falls back to userspace read/write copying. We should use `io::copy` instead as it tries copy_file_range, sendfile, and splice before falling back to userspace copying. This was discovered here: https://github.com/SUPERCILEX/fuc/issues/40

Perf impact: `fs::copy` will now have two additional statx calls to decide which syscall to use. I wonder if we should get rid of the statx calls and only continue down the next fallback when the relevant syscalls say the FD isn't supported.
2024-12-28 13:49:45 +00:00
Trevor Gross
68bd853bb6 Update compiler-builtins to 0.1.140
Nothing significant here, just syncing the following small changes:

- https://github.com/rust-lang/compiler-builtins/pull/727
- https://github.com/rust-lang/compiler-builtins/pull/730
- https://github.com/rust-lang/compiler-builtins/pull/736
- https://github.com/rust-lang/compiler-builtins/pull/737
2024-12-27 22:26:08 +00:00
bors
6d3db555e6 Auto merge of #134822 - jieyouxu:rollup-5xuaq82, r=jieyouxu
Rollup of 8 pull requests

Successful merges:

 - #134606 (ptr::copy: fix docs for the overlapping case)
 - #134622 (Windows: Use WriteFile to write to a UTF-8 console)
 - #134759 (compiletest: Remove the `-test` suffix from normalize directives)
 - #134787 (Spruce up the docs of several queries related to the type/trait system and const eval)
 - #134806 (rustdoc: use shorter paths as preferred canonical paths)
 - #134815 (Sort triples by name in platform_support.md)
 - #134816 (tools: fix build failure caused by PR #134420)
 - #134819 (Fix mistake in windows file open)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-27 13:01:07 +00:00
许杰友 Jieyou Xu (Joe)
5544091054
Rollup merge of #134819 - ChrisDenton:trunc, r=Mark-Simulacrum
Fix mistake in windows file open

In #134722 this should have been `c::FileAllocationInfo` not `c::FileEndOfFileInfo`. Oops.
2024-12-27 20:44:15 +08:00
许杰友 Jieyou Xu (Joe)
7bbbfc650d
Rollup merge of #134622 - ChrisDenton:write-file-utf8, r=Mark-Simulacrum
Windows: Use WriteFile to write to a UTF-8 console

If the console code page is UTF-8 then we can simply write to it without needing to convert to UTF-16 and calling `WriteConsole`.
2024-12-27 20:44:11 +08:00
bors
42591a4cc0 Auto merge of #134786 - ChrisDenton:fix-rename-symlink, r=tgross35
Fix renaming symlinks on Windows

Previously we only detected mount points and not other types of links when determining reparse point behaviour.

Also added some tests to avoid this regressing again in the future.
2024-12-27 10:14:53 +00:00
Chris Denton
54b130afa2
Fix renaming symlinks on Windows
Previously we only detected mount points and not other types of links when determining reparse point behaviour.
2024-12-27 10:07:10 +00:00
Chris Denton
0af396f183
Fix mistake in windows file open 2024-12-27 09:20:37 +00:00
Jacob Pratt
c1447e3449
Rollup merge of #134791 - notriddle:notriddle/inline-ffi-error-types, r=tgross35
docs: inline `std::ffi::c_str` types to `std::ffi`

Rustdoc has no way to show that an item is stable, but only at a different path. `std::ffi::c_str::NulError` is not stable, but `std::ffi::NulError` is.

To avoid marking these types as unstable when someone just wants to follow a link from `CString`, inline them into their stable paths.

Fixes #134702

r? `@tgross35`
2024-12-26 21:56:51 -05:00
Jacob Pratt
50c3696735
Rollup merge of #134728 - deltragon:barrier-doc, r=tgross35
Use scoped threads in `std::sync::Barrier` examples

This removes boilerplate around `Arc`s and makes the code more clear.
2024-12-26 21:56:50 -05:00
Jacob Pratt
0521d6cf2c
Rollup merge of #134649 - SUPERCILEX:statx-remember, r=thomcc
Fix forgetting to save statx availability on success

Looks like we forgot to save the statx state on success which means the first failure (common when checking if a file exists) will always require spending an invalid statx to confirm the failure is real.

r? `@thomcc`
2024-12-26 21:56:49 -05:00
Jacob Pratt
9551808f42
Rollup merge of #134644 - kpreid:duplicates, r=Mark-Simulacrum
Document collection `From` and `FromIterator` impls that drop duplicate keys.

This behavior is worth documenting because there are other plausible alternatives, such as panicking when a duplicate is encountered, and it reminds the programmer to consider whether they should, for example, coalesce duplicate keys first.

Followup to #89869.
2024-12-26 21:56:48 -05:00
Michael Howell
40b0026a2f docs: inline std::ffi::c_str types to std::ffi
Rustdoc has no way to show that an item is stable,
but only at a different path. `std::ffi::c_str::NulError` is
not stable, but `std::ffi::NulError` is.

To avoid marking these types as unstable when someone just
wants to follow a link from `CString`, inline them into their
stable paths.
2024-12-26 08:58:17 -07:00
Alex Saveau
96cc078878
Fix compilation issues on other unixes
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-12-24 10:58:31 -08:00
deltragon
6a89f8789a Use scoped threads in std::sync::Barrier examples
This removes boilerplate around `Arc`s and makes the code more clear.
2024-12-24 14:39:02 +01:00
Chris Denton
ca56dc8537
Windows: Use FILE_ALLOCATION_INFO for truncation
But fallback to FILE_END_OF_FILE_INFO for WINE
2024-12-24 11:04:12 +00:00
Matthias Krüger
95c33e303b
Rollup merge of #134363 - estebank:derive-default, r=SparrowLii
Use `#[derive(Default)]` instead of manual `impl` when possible

While working on #134175 I noticed a few manual `Default` `impl`s that could be `derive`d instead. These likely predate the existence of the `#[default]` attribute for `enum`s.
2024-12-23 14:44:20 +01:00
Esteban Küber
1f82b45b6a Use #[derive(Default)] instead of manually implementing it 2024-12-23 03:01:29 +00:00
Marti Raudsepp
edfdfbe832 docs: Permissions.readonly() also ignores root user special permissions
The root user can write to files without any (write) access bits set. But this is not taken into account by `std::fs::Permissions.readonly()`.
2024-12-22 20:47:41 +02:00
Kevin Reid
6a43716ada Specify only that duplicates are discarded, not the order. 2024-12-22 08:16:54 -08:00
Alex Saveau
f19ba15a2c
Fix forgetting to save statx availability on success
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-12-21 22:50:08 -08:00
Kevin Reid
b5e8a5d393 Document collection From and FromIterator impls that drop duplicate keys.
This behavior is worth documenting because there are other plausible
alternatives, such as panicking when a duplicate is encountered, and
it reminds the programmer to consider whether they should, for example,
coalesce duplicate keys first.
2024-12-21 19:57:42 -08:00
Alex Saveau
e0a1549e44
Eliminate redundant statx syscalls
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-12-21 15:22:28 -08:00
Matthias Krüger
51df98ddb0
Rollup merge of #131072 - Fulgen301:windows-rename-posix-semantics, r=ChrisDenton
Win: Use POSIX rename semantics for `std::fs::rename` if available

Windows 10 1601 introduced `FileRenameInfoEx` as well as `FILE_RENAME_FLAG_POSIX_SEMANTICS`, allowing for atomic renaming and renaming if the target file is has already been opened with `FILE_SHARE_DELETE`, in which case the file gets renamed on disk while the open file handle still refers to the old file, just like in POSIX. This resolves #123985, where atomic renaming proved difficult to impossible due to race conditions.

If `FileRenameInfoEx` isn't available due to missing support from the underlying filesystem or missing OS support, the renaming is retried with `FileRenameInfo`, which matches the behavior of `MoveFileEx`.

This PR also manually replicates parts of `MoveFileEx`'s internal logic, as reverse-engineered from the disassembly: If the source file is a reparse point and said reparse point is a mount point, the mount point itself gets renamed; otherwise the reparse point is resolved and the result renamed.

Notes:
- Currently, the `win7` target doesn't bother with `FileRenameInfoEx` at all; it's probably desirable to remove that special casing and try `FileRenameInfoEx` anyway if it doesn't exist, in case the binary is run on newer OS versions.

Fixes #123985
2024-12-21 22:16:02 +01:00
Alex Saveau
73b41fbcfa
Unify fs::copy and io::copy 2024-12-21 12:20:58 -08:00
Chris Denton
1e3ecd5e4d
Windows: Use WriteFile to write to a UTF-8 console 2024-12-21 15:59:56 +00:00
Chris Denton
fdb43ef0c4
Avoid short writes in LineWriter
Also update the tests to avoid testing implementation details.
2024-12-21 15:13:22 +00:00
Jacob Pratt
cc27e3f08b
Rollup merge of #134593 - kornelski:less-unwrap, r=jhpratt
Less unwrap() in documentation

I think the common use of `.unwrap()` in examples makes it overrepresented, looking like a more typical way of error handling than it really is in real programs.

Therefore, this PR changes a bunch of examples to use different error handling methods, primarily the `?` operator. Additionally, `unwrap()` docs warn that it might abort the program.
2024-12-21 01:18:43 -05:00
Kornel
7b42bc0c79
Less unwrap() in documentation 2024-12-21 01:26:47 +00:00
Matthias Krüger
758ad53005
Rollup merge of #123604 - michaelvanstraten:proc_thread_attribute_list, r=ChrisDenton
Abstract `ProcThreadAttributeList` into its own struct

As extensively discussed in issue #114854, the current implementation of the unstable `windows_process_extensions_raw_attribute` features lacks support for passing a raw pointer.

This PR wants to explore the opportunity to abstract away the `ProcThreadAttributeList` into its own struct to for one improve safety and usability and secondly make it possible to maybe also use it to spawn new threads.

try-job: x86_64-mingw
2024-12-21 01:30:13 +01:00
Ralf Jung
8b2b6359f9 mri: add track_caller to thread spawning methods for better backtraces 2024-12-20 15:03:51 +01:00
Sergio Gasquez
c28e3e36b5 build: Update libc version 2024-12-19 10:08:29 +01:00
Josh Triplett
a105cd6066 Use field init shorthand where possible
Field init shorthand allows writing initializers like `tcx: tcx` as
`tcx`. The compiler already uses it extensively. Fix the last few places
where it isn't yet used.
2024-12-17 14:33:10 -08:00
Nicholas Nethercote
121e87bf14 Remove rustc::existing_doc_keyword lint.
`CheckAttrVisitor::check_doc_keyword` checks `#[doc(keyword = "..")]`
attributes to ensure they are on an empty module, and that the value is
a non-empty identifier.

The `rustc::existing_doc_keyword` lint checks these attributes to ensure
that the value is the name of a keyword.

It's silly to have two different checking mechanisms for these
attributes. This commit does the following.
- Changes `check_doc_keyword` to check that the value is the name of a
  keyword (avoiding the need for the identifier check, which removes a
  dependency on `rustc_lexer`).
- Removes the lint.
- Updates tests accordingly.

There is one hack: the `SelfTy` FIXME case used to used to be handled by
disabling the lint, but now is handled with a special case in
`is_doc_keyword`. That hack will go away if/when the FIXME is fixed.

Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2024-12-17 13:56:10 +11:00
Nicholas Nethercote
f10169c4ec Move doc(keyword = "while").
All the other unconditional keywords are in the alphabetical order, but
`while` is for some reason not.
2024-12-17 13:40:08 +11:00
bors
0894fb0fbf Auto merge of #134332 - Zalathar:rollup-oe23hkw, r=Zalathar
Rollup of 7 pull requests

Successful merges:

 - #130361 (std::net: Solaris supports `SOCK_CLOEXEC` as well since 11.4.)
 - #133406 (Add value accessor methods to `Mutex` and `RwLock`)
 - #133633 (don't show the full linker args unless `--verbose` is passed)
 - #134285 (Add some convenience helper methods on `hir::Safety`)
 - #134310 (Add clarity to the examples of some `Vec` & `VecDeque` methods)
 - #134313 (Don't make a def id for `impl_trait_in_bindings`)
 - #134315 (A couple of polonius fact generation cleanups)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-15 11:08:21 +00:00
Stuart Cook
66679081c7
Rollup merge of #133406 - EFanZh:lock-value-accessors, r=Noratrieb
Add value accessor methods to `Mutex` and `RwLock`

- ACP: https://github.com/rust-lang/libs-team/issues/485.
- Tracking issue: https://github.com/rust-lang/rust/issues/133407.

This PR adds `get`, `set` and `replace` methods to the `Mutex` and `RwLock` types for quick access to their contained values.

One possible optimization would be to check for poisoning first and return an error immediately, without attempting to acquire the lock. I didn’t implement this because I consider poisoning to be relatively rare, adding this extra check could slow down common use cases.
2024-12-15 20:01:36 +11:00