about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2023-12-22Auto merge of #118847 - eholk:for-await, r=compiler-errorsbors-0/+1
Add support for `for await` loops This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library. Given a loop like: ```rust for await i in iter { ... } ``` this is desugared to something like: ```rust let mut iter = iter.into_async_iter(); while let Some(i) = loop { match core::pin::Pin::new(&mut iter).poll_next(cx) { Poll::Ready(i) => break i, Poll::Pending => yield, } } { ... } ``` This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this. I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue. r? `@compiler-errors`
2023-12-20Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcmbors-2/+0
do not allow ABI mismatches inside repr(C) types In https://github.com/rust-lang/rust/pull/115476 we allowed ABI mismatches inside `repr(C)` types. This wasn't really discussed much; I added it because from how I understand calling conventions, this should actually be safe in practice. However I entirely forgot to actually allow this in Miri, and in the mean time I have learned that too much ABI compatibility can be a problem for CFI (it can reject fewer calls so that gives an attacker more room to play with). So I propose we take back that part about ABI compatibility in `repr(C)`. It is anyway something that C and C++ do not allow, as far as I understand. In the future we might want to introduce a class of ABI compatibilities where we say "this is a bug and it may lead to aborting the process, but it won't lead to arbitrary misbehavior -- worst case it'll just transmute the arguments from the caller type to the callee type". That would give CFI leeway to reject such calls without introducing the risk of arbitrary UB. (The UB can still happen if the transmute leads to bad results, of course, but it wouldn't be due to ABI weirdness.) #115476 hasn't reached beta yet so if we land this before Dec 22nd we can just pretend this all never happened. ;) Otherwise we should do a beta backport (of the docs change at least). Cc `@rust-lang/opsem` `@rust-lang/types`
2023-12-20Auto merge of #106790 - the8472:rawvec-niche, r=scottmcmbors-15/+50
add more niches to rawvec Previously RawVec only had a single niche in its `NonNull` pointer. With this change it now has `isize::MAX` niches since half the value-space of the capacity field is never needed, we can't have a capacity larger than isize::MAX.
2023-12-19Desugar for await loopsEric Holk-0/+1
2023-12-19Auto merge of #118853 - calebzulawski:simd-intrinsics, r=RalfJungbors-0/+474
Add core::intrinsics::simd Intended to close rust-lang/portable-simd#381. r? ralfjung
2023-12-18Disable new intrinsics for bootstrapCaleb Zulawski-0/+2
2023-12-18Rollup merge of #119051 - ChrisDenton:wine, r=workingjubileeMatthias Krüger-6/+8
Replace `FileAllocationInfo` with `FileEndOfFileInfo` This fixes WINE support
2023-12-17Add new intrinsicsCaleb Zulawski-0/+39
2023-12-17Further explain semanticsCaleb Zulawski-2/+13
2023-12-17Apply suggestions from code reviewCaleb Zulawski-2/+3
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-12-17Improve simd_bitmask documentation and other minor fixesCaleb Zulawski-8/+15
2023-12-17State type requirements firstCaleb Zulawski-61/+62
2023-12-17Clarify UB and improve grammarCaleb Zulawski-4/+4
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-12-17Add core::intrinsics::simdCaleb Zulawski-0/+413
2023-12-17Auto merge of #114962 - darklyspaced:debug, r=est31bors-3/+3
adds a column number to `dbg!()` this would be very nice to have for a few reasons: 1. the rfc, when deciding not to add column numbers to macro, failed to acknowledge any potential ambiguous cases -- such as the one provided in #114910 -- which do exist 2. would be able to consistently and easily jump directly to the `dbg!()` regardless of the sutation 3. takes up, at a maximum, 3 characters of _horizontal_ screen space fixes #114910
2023-12-17Use FileEndOfFileInfo, not FileAllocationInfoChris Denton-6/+8
This fixes WINE support
2023-12-17do not allow ABI mismatches inside repr(C) typesRalf Jung-2/+0
2023-12-17Auto merge of #118830 - GuillaumeGomez:env-tracked_env, r=Nilstriebbors-1/+3
Add support for `--env` on `tracked_env::var` Follow-up of https://github.com/rust-lang/rust/pull/118368. Part of Part of https://github.com/rust-lang/rust/issues/80792. It adds support of the `--env` option for proc-macros through `tracked_env::var`. r? `@Nilstrieb`
2023-12-15Rollup merge of #118851 - bzEq:std-xcoff, r=Mark-SimulacrumJubilee-0/+5
[std] Add xcoff in object's feature list object-0.32.0 has supported XCOFF format. And backtrace in submodule has been updated to support XCOFF and AIX. Add `xcoff` to supported feature list to make backtrace built on AIX.
2023-12-15Rollup merge of #118523 - okaneco:trim_ascii, r=Mark-SimulacrumJubilee-0/+82
Add ASCII whitespace trimming functions to `&str` - Add `trim_ascii_start`, `trim_ascii_end`, and `trim_ascii` functions to `&str` for trimming ASCII whitespace - Add `#[inline]` to `[u8]` `trim_ascii` functions These functions are feature-gated by `#![feature(byte_slice_trim_ascii)]` #94035
2023-12-15Rollup merge of #118998 - jstasiak:improve-doc, r=workingjubileeJubilee-1/+1
Link to is_benchmark from the Ipv6Addr::is_global documentation All other relevant is_* methods are mentioned in the list of addresses here, is_benchmarking has been the only one missing.
2023-12-15Rollup merge of #118956 - danielhuang:patch-2, r=workingjubileeJubilee-5/+5
Make CStr documentation consistent ("nul" instead of "null") "nul" is used in method names and appears more often in the documentation than "null", so make all instances "nul" to keep it consistent.
2023-12-15Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillotJubilee-5/+5
Collect lang items from AST, get rid of `GenericBound::LangItemTrait` r? `@cjgillot` cc #115178 Looking forward, the work to remove `QPath::LangItem` will also be significantly more difficult, but I plan on doing it as well. Specifically, we have to change: 1. A lot of `rustc_ast_lowering` for things like expr `..` 2. A lot of astconv, since we actually instantiate lang and non-lang paths quite differently. 3. A ton of diagnostics and clippy lints that are special-cased via `QPath::LangItem` Meanwhile, it was pretty easy to remove `GenericBound::LangItemTrait`, so I just did that here.
2023-12-15Add link to is_benchmark from the Ipv6Addr::is_global documentationJakub Stasiak-1/+1
All other relevant is_* methods are mentioned in the list of addresses here, is_benchmarking has been the only one missing.
2023-12-15Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnayMatthias Krüger-21/+18
Stabilize `type_name_of_val` Make the following API stable: ```rust // in core::any pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str ``` This is a convenience method to get the type name of a value, as opposed to `type_name` that takes a type as a generic. Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue https://github.com/rust-lang/rust/issues/97156. Wording was also changed to direct most of the details to `type_name` so we don't have as much duplicated documentation. Fixes tracking issue #66359. There were two main concerns in the tracking issue: 1. Naming: `type_name_of` and `type_name_of_val` seem like the only mentioned options. Differences in opinion here come from `std::mem::{size_of, align_of, size_of_val, align_of_val}`. This PR leaves the name as `type_name_of_val`, but I can change if desired since it is pretty verbose. 2. What this displays for `&dyn`: I don't think that having `type_name_of_val` function resolve those is worth the headache it would be, see https://github.com/rust-lang/rust/issues/66359#issuecomment-1718480774 for some workarounds. I also amended the docs wording to leave it open-ended, in case we have means to change that behavior in the future. ``@rustbot`` label -T-libs +T-libs-api +needs-fcp r? libs-api
2023-12-15Stabilize `ptr::{from_ref, from_mut}`Maybe Waffle-3/+5
2023-12-15Cfg remove lang items in doctestCameron Steffen-5/+5
2023-12-15Auto merge of #118966 - matthiaskrgr:rollup-sdvjwy6, r=matthiaskrgrbors-10/+40
Rollup of 3 pull requests Successful merges: - #116888 (Add discussion that concurrent access to the environment is unsafe) - #118888 (Uplift `TypeAndMut` and `ClosureKind` to `rustc_type_ir`) - #118929 (coverage: Tidy up early parts of the instrumentor pass) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-15Rollup merge of #116888 - tbu-:pr_unsafe_env, r=AmanieuMatthias Krüger-10/+40
Add discussion that concurrent access to the environment is unsafe The bug report #27970 has existed for 8 years, the actual bug dates back to Rust pre-1.0. I documented it since it's in the interest of the user to be aware of it. The note can be removed once #27970 is fixed.
2023-12-15Auto merge of #118770 - saethlin:fix-inline-never-uses, r=nnethercotebors-1/+0
Fix cases where std accidentally relied on inline(never) This PR increases the power of `-Zcross-crate-inline-threshold=always` so that it applies through `#[inline(never)]`. Note that though this is called "cross-crate-inlining" in this case especially it is _just_ lazy per-CGU codegen. The MIR inliner and LLVM still respect the attribute as much as they ever have. Trying to bootstrap with the new `-Zcross-crate-inline-threshold=always` change revealed two bugs: We have special intrinsics `assert_inhabited`, `assert_zero_valid`, and `assert_mem_uniniitalized_valid` which codegen backends will lower to nothing or a call to `panic_nounwind`. Since we may not have any call to `panic_nounwind` in MIR but emit one anyway, we need to specially tell `MirUsedCollector` about this situation. `#[lang = "start"]` is special-cased already so that `MirUsedCollector` will collect it, but then when we make it cross-crate-inlinable it is only assigned to a CGU based on whether `MirUsedCollector` saw a call to it, which of course we didn't. --- I started looking into this because https://github.com/rust-lang/rust/pull/118683 revealed a case where we were accidentally relying on a function being `#[inline(never)]`, and cranking up cross-crate-inlinability seems like a way to find other situations like that. r? `@nnethercote` because I don't like what I'm doing to the CGU partitioning code here but I can't come up with something much better
2023-12-14Update c_str.rsDaniel Huang-3/+3
2023-12-14Update c_str.rsDaniel Huang-2/+2
2023-12-14Fix target_feature config in portable-simdUrgau-1/+1
2023-12-14Fix cases where std accidentally relied on inline(never)Ben Kimock-1/+0
2023-12-14Auto merge of #118566 - klensy:cstr-new, r=WaffleLapkinbors-26/+26
use c literals in compiler and library Relands refreshed https://github.com/rust-lang/rust/pull/111647
2023-12-13Reformulate `std::env::{set,remove}_env` as safety noteTobias Bucher-24/+36
2023-12-13Auto merge of #117050 - c410-f3r:here-we-go-again, r=petrochenkovbors-0/+143
[`RFC 3086`] Attempt to try to resolve blocking concerns Implements what is described at https://github.com/rust-lang/rust/issues/83527#issuecomment-1744822345 to hopefully make some progress. It is unknown if such approach is or isn't desired due to the lack of further feedback, as such, it is probably best to nominate this PR to the official entities. `@rustbot` labels +I-compiler-nominated
2023-12-13Auto merge of #118900 - workingjubilee:rollup-wkv9hq1, r=workingjubileebors-6/+6
Rollup of 10 pull requests Successful merges: - #118858 (Remove dead codes in core) - #118864 (Fix alignment passed down to LLVM for simd_masked_load) - #118872 (Add rustX check to codeblock attributes lint) - #118873 (fix `waker_getters` tracking issue number) - #118884 (NFC: simplify merging of two vecs) - #118885 (clippy::complexity fixes) - #118886 (Clean up variables in `search.js`) - #118887 (Typo) - #118889 (more clippy::complexity fixes) - #118891 (Actually parse async gen blocks correctly) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-12Rollup merge of #118873 - lukas-code:fix_waker_getter_tracking_issue_number, ↵Jubilee-3/+3
r=workingjubilee fix `waker_getters` tracking issue number The feature currently links to the closed issue https://github.com/rust-lang/rust/issues/87021. Make it link to the tracking issue https://github.com/rust-lang/rust/issues/96992 instead.
2023-12-12Rollup merge of #118858 - mu001999:dead_code/clean, r=cuviperJubilee-3/+3
Remove dead codes in core Detected by #118257
2023-12-13Auto merge of #116438 - ChrisDenton:truncate, r=thomccbors-7/+53
Windows: Allow `File::create` to work on hidden files This makes `OpenOptions::new().write(true).create(true).truncate(true).open(&path)` work if the path exists and is a hidden file. Previously it would fail with access denied. This makes it consistent with `OpenOptions::new().write(true).truncate(true).open(&path)` (note the lack of `create`) which does not have this restriction. It's also more consistent with other platforms. Fixes #115745 (see that issue for more details).
2023-12-13Use different cfg for AIXKai Luo-1/+6
2023-12-12Add ASCII whitespace trimming functions to `&str`okaneco-0/+82
Add `trim_ascii_start`, `trim_ascii_end`, and `trim_ascii` functions to `&str` for trimming ASCII whitespace under the `byte_slice_trim_ascii` feature gate. Add `inline` to `[u8]` `trim_ascii` functions
2023-12-12fix `waker_getters` tracking issue numberLukas Markeffsky-3/+3
2023-12-12added column number to dbg!()darklyspaced-3/+3
2023-12-12Remove dead codes in corer01and-3/+3
2023-12-12Add xcoff supportKai Luo-1/+1
2023-12-11add comment to RawVec::cap fieldThe 8472-0/+5
2023-12-11add more niches to rawvecThe 8472-15/+45
2023-12-11Add support for `--env` on `tracked_env::var`Guillaume Gomez-1/+3