Commit Graph

265682 Commits

Author SHA1 Message Date
Ralf Jung
ed24426824 remove some unnecessary to_owned 2024-09-22 16:50:38 +02:00
Ralf Jung
5dee646aea read, write: move cast-to-usize logic up and deduplicate it 2024-09-22 16:50:37 +02:00
Ralf Jung
fb1193078d further tweak FileDescription comments 2024-09-22 16:50:37 +02:00
tiif
d29be1f90a Pass pointer and len to FileDescription::write and change the type of len in read to usize 2024-09-22 16:50:36 +02:00
tiif
503b6af065 Use &[u8] instead of Vec<u8> and improve docs 2024-09-22 16:50:17 +02:00
tiif
f392648c15 Refactor FileDescription::read/write 2024-09-17 00:37:16 +08:00
bors
583f358e94 Auto merge of #3885 - rust-lang:rustup-2024-09-14, r=RalfJung
Automatic Rustup
2024-09-14 07:07:30 +00:00
The Miri Cronjob Bot
94d49917ad Merge from rustc 2024-09-14 05:06:03 +00:00
Christopher Durham
42a44a04ee
simplify abort_unwind
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2024-09-15 14:27:24 -04:00
Christopher Durham
7e7ccb25b4
add std::panic::abort_unwind 2024-09-14 01:41:00 -04:00
Christopher Durham
de66d3aa2b
add core::panic::abort_unwind 2024-09-14 01:34:05 -04:00
The Miri Cronjob Bot
9bab91f5d4 Preparing for merge from rustc 2024-09-14 04:58:15 +00:00
bors
23b04c0513 Auto merge of #125419 - GuillaumeGomez:add-gcc-to-dist, r=Kobzol
[bootstrap] Add support for building gcc and libgccjit

As `@eholk` summarized below:

> From my understanding, this change would add libgccjit as an optional component to the Rust distribution. This library is licensed under GPLv2 and currently we do not have any other components under that license so it would be a new license, and one that is generally more restrictive than the other licenses we use.

It'll greatly improve the experience for anyone wanting to work on the GCC backend from the compiler.

Should help with https://github.com/rust-lang/rust/issues/124172.
Will unblock #124353.

r? `@Kobzol`
2024-09-14 00:26:04 +00:00
bors
507c05bead Auto merge of #130121 - lolbinarycat:bootstrap-warn-old-upstream-worktree, r=albertlarsan68
bootstrap: handle worktrees in warn_old_master_branch

fixes #130111
2024-09-13 22:02:35 +00:00
bors
0609062a91 Auto merge of #130312 - matthiaskrgr:rollup-ihwsc91, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #129320 (Fix crash when labeling arguments for call_once and friends)
 - #130266 (target: default to the medium code model on LoongArch targets)
 - #130297 (Dataflow cleanups)
 - #130299 (Add set_dcx to ParseSess)
 - #130301 (some fixes for clashing_extern_declarations lint)
 - #130305 (Clippy: consider msrv for const context for const_float_bits_conv)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-13 19:21:37 +00:00
Matthias Krüger
5343fcdf17
Rollup merge of #130305 - tspiteri:clippy-msrv-for-const_float_bits_conv, r=flip1995
Clippy: consider msrv for const context for const_float_bits_conv

When `const_float_bits_conv` was stabilized for 1.83.0, clippy lints started to be triggered in const context ignoring MSRV. This PR makes the lints trigger in const context only when the MSRV meets 1.83.0.

Fixes https://github.com/rust-lang/rust-clippy/issues/13383.
2024-09-13 18:25:47 +02:00
Matthias Krüger
7d36bfa6c0
Rollup merge of #130301 - RalfJung:clashing_extern_declarations, r=compiler-errors
some fixes for clashing_extern_declarations lint

