about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-04-16refactor struct pattern checking to get info for peelingdianne-19/+32
See the previous commit for details. This doesn't yet extract the struct pat's type's ADT def before peeling, but it should now be possible.
2025-04-16refactor path pattern checking to get info for peelingdianne-48/+89
See the doc comment on `ResolvedPat` for more information. This and the next couple commits split resolution apart from checking for path, struct, and tuple struct patterns, in order to find the pattern's type before peeling the scrutinee. This helps us avoid peeling the scrutinee when the pattern could match it. The reason this handles errors from resolution after peeling is for struct and tuple struct patterns: we check their subpatterns even when they fail to resolve, to potentially catch more resolution errors. By doing this after peeling, we're able to use the updated `PatInfo`. I don't know if there's currently any observable difference from using the outdated `PatInfo`, but it could potentially be a source of subtle diagnostic bugs in the future, so I'm opting to peel first.
2025-04-16register `DerefMut` bounds for implicit mutable derefsdianne-15/+38
2025-04-16pattern typing for immutable implicit deref patternsdianne-27/+89
2025-04-16lower implicit deref patterns to THIRdianne-21/+36
Since this uses `pat_adjustments`, I've also tweaked the documentation to mention implicit deref patterns and made sure the pattern migration diagnostic logic accounts for it. I'll adjust `ExprUseVisitor` in a later commit and add some tests there for closure capture inference.
2025-04-16working dupv and dupvonly for fwd modeManuel Drehwald-28/+107
2025-04-16Don't require rigid alias's trait to holdMichael Goulet-1/+0
2025-04-16Remove FIXME that is no longer relevantMichael Goulet-6/+0
2025-04-16Fix replacing supertrait aliases in ReplaceProjectionWithMichael Goulet-68/+135
2025-04-16Add hard error for `extern` without explicit ABIObei Sideg-6/+21
2025-04-16Don't canonicalize crate pathsChris Denton-6/+15
2025-04-16Rollup merge of #139886 - nnethercote:graphviz_borrowck, r=compiler-errorsMatthias Krüger-2/+1
`borrowck_graphviz_*` attribute tweaks A couple of small fixes to out-of-date things. r? ```@davidtwco```
2025-04-16Rollup merge of #139880 - compiler-errors:rpitit-nameless, r=nnethercoteMatthias Krüger-2/+1
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-16Rollup merge of #139876 - blyxyas:write_type_sizes, r=nnethercoteMatthias Krüger-1/+1
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-16Rollup merge of #139871 - GuillaumeGomez:async-gen-move, r=compiler-errorsMatthias Krüger-4/+9
Fix wrong "move keyword" suggestion for async gen block Fixes #139839. It was just missing a string comparison with `async gen`.
2025-04-16Rollup merge of #139647 - eholk:package-namespace, r=fmeaseMatthias Krüger-34/+178
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-16Remove old diagnostic notes for type ascription syntaxZalathar-19/+1
Type ascription syntax was removed in 2023.
2025-04-16fix multiple `#[repr(align(N))]` on functionsFolkert de Vries-1/+2
2025-04-16stepping into impls for norm is unproductivelcnr-8/+13
2025-04-16Auto merge of #136926 - wesleywiser:stabilize_dwarf-version, r=petrochenkovbors-2/+12
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: https://github.com/rust-lang/rust/blob/34a5ea911c56e79bd451c63f04ea2f5023d7d1a3/compiler/rustc_target/src/spec/mod.rs#L2369 - We use the target default but this can be overriden by `-{C,Z} dwarf-version` https://github.com/rust-lang/rust/blob/34a5ea911c56e79bd451c63f04ea2f5023d7d1a3/compiler/rustc_session/src/session.rs#L738 - The flag is validated https://github.com/rust-lang/rust/blob/34a5ea911c56e79bd451c63f04ea2f5023d7d1a3/compiler/rustc_session/src/session.rs#L1253-L1258 - When debuginfo is generated, we tell LLVM to use the requested value or the target default https://github.com/rust-lang/rust/blob/34a5ea911c56e79bd451c63f04ea2f5023d7d1a3/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](https://github.com/rust-lang/rust/blob/34a5ea911c56e79bd451c63f04ea2f5023d7d1a3/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-16Auto merge of #139768 - compiler-errors:split-fold, r=lcnrbors-218/+402
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-16rustc_target: Use "B" shorthand on the RISC-V Android targetTsukasa OI-1/+1
The "B" extension is ratified as a combination of three extensions: "Zba", "Zbb" and "Zbs". To maximize discoverability of the RISC-V target features, this commit makes use of the "B" extension instead of its three members. This way, `#[cfg(target_feature = "b")]` can also be used instead of: `#[cfg(all(target_feature = "zba", target_feature = "zbb", target_feature = "zbs"))]`
2025-04-16rustc_target: RISC-V: feature addition batch 2Tsukasa OI-1/+11
This commit adds unprivileged ratified extensions that are either dicoverable from the `riscv_hwprobe` syscall of the Linux kernel (as of version 6.14) plus 1 minus 3 extensions. Plus 1: * "B" This is a combination of "Zba", "Zbb" and "Zbs". Note: Although not required by the RISC-V specification, it is convenient to imply "B" from its three members (will be implemented in LLVM 21/22) but this is not yet implemented in Rust due to current implication handling. It still implies three members *from* "B". Minus 2: * "Zcf" (target_arch = "riscv32" only) This is the compression instruction subset corresponding "F". This is implied from RV32 + "C" + "F" but this complex handling is not yet supported by Rust's feature handling. * "Zcd" This is the compression instruction subset corresponding "D". This is implied from "C" + "D" but this complex handling is not yet supported by Rust's feature handling. * "Supm" Unlike regular RISC-V extensions, "Supm" and "Sspm" extensions do not provide any specific architectural features / constraints but requires *some* mechanisms to control pointer masking for the current mode. For instance, reported existence of the "Supm" extension in Linux means that `prctl` system call to control pointer masking is available and there are alternative ways to detect the existence. Notes: * Because this commit adds the "Zca" extension (an integer subset of the "C" extension), the "C" extension is modified to imply "Zca".
2025-04-16Make CodeStat's type sizes a public fieldblyxyas-1/+1
2025-04-16Remove support for `#[rustc_mir(borrowck_graphviz_format="gen_kill")]`.Nicholas Nethercote-2/+1
Because it's equivalent to `#[rustc_mir(borrowck_graphviz_format)]`. It used to be distinct, but the distinction was removed in https://github.com/rust-lang/rust/pull/76044/commits/3233fb18a891363a2da36ce69ca16fbb219c96be.
2025-04-15Auto merge of #139878 - petrochenkov:revllvmclean2, r=compiler-errorsbors-26/+45
Revert "Deduplicate template parameter creation" This reverts commit 6adc2c1fd6ecde7bf83c8b8fbc71f402ced87054. More precise subset of https://github.com/rust-lang/rust/pull/139874.
2025-04-16Rename `LifetimeName` as `LifetimeKind`.Nicholas Nethercote-51/+51
It's a much better name, more consistent with how we name such things. Also rename `Lifetime::res` as `Lifetime::kind` to match. I suspect this field used to have the type `LifetimeRes` and then the type was changed but the field name remained the same.
2025-04-15Add unstable foo::bar extern command line argumentsEric Holk-34/+178
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-15Fix wrong suggestion for async gen block and add regression ui test for #139839Guillaume Gomez-4/+9
2025-04-15Auto merge of #139881 - matthiaskrgr:rollup-7x6zcrc, r=matthiaskrgrbors-72/+43
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-15Rollup merge of #139848 - nnethercote:kw-Empty-5, r=compiler-errorsMatthias Krüger-13/+5
Reduce kw::Empty usage, part 5 Another step towards https://github.com/rust-lang/rust/issues/137978. r? `@davidtwco`
2025-04-15Rollup merge of #139824 - ChrisDenton:non-canonical, r=petrochenkovMatthias Krüger-28/+6
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-15Rollup merge of #139818 - compiler-errors:normalize-tails, r=oli-obkMatthias Krüger-31/+32
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-15Don't compute name of associated item if it's an RPITITMichael Goulet-2/+1
2025-04-15Split TypeFolder and FallibleTypeFolderMichael Goulet-186/+395
2025-04-15Revert "Deduplicate template parameter creation"Vadim Petrochenkov-26/+45
This reverts commit 6adc2c1fd6ecde7bf83c8b8fbc71f402ced87054.
2025-04-15Auto merge of #138906 - thaliaarchi:unsupported-test-exe, r=bjorn3bors-0/+7
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-15Add `copy_within` to `IndexSlice`Jason Newcomb-1/+12
2025-04-15Add `explicit_extern_abis` unstable featureObei Sideg-0/+3
also add `explicit-extern-abis` feature section to the unstable book.
2025-04-15Don't name macro internals in "does not live long enough" errors.Mara Bos-6/+14
2025-04-15Implement `pin!()` using `super let`.Mara Bos-1/+0
2025-04-15Improve diagnostic for E0178 (bad `+` in type)León Orell Valerian Liehr-7/+6
Namely, use a more sensical primary span. Don't pretty-print AST nodes for the diagnostic message. Why: * It's lossy (e.g., it doesn't replicate trailing `+`s in trait objects. * It's prone to leak error nodes (printed as `(/*ERROR*/)`) since the LHS can easily represent recovered code (e.g., `fn(i32?) + T`).
2025-04-15Improve parse errors for lifetimes in type positionLeón Orell Valerian Liehr-7/+62
2025-04-15Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalatharbors-614/+728
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-15Use a dummy ident for a `lint_if_path_starts_with_module` call.Nicholas Nethercote-1/+1
This is pretty weird code. As the `HACK` comment indicates, we push the empty ident here only to make the path longer, so certain checks to occur within `lint_if_path_starts_with_module`. `dummy` is a better choice because it explicitly communicates that the actual value doesn't matter.
2025-04-15Remove a `kw::Empty` usage in symbol mangling.Nicholas Nethercote-1/+1
Field names are never empty, so the unwrap is unnecessary.
2025-04-15Remove some "name isn't empty" assertions.Nicholas Nethercote-11/+3
These were low value even before #137978 resulted in empty names being used much less. (Why check for non-emptiness in these three places? There are thousands of places in the compiler you could check.)
2025-04-15Rollup merge of #139833 - nnethercote:fix-139633, r=oli-obkStuart Cook-4/+7
Fix some HIR pretty-printing problems r? `@oli-obk`
2025-04-15Rollup merge of #139798 - lcnr:where-bounds-gt-alias-bound, r=compiler-errorsStuart Cook-21/+30
normalize: prefer `ParamEnv` over `AliasBound` candidates cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/175 not the only issue affecting bevy sadly r? ``@compiler-errors``
2025-04-15Rollup merge of #139791 - lcnr:ignore-global-where-bounds, r=compiler-errorsStuart Cook-2/+6
drop global where-bounds before merging candidates fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/172 r? ```@compiler-errors```