Commit Graph

260876 Commits

Author SHA1 Message Date
Chris Denton
a216a34ef3
jhpratt on vacation 2024-07-17 07:53:02 +00:00
bors
a28b35eb35 Auto merge of #127840 - tgross35:rollup-jfkg1dq, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - #125206 (Simplify environment variable examples)
 - #126271 (Skip fast path for dec2flt when optimize_for_size)
 - #126776 (Clean up more comments near use declarations)
 - #127444 (`impl Send + Sync` and override `count` for the `CStr::bytes` iterator)
 - #127512 (Terminate `--print link-args` output with newline)
 - #127792 (std: Use `read_unaligned` for reads from DWARF)
 - #127807 (Use futex.rs for Windows thread parking)
 - #127833 (zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`)
 - #127836 (std: Forbid unwrapped unsafe ops in xous and uefi modules)

Failed merges:

 - #127813 (Prevent double reference in generic futex)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-17 03:31:18 +00:00
Trevor Gross
1a1b44fcae
Rollup merge of #127836 - workingjubilee:forbid-unsafe-ops-in-xous-uefi, r=tgross35
std: Forbid unwrapped unsafe ops in xous and uefi modules
2024-07-16 20:10:14 -05:00
Trevor Gross
dd80a728cc
Rollup merge of #127833 - risc0:erik/zkvm-deny-unsafe, r=workingjubilee
zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`

This also adds an additional `unsafe` block to address compiler errors.
This PR is intended to address https://github.com/rust-lang/rust/issues/127747 for the zkvm target.
2024-07-16 20:10:13 -05:00
Trevor Gross
446e0177ec
Rollup merge of #127807 - ChrisDenton:win-parking, r=joboet
Use futex.rs for Windows thread parking

If I'm not overlooking anything then the Windows 10+ thread parking implementation is practically the same as the futex.rs implementation. So we may as well use the same implementation for both. The old version is still kept around for Windows 7 support.

r? ````@joboet```` if you wouldn't mind double checking I've not missed something
2024-07-16 20:10:12 -05:00
Trevor Gross
045b8107f2
Rollup merge of #127792 - workingjubilee:read-unaligned-is-dwarfier, r=joboet
std: Use `read_unaligned` for reads from DWARF

There's a lot of... *stuff* going on here. Meanwhile, `read_unaligned` has been available since 1.17.0, so let's just use that.
2024-07-16 20:10:12 -05:00
Trevor Gross
8840d302e5
Rollup merge of #127512 - eggyal:newline-terminate-print-linkargs, r=compiler-errors
Terminate `--print link-args` output with newline

Fixes #127507
2024-07-16 20:10:11 -05:00
Trevor Gross
4013acdda2
Rollup merge of #127444 - Sky9x:cstr-bytes-iter, r=dtolnay
`impl Send + Sync` and override `count` for the `CStr::bytes` iterator

cc tracking issue #112115
2024-07-16 20:10:11 -05:00
Trevor Gross
606d8cf9e8
Rollup merge of #126776 - nnethercote:rustfmt-use-pre-cleanups-2, r=cuviper
Clean up more comments near use declarations

#125443 will reformat all use declarations in the repository. There are a few edge cases involving comments on use declarations that require care. This PR fixes them up so #125443 can go ahead with a simple `x fmt --all`. A follow-up to #126717.

r? ``@cuviper``
2024-07-16 20:10:10 -05:00
Trevor Gross
fe1dc02163
Rollup merge of #126271 - diondokter:dec2flt-skip-fast-path, r=tgross35
Skip fast path for dec2flt when optimize_for_size

Tracking issue: https://github.com/rust-lang/rust/issues/125612

Skip the fast algorithm when optimizing for size.
When compiling for https://github.com/quartiq/stabilizer I get these numbers:

Before
```
   text    data     bss     dec     hex filename
 192192       8   49424  241624   3afd8 dual-iir
```

After
```
   text    data     bss     dec     hex filename
 191632       8   49424  241064   3ada8 dual-iir