There were two issues with the clashing_extern_declarations lint:
- It would accept non-`repr(C)` structs as compatible with each other by comparing their fields in declaration order, but the fields could have different memory order (and with `-Zrandomize-layout`, this can really happen).
- It would accept two types as compatible if `compare_layouts` returns `true`, but that function actually just compared the *ABI*, not the fully layout -- and all sized structs with more than 2 fields have the same ABI (`Abi::Aggregate`), so this missed a *lot* of cases.

We don't currently have a clear spec for what we *want* to consider "clashing" and what is fine, so I otherwise kept the original logic. I hope to have a t-lang discussion about this at some point. But meanwhile, these changes seem like clear bugfixes.
2024-09-13 18:25:46 +02:00
Matthias Krüger
b0e323549a
Rollup merge of #130299 - vetleras:add_set_dcx, r=compiler-errors
Add set_dcx to ParseSess

After [this](https://github.com/rust-lang/rust/pull/126623) PR was merged, it is no longer possible to inject one's own `Emitter` in the way [described in the Compiler Development Guide](https://rustc-dev-guide.rust-lang.org/rustc-driver-getting-diagnostics.html). The reason is that the `dcx` field in `ParseSess` is no longer public, so it is not possible to update the `dcx` field with a `DiagCtxt` that contains one's own `Emitter` in the `psess_created` callback in `rustc_interface::Config`. The only way I have found to insert my own `DiagCtxt` is by creating an entirely new `ParseSess` and replacing the old one. This is not a good solution as the original `ParseSess` contains fields I would like to keep. (In my case the problem is that I lose the `cfg` and `check-cfg` fields of the original.)

The solution proposed in this PR is to add a `set_dcx` method to `ParseSess`. Per my limited understanding of the rustc codebase this should be fine as `set_dcx` requires a mutable reference to `ParseSess`, which is as far as I know only available in the `psess_created` callback (outside of `rustc_interface::run_compiler`).

If this PR is accepted, I will create a new PR to update the aforementioned example in the Compiler Development Guide.
2024-09-13 18:25:46 +02:00
Matthias Krüger
c5e0f9ae42
Rollup merge of #130297 - nnethercote:dataflow-cleanups, r=cjgillot
Dataflow cleanups

r? `@cjgillot`
2024-09-13 18:25:45 +02:00
Matthias Krüger
778f6fba2b
Rollup merge of #130266 - heiher:loong-medium-cmodel, r=compiler-errors
target: default to the medium code model on LoongArch targets

The Rust LoongArch targets have been using the default LLVM code model so far, which is "small" in LLVM-speak and "normal" in LoongArch-speak. As described in the "Code Model" section of LoongArch ELF psABI spec v20231219 [1], one can only make function calls as far as ±128MiB with the "normal" code model; this is insufficient for very large software containing Rust components that needs to be linked into the big text section, such as Chromium.

Because:

* we do not want to ask users to recompile std if they are to build such software,
* objects compiled with larger code models can be linked with those with smaller code models without problems, and
* the "medium" code model is comparable to the "small"/"normal" one performance-wise (same data access pattern; each function call becomes 2-insn long and indirect, but this may be relaxed back into the direct 1-insn form in a future LLVM version), but is able to perform function calls within ±128GiB,

it is better to just switch the targets to the "medium" code model, which is also "medium" in LLVM-speak.

Relands [2]:  #120661

[1]: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#code-models
[2]: https://github.com/rust-lang/rust/issues/121289#issuecomment-2333687396
2024-09-13 18:25:45 +02:00
Matthias Krüger
24da940631
Rollup merge of #129320 - jder:issue-128848, r=compiler-errors
Fix crash when labeling arguments for call_once and friends

When calling a method on Fn* traits explicitly, argument diagnostics should point at the called method (eg Fn::call_once), not the underlying callee.

This PR makes 3 main changes:

* It uses TupleArguments to detect if the user called a Fn* method directly (`my_fn.call_once(…)`) or implicitly (`my_fn(…)`). If it was explicit, argument diagnostics should point at the call_once method, not the underlying callable.
* The previous state was causing confusion between the two arguments lists (which could be different lengths), causing an out-of-bounds slice indexing in #128848. I added a length assert to capture the requirement in case this regresses or happens in another case.
* Unfortunately, this assert tripped when the required arguments information was not available (`self.get_hir_params_with_generics` was returning an empty Vec), so I've updated that to return None when that information is not available. (cc `@strottos` if you have any comments, since you added this function in #121595) Sorry this causes a bunch of indentation changes, recommend reviewing [ignoring whitespace](https://github.com/rust-lang/rust/pull/129320/files?w=1).)

This is my first rustc PR, so please call out if you'd like this split into more commits (or PRs), style nits, etc. I will add a few comments/questions inline. Thank you!

Fixes #128848
2024-09-13 18:25:44 +02:00
Guillaume Gomez
e7fa03ba5e Remove gcc changes for dist build 2024-09-13 17:14:40 +02:00
bors
20862e4653 Auto merge of #3881 - RalfJung:miri-run, r=RalfJung
./miri run: directly run binary instead of using 'cargo run'

This avoids re-building miri without dev dependencies, so it makes `./miri run` a lot faster if `./miri test` was already executed before.
2024-09-13 15:09:11 +00:00
Ralf Jung
03f14f00bf ./miri run: directly run binary instead of using 'cargo run' 2024-09-13 17:03:37 +02:00
bors
0307e401c2 Auto merge of #130215 - RalfJung:interpret-simd, r=compiler-errors
interpret: simplify SIMD type handling

This is possible as a follow-up to https://github.com/rust-lang/rust/pull/129403
2024-09-13 13:55:22 +00:00
Jesse Rusak
57de75050a When calling a method on Fn* traits explicitly, argument diagnostics should
point at the called method (eg Fn::call_once), not the underlying callee.

Fixes 128848
2024-09-13 09:33:51 -04:00
Ralf Jung
e2bc16c101 interpret: simplify SIMD type handling 2024-09-13 15:26:08 +02:00
Trevor Spiteri
581f1924e3 handle transmutes in const context if msrvs::CONST_FLOAT_BITS_CONV 2024-09-13 13:57:41 +02:00
Trevor Spiteri
d195f80639 Revert "stabilize const_float_bits_conv" for src/tools/clippy/clippy_lints
This reverts the part of commit 19908ff7a3 in
subdirectory src/tools/clippy/clippy_lints.
2024-09-13 13:56:41 +02:00
bors
473ae00839 Auto merge of #130303 - Zalathar:rollup-8vsqdox, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - #130245 (make basic allocation functions track_caller in Miri for nicer backtraces)
 - #130261 (skip target sanity check when it's a `local-rebuild`)
 - #130287 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 9))

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-13 11:27:53 +00:00
bors
d5ad772b44 Auto merge of #3883 - RalfJung:miri-run-dep, r=RalfJung
smoke-test './miri run --dep'

I don't actually know if this works on Windows.^^
2024-09-13 10:13:42 +00:00
Ralf Jung
f362a59c3e some fixes for clashing_extern_declarations lint 2024-09-13 11:51:17 +02:00
Ralf Jung
dd01ee7cd2 smoke-test './miri run --dep' 2024-09-13 11:49:01 +02:00
Stuart Cook
1c23c8ba0c
Rollup merge of #130287 - notriddle:notriddle/issue-d, r=jieyouxu
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 9)

