Commit Graph

12992 Commits

Author SHA1 Message Date
Michael Goulet
50e380c8f3
Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb
Add missing feature gate for sanitizer CFI cfgs

Found during the review of https://github.com/rust-lang/rust/pull/118494 in https://github.com/rust-lang/rust/pull/118494#discussion_r1416079288.

cc `@rcvalle`
2023-12-26 13:29:13 -05:00
bors
e1fadb2c35 Auto merge of #119133 - scottmcm:assert-unchecked, r=thomcc
Add `hint::assert_unchecked`

Libs-API expressed interest, modulo bikeshedding, in https://github.com/rust-lang/libs-team/issues/315#issuecomment-1863159430

I think that means this is good for nightly, since we can always rename it before stabilization.

Tracking issue: https://github.com/rust-lang/rust/issues/119131
2023-12-26 15:31:44 +00:00
bors
a815c3b69c Auto merge of #119313 - matthiaskrgr:rollup-41x48j6, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #119287 (Fix doc typo for read_exact_at)
 - #119294 (fix `./configure --set change-id`)
 - #119303 (Update sysinfo)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-26 08:22:57 +00:00
AlexBuz
3896f0bb9b
Fix doc typo for read_exact_at 2023-12-24 19:28:03 -06:00
lch361
c082c1c4c3 Documented unsafe blocks 2023-12-25 01:59:37 +03:00
lch361
b15e13760a Removed redundant bounds checking at Split's next and next_mut methods 2023-12-25 01:34:07 +03:00
Linus Färnstrand
98899b7131 Stabilize ip_in_core feature 2023-12-24 12:23:50 +01:00
Matthias Krüger
89c3236789
Rollup merge of #119205 - mumbleskates:vecdeque-comment-fix, r=Mark-Simulacrum
fix minor mistake in comments describing VecDeque resizing

Avoiding confusion where one of the items in the deque seems to disappear in two of the three cases
2023-12-24 01:08:09 +01:00
Matthias Krüger
b136919ca6
Rollup merge of #119153 - rursprung:stabilize-file_create_new, r=dtolnay
stabilize `file_create_new`

closes #105135
2023-12-23 20:02:28 +01:00
Michael Goulet
eef023c806
Rollup merge of #119222 - eholk:into-async-iterator, r=compiler-errors,dtolnay
Add `IntoAsyncIterator`

This introduces the `IntoAsyncIterator` trait and uses it in the desugaring of the unstable `for await` loop syntax. This is mostly added for symmetry with `Iterator` and `IntoIterator`.

r? `@compiler-errors`

cc `@rust-lang/libs-api,` `@rust-lang/wg-async`
2023-12-22 21:41:04 -05:00
bors
495203bf61 Auto merge of #119211 - rust-lang:pa-master-1.77, r=Mark-Simulacrum
Bump stage0 to 1.76 beta

r? `@Mark-Simulacrum`
2023-12-23 00:26:47 +00:00
Urgau
c88b021782 Adjust the std library for sanitizer_cfi cfgs changes 2023-12-23 01:01:09 +01:00
Eric Holk
acb6f17adf
Use IntoAsyncIterator in for await loop desugaring 2023-12-22 11:01:06 -08:00
Eric Holk
8e34391d6a
Add IntoAsyncIterator 2023-12-22 11:01:05 -08:00
bors
208dd2032b Auto merge of #118847 - eholk:for-await, r=compiler-errors
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-22 14:17:10 +00:00
Pietro Albini
f9f5840eb4
update cfg(bootstrap)s 2023-12-22 11:14:11 +01:00
Pietro Albini
c00486c9bb
update version placeholders 2023-12-22 11:01:42 +01:00
Kent Ross
f2e711e4c2 fix minor mistake in comments describing VecDeque resizing 2023-12-21 15:20:14 -08:00
bors
5ac4c8a63e Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcm
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-20 18:04:40 +00:00
Ralph Ursprung
62d53211b0
stabilize file_create_new
closes #105135
2023-12-20 08:45:46 +01:00
bors
51c0db6a91 Auto merge of #106790 - the8472:rawvec-niche, r=scottmcm
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-20 02:19:10 +00:00
Scott McMurray
7556d6f61b Add hint::assert_unchecked 2023-12-19 13:56:50 -08:00
Eric Holk
97df0d3657
Desugar for await loops 2023-12-19 12:26:27 -08:00
bors
558ac1cfb7 Auto merge of #118853 - calebzulawski:simd-intrinsics, r=RalfJung
Add core::intrinsics::simd

