about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2023-11-10Closure-consuming helper functions for `fmt::Debug` helpersJohn Millikin-13/+136
2023-11-08Auto merge of #115460 - zachs18:borrowedcursor_write_no_panic, r=dtolnaybors-2/+3
Don't panic in `<BorrowedCursor as io::Write>::write` Instead of panicking if the BorrowedCursor does not have enough capacity for the whole buffer, just return a short write, [like `<&mut [u8] as io::Write>::write` does](https://doc.rust-lang.org/src/std/io/impls.rs.html#349). (cc `@ChayimFriedman2` https://github.com/rust-lang/rust/issues/78485#issuecomment-1493129588) (I'm not sure if this needs an ACP? since it's not changing the "API", just what the function does)
2023-11-07Auto merge of #117617 - Urgau:bump-libc-0.2.150, r=Mark-Simulacrumbors-1/+1
Bump libc dependency This bumps the `libc` crate to version 0.2.150 which includes https://github.com/rust-lang/libc/pull/3410 which will help remove the old and deprecated check-cfg syntax. Extracted from https://github.com/rust-lang/rust/pull/117612
2023-11-06Rollup merge of #117631 - smarnach:error-request-doc-fix, r=ChrisDentonMatthias Krüger-4/+4
Documentation cleanup for core::error::Request. This part of the documentation currently render like this: ![image](https://github.com/rust-lang/rust/assets/249196/b34cb907-4ce4-4e85-beca-510d8aa1fefb) The new version renders like this: ![image](https://github.com/rust-lang/rust/assets/249196/fe18398a-15fb-42a7-82a4-f1856d48bd79) Fixes: * Add missing closing back tick. * Remove spurious double back ticks. * Add missing newline to render bullet point correctly. * Fix grammar "there are methods calledrequest_ref and request_value are available" -> "there are methods calledrequest_ref and request_value". * Change "methods" to "functions", which seems more appropriate for free functions.
2023-11-06Auto merge of #116988 - RalfJung:null, r=WaffleLapkinbors-0/+10
document that the null pointer has the 0 address Fixes https://github.com/rust-lang/rust/issues/116895 Will need t-lang FCP, but I think this is fairly uncontroversial -- there's probably already tons of code out there that relies on this.
2023-11-06Documentation cleanup for core::error::Request.Sven Marnach-4/+4
2023-11-06Auto merge of #117576 - the8472:fix-io-copy-vec, r=Mark-Simulacrumbors-22/+54
Fix excessive initialization and reads beyond EOF in `io::copy(_, Vec<u8>)` specialization fixes #117545 and https://github.com/bczhc/bzip3-rs/pull/8
2023-11-05Auto merge of #96979 - SabrinaJewson:waker-update, r=workingjubileebors-1/+14
Override `Waker::clone_from` to avoid cloning `Waker`s unnecessarily This would be very useful for futures — I think it’s pretty much always what they want to do instead of `*waker = cx.waker().clone()`. Tracking issue: https://github.com/rust-lang/rust/issues/98287 r? rust-lang/libs-api `@rustbot` label +T-libs-api -T-libs
2023-11-05Auto merge of #117179 - Voultapher:fix-useless-comp-in-partition-equal, ↵bors-3/+10
r=Mark-Simulacrum Avoid unnecessary comparison in partition_equal The branchy Hoare partition `partition_equal` as part of `slice::sort_unstable` has a bug that makes it perform a comparison of the last element twice. Measuring inputs with a Zipfian distribution with characterizing exponent s == 1.0, yields a ~0.05% reduction in the total number of comparisons performed.
2023-11-05libc: bump dependency to 0.2.150Urgau-1/+1
2023-11-05Auto merge of #117537 - GKFX:offset-of-enum-feature, r=cjgillotbors-0/+1
Feature gate enums in offset_of As requested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790815262, put enums in offset_of behind their own feature gate. `@rustbot` label F-offset_of
2023-11-05Auto merge of #117608 - matthiaskrgr:rollup-g9fagmv, r=matthiaskrgrbors-0/+3
Rollup of 4 pull requests Successful merges: - #116017 (Don't pass `-stdlib=libc++` when building C files on macOS) - #117524 (bootstrap/setup: create hooks directory if non-existing) - #117588 (Remove unused LoadResult::DecodeIncrCache variant) - #117596 (Add diagnostic items for a few of core's builtin macros) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-05Rollup merge of #117596 - thomcc:core_macro_diag_items, r=NilstriebMatthias Krüger-0/+3
Add diagnostic items for a few of core's builtin macros Specifically, `env`, `option_env`, and `include`. There are a number of reasons why people might want to look at these in lints (For example, to ensure that things behave consistently, detect things that might make builds less reproducible, etc). Concretely, in PL/Rust (well, `plrustc`) we have lints that forbid these (which I'd like to [add to clippy as restriction lints](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Landing.20a.20flotilla.20of.20lints.3F) eventually), and `dylint` also has [lints that look for `env!`/`option_env!`](https://github.com/trailofbits/dylint/blob/109a07e9f27a9651ef33b6677ccaddd21466e97a/examples/general/env_cargo_path/src/lib.rs) (although perhaps not `include`), which would benefit from this. My experience is that it's pretty annoying to (robustly) check uses of builtin macros without these IME, although that's perhaps just my own fault (e.g. I could be doing it wrong). At `@Nilstrieb's` suggestion, I've added a comment that explains why these are here, even though they are not used in the compiler. This is mostly to discourage removal, although it's not a big deal if it happens (I'm certainly not suggesting the presence of these be in any way stable). --- In theory this is a library PR (in that it's in library/core), but I'm going to roll compiler because the existence of this or not is much more likely something they care about rather than libs. Hopefully nobody objects to this. r? compiler
2023-11-05Auto merge of #117504 - pcc:android-link-libunwind, r=Mark-Simulacrumbors-33/+1
Remove obsolete support for linking unwinder on Android Linking libgcc is no longer supported (see #103673), so remove the related link attributes and the check in unwind's build.rs. The check was the last remaining significant piece of logic in build.rs, so remove build.rs as well.
2023-11-05Auto merge of #116218 - tgross35:const-maybe-uninit-zeroed, r=dtolnaybors-10/+36
Stabilize `const_maybe_uninit_zeroed` and `const_mem_zeroed` Make `MaybeUninit::zeroed` and `mem::zeroed` const stable. Newly stable API: ```rust // core::mem pub const unsafe fn zeroed<T>() ->; impl<T> MaybeUninit<T> { pub const fn zeroed() -> MaybeUninit<T>; } ``` This relies on features based around `const_mut_refs`. Per `@RalfJung,` this should be OK since we do not leak any `&mut` to the user. For this to be possible, intrinsics `assert_zero_valid` and `assert_mem_uninitialized_valid` were made const stable. Tracking issue: #91850 Zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const_mut_refs.60.20dependents r? libs-api `@rustbot` label -T-libs +T-libs-api +A-const-eval cc `@RalfJung` `@oli-obk` `@rust-lang/wg-const-eval`
2023-11-05Auto merge of #117581 - nicholasbishop:bishop-update-cb, r=Mark-Simulacrumbors-1/+1
Bump compiler_builtins to 0.1.103
2023-11-05Auto merge of #117503 - kornelski:hint-try-reserved, r=workingjubileebors-4/+14
Hint optimizer about try-reserved capacity This is #116568, but limited only to the less-common `try_reserve` functions to reduce bloat in debug binaries from debug info, while still addressing the main use-case #116570
2023-11-04Add diagnostic items for a few of core's builtin macrosThom Chiovoloni-0/+3
2023-11-04Rollup merge of #117534 - RalfJung:str, r=Mark-SimulacrumMatthias Krüger-11/+17
clarify that the str invariant is a safety, not validity, invariant Updates these docs to match https://github.com/rust-lang/reference/pull/792
2023-11-04Rollup merge of #116894 - joshlf:patch-12, r=RalfJungMatthias Krüger-1/+8
Guarantee that `char` has the same size and alignment as `u32`
2023-11-04Rollup merge of #110340 - jmaargh:jmaargh/deref-docs, r=Mark-SimulacrumMatthias Krüger-41/+125
Deref docs: expand and remove "smart pointer" qualifier **Ready for review** ~~This is an unpolished draft to be sanity-checked~~ Fixes #91004 ~~Comments on substance and content of this are welcome. This is deliberately unpolished until ready to review so please try to stay focused on the big-picture.~~ ~~Once this has been sanity checked, I will similarly update `DerefMut` and polish for review.~~
2023-11-04Stabilize `const_mem_zeroed`Trevor Gross-3/+4
Make `core::mem::zeroed` const stable. Newly stable API: // core::mem pub const unsafe fn zeroed<T>() -> T; This is stabilized with `const_maybe_uninit_zeroed` since it is a simple wrapper. In order to make this possible, intrinsics `assert_zero_valid` was made const stable under `const_assert_type2`. `assert_mem_uninitialized_valid` was also made const stable since it is under the same gate.
2023-11-04Stabilize `const_maybe_uninit_zeroed`Trevor Gross-7/+32
Make `MaybeUninit::zeroed` const stable. Newly stable API: // core::mem impl<T> MaybeUninit<T> { pub const fn zeroed() -> MaybeUninit<T>; } Use of `const_mut_refs` should be acceptable since we do not leak the mutability. Tracking issue: #91850
2023-11-04Draft fleshed-out deref docsjmaargh-41/+125
Re-draft Deref docs Make general advice more explicit and note the difference between generic and specific implementations. Re-draft DerefMut docs in-line with Deref Fix Deref docs typos Fix broken links Clarify advice for specific-over-generic impls Add comment addressing Issue #73682 x fmt Copy faillibility warning to DerefMut
2023-11-04Bump compiler_builtins to 0.1.103Nicholas Bishop-1/+1
2023-11-04detect EOF earlierThe 8472-5/+7
The initial probe-for-empty-source by stack_buffer_copy only detected EOF if the source was empty but not when it was merely small which lead to additional calls to read() after Ok(0) had already been returned in the stack copy routine
2023-11-04avoid excessive initialization when copying to a VecThe 8472-17/+47
It now keeps track of initialized bytes to avoid reinitialization. It also keeps track of read sizes to avoid initializing more bytes than the reader needs. This is important when passing a huge vector to a Read that only has a few bytes to offer and doesn't implement read_buf().
2023-11-04avoid acronyms when we don't really need themRalf Jung-12/+11
2023-11-03Auto merge of #116412 - nnethercote:rm-plugin-support, r=bjorn3bors-2/+2
Remove support for compiler plugins. They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597. r? `@ghost`
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-2/+2
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597.
2023-11-03Auto merge of #115333 - joshlf:patch-5, r=RalfJungbors-9/+15
Guarantee representation of None in NPO This allows users to soundly transmute zeroes into `Option` types subject to the null pointer optimization (NPO). It unblocks https://github.com/google/zerocopy/issues/293.
2023-11-03cfg_attr offset_of_enum feature in doctestGeorge Bateman-1/+2
2023-11-03Feature gate enums in offset_ofGeorge Bateman-1/+1
2023-11-03Rollup merge of #117434 - BugenZhao:box-error-provide, r=cuviperMatthias Krüger-0/+4
delegate `<Box<E> as Error>::provide` to `<E as Error>::provide` Fix #117432.
2023-11-03Auto merge of #117510 - elichai:patch-3, r=cuviperbors-0/+1
Add track_caller to transmute_copy Currently if `size_of::<Src>() < size_of::<Dst>()` you will see the following error: ```rust thread 'test' panicked at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/mem/mod.rs:1056:5: cannot transmute_copy if Dst is larger than Src ``` This fixes it so it will show the invocation location
2023-11-03clarify that the str invariant is a safety, not validity, invariantRalf Jung-6/+13
2023-11-02Remove obsolete support for linking unwinder on AndroidPeter Collingbourne-33/+1
Linking libgcc is no longer supported (see #103673), so remove the related link attributes and the check in unwind's build.rs. The check was the last remaining significant piece of logic in build.rs, so remove build.rs as well.
2023-11-02Pretty print Fn traits in rustc_on_unimplementedMichael Goulet-12/+12
2023-11-02Rollup merge of #117512 - joshlf:patch-8, r=dtolnayMatthias Krüger-2/+63
Expand mem::offset_of! docs Makes progress on #106655
2023-11-02Rollup merge of #117495 - compiler-errors:unsize-docs, r=lcnrMatthias Krüger-6/+12
Clarify `Unsize` documentation The documentation erroneously says that: ```rust /// - Types implementing a trait `Trait` also implement `Unsize<dyn Trait>`. /// - Structs `Foo<..., T, ...>` implement `Unsize<Foo<..., U, ...>>` if all of these conditions /// are met: /// - `T: Unsize<U>`. /// - Only the last field of `Foo` has a type involving `T`. /// - `Bar<T>: Unsize<Bar<U>>`, where `Bar<T>` stands for the actual type of that last field. ``` Specifically, `T: Unsize<U>` is not required to hold -- only the final field must implement `FinalField<T>: Unsize<FinalField<U>>`. This can be demonstrated by the test I added. --- Second commit fleshes out the documentation a lot more.
2023-11-02Update mod.rsJoshua Liebow-Feeser-0/+2
2023-11-02Update mod.rsJoshua Liebow-Feeser-2/+1
2023-11-02Remove trailing spaceJoshua Liebow-Feeser-1/+1
2023-11-02Expand mem::offset_of! docsJoshua Liebow-Feeser-2/+62
Makes progress on #106655
2023-11-02Add track_caller to transmute_copyElichai Turkel-0/+1
2023-11-02Auto merge of #117386 - roblabla:fix-switch-stdio-win7, r=ChrisDentonbors-3/+21
Fix switch_stdout_to on Windows7 The `switch_stdout_to` test was broken on Windows7, as deleting the temporary test folder would fail since the `switch-stdout-output` file we redirected the stdout to is never closed, and it's impossible on Win7 to delete an opened file. To fix this issue, we make `switch_stdout_to` return the previous handle. Using this, we add a new `switch_stdout_to` call at the end of the test to return the stdio handles to their original state, and recover the handle to the file we opened. This handle is automatically closed at the end of the function, which should allow the temporary test folder to be deleted properly.
2023-11-01fixes: typo in `std::cmp::Ord` trait docsmassivebird-1/+1
2023-11-02Hint optimizer about reserved capacityKornel-4/+14
2023-11-01Rework unsize documentationMichael Goulet-5/+12
2023-11-01Remove a false statement from Unsize docs, add a testMichael Goulet-1/+0