Follow up

* https://github.com/rust-lang/rust/pull/116214
* https://github.com/rust-lang/rust/pull/116432
* https://github.com/rust-lang/rust/pull/116824
* https://github.com/rust-lang/rust/pull/118105
* https://github.com/rust-lang/rust/pull/119561
* https://github.com/rust-lang/rust/pull/123574
* https://github.com/rust-lang/rust/pull/125382
* https://github.com/rust-lang/rust/pull/127671

As always, it's easier to review the commits one at a time. Don't use the Files Changed tab. It's confusing.
2024-09-13 19:38:01 +10:00
Stuart Cook
26bda05938
Rollup merge of #130261 - onur-ozkan:#130242, r=Kobzol
skip target sanity check when it's a `local-rebuild`

Running the stage0 target sanity check on the newly built compiler can result in errors and incorrect assumptions.

Resolves #130242
2024-09-13 19:38:00 +10:00
Stuart Cook
368718961c
Rollup merge of #130245 - RalfJung:miri-alloc-backtrace, r=Amanieu
make basic allocation functions track_caller in Miri for nicer backtraces

This matches what we did with basic pointer and atomic operations.
2024-09-13 19:37:59 +10:00
Vetle Rasmussen
bde1f4dd57 Add set_dcx to ParseSess 2024-09-13 11:15:19 +02:00
bors
5e842953cc Auto merge of #130052 - khuey:clear-dilocation-after-const-emission, r=michaelwoerister
Don't leave debug locations for constants sitting on the builder indefinitely