Intended to close rust-lang/portable-simd#381.

r? ralfjung
2023-12-19 12:42:33 +00:00
Caleb Zulawski
e61aaf91c8 Disable new intrinsics for bootstrap 2023-12-18 21:41:50 -05:00
Matthias Krüger
10ad10ee2a
Rollup merge of #119051 - ChrisDenton:wine, r=workingjubilee
Replace `FileAllocationInfo` with `FileEndOfFileInfo`

This fixes WINE support
2023-12-18 08:08:24 +01:00
Caleb Zulawski
d655dd6dca Add new intrinsics 2023-12-17 23:00:29 -05:00
Caleb Zulawski
4767aaf826 Further explain semantics 2023-12-17 21:17:00 -05:00
Caleb Zulawski
e245bafa9c Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-12-17 21:17:00 -05:00
Caleb Zulawski
71a5698989 Improve simd_bitmask documentation and other minor fixes 2023-12-17 21:17:00 -05:00
Caleb Zulawski
560ac23b70 State type requirements first 2023-12-17 21:17:00 -05:00
Caleb Zulawski
1fd7de062e Clarify UB and improve grammar
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-12-17 21:17:00 -05:00
Caleb Zulawski
ef4cf01542 Add core::intrinsics::simd 2023-12-17 21:16:59 -05:00
bors
43dcc9b786 Auto merge of #114962 - darklyspaced:debug, r=est31
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-17 23:01:18 +00:00
Chris Denton
e585b0ed58
Use FileEndOfFileInfo, not FileAllocationInfo
This fixes WINE support
2023-12-17 17:57:33 +00:00
Ralf Jung
c7e3b3f84c do not allow ABI mismatches inside repr(C) types 2023-12-17 09:34:25 +01:00
bors
5e7025419d Auto merge of #118830 - GuillaumeGomez:env-tracked_env, r=Nilstrieb
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-17 04:23:08 +00:00
Jubilee
6c2f00fbd7
Rollup merge of #118851 - bzEq:std-xcoff, r=Mark-Simulacrum
[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-15 21:32:58 -08:00
Jubilee
15e84ebc7b
Rollup merge of #118523 - okaneco:trim_ascii, r=Mark-Simulacrum
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-15 21:32:57 -08:00
Jubilee
4b447b8bb7
Rollup merge of #118998 - jstasiak:improve-doc, r=workingjubilee
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-15 14:08:18 -08:00
Jubilee
5e85fece3a
Rollup merge of #118956 - danielhuang:patch-2, r=workingjubilee
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-15 14:08:16 -08:00
Jubilee
1d54949765
Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillot
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-15 14:08:15 -08:00
Jakub Stasiak
47282799da Add 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-15 20:53:54 +01:00
Matthias Krüger
ea6daca3cb
Rollup merge of #118234 - tgross35:type_name_of_value, r=dtolnay
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-15 20:19:53 +01:00
Maybe Waffle
b863e9ba57
Stabilize ptr::{from_ref, from_mut} 2023-12-15 08:34:59 -08:00
Cameron Steffen
04fafd69de Cfg remove lang items in doctest 2023-12-15 16:17:28 +00:00
bors
cca2bda07e Auto merge of #118966 - matthiaskrgr:rollup-sdvjwy6, r=matthiaskrgr
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-15 06:52:44 +00:00
Matthias Krüger
44fd74aede
Rollup merge of #116888 - tbu-:pr_unsafe_env, r=Amanieu
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-15 06:50:17 +01:00
bors
1559dd2dbf Auto merge of #118770 - saethlin:fix-inline-never-uses, r=nnethercote
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-15 04:54:14 +00:00
Daniel Huang
f2f9b1d82a
Update c_str.rs 2023-12-14 19:08:36 -05:00