```

This saves 560 bytes.
2024-07-16 20:10:09 -05:00
Trevor Gross
689d27293a
Rollup merge of #125206 - mgeisler:simplify-std-env-vars, r=jhpratt,tgross35
Simplify environment variable examples

I’ve found myself visiting the documentation for `std::env::vars` every few months, and every time I do, it is because I want to quickly get a snippet to print out all environment variables :-)

So I think it could be nice to simplify the examples a little to make them self-contained. It is of course a style question if one should import a module a not, but I personally don’t import modules used just once in a code snippet.
2024-07-16 20:10:09 -05:00
bors
1a6e777c3c Auto merge of #126208 - Oneirical:one-flew-over-the-cuckoo's-test, r=jieyouxu
Migrate `compiler-lookup-paths`, `dump-mono-stats` and `prune-link-args` `run-make` tests to `rmake` or `ui` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
try-job: aarch64-apple
try-job: dist-x86_64-linux
try-job: armhf-gnu
2024-07-17 01:09:18 +00:00
Jubilee Young
586ef83f3f uefi: Forbid unwrapped unsafe in platform modules 2024-07-16 16:21:10 -07:00
Dion Dokter
33f1d9d554
Cfg nit
Co-authored-by: Clar Fon <15850505+clarfonthey@users.noreply.github.com>
2024-07-17 01:20:56 +02:00
Jubilee Young
b5a83a6f71 xous: Forbid unwrapped unsafe in platform modules 2024-07-16 16:16:03 -07:00
Erik Kaneda
e48d33e18a
zkvm: add #[forbid(unsafe_op_in_unsafe_fn)] in stdlib
This also adds an additional `unsafe` block to address compiler errors.
2024-07-16 16:04:02 -07:00
Nicholas Nethercote
7f0ccfe69d Adjust some comments on individual use declarations.
When we do the big `use` reformatting there are a tiny number of cases
where rustfmt moves a comment from one `use` item to another in an
undesirable way. This commit pre-emptively rearranges things to prevent
this from happening.
2024-07-17 08:05:39 +10:00
Nicholas Nethercote
75b6ec9800 Avoid comments that describe multiple use items.
There are some comments describing multiple subsequent `use` items. When
the big `use` reformatting happens some of these `use` items will be
reordered, possibly moving them away from the comment. With this
additional level of formatting it's not really feasible to have comments
of this type. This commit removes them in various ways:

- merging separate `use` items when appropriate;

- inserting blank lines between the comment and the first `use` item;

- outright deletion (for comments that are relatively low-value);

- adding a separate "top-level" comment.

We also entirely skip formatting for four library files that contain
nothing but `pub use` re-exports, where reordering would be painful.
2024-07-17 08:02:46 +10:00
Nicholas Nethercote
d9fde2504a Merge some core::iter entries. 2024-07-17 08:02:46 +10:00
bors
7d356ebde3 Auto merge of #127831 - tgross35:rollup-c0j9n7b, r=tgross35
Rollup of 7 pull requests

Successful merges:

 - #124033 (Sync ar_archive_writer to LLVM 18.1.3)
 - #126699 (Delegation: support coercion for target expression)
 - #126762 (Deny keyword lifetimes pre-expansion)
 - #126967 (Promote the `wasm32-wasip2` target to Tier 2)
 - #127390 (Migrate `raw-dylib-inline-cross-dylib` and `raw-dylib-custom-dlltool` `run-make` tests to rmake)
 - #127501 (Invert infer `error_reporting` mod struture)
 - #127816 (Update method name to reflect changes to its internals)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-16 21:46:24 +00:00
Trevor Gross
7d534dd4eb
Rollup merge of #127816 - oli-obk:misnomer, r=compiler-errors
Update method name to reflect changes to its internals

forgot to do this in https://github.com/rust-lang/rust/pull/127431
2024-07-16 16:15:17 -05:00
Trevor Gross
059222ddc9
Rollup merge of #127501 - compiler-errors:invert-infer-error-mod-struture, r=lcnr
Invert infer `error_reporting` mod struture

Parallel change to #127493, which moves `rustc_infer::infer::error_reporting` to `rustc_infer::error_reporting::infer`. After this, we should just be able to merge this into `rustc_trait_selection::error_reporting::infer`, and pull down `TypeErrCtxt` into that crate. 👍

r? lcnr
2024-07-16 16:15:16 -05:00
Trevor Gross
d18a741569
Rollup merge of #127390 - Oneirical:rough-testimation, r=jieyouxu
Migrate `raw-dylib-inline-cross-dylib` and `raw-dylib-custom-dlltool` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Please try:

try-job: i686-mingw
2024-07-16 16:15:16 -05:00
Trevor Gross
4e4fa7eb37
Rollup merge of #126967 - alexcrichton:wasm32-wasip2-tier-2, r=Mark-Simulacrum
Promote the `wasm32-wasip2` target to Tier 2

This commit promotes the `wasm32-wasip2` Rust target to tier 2 as proposed in rust-lang/compiler-team#760. There are two major changes in this PR:

1. The `dist-various-2` container, which already produces the other WASI targets, now has an extra target added for `wasm32-wasip2`.
2. A new `wasm-component-ld` binary is added to all host toolchains when LLD is enabled. This is the linker used for the `wasm32-wasip2` target.

This new linker is added for all host toolchains to ensure that all host toolchains can produce the `wasm32-wasip2` target. This is similar to how `rust-lld` was originally included for all host toolchains to be able to produce WebAssembly output when the targets were first added. The new linker is developed [here][wasm-component-ld] and is pulled in via a crates.io-based dependency to the tree here.

[wasm-component-ld]: https://github.com/bytecodealliance/wasm-component-ld
2024-07-16 16:15:15 -05:00
Trevor Gross
9833e21c5d
Rollup merge of #126762 - compiler-errors:kw-lt, r=michaelwoerister
Deny keyword lifetimes pre-expansion

https://github.com/rust-lang/rust/pull/126452#issuecomment-2179464266

> Secondly, we confirmed that we're OK with moving the validation of keywords in lifetimes to pre-expansion from post-expansion. We similarly consider this a bug fix. While the breakage of the convenience feature of the with_locals crate that relies on this is unfortunate, and we wish we had not overlooked this earlier for that reason, we're fortunate that the breakage is contained to only one crate, and we're going to accept this breakage as the extra complexity we'd need to carry in the compiler to work around this isn't deemed worth it.

T-lang considers it to be a bugfix to deny `'keyword` lifetimes in the parser, rather than during AST validation that only happens post-expansion. This has one breakage: https://github.com/rust-lang/rust/pull/126452#issuecomment-2171654756

This probably should get lang FCP'd just for consistency.
2024-07-16 16:15:15 -05:00
Trevor Gross
36ea06827b
Rollup merge of #126699 - Bryanskiy:delegation-coercion, r=compiler-errors
Delegation: support coercion for target expression

(solves https://github.com/rust-lang/rust/issues/118212#issuecomment-2160723092)

The implementation consist of 2 parts. Firstly, method call is generated instead of fully qualified call in AST->HIR lowering if there were no generic arguments or `Qpath` were provided. These restrictions are imposed due to the loss of information after desugaring. For example in

```rust
trait Trait {
  fn foo(&self) {}
}

reuse <u8 as Trait>::foo;
```

We would like to generate such a code:

```rust
fn foo<u8: Trait>(x: &u8) {
  x.foo(x)
}
```

however, the signature is inherited during HIR analysis where `u8` was discarded.

Then, we probe the single pre-resolved method.

P.S In the future, we would like to avoid restrictions on the callee path by `Self` autoref/autoderef in fully qualified calls, but at the moment it didn't work out.

r? `@petrochenkov`
2024-07-16 16:15:14 -05:00
Trevor Gross
63f239c89f
Rollup merge of #124033 - bjorn3:ar_archive_writer_0_3_0, r=davidtwco
Sync ar_archive_writer to LLVM 18.1.3

From LLVM 15.0.0-rc3. This adds support for COFF archives containing Arm64EC object files and has various fixes for AIX big archive files.
2024-07-16 16:15:13 -05:00
Jubilee
249905780f
std: unwrapped unsafe is VERBOTEN!
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-07-16 12:51:14 -07:00
Oneirical
ea2b699b94 build_native_static_lib with llvm_ar for run_make_support 2024-07-16 15:34:04 -04:00
Oneirical
3b495bb60b rewrite prune-link-args to rmake format 2024-07-16 15:33:26 -04:00
Oneirical
b55fa8f757 rewrite dump-mono-stats to rmake format 2024-07-16 15:33:26 -04:00
Oneirical
9ce62297fa rewrite compiler-lookup-paths to rmake 2024-07-16 15:33:26 -04:00
bors
032be6f7bb Auto merge of #126484 - Oneirical:test-in-peace, r=jieyouxu,kobzol
Migrate `std-core-cycle`, `obey-crate-type-flag`, `mixing-libs` and `issue-18943` `run-make` tests to `rmake.rs`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-apple-1
try-job: x86_64-msvc
try-job: aarch64-gnu
2024-07-16 19:25:51 +00:00
bors
16b569057e Auto merge of #127819 - matthiaskrgr:rollup-djdffkl, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #127669 (Fix the issue of invalid suggestion for a reference of iterator)
 - #127707 (match lowering: Use an iterator to find `expand_until`)
 - #127730 (Fix and enforce `unsafe_op_in_unsafe_fn` in compiler)
 - #127789 (delete #![allow(unsafe_op_in_unsafe_fn)] in teeos)
 - #127805 (run-make-support: update gimli to 0.31.0)
 - #127808 (Make ErrorGuaranteed discoverable outside types, consts, and lifetimes)
 - #127817 (Fix a bunch of sites that were walking instead of visiting, making it impossible for visitor impls to look at these values)
 - #127818 (Various ast validation simplifications)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-16 16:14:47 +00:00
Matthias Krüger
ab4cc440dd
Rollup merge of #127818 - oli-obk:ast_validation_simplifications, r=petrochenkov
Various ast validation simplifications

Changes pulled out of https://github.com/rust-lang/rust/pull/127524

These are needed to make ast validation a mutable visitor, as we can't keep immutable references to the AST around in that case. But I think they are simplifying things in general and can stand on their own
2024-07-16 18:09:14 +02:00
Matthias Krüger
862852fd33
Rollup merge of #127817 - oli-obk:mut_visitor_fix, r=petrochenkov
Fix a bunch of sites that were walking instead of visiting, making it impossible for visitor impls to look at these values

This doesn't affects anything right now, but a `MutVisitor` impl could be surprised by this.

The reason this doesn't affect anything is that no one overrrides `visit_lifetime` or `visit_param_bounds` currently.
2024-07-16 18:09:13 +02:00
Matthias Krüger
8fd1df8c5f
Rollup merge of #127808 - oli-obk:tainting_visitors2, r=lcnr,nnethercote
Make ErrorGuaranteed discoverable outside types, consts, and lifetimes

types like `PatKind` could contain `ErrorGuaranteed`, but not return them via `tainted_by_errors` or `error_reported` (see https://github.com/rust-lang/rust/pull/127687#discussion_r1679027883). Now this happens, but it's a bit fragile as you can see with the `TypeSuperVisitable for Ty` impl.

We will catch any problems around Ty, Region or Const at runtime with an assert, and everything using derives will not have such issues, as it will just invoke the `TypeVisitable for ErrorGuaranteed` impl
2024-07-16 18:09:12 +02:00
Matthias Krüger
2876b1bb88
Rollup merge of #127805 - Mrmaxmeier:run-make-bump-gimli, r=jieyouxu
run-make-support: update gimli to 0.31.0

This version bump is required for the tests in #126985 as suggested [here](https://github.com/rust-lang/rust/pull/126985#issuecomment-2196745112).

r​? tgross35
(^ that didn't work. cc `@tgross35)`

try-job: x86_64-msvc
try-job: x86_64-mingw
try-job: aarch64-apple
try-job: test-various
try-job: armhf-gnu
try-job: dist-x86_64-linux
2024-07-16 18:09:11 +02:00
Matthias Krüger
08809eb746
Rollup merge of #127789 - Sword-Destiny:master, r=petrochenkov
delete #![allow(unsafe_op_in_unsafe_fn)] in teeos

deny unsafe_op_in_unsafe_fn for teeos
2024-07-16 18:09:11 +02:00
Matthias Krüger
73028fe483
Rollup merge of #127730 - compiler-errors:ed-2024-unsafe, r=petrochenkov
Fix and enforce `unsafe_op_in_unsafe_fn` in compiler

In preparation for edition 2024, this PR previews the fallout of enabling the `unsafe_op_in_unsafe_fn` lint in the compiler, since it's defaulting to warn in the new edition (#112038).

The major annoyance comes primarily from the `rustc_codegen_llvm` module, where there's a ton of unsafe calls. I tended to wrap individual calls to unsafe fns in `unsafe {}`, but there a handful of places I chose to just wrap several calls in an `unsafe {}` block just because it would've been excessive to wrap each call individually.

This doesn't enable the lint for the standard library, since I'm not totally certain what T-libs prefers w/ this lint.
2024-07-16 18:09:10 +02:00
Matthias Krüger
7409a5281d
Rollup merge of #127707 - Zalathar:expand-until, r=Nadrieril
match lowering: Use an iterator to find `expand_until`

A small cleanup that I noticed while looking at #127164.

This makes it easier to see that the split point is always the index after the found item, or the whole list if no stopping point was found.

r? `@Nadrieril`
2024-07-16 18:09:09 +02:00
Matthias Krüger
5ee45330da
Rollup merge of #127669 - chenyukang:yukang-fix-deref-127590, r=nnethercote
Fix the issue of invalid suggestion for a reference of iterator

Fixes #127590
2024-07-16 18:09:08 +02:00
Michael Goulet
d0a1851ec2 Deny keyword lifetimes pre-expansion 2024-07-16 12:06:25 -04:00
Oli Scherer
117ff0a4fd Fix a bunch of sites that were walking instead of visiting, making it impossible for visitor impls to look at these values 2024-07-16 15:50:36 +00:00
Oli Scherer
d9f9592924 Remove a boilerplaty abstraction 2024-07-16 15:46:45 +00:00
Oli Scherer
b879e29864 Remove a needless borrow 2024-07-16 15:46:45 +00:00
Oli Scherer
9a4c1058fa Just store a span instead of the whole item 2024-07-16 15:44:17 +00:00
Oli Scherer
6ce78bea03 Update method name to reflect changes to its internals 2024-07-16 15:34:35 +00:00
Bryanskiy
7ee97f93da Delegation: support coercion for target expression 2024-07-16 18:03:15 +03:00
Oli Scherer
53f7f8ce5c Remove an unnecessary impl 2024-07-16 14:15:44 +00:00