Because constants are currently emitted *before* the prologue, leaving the debug location on the IRBuilder spills onto other instructions in the prologue and messes up both line numbers as well as the point LLVM chooses to be the prologue end.

Example LLVM IR (irrelevant IR elided):
Before:
```
define internal { i64, i64 } `@_ZN3tmp3Foo18var_return_opt_try17he02116165b0fc08cE(ptr` align 8 %self) !dbg !347 { start:
  %self.dbg.spill = alloca [8 x i8], align 8
  %_0 = alloca [16 x i8], align 8
  %residual.dbg.spill = alloca [0 x i8], align 1
    #dbg_declare(ptr %residual.dbg.spill, !353, !DIExpression(), !357)
  store ptr %self, ptr %self.dbg.spill, align 8, !dbg !357
    #dbg_declare(ptr %self.dbg.spill, !350, !DIExpression(), !358)
```
After:
```
define internal { i64, i64 } `@_ZN3tmp3Foo18var_return_opt_try17h00b17d08874ddd90E(ptr` align 8 %self) !dbg !347 { start:
  %self.dbg.spill = alloca [8 x i8], align 8
  %_0 = alloca [16 x i8], align 8
  %residual.dbg.spill = alloca [0 x i8], align 1
    #dbg_declare(ptr %residual.dbg.spill, !353, !DIExpression(), !357)
  store ptr %self, ptr %self.dbg.spill, align 8
    #dbg_declare(ptr %self.dbg.spill, !350, !DIExpression(), !358)
```
Note in particular how !357 from %residual.dbg.spill's dbg_declare no longer falls through onto the store to %self.dbg.spill. This fixes argument values at entry when the constant is a ZST (e.g. `<Option as Try>::Residual`). This fixes #130003 (but note that it does *not* fix issues with argument values and non-ZST constants, which emit their own stores that have debug info on them, like #128945).

r? `@michaelwoerister`
2024-09-13 08:57:41 +00:00
bors
d0985bb524 Auto merge of #130292 - ehuss:revert-130040, r=onur-ozkan
Revert  #130040 - unify llvm-bitcode-linker, wasm-component-ld and llvm-tools logics

This is a revert of #130040 to fix #130291 which is preventing installing nightly with the llvm-tools component due to a conflict with the `bin/llc` file which exists in both the rustc and llvm-tools components.
2024-09-13 06:33:05 +00:00
Nicholas Nethercote
bb943f93ff Rename FlowState as Domain.
Because that's what it is; no point having a different name for it.
2024-09-13 16:27:24 +10:00
bors
a5efa01895 Auto merge of #107251 - dingxiangfei2009:let-chain-rescope, r=jieyouxu
Rescope temp lifetime in if-let into IfElse with migration lint

Tracking issue #124085

This PR shortens the temporary lifetime to cover only the pattern matching and consequent branch of a `if let`.

At the expression location, means that the lifetime is shortened from previously the deepest enclosing block or statement in Edition 2021. This warrants an Edition change.

Coming with the Edition change, this patch also implements an edition lint to warn about the change and a safe rewrite suggestion to preserve the 2021 semantics in most cases.

Related to #103108.
Related crater runs: https://github.com/rust-lang/rust/pull/129466.
2024-09-13 03:47:30 +00:00
Eric Huss
df8e6c343c Revert "Auto merge of #130040 - onur-ozkan:llvm-tools-with-ci-rustc, r=Kobzol"
This reverts commit adaff5368b, reversing
changes made to 2e8db5e9e3.
2024-09-12 20:18:56 -07:00
bors
d3a8524e80 Auto merge of #129137 - camelid:lazy-def-macro-const, r=BoxyUwU
Fix anon const def-creation when macros are involved

Fixes #128016.

Ever since #125915, some `ast::AnonConst`s turn into `hir::ConstArgKind::Path`s,
which don't have associated `DefId`s. To deal with the fact that we don't have
resolution information in `DefCollector`, we decided to implement a process
where if the anon const *appeared* to be trivial (i.e., `N` or `{ N }`), we
would avoid creating a def for it in `DefCollector`. If later, in AST lowering,
we realized it turned out to be a unit struct literal, or we were lowering it
to something that didn't use `hir::ConstArg`, we'd create its def there.

However, let's say we have a macro `m!()` that expands to a reference to a free
constant `FOO`. If we use `m!()` in the body of an anon const (e.g., `Foo<{ m!() }>`),
then in def collection, it appears to be a nontrivial anon const and we create
a def. But the macro expands to something that looks like a trivial const arg,
but is not, so in AST lowering we "fix" the mistake we assumed def collection
made and create a def for it. This causes a duplicate definition ICE.

The long-term fix for this is to delay the creation of defs for all expression-like
nodes until AST lowering (see #128844 for an incomplete attempt at this). This
would avoid issues like this one that are caused by hacky workarounds. However,
doing this uncovers a pre-existing bug with opaque types that is quite involved
to fix (see #129023).

In the meantime, this PR fixes the bug by delaying def creation for anon consts
whose bodies are macro invocations until after we expand the macro and know
what is inside it. This is accomplished by adding information to create the
anon const's def to the data in `Resolver.invocation_parents`.

r? `@BoxyUwU`
2024-09-13 01:10:51 +00:00
Nicholas Nethercote
55c9f96265 Remove unnecessary Clone/Copy derives from analyses.
No analysis needs `Copy`, and `MaybeBorrowedLocals` is the only analysis
that needs `Clone`. In `locals_live_across_suspend_points` it gets
cloned so it can be used within a `MaybeRequiresStorage`.
2024-09-13 09:58:30 +10:00
bors
adaff5368b Auto merge of #130040 - onur-ozkan:llvm-tools-with-ci-rustc, r=Kobzol
unify `llvm-bitcode-linker`, `wasm-component-ld` and llvm-tools logics

To use the precompiled `ci-rustc` in CI, we need to install `llvm-bitcode-linker` and LLVM tools into ci-rustc's sysroot. Without them some CI pipelines may fail, as shown [here](https://github.com/rust-lang/rust/pull/122709#issuecomment-2334365988).

Blocker for https://github.com/rust-lang/rust/pull/122709
2024-09-12 20:51:46 +00:00
Michael Howell
48c7e444b1 rustdoc: re-bless stderrs after renaming the test case 2024-09-12 13:48:51 -07:00
Michael Howell
061cbae7c9 rustdoc: rename issue-\d+.rs tests to have meaningful names 2024-09-12 13:47:51 -07:00
Michael Howell
9454a89ef0 Add URL and crate_name to test cases 2024-09-12 13:38:24 -07:00
bors
9621058b7b Auto merge of #3880 - RalfJung:sync, r=RalfJung
add non-portable linux pthread initializers to layout sanity check

Also, turns out we can enable all pthread tests on Solarish.
2024-09-12 20:05:57 +00:00
Ralf Jung
b7c7a45b30 enable all pthread tests on Solarish 2024-09-12 22:02:10 +02:00