about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2025-04-24Work around cygwin issue on timeout王宇逸-1/+4
2025-04-23Auto merge of #140180 - ChrisDenton:rollup-5pvs08u, r=ChrisDentonbors-11/+21
Rollup of 7 pull requests Successful merges: - #140142 (Some more graphviz tweaks) - #140146 (Update `compiler_builtins` to 0.1.156) - #140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.) - #140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic) - #140163 (Validate extension in `PathBuf::add_extension`) - #140173 (Ping Mara when touching format_args!() internals.) - #140175 (`rc""` more clear error message) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-23Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`Jiahao XU-1/+63
Tracking issue #139324 Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-04-23fix f*::MAX_EXP and MIN_EXP docsRalf Jung-24/+48
2025-04-23Document breaking out of a named code blockArtur Roos-0/+27
2025-04-23Remove workarounds for llvm/llvm-project#98306sayantn-6/+14
2025-04-23Re-enable `armv7-unknown-linux-gnueabihf`sayantn-3/+1
2025-04-23Add power9 and power8 target-featuresLuca Barbato-1/+36
2025-04-23reset the host linkerFolkert de Vries-0/+6
The host's linker is used to compile build.rs files (e.g. for libc). When the user configures a custom liker (e.g. mold) in their own .cargo/config.toml or ~/.cargo/config.toml, that linker will likely not work when running run-docker.sh. So, we now reset it to `cc`, which should always be installed in the docker container.
2025-04-23run `cargo generate-lockfile` before running dockerFolkert de Vries-0/+3
2025-04-23run `powerpc64le` `assert_instr` on CIFolkert de Vries-3/+2
2025-04-23libm-macros: Start tracking which functions are publicTrevor Gross-175/+226
It would be nice to reuse some of the macro structure for internal functions, like `rem_pio2`. To facilitate this, add a `public` field and make it available in the macro's API.
2025-04-23Make algebraic intrinsics into 'const fn' items; Make algebraic functions of ↵Gabriel Bjørnager Jensen-25/+45
'f16', 'f32', 'f64', and 'f128' into 'const fn' items;
2025-04-23Rollup merge of #140163 - thaliaarchi:pathbuf-validate-extension, r=ChrisDentonChris Denton-7/+17
Validate extension in `PathBuf::add_extension` The extension is validated in `PathBuf::set_extension`, but not `add_extension`. Fix that. Check for both `/` and `\` path separators on Windows, even when the path is verbatim, since this is logically like `PathBuf::push` which normalizes separators (i.e., keeping the current behavior). `PathBuf::add_extension` is tracked in #127292. r? `@ChrisDenton`
2025-04-23Rollup merge of #140146 - tgross35:update-builtins, r=tgross35Chris Denton-4/+4
Update `compiler_builtins` to 0.1.156 Includes the following changes: * Provide `abort` on AVR [1] [1]: https://github.com/rust-lang/compiler-builtins/pull/830
2025-04-22musl: Update submoduleTrevor Gross-0/+0
Update the musl submodule to c47ad25ea3 ("iconv: harden UTF-8 output code path against input decoder bugs").
2025-04-22Rollup merge of #140149 - RalfJung:test_nan, r=tgross35Chris Denton-0/+20
test_nan: ensure the NAN contant is quiet Follow-up to https://github.com/rust-lang/rust/pull/139483 r? ``@tgross35``
2025-04-22Rollup merge of #139617 - Berrysoft:cygwin-posix-spawn, r=joboetChris Denton-2/+6
Use posix_spawn on cygwin r? ``@joboet`` Depends on: - [x] https://github.com/rust-lang/libc/pull/4387 - [x] https://github.com/rust-lang/rust/pull/140081
2025-04-22Validate extension in `PathBuf::add_extension`Thalia Archibald-7/+17
The extension is validated in `PathBuf::set_extension`, but not `add_extension`. Fix that. Check for both / and \ path separators on Windows, even when the path is verbatim, since this is logically like `PathBuf::push` which normalizes separators (i.e., keeping the current behavior).
2025-04-22remove intrinsics::drop_in_placeRalf Jung-9/+0
2025-04-22chore: Release libm v0.2.13Trevor Gross-1/+7
2025-04-22fix: Switch to resolver v2Trevor Gross-1/+1
The published crates fail to build with an edition less than 2024 because they are packaged with `resolver = "3"`, which is a 2024-only option. Revert back to resolver v2 to drop this requirement. Fixes: https://github.com/rust-lang/compiler-builtins/issues/883
2025-04-22MANTISSA_DIGITS: explain relation to bitwise representationRalf Jung-0/+12
2025-04-22test_nan: ensure the NAN contant is quietRalf Jung-0/+8
2025-04-22Update `compiler_builtins` to 0.1.156Trevor Gross-4/+4
Includes the following changes: * Provide `abort` on AVR [1] [1]: https://github.com/rust-lang/compiler-builtins/pull/830
2025-04-21Unify owned `Env` types between platformsThalia Archibald-348/+98
Also, update the same pattern of reuse in `sys::args` to match.
2025-04-22chore: Combine CHANGELOG files for compiler-builtinsTrevor Gross-108/+100
This unintentionally got split when compiler-builtins was moved to a subdirectory.
2025-04-22chore: release builtins 0.1.156 and libm 0.2.12github-actions[bot]-2/+50
2025-04-21Deduplicate unsupported env itemsThalia Archibald-42/+8
2025-04-22Reimplement the generic fmodquaternic-66/+55
2025-04-21Fix `unsafe_op_in_unsafe_fn` for Unix envThalia Archibald-6/+4
2025-04-21Move zkVM constants into `sys::env_consts`Thalia Archibald-9/+11
I missed this in #139868. Its `mod` declaration was removed, but the contents were not moved.
2025-04-21Move `sys::pal::os::Env` into `sys::env`Thalia Archibald-1198/+1228
Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`.
2025-04-21Rename the `public-test-deps` feature to `unstable-public-internals`Trevor Gross-19/+19
`compiler-builtins` uses `public-test-deps`, `libm` uses `unstable-public-internals`. Consolidate these under the `libm` name. Once compiler-builtins is no longer published, this feature can probably be dropped. Also switch to `dep:` syntax for features that enable dependencies.
2025-04-21ci: Fix extensive testsTrevor Gross-16/+25
Move this to a script and ensure only `libm-test` gets built to avoid default feature issues with `compiler-builtins`.
2025-04-22Rollup merge of #140081 - Berrysoft:update-libc-172, r=tgross35Chris Denton-3/+3
Update `libc` to 0.2.172 r? ````@joboet````
2025-04-21Auto merge of #140127 - ChrisDenton:rollup-2kye32h, r=ChrisDentonbors-60/+35
Rollup of 11 pull requests Successful merges: - #134213 (Stabilize `naked_functions`) - #139711 (Hermit: Unify `std::env::args` with Unix) - #139795 (Clarify why SGX code specifies linkage/symbol names for certain statics) - #140036 (Advent of `tests/ui` (misc cleanups and improvements) [4/N]) - #140047 (remove a couple clones) - #140052 (Fix error when an intra doc link is trying to resolve an empty associated item) - #140074 (rustdoc-json: Improve test for auto-trait impls) - #140076 (jsondocck: Require command is at start of line) - #140107 (rustc-dev-guide subtree update) - #140111 (cleanup redundant pattern instances) - #140118 ({B,C}Str: minor cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-21Rollup merge of #140118 - tamird:cstr-cleanup, r=joboetChris Denton-12/+10
{B,C}Str: minor cleanup (hopefully) uncontroversial bits extracted from #139994.
2025-04-21Rollup merge of #140111 - jogru0:redundant_pattern, r=compiler-errorsChris Denton-1/+1
cleanup redundant pattern instances Just two small code cleanups.
2025-04-21Rollup merge of #139795 - jethrogb:jb/sgx-linkage-comments, r=joboetChris Denton-6/+14
Clarify why SGX code specifies linkage/symbol names for certain statics Specifying linkage/symbol name is solely to ensure a single instance between the `std` crate and its unit tests. Also update the symbol names as items have moved around a bit. The actual name isn't that important, it just needs to be unique. But for debugging it can be useful for it to point to the right place.
2025-04-21Rollup merge of #139711 - thaliaarchi:hermit-args, r=jhprattChris Denton-40/+9
Hermit: Unify `std::env::args` with Unix The only differences between these implementations of `std::env::args` are that Unix uses relaxed ordering, but Hermit uses acquire/release, and Unix truncates `argv` at the first null pointer, but Hermit doesn't. Since Hermit aims for Unix compatibility, unify it with Unix. The atomic orderings were established in https://github.com/rust-lang/rust/pull/74006 (cc `@euclio)` for Unix and https://github.com/rust-lang/rust/pull/100579 (cc `@joboet)` for Hermit and, before those, they used mutexes and non-atomic statics. I think the difference in orderings is simply from them being changed at different times. The commented explanation for using acquire/release for Hermit is “to broadcast writes by the OS”. I'm not experienced enough with atomics to accurately judge, but I think acquire/release is stronger than needed. Either way, they should match. Truncating at the first null pointer seems desirable, though I don't know whether it is necessary in practice on Hermit. cc `@mkroening` `@stlankes` for Hermit
2025-04-21Rollup merge of #134213 - folkertdev:stabilize-naked-functions, ↵Chris Denton-1/+1
r=tgross35,Amanieu,traviscross Stabilize `naked_functions` tracking issue: https://github.com/rust-lang/rust/issues/90957 request for stabilization on tracking issue: https://github.com/rust-lang/rust/issues/90957#issuecomment-2539270352 reference PR: https://github.com/rust-lang/reference/pull/1689 # Request for Stabilization Two years later, we're ready to try this again. Even though this issue is already marked as having passed FCP, given the amount of time that has passed and the changes in implementation strategy, we should follow the process again. ## Summary The `naked_functions` feature has two main parts: the `#[naked]` function attribute, and the `naked_asm!` macro. An example of a naked function: ```rust const THREE: usize = 3; #[naked] pub extern "sysv64" fn add_n(number: usize) -> usize { // SAFETY: the validity of the used registers // is guaranteed according to the "sysv64" ABI unsafe { core::arch::naked_asm!( "add rdi, {}", "mov rax, rdi", "ret", const THREE, ) } } ``` When the `#[naked]` attribute is applied to a function, the compiler won't emit a [function prologue](https://en.wikipedia.org/wiki/Function_prologue_and_epilogue) or epilogue when generating code for this function. This attribute is analogous to [`__attribute__((naked))`](https://developer.arm.com/documentation/100067/0608/Compiler-specific-Function--Variable--and-Type-Attributes/--attribute----naked---function-attribute) in C. The use of this feature allows the programmer to have precise control over the assembly that is generated for a given function. The body of a naked function must consist of a single `naked_asm!` invocation, a heavily restricted variant of the `asm!` macro: the only legal operands are `const` and `sym`, and the only legal options are `raw` and `att_syntax`. In lieu of specifying operands, the `naked_asm!` within a naked function relies on the function's calling convention to determine the validity of registers. ## Documentation The Rust Reference: https://github.com/rust-lang/reference/pull/1689 (Previous PR: https://github.com/rust-lang/reference/pull/1153) ## Tests * [tests/run-make/naked-symbol-visiblity](https://github.com/rust-lang/rust/tree/master/tests/codegen/naked-fn) verifies that `pub`, `#[no_mangle]` and `#[linkage = "..."]` work correctly for naked functions * [tests/codegen/naked-fn](https://github.com/rust-lang/rust/tree/master/tests/codegen/naked-fn) has tests for function alignment, use of generics, and validates the exact assembly output on linux, macos, windows and thumb * [tests/ui/asm/naked-*](https://github.com/rust-lang/rust/tree/master/tests/ui/asm) tests for incompatible attributes, generating errors around incorrect use of `naked_asm!`, etc ## Interaction with other (unstable) features ### [fn_align](https://github.com/rust-lang/rust/issues/82232) Combining `#[naked]` with `#[repr(align(N))]` works well, and is tested e.g. here - https://github.com/rust-lang/rust/blob/master/tests/codegen/naked-fn/aligned.rs - https://github.com/rust-lang/rust/blob/master/tests/codegen/naked-fn/min-function-alignment.rs It's tested extensively because we do need to explicitly support the `repr(align)` attribute (and make sure we e.g. don't mistake powers of two for number of bytes). ## History This feature was originally proposed in [RFC 1201](https://github.com/rust-lang/rfcs/pull/1201), filed on 2015-07-10 and accepted on 2016-03-21. Support for this feature was added in [#32410](https://github.com/rust-lang/rust/pull/32410), landing on 2016-03-23. Development languished for several years as it was realized that the semantics given in RFC 1201 were insufficiently specific. To address this, a minimal subset of naked functions was specified by [RFC 2972](https://github.com/rust-lang/rfcs/pull/2972), filed on 2020-08-07 and accepted on 2021-11-16. Prior to the acceptance of RFC 2972, all of the stricter behavior specified by RFC 2972 was implemented as a series of warn-by-default lints that would trigger on existing uses of the `naked` attribute; these lints became hard errors in [#93153](https://github.com/rust-lang/rust/pull/93153) on 2022-01-22. As a result, today RFC 2972 has completely superseded RFC 1201 in describing the semantics of the `naked` attribute. More recently, the `naked_asm!` macro was added to replace the earlier use of a heavily restricted `asm!` invocation. The `naked_asm!` name is clearer in error messages, and provides a place for documenting the specific requirements of inline assembly in naked functions. The implementation strategy was changed to emitting a global assembly block. In effect, an extern function ```rust extern "C" fn foo() { core::arch::naked_asm!("ret") } ``` is emitted as something similar to ```rust core::arch::global_asm!( "foo:", "ret" ); extern "C" { fn foo(); } ``` The codegen approach was chosen over the llvm naked function attribute because: - the rust compiler can guarantee the behavior (no sneaky additional instructions, no inlining, etc.) - behavior is the same on all backends (llvm, cranelift, gcc, etc) Finally, there is now an allow list of compatible attributes on naked functions, so that e.g. `#[inline]` is rejected with an error. The `#[target_feature]` attribute on naked functions was later made separately unstable, because implementing it is complex and we did not want to block naked functions themselves on how target features work on them. See also https://github.com/rust-lang/rust/issues/138568. relevant PRs for these recent changes - https://github.com/rust-lang/rust/pull/127853 - https://github.com/rust-lang/rust/pull/128651 - https://github.com/rust-lang/rust/pull/128004 - https://github.com/rust-lang/rust/pull/138570 - ### Various historical notes #### `noreturn` [RFC 2972](https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md) mentions that naked functions > must have a body which contains only a single asm!() statement which: > iii. must contain the noreturn option. Instead of `asm!`, the current implementation mandates that the body contain a single `naked_asm!` statement. The `naked_asm!` macro is a heavily restricted version of the `asm!` macro, making it easier to talk about and document the rules of assembly in naked functions and give dedicated error messages. For `naked_asm!`, the behavior of the `asm!`'s `noreturn` option is implicit. The `noreturn` option means that it is UB for control flow to fall through the end of the assembly block. With `asm!`, this option is usually used for blocks that diverge (and thus have no return and can be typed as `!`). With `naked_asm!`, the intent is different: usually naked funtions do return, but they must do so from within the assembly block. The `noreturn` option was used so that the compiler would not itself also insert a `ret` instruction at the very end. #### padding / `ud2` A `naked_asm!` block that violates the safety assumption that control flow must not fall through the end of the assembly block is UB. Because no return instruction is emitted, whatever bytes follow the naked function will be executed, resulting in truly undefined behavior. There has been discussion whether rustc should emit an invalid instruction (e.g. `ud2` on x86) after the `naked_asm!` block to at least fail early in the case of an invalid `naked_asm!`. It was however decided that it is more useful to guarantee that `#[naked]` functions NEVER contain any instructions besides those in the `naked_asm!` block. # unresolved questions None r? ``@Amanieu`` I've validated the tests on x86_64 and aarch64
2025-04-21use 'unadjusted' ABI for wasm LLVM intrinsicsRalf Jung-4/+4
2025-04-21Rollup merge of #140009 - ShE3py:tls-abort, r=thomccChris Denton-2/+6
docs(LocalKey<T>): clarify that T's Drop shouldn't panic Clarify that should a TLS destructor panics, the process will abort. Also, an abort may be obfuscated as the process can be terminated with `SIGSEGV` or [`STATUS_STACK_BUFFER_OVERRUN`](https://devblogs.microsoft.com/oldnewthing/20190108-00/?p=100655) (i.e., `SIGABRT` is not guaranteed), so explicitly prints that the process was aborted. Context: https://users.rust-lang.org/t/status-stack-buffer-overrun-on-windows-without-any-usage-of-unsafe/128417 ``@rustbot`` label -T-compiler
2025-04-21Rollup merge of #139982 - coolreader18:time-doc-tweak, r=jhprattChris Denton-2/+3
SystemTime doc tweaks * Change the `UNIX_EPOCH` link in the `SystemTime` docs to point to the associated constant, not the module level constant. The former seems to be the recommended way to access it, since aiui the only reason the module constant exists in the first place is that associated constants weren't stable yet at the time. * Reword the comment in the `SystemTime` example - "an error occurred!" is a tad misleading; I feel like it implies a system error out of our control while `SystemTimeError` is more of a logic error. I was originally just gonna do the first thing but I noticed the second and figured I may as well. I'm also somewhat surprised that there aren't more in-depth module level docs for `std::time`; they don't even mention `SystemTime` at all. I might make another PR for that but mainly just wanted to flag it.
2025-04-21Rollup merge of #139946 - mumbleskates:any-fix-missing-word, r=jhprattChris Denton-2/+2
fix missing word in comment a very simple fix, rectifying a situation in which a word was accidentally .
2025-04-21Replace colon with parentheses, add missing periodTamir Duberstein-1/+1
2025-04-21cleanup redundant pattern instancesJonathan Gruner-1/+1
2025-04-21Fix compiler-builtins publishTrevor Gross-16/+7
compiler-builtins currently wouldn't publish correctly because of a relative path to `libm` that doesn't get included in the package. Fix this by simlinking `libm` to within the `compiler-builtins` directory. Also symlink LICENSE.txt which lets us drop the `include` array in Cargo.toml. LICENSE.txt and compiler-rt were not being included anyway, since Cargo silently drops items that are not within the crate directory.
2025-04-21Update README and CONTRIBUTING for the new repository layoutTrevor Gross-158/+213