Commit graph

286548 commits

Author SHA1 Message Date
Nicholas Nethercote
400e8e5dc8 Fix attribute printing in an error.
The current code assumes that the attribute is just an identifier, and
so misprints paths.
2025-04-17 09:50:52 +10:00
Nicholas Nethercote
4be670f89b Warnings-as-errors in check-builtin-attr-ice.rs.
This adds two new warnings, both of which print the attribute
incorrectly as `#[]`. The next commit will fix this.
2025-04-17 09:50:52 +10:00
bors
78f2104e33 Auto merge of #139912 - matthiaskrgr:rollup-va0rqvk, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #139647 (Add unstable parsing of `--extern foo::bar=libbar.rlib` command line options)
 - #139823 (Fix some bootstrap papercuts)
 - #139867 (Fix some tidy paper cuts)
 - #139871 (Fix wrong "move keyword" suggestion for async gen block)
 - #139876 (Make CodeStats' type_sizes public)
 - #139880 (Don't compute name of associated item if it's an RPITIT)
 - #139884 (Update books)
 - #139886 (`borrowck_graphviz_*` attribute tweaks)
 - #139893 (Add test for issue 125668)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-16 18:58:17 +00:00
bors
c6aad02ddb Auto merge of #139914 - GuillaumeGomez:update-stdarch, r=Amanieu
Update stdarch submodule

https://github.com/rust-lang/stdarch/pull/1768 is needed to unblock the `cg_gcc` current sync so this PR updates the `stdarch` submodule.

cc `@antoyo`
r? `@Amanieu`
2025-04-16 15:30:36 +00:00
Guillaume Gomez
299877e280 Update stdarch submodule 2025-04-16 14:52:08 +02:00
Matthias Krüger
0039c7d7bf
Rollup merge of #139893 - reddevilmidzy:add-test, r=SparrowLii
Add test for issue 125668

closes: #125668

The issue stemmed from improper handling of const {} blocks used in array length expressions. As of rustc 1.80.0-nightly (804421dff 2024-06-07), this ICE no longer occurs and the code compiles successfully 😀
2025-04-16 13:45:32 +02:00
Matthias Krüger
e96b999bd1
Rollup merge of #139886 - nnethercote:graphviz_borrowck, r=compiler-errors
`borrowck_graphviz_*` attribute tweaks

A couple of small fixes to out-of-date things.

r? ```@davidtwco```
2025-04-16 13:45:32 +02:00
Matthias Krüger
1bde68e26e
Rollup merge of #139884 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

1 commits in 45f05367360f033f89235eacbbb54e8d73ce6b70..d33916341d480caede1d0ae57cbeae23aab23e88
2025-04-08 18:24:27 UTC to 2025-04-08 18:24:27 UTC

- Ch01+ch02 after tech review (rust-lang/book#4329)

## rust-lang/edition-guide

2 commits in 1e27e5e6d5133ae4612f5cc195c15fc8d51b1c9c..467f45637b73ec6aa70fb36bc3054bb50b8967ea
2025-04-15 19:49:59 UTC to 2025-04-11 15:27:31 UTC

- fix grammar errors (rust-lang/edition-guide#374)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-lang/edition-guide#375)

## rust-lang/nomicon

2 commits in b4448fa406a6dccde62d1e2f34f70fc51814cdcc..0c10c30cc54736c5c194ce98c50e2de84eeb6e79
2025-04-09 01:54:42 UTC to 2025-04-07 20:22:31 UTC

- Remove double wording in opaque type chapter (rust-lang/nomicon#487)
- remove `rust-intrinsic` ABI (rust-lang/nomicon#485)

## rust-lang/reference

6 commits in 46435cd4eba11b66acaa42c01da5c80ad88aee4b..3340922df189bddcbaad17dc3927d51a76bcd5ed
2025-04-15 19:03:24 UTC to 2025-04-10 01:56:25 UTC

- Add a new grammar renderer (rust-lang/reference#1787)
- Misc. spelling fixes (rust-lang/reference#1785)
- Fix std::ops links in range-expr (rust-lang/reference#1786)
- traits.md: remove unusual formatting (rust-lang/reference#1784)
- doc: add missing space (rust-lang/reference#1782)
- spelling fix, Discrimants -> Discriminants (rust-lang/reference#1783)
2025-04-16 13:45:31 +02:00
Matthias Krüger
ec6bdda983
Rollup merge of #139880 - compiler-errors:rpitit-nameless, r=nnethercote
Don't compute name of associated item if it's an RPITIT

Use `Option::then` in favor of `Option::then_some` to not compute `AssocItem::name` if it fails the condition. Alternatively, I'd be open to changing this just to an `if`.

Fixes https://github.com/rust-lang/rust/issues/139873

r? ```@nnethercote```
2025-04-16 13:45:30 +02:00
Matthias Krüger
b3284adb54
Rollup merge of #139876 - blyxyas:write_type_sizes, r=nnethercote
Make CodeStats' type_sizes public

Add another way to get type sizes in CodeStats. I find it weird that the only way to get this information in block for all types is via printing directly to stdout. So this PR adds that flexibility.
2025-04-16 13:45:30 +02:00
Matthias Krüger
a1de2a2d05
Rollup merge of #139871 - GuillaumeGomez:async-gen-move, r=compiler-errors
Fix wrong "move keyword" suggestion for async gen block

Fixes #139839.

It was just missing a string comparison with `async gen`.
2025-04-16 13:45:29 +02:00
Matthias Krüger
b65e6b7c40
Rollup merge of #139867 - WaffleLapkin:tidypaper, r=jieyouxu
Fix some tidy paper cuts

The main thing this fixes is that currently, if you run `x t tidy` it will format ~6K files, even though it's supposed to format only modified files (whatever this is a useful optimization or not is besides the point). The problem is that `x t tidy` never writes the `rustfmt` stamp, so it always assumes `rustfmt` that was last used is outdated and we need to recheck everything. This PR fixes it by actually writing the stamp.

There are also some minor tweaks to comments/diagnostics. cc ```@Kobzol``` this probably conflicts with #138591. I didn't fix anything, just tried to document better the status quo.

r? ```@jieyouxu```
2025-04-16 13:45:29 +02:00
Matthias Krüger
f7b6f15298
Rollup merge of #139823 - WaffleLapkin:bootpaper, r=jieyouxu
Fix some bootstrap papercuts

... related to jj and my `./build` symlink setup[^1].

I'm not sure if these are good solutions, but they seem to work. See commits for a bit more info.

r? ``@jieyouxu``

[^1]: see #139804
2025-04-16 13:45:28 +02:00
Matthias Krüger
723ef24e27
Rollup merge of #139647 - eholk:package-namespace, r=fmease
Add unstable parsing of `--extern foo::bar=libbar.rlib` command line options

This is a tiny step towards implementing the rustc side of support for implementing packages as optional namespaces (#122349). We add support for parsing command line options like `--extern foo::bar=libbar.rlib` when the `-Z namespaced-crates` option is present.

We don't do anything further with them. The next step is to plumb this down to the name resolver.

This PR also generally refactors the extern argument parsing code and adds some unit tests to make it clear what forms should be accepted with and without the flag.

cc ```@epage``` ```@ehuss```
2025-04-16 13:45:27 +02:00
bors
afa859f812 Auto merge of #136926 - wesleywiser:stabilize_dwarf-version, r=petrochenkov
Stabilize `-Zdwarf-version` as `-Cdwarf-version`

I propose stabilizing `-Zdwarf-version` as `-Cdwarf-version`. This PR adds a new `-Cdwarf-version` flag, leaving the unstable `-Z` flag as is to ease the transition period. The `-Z` flag will be removed in the future.

# `-Zdwarf-version` stabilization report

## What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?

No RFC/MCP, this flag was added in https://github.com/rust-lang/rust/pull/98350 and was not deemed large enough to require additional process.

The tracking issue for this feature is #103057.

## What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

None that has been extensively debated but there are a few questions that could have been chosen differently:

1. What should the flag name be?
  The current flag name is very specific to DWARF. Other debuginfo formats exist (msvc's CodeView format or https://en.wikipedia.org/wiki/Stabs) so we could have chosen to generalize the flag name (`-{C,Z} debuginfo-version=dwarf-5` for example). While this would extend cleanly to support formats other than DWARF, there are some downsides to this design. Neither CodeView nor Stabs have specification or format versions so it's not clear what values would be supported beyond `dwarf-{2,3,4,5}` or `codeview`. We would also need to take care to ensure the name does not lead users to think they can pick a format other than one supported by the target. For instance, what would `--target x86_64-pc-windows-msvc -Cdebuginfo-version=dwarf-5` do?

2. What is the behavior when flag is used on targets that do not support DWARF?
  Currently, passing `-{C,Z} dwarf-version` on targets like `*-windows-msvc` does not do anything. It may be preferable to emit a warning alerting the user that the flag has no effect on the target platform. Alternatively, we could emit an error but this could be annoying since it would require the use of target specific RUSTFLAGS to use the flag correctly (and there isn't a way to target "any platform that uses DWARF" using cfgs).

3. Does the precompiled standard library potentially using a different version of DWARF a problem?
  I don't believe this is an issue as debuggers (and other such tools) already must deal with the possibility that an application uses different DWARF versions across its statically or dynamically linked libraries.

## Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those.

No extensions per se, although future DWARF versions could be considered as such. At present, we validate the requested DWARF version is between 2 and 5 (inclusive) so new DWARF versions will not automatically be supported until the validation logic is adjusted.

## Summarize the major parts of the implementation and provide links into the code (or to PRs)

- Targets define their preferred or default DWARF version: 34a5ea911c/compiler/rustc_target/src/spec/mod.rs (L2369)
- We use the target default but this can be overriden by `-{C,Z} dwarf-version` 34a5ea911c/compiler/rustc_session/src/session.rs (L738)
- The flag is validated 34a5ea911c/compiler/rustc_session/src/session.rs (L1253-L1258)
- When debuginfo is generated, we tell LLVM to use the requested value or the target default 34a5ea911c/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs (L106)

## Summarize existing test coverage of this feature

- Test that we actually generate the appropriate DWARF version
  - https://github.com/rust-lang/rust/blob/master/tests/assembly/dwarf5.rs
  - https://github.com/rust-lang/rust/blob/master/tests/assembly/dwarf4.rs
- Test that LTO with different DWARF versions picks the highest version
  - https://github.com/rust-lang/rust/blob/master/tests/assembly/dwarf-mixed-versions-lto.rs
- Test DWARF versions 2-5 are valid while 0, 1 and 6 report an error
  - https://github.com/rust-lang/rust/blob/master/tests/ui/debuginfo/dwarf-versions.rs
- Ensure LLVM does not report a warning when LTO'ing different DWARF versions together
  - https://github.com/rust-lang/rust/blob/master/tests/ui/lto/dwarf-mixed-versions-lto.rs

## Has a call-for-testing period been conducted? If so, what feedback was received?

No call-for-testing has been conducted but Rust for Linux has been using this flag without issue.

## What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?

All reported bugs have been resolved.

## Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization

- Initial implementation in https://github.com/rust-lang/rust/pull/98350 by `@pcwalton`
- Stop emitting `.debug_pubnames` and `.debug_pubtypes` when using DWARF 5 in https://github.com/rust-lang/rust/pull/117962 by `@weihanglo.`
- Refactoring & cleanups (#135739), fix LLVM warning on LTO with different DWARF versions (#136659) and argument validation (#136746) by `@wesleywiser`

## What FIXMEs are still in the code for that feature and why is it ok to leave them there?

No FIXMEs related to this feature.

## What static checks are done that are needed to prevent undefined behavior?

This feature cannot cause undefined behavior.
We ensure the DWARF version is one of the supported values [here](34a5ea911c/compiler/rustc_session/src/session.rs (L1255-L1257)).

## In what way does this feature interact with the reference/specification, and are those edits prepared?

No changes to reference/spec, unstable rustc docs are moved to the stable book as part of the stabilization PR.

## Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries?

No.

## What other unstable features may be exposed by this feature?

`-Zembed-source` requires use of DWARF 5 extensions but has its own feature gate.

## What is tooling support like for this feature, w.r.t rustdoc, clippy, rust-analzyer, rustfmt, etc.?

No support needed for rustdoc, clippy, rust-analyzer, rustfmt or rustup.

Cargo could expose this as an option in build profiles but I would expect the decision as to what version should be used would be made for the entire crate graph at build time rather than by individual package authors.

cc-rs has support for detecting the presence of `-{C,Z} dwarf-version` in `RUSTFLAGS` and providing the corresponding flag to Clang/gcc (https://github.com/rust-lang/cc-rs/pull/1395).

---

Closes #103057
2025-04-16 06:38:00 +00:00
bors
efb1e3d676 Auto merge of #139768 - compiler-errors:split-fold, r=lcnr
Split `TypeFolder` and `FallibleTypeFolder` atwain

Right now there is a coherence problem with `TypeFolder` and `FallibleTypeFolder`. Namely, it's impossible to implement a `FallibleTypeFolder` that is generic over interner, b/c it has a *downstream* conflict with the blanket impl:

```
impl<I, F> FallibleTypeFolder<I> for F where F: TypeFolder<I> {}
```

Because downstream crates may implement `TypeFolder<SomeLocalInterner>` for the fallible type folder.

This PR removes the relationship between `FallibleTypeFolder` and `TypeFolder`; it leads to *modest* code duplication, but otherwise does not affect perf and really doesn't matter in general.
2025-04-16 01:46:01 +00:00
blyxyas
6999305926 Make CodeStat's type sizes a public field 2025-04-16 02:10:53 +02:00
Nicholas Nethercote
62882f355e Improve borrowck_graphviz_* documentation.
In particular, `borrowck_graphviz_preflow` no longer exists.
2025-04-16 08:57:15 +10:00
Nicholas Nethercote
766cd3a583 Remove support for #[rustc_mir(borrowck_graphviz_format="gen_kill")].
Because it's equivalent to `#[rustc_mir(borrowck_graphviz_format)]`. It
used to be distinct, but the distinction was removed in
3233fb18a8.
2025-04-16 08:35:34 +10:00
bors
cacb9eed38 Auto merge of #139878 - petrochenkov:revllvmclean2, r=compiler-errors
Revert "Deduplicate template parameter creation"

This reverts commit 6adc2c1fd6.

More precise subset of https://github.com/rust-lang/rust/pull/139874.
2025-04-15 22:35:30 +00:00
Eric Huss
ea1b230170 Update Cargo.lock for rustbook 2025-04-15 15:20:27 -07:00
rustbot
f3f53d2183 Update books 2025-04-15 22:48:28 +02:00
Eric Holk
f35c85f72f
Add unstable foo::bar extern command line arguments
Also refactors some of the crate name parsing code and adds unit tests

Issue #122349

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2025-04-15 13:04:50 -07:00
Waffle Lapkin
89b4eba49c
normalize canonical and non-canonical paths in compiletest
Apparently there are tests that print canonical paths *and* tests which
print non-canonical paths.

An example of the latter is `tests/ui/type_length_limit.rs`.
2025-04-15 21:55:41 +02:00
Waffle Lapkin
90aec13674
commit rustfmt stump in x t tidy even on check
If checking succeeded, it's equivalent to successfully formatting.
2025-04-15 21:51:33 +02:00
Guillaume Gomez
2020adba86 Fix wrong suggestion for async gen block and add regression ui test for #139839 2025-04-15 21:48:36 +02:00
bors
38c560ae68 Auto merge of #139881 - matthiaskrgr:rollup-7x6zcrc, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138455 (`librustdoc`: more `impl fmt::Display`)
 - #139818 (Normalize ADT field in `find_tails_for_unsizing`)
 - #139819 (Use `rust-cache` to speed-up `citool` compilation)
 - #139824 (Remove safe remove)
 - #139848 ( Reduce kw::Empty usage, part 5)
 - #139859 (CI: rename MacOS runner)
 - #139877 (Add warning comment to `Take::get_ref` and `Chain::get_ref`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-15 19:21:06 +00:00
Matthias Krüger
ebaef469b0
Rollup merge of #139877 - joshtriplett:take-care, r=dtolnay
Add warning comment to `Take::get_ref` and `Chain::get_ref`

The methods `Take::get_mut` and `Chain::get_mut` include comments
warning about modifying the I/O state of the underlying reader. However,
many readers (e.g. `File`) allow I/O using a shared reference (e.g.
`&File`). So, add the same caveat to the `get_ref` methods.
2025-04-15 21:16:06 +02:00
Matthias Krüger
2e363ce1df
Rollup merge of #139859 - marcoieni:rename-macos-runner, r=Kobzol
CI: rename MacOS runner

r? ``@Kobzol``
2025-04-15 21:16:06 +02:00
Matthias Krüger
2144c940ce
Rollup merge of #139848 - nnethercote:kw-Empty-5, r=compiler-errors
Reduce kw::Empty usage, part 5

Another step towards https://github.com/rust-lang/rust/issues/137978.

r? `@davidtwco`
2025-04-15 21:16:05 +02:00
Matthias Krüger
8bb01ff117
Rollup merge of #139824 - ChrisDenton:non-canonical, r=petrochenkov
Remove safe remove

`safe_remove_dir_all` and `safe_remove_file` use `canonicalize` to workaround a `MAX_PATH` limitation. However, this has not been needed in a long time, since the standard library handles this situation itself.

I've kept `safe_remove_file` (without `canonicalize`) because it also returns `Ok` if the file is not found. While, `safe_remove_file` is only used twice, matching on the error kind is sufficiently verbose that maybe it's still worth it?
2025-04-15 21:16:05 +02:00
Matthias Krüger
b3e55a5c84
Rollup merge of #139819 - Kobzol:rust-cache, r=marcoieni
Use `rust-cache` to speed-up `citool` compilation

Alternative to https://github.com/rust-lang/rust/pull/139678.

r? ``@marcoieni``
2025-04-15 21:16:04 +02:00
Matthias Krüger
27f1f4d27b
Rollup merge of #139818 - compiler-errors:normalize-tails, r=oli-obk
Normalize ADT field in `find_tails_for_unsizing`

See the comment inline and in the test.

TL;DR is that we're getting getting a type from a `type_of` query and then matching on it structurally in codegen, so we're obligated to normalize it. The fact that this wasn't triggered earlier is that all of the types that have `CoerceUnsized` implementations never encounter aliases when peeling the ADT down to their base reference/ptr type.

**NOTE**: I also renamed some things and reorganized the function a bit.

Fixes #139812
Fixes #74451, which I didn't think was interesting enough to add another test.

r? oli-obk
2025-04-15 21:16:03 +02:00
Matthias Krüger
ca0b7f4dcf
Rollup merge of #138455 - yotamofek:pr/rustdoc/more-impl-display, r=GuillaumeGomez
`librustdoc`: more `impl fmt::Display`

Continuation of #137425 and #136828 and #136784
Working towards getting rid of the `write_str` helper
r? `@GuillaumeGomez` (if you want!)
2025-04-15 21:16:03 +02:00
Michael Goulet
11e5987d01 Don't compute name of associated item if it's an RPITIT 2025-04-15 18:46:26 +00:00
Michael Goulet
c774adcbb5 Split TypeFolder and FallibleTypeFolder 2025-04-15 18:30:35 +00:00
Vadim Petrochenkov
38f7060a73 Revert "Deduplicate template parameter creation"
This reverts commit 6adc2c1fd6.
2025-04-15 21:00:11 +03:00
Josh Triplett
043c5ff982 Add warning comment to Take::get_ref and Chain::get_ref
The methods `Take::get_mut` and `Chain::get_mut` include comments
warning about modifying the I/O state of the underlying reader. However,
many readers (e.g. `File`) allow I/O using a shared reference (e.g.
`&File`). So, add the same caveat to the `get_ref` methods.
2025-04-15 10:54:08 -07:00
bors
414da5b63d Auto merge of #138906 - thaliaarchi:unsupported-test-exe, r=bjorn3
Reject test executables when not supported by target

Currently, compiling tests for SOLID produces an ICE, because SOLID does not support executables.

See https://github.com/rust-lang/rust/issues/138047
2025-04-15 16:05:15 +00:00
reddevilmidzy
812095031b Add test for issue 125668 2025-04-15 23:51:10 +09:00
Waffle Lapkin
8934ac5759
add a comment for code that isn't 2025-04-15 15:02:05 +02:00
Waffle Lapkin
dda4d7bc44
slightly correct comments and diagnostics about checking modifications
I feel like they are still wrong, but maybe less so .-.

The `info:` was unhelpful -- we only use upstream in CI nowdays.
2025-04-15 15:02:05 +02:00
Waffle Lapkin
52f4b16075
use helper function instead of writing rustfmt stamp by hand 2025-04-15 15:02:05 +02:00
Waffle Lapkin
502b630cd1
tidy: don't crush on non-existent submodules 2025-04-15 15:01:56 +02:00
bors
40dacd50b7 Auto merge of #139632 - Darksonn:cfi-fmt, r=m-ou-se
cfi: do not transmute function pointers in formatting code

Follow-up to #115954.
Addresses #115199 point 2.
Related to #128728.
Discussion [on the LKML](https://lore.kernel.org/all/20250410115420.366349-1-panikiel@google.com/).

cc `@maurer` `@rcvalle` `@RalfJung`
2025-04-15 11:11:31 +00:00
MarcoIeni
73065b9484
CI: rename MacOS runner 2025-04-15 12:28:32 +02:00
Jakub Beránek
c49b0bdb1a
Use rust-cache to speed-up citool compilation 2025-04-15 10:04:25 +02:00
bors
f433fa46b0 Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalathar
Rollup of 17 pull requests

Successful merges:

 - #138374 (Enable contracts for const functions)
 - #138380 (ci: add runners for vanilla LLVM 20)
 - #138393 (Allow const patterns of matches to contain pattern types)
 - #139517 (std: sys: process: uefi: Use NULL stdin by default)
 - #139554 (std: add Output::exit_ok)
 - #139660 (compiletest: Add an experimental new executor to replace libtest)
 - #139669 (Overhaul `AssocItem`)
 - #139671 (Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file})
 - #139750 (std/thread: Use default stack size from menuconfig for NuttX)
 - #139772 (Remove `hir::Map`)
 - #139785 (Let CStrings be either 1 or 2 byte aligned.)
 - #139789 (do not unnecessarily leak auto traits in item bounds)
 - #139791 (drop global where-bounds before merging candidates)
 - #139798 (normalize: prefer `ParamEnv` over `AliasBound` candidates)
 - #139822 (Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix)
 - #139833 (Fix some HIR pretty-printing problems)
 - #139836 (Basic tests of MPMC receiver cloning)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-15 08:02:23 +00:00
Waffle Lapkin
6c441cc7a5
canonicalize test build dir before normalizing it
Fix fixes failures of the following tests when build directory is a
symlink:
- `tests/ui/error-codes/E{0464,0523}.rs`
- `tests/ui/crate-loading/crateresolve{1,2}.rs` (those are the same tests)
2025-04-15 09:46:22 +02:00
Waffle Lapkin
1397dabd1e
fix typo 2025-04-15 09:42:30 +02:00