about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-04-21Rollup merge of #140030 - EnzymeAD:autodiff-debug, r=jieyouxuChris Denton-1/+2
Fix autodiff debug builds r? `@oli-obk` closes: #139704 Tracking: - https://github.com/rust-lang/rust/issues/124509
2025-04-21Rollup merge of #140021 - compiler-errors:no-deep-norm-ice, r=lcnrChris Denton-1/+9
Don't ICE on pending obligations from deep normalization in a loop See the comment I left inline in `compiler/rustc_trait_selection/src/traits/normalize.rs`. Fixes https://github.com/rust-lang/rust/issues/133868 r? lcnr
2025-04-21Document why CodeStats::type_sizes is publicblyxyas-0/+2
2025-04-21mir-opt: execute MatchBranchSimplification after GVNdianqk-2/+1
This can provide more opportunities for MatchBranchSimplification.
2025-04-21cleanup redundant pattern instancesJonathan Gruner-1/+1
2025-04-21Construct OutputType using macro and print [=FILENAME] help infoxizheyin-112/+198
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-21support both trait and non-trail associated declarationbit-aloo-8/+6
2025-04-21Store `Results` in Formatter.Nicholas Nethercote-20/+20
Instead of `ResultsCursor`. This partly undoes the second commit from #132346; possible because `Results::as_result_cursor` (which doesn't consume the `Results`) is now available. Delaying the `ResultsCursor` construction will facilitate the next couple of commits.
2025-04-20Auto merge of #140079 - ChrisDenton:rollup-2h5cg94, r=ChrisDentonbors-380/+265
Rollup of 5 pull requests Successful merges: - #137953 (simd intrinsics with mask: accept unsigned integer masks, and fix some of the errors) - #139990 (transmutability: remove NFA intermediate representation) - #140044 (rustc-dev-guide subtree update) - #140051 (Switch exploit mitigations to mdbook footnotes) - #140054 (docs: fix typo change from inconstants to invariants) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-21Remove `token::{Open,Close}Delim`.Nicholas Nethercote-490/+444
By replacing them with `{Open,Close}{Param,Brace,Bracket,Invisible}`. PR #137902 made `ast::TokenKind` more like `lexer::TokenKind` by replacing the compound `BinOp{,Eq}(BinOpToken)` variants with fieldless variants `Plus`, `Minus`, `Star`, etc. This commit does a similar thing with delimiters. It also makes `ast::TokenKind` more similar to `parser::TokenType`. This requires a few new methods: - `TokenKind::is_{,open_,close_}delim()` replace various kinds of pattern matches. - `Delimiter::as_{open,close}_token_kind` are used to convert `Delimiter` values to `TokenKind`. Despite these additions, it's a net reduction in lines of code. This is because e.g. `token::OpenParen` is so much shorter than `token::OpenDelim(Delimiter::Parenthesis)` that many multi-line forms reduce to single line forms. And many places where the number of lines doesn't change are still easier to read, just because the names are shorter, e.g.: ``` - } else if self.token != token::CloseDelim(Delimiter::Brace) { + } else if self.token != token::CloseBrace { ```
2025-04-20Don't call ungate_lastest31-54/+45
2025-04-20Check bare function idents for non snake-case nameUrgau-0/+10
2025-04-20remove a couple clonesMatthias Krüger-7/+5
2025-04-20Don't compute name of associated item if it's an RPITITMichael Goulet-10/+10
2025-04-20Rollup merge of #139990 - jswrenn:no-nfas, r=tmiaskoChris Denton-295/+239
transmutability: remove NFA intermediate representation Prior to this commit, the transmutability analysis used an intermediate NFA representation of type layout. We then determinized this representation into a DFA, upon which we ran the core transmutability analysis. Unfortunately, determinizing NFAs is expensive. In this commit, we avoid NFAs entirely by observing that Rust `union`s are the only source of nondeterminism and that it is comparatively cheap to compute the DFA union of DFAs. We also implement Graphviz DOT debug formatting of DFAs. Fixes rust-lang/project-safe-transmute#23 Fixes rust-lang/project-safe-transmute#24 r? ``@compiler-errors``
2025-04-20Rollup merge of #137953 - RalfJung:simd-intrinsic-masks, r=WaffleLapkinChris Denton-85/+26
simd intrinsics with mask: accept unsigned integer masks, and fix some of the errors It's not clear at all why the mask would have to be signed, it is anyway interpreted bitwise. The backend should just make sure that works no matter the surface-level type; our LLVM backend already does this correctly. The note of "the mask may be widened, which only has the correct behavior for signed integers" explains... nothing? Why can't the code do the widening correctly? If necessary, just cast to the signed type first... Also while we are at it, fix the errors. For simd_masked_load/store, the errors talked about the "third argument" but they meant the first argument (the mask is the first argument there). They also used the wrong type for `expected_element`. I have extremely low confidence in the GCC part of this PR. See [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/257879-project-portable-simd/topic/On.20the.20sign.20of.20masks)
2025-04-20mir-opt: Use one MirPatch in MatchBranchSimplificationdianqk-23/+14
2025-04-20respect `repr(align(N))` on functions in miriFolkert de Vries-2/+14
2025-04-20simd intrinsics with mask: accept unsigned integer masksRalf Jung-85/+26
2025-04-20Implement lint against dangerous implicit autorefsUrgau-0/+180
2025-04-20Add `#[rustc_no_implicit_autorefs]` and apply it to std methodsUrgau-0/+8
2025-04-20make abi_unsupported_vector_types a hard errorRalf Jung-97/+22
2025-04-20stabilize `naked_functions`Folkert de Vries-27/+4
2025-04-20Remove #[rustc_macro_edition_2021].Mara Bos-40/+1
It was only temporarily used by pin!(), which no longer needs it.
2025-04-20transmutability: remove NFA intermediate representationJack Wrenn-295/+239
Prior to this commit, the transmutability analysis used an intermediate NFA representation of type layout. We then determinized this representation into a DFA, upon which we ran the core transmutability analysis. Unfortunately, determinizing NFAs is expensive. In this commit, we avoid NFAs entirely by observing that Rust `union`s are the only source of nondeterminism and that it is comparatively cheap to compute the DFA union of DFAs. We also implement Graphviz DOT debug formatting of DFAs. Fixes rust-lang/project-safe-transmute#23 Fixes rust-lang/project-safe-transmute#24
2025-04-20Auto merge of #140043 - ChrisDenton:rollup-vwf0s9j, r=ChrisDentonbors-450/+913
Rollup of 8 pull requests Successful merges: - #138934 (support config extensions) - #139091 (Rewrite on_unimplemented format string parser.) - #139753 (Make `#[naked]` an unsafe attribute) - #139762 (Don't assemble non-env/bound candidates if projection is rigid) - #139834 (Don't canonicalize crate paths) - #139868 (Move `pal::env` to `std::sys::env_consts`) - #139978 (Add citool command for generating a test dashboard) - #139995 (Clean UI tests 4 of n) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-19Rollup merge of #140024 - cjgillot:continue-jumping, r=compiler-errorsChris Denton-71/+64
Remove early exits from JumpThreading. This removes early exits from https://github.com/rust-lang/rust/pull/131203 as I asked during review. The correctness of the backtracking is `mutated_statement` clearing all relevant conditions. If `process_statement` fails to insert a new condition, for instance by const-eval failure, `mutated_statement` still removes the obsolete conditions from the state. r? `@compiler-errors`
2025-04-19Rollup merge of #139042 - compiler-errors:do-not-optimize-switchint, r=saethlinChris Denton-19/+36
Do not remove trivial `SwitchInt` in analysis MIR This PR ensures that we don't prematurely remove trivial `SwitchInt` terminators which affects both the borrow-checking and runtime semantics (i.e. UB) of the code. Previously the `SimplifyCfg` optimization was removing `SwitchInt` terminators when they was "trivial", i.e. when all arms branched to the same basic block, even if that `SwitchInt` terminator had the side-effect of reading an operand which (for example) may not be initialized or may point to an invalid place in memory. This behavior is unlike all other optimizations, which are only applied after "analysis" (i.e. borrow-checking) is finished, and which Miri disables to make sure the compiler doesn't silently remove UB. Fixing this code "breaks" (i.e. unmasks) code that used to borrow-check but no longer does, like: ```rust fn foo() { let x; let (0 | _) = x; } ``` This match expression should perform a read because `_` does not shadow the `0` literal pattern, and the compiler should have to read the match scrutinee to compare it to 0. I've checked that this behavior does not actually manifest in practice via a crater run which came back clean: https://github.com/rust-lang/rust/pull/139042#issuecomment-2767436367 As a side-note, it may be tempting to suggest that this is actually a good thing or that we should preserve this behavior. If we wanted to make this work (i.e. trivially optimize out reads from matches that are redundant like `0 | _`), then we should be enabling this behavior *after* fixing this. However, I think it's kinda unprincipled, and for example other variations of the code don't even work today, e.g.: ```rust fn foo() { let x; let (0.. | _) = x; } ```
2025-04-19Update docs for `AssocItems::filter_by_name_unhygienic`Guillaume Gomez-0/+2
2025-04-19Don't ICE on pending obligations from deep normalization in a loopMichael Goulet-1/+9
2025-04-19Rollup merge of #139868 - thaliaarchi:move-env-consts-pal, r=joboetChris Denton-16/+14
Move `pal::env` to `std::sys::env_consts` Combine the `std::env::consts` platform implementations as a single file. Use the Unix file as the base, since it has 28 entries, and fold the 8 singleton platforms into it. The Unix file was roughly grouped into Linux, Apple, BSD, and everything else, roughly in alphabetical order. Alphabetically order them to make it easier to maintain and discard the Unix-specific groups to generalize it to all platforms. I'd prefer to have no fallback implementation, as I consider it a bug; however TEEOS, Trusty, and Xous have no definitions here. Since they otherwise have `pal` abstractions, that indicates that there are several platforms without `pal` abstractions which are also missing here. To support unsupported, create a little macro to handle the fallback case and not introduce ordering between the `cfg`s like `cfg_if!`. I've named the module `std::sys::env_consts`, because they are used in `std::env::consts` and I intend to use the name `std::sys::env` for the combination of `Args` and `Vars`. cc `@joboet` `@ChrisDenton` Tracked in #117276.
2025-04-19Rollup merge of #139834 - ChrisDenton:spf, r=WaffleLapkinChris Denton-6/+15
Don't canonicalize crate paths When printing paths in diagnostic we should favour printing the paths that were passed in rather than resolving all symlinks. This PR changes the form of the crate path but it should only really affect diagnostics as filesystem functions won't care which path is used. The uncanonicalized path was already used as a fallback for when canonicalization failed. This is a partial alternative to #139823.
2025-04-19Rollup merge of #139762 - compiler-errors:non-env, r=lcnrChris Denton-39/+58
Don't assemble non-env/bound candidates if projection is rigid Putting this up for an initial review, it's still missing comments, clean-up, and possibly a tweak to deal with ambiguities in the `BestObligation` folder. This PR fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/173. Specifically, we're creating an unnecessary query cycle in normalization by assembling an *impl candidate* even if we know later on during `merge_candidates` that we'll be filtering out that impl candidate. This PR adjusts the `merge_candidates` to assemble *only* env/bound candidates if we have `TraitGoalProvenVia::ParamEnv | TraitGoalProvenVia::AliasBound`. I'll leave some thoughts/comments in the code. r? lcnr
2025-04-19Rollup merge of #139753 - folkertdev:naked-function-unsafe-attribute, ↵Chris Denton-21/+17
r=tgross35,traviscross Make `#[naked]` an unsafe attribute tracking issue: https://github.com/rust-lang/rust/issues/138997 Per https://github.com/rust-lang/rust/pull/134213#issuecomment-2755984503, the `#[naked]` attribute is now an unsafe attribute (in any edition). This can only be merged when the above PRs are merged, I'd just like to see if there are any CI surprises here, and maybe there is early review feedback too. r? ``@traviscross``
2025-04-19Rollup merge of #139091 - mejrs:format, r=compiler-errorsChris Denton-368/+809
Rewrite on_unimplemented format string parser. This PR rewrites the format string parser for `rustc_on_unimplemented` and `diagnostic::on_unimplemented`. I plan on moving this code (and more) into the new attribute parsing system soon and wanted to PR it separately. This PR introduces some minor differences though: - `rustc_on_unimplemented` on trait *implementations* is no longer checked/used - this is actually never used (outside of some tests) so I plan on removing it in the future. - for `rustc_on_unimplemented`, it introduces the `{This}` argument in favor of `{ThisTraitname}` (to be removed later). It'll be easier to parse. - for `rustc_on_unimplemented`, `Self` can now consistently be used as a filter, rather than just `_Self`. It used to not match correctly on for example `Self = "[{integer}]"` - Some error messages now have better spans. Fixes https://github.com/rust-lang/rust/issues/130627
2025-04-19Rollup merge of #140025 - Sky9x:re-remove-adtflags-anon, r=compiler-errorsChris Denton-2/+0
Re-remove `AdtFlags::IS_ANONYMOUS` Removed in #138296. I accidentally re-added it in #137043 while resolving merge conflicts. This PR re-removes it. r? ``@compiler-errors`` (sorry)
2025-04-19Rollup merge of #140007 - roblabla:fix-win7, r=ChrisDentonChris Denton-0/+6
Disable has_thread_local on i686-win7-windows-msvc On Windows 7 32-bit, the alignment characteristic of the TLS Directory don't appear to be respected by the PE Loader, leading to crashes. As a result, let's disable has_thread_local to make sure TLS goes through the emulation layer. Fixes #138903
2025-04-19Rollup merge of #137454 - mu001999-contrib:fix-137414, r=wesleywiserChris Denton-6/+8
not lint break with label and unsafe block fixes #137414 we can't label unsafe blocks, so that we can do not lint them
2025-04-19Auto merge of #139114 - m-ou-se:super-let-pin, r=davidtwcobors-7/+14
Implement `pin!()` using `super let` Tracking issue for super let: https://github.com/rust-lang/rust/issues/139076 This uses `super let` to implement `pin!()`. This means we can remove [the hack](https://github.com/rust-lang/rust/pull/138717) we had to put in to fix https://github.com/rust-lang/rust/issues/138596. It also means we can remove the original hack to make `pin!()` work, which used a questionable public-but-unstable field rather than a proper private field. While `super let` is still unstable and subject to change, it seems safe to assume that future Rust will always have a way to express `pin!()` in a compatible way, considering `pin!()` is already stable. It'd help [the experiment](https://github.com/rust-lang/rust/issues/139076) to have `pin!()` use `super let`, so we can get some more experience with it.
2025-04-19Only consider MonoItem::Fn when preventing inlining for autodiff source ↵Manuel Drehwald-1/+2
functions
2025-04-18Use struct update syntax for some TargetOptionsThalia Archibald-16/+14
2025-04-18Re-remove `AdtFlags::IS_ANONYMOUS`Sky-2/+0
2025-04-19Introduce Arena::try_alloc_from_iter.Camille GILLOT-33/+47
2025-04-18Remove early exits from JumpThreading.Camille GILLOT-71/+64
2025-04-19Fix importGuillaume Gomez-1/+2
2025-04-19Make `#[naked]` an unsafe attributeFolkert de Vries-21/+17
2025-04-18Fix compilation error in GCC backendGuillaume Gomez-1/+1
2025-04-18Fix `rustc_codegen_gcc/tests/run/return-tuple.rs` testGuillaume Gomez-6/+0
2025-04-18Merge commit 'db1a31c243a649e1fe20f5466ba181da5be35c14' into ↵Guillaume Gomez-1244/+962
subtree-update_cg_gcc_2025-04-18
2025-04-18Also allow let chains in match guardsest31-11/+20