about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-04-30Rollup merge of #139059 - RalfJung:uses_power_alignment, r=nagisaMatthias Krüger-21/+14
uses_power_alignment: wording tweaks Slightly improves the wording introduced with https://github.com/rust-lang/rust/pull/135552.
2025-04-30ast: Remove token visiting from AST visitorVadim Petrochenkov-214/+32
It's no longer necessary after the removal of nonterminal tokens in #124141.
2025-04-30Inline check_method_argument_types and remove error_reported special casing ↵Michael Goulet-62/+36
(unnecessary)
2025-04-30Inline check_method_argument_types to get rid of TupleArgumentsFlag argMichael Goulet-23/+13
2025-04-30Move the error handling out of confirm_builtin_callMichael Goulet-31/+25
2025-04-30Rename lookup_method_in_trait and consolidate a Ident::with_dummy_span callMichael Goulet-26/+20
2025-04-29Parser: Document restrictionsEric Huss-0/+49
I had trouble easily understanding what these various flags do. This is my attempt to try to explain what these do.
2025-04-30Auto merge of #127516 - nnethercote:simplify-LazyAttrTokenStream, r=petrochenkovbors-378/+399
Simplify `LazyAttrTokenStream` `LazyAttrTokenStream` is an unpleasant type: `Lrc<Box<dyn ToAttrTokenStream>>`. Why does it look like that? - There are two `ToAttrTokenStream` impls, one for the lazy case, and one for the case where we already have an `AttrTokenStream`. - The lazy case (`LazyAttrTokenStreamImpl`) is implemented in `rustc_parse`, but `LazyAttrTokenStream` is defined in `rustc_ast`, which does not depend on `rustc_parse`. The use of the trait lets `rustc_ast` implicitly depend on `rustc_parse`. This explains the `dyn`. - `LazyAttrTokenStream` must have a `size_of` as small as possible, because it's used in many AST nodes. This explains the `Lrc<Box<_>>`, which keeps it to one word. (It's required `Lrc<dyn _>` would be a fat pointer.) This PR moves `LazyAttrTokenStreamImpl` (and a few other token stream things) from `rustc_parse` to `rustc_ast`. This lets us replace the `ToAttrTokenStream` trait with a two-variant enum and also remove the `Box`, changing `LazyAttrTokenStream` to `Lrc<LazyAttrTokenStreamInner>`. Plus it does a few cleanups. r? `@petrochenkov`
2025-04-29canonical no type foldable :<lcnr-26/+4
2025-04-30Use `ThinVec` to shrink `LazyAttrTokenStreamInner`.Nicholas Nethercote-5/+7
2025-04-30Simplify `LazyAttrTokenStream`.Nicholas Nethercote-118/+138
This commit does the following. - Changes it from `Lrc<Box<dyn ToAttrTokenStream>>` to `Lrc<LazyAttrTokenStreamInner>`. - Reworks `LazyAttrTokenStreamImpl` as `LazyAttrTokenStreamInner`, which is a two-variant enum. - Removes the `ToAttrTokenStream` trait and the two impls of it. The recursion limit must be increased in some crates otherwise rustdoc aborts.
2025-04-29Auto merge of #140023 - cjgillot:arena-try-alloc, r=BoxyUwUbors-33/+47
Introduce Arena::try_alloc_from_iter. `alloc_from_iter` already collects the iterator for reentrancy. So adding an early exit for a fallible iterator integrates naturally into the code. This avoids the other solution to allocate and dump the allocation.
2025-04-29transmutability: uninit transition matches unit byte onlyTomasz Miąsko-352/+173
The previous implementation was inconsistent about transitions that apply for an init byte. For example, when answering a query, an init byte could use corresponding init transition. Init byte could also use uninit transition, but only when the corresponding init transition was absent. This behaviour was incompatible with DFA union construction. Define an uninit transition to match an uninit byte only and update implementation accordingly. To describe that `Tree::uninit` is valid for any value, build an automaton that accepts any byte value. Additionally, represent byte ranges uniformly as a pair of integers to avoid special case for uninit byte.
2025-04-29confusingsBoxy-52/+56
2025-04-29Don't FCW assoc consts in patternsBoxy-9/+10
2025-04-30stop check paren if has different ctxbohan-0/+16
2025-04-29Rollup merge of #140433 - BjoernLange:master, r=nnethercoteTrevor Gross-0/+2
Replace the \01__gnu_mcount_nc to LLVM intrinsic for additional ARM targets This is an extension to #113814 which seems to have missed two targets which also need this patch for instrumentation with `-Z instrument-mcount` to work correctly. For anyone who might stumble over this issue again in the future: As a workaround one can dump the current target configuration using ``` rustc +nightly -Z unstable-options --target armv7-unknown-linux-gnueabihf --print target-spec-json ``` (assuming `armv7-unknown-linux-gnueabihf` is the target to build for) add the line ``` "llvm-mcount-intrinsic": "llvm.arm.gnu.eabi.mcount", ``` and compile with ``` RUSTFLAGS="-Z instrument-mcount -C passes=ee-instrument<post-inline>" cargo +nightly build -Z build-std --target <path to directory with modified target config>/armv7-unknown-linux-gnueabihf.json ``` It might be necessary to set the compiler for cross compiling using something like ``` export TARGET_CC=arm-linux-gnueabihf-gcc ```
2025-04-29Rollup merge of #140432 - tgross35:target-config-docs-update, r=jieyouxuTrevor Gross-5/+4
Update documentation for `fn target_config` This was missed as part of [1]. [1]: https://github.com/rust-lang/rust/pull/140323
2025-04-29Rollup merge of #140400 - durin42:llvm-21-getguid, r=cuviperTrevor Gross-4/+9
PassWrapper: adapt for llvm/llvm-project@d3d856ad8469 LLVM 21 moves to making it more explicit what this function call is doing, but nothing has changed behaviorally, so for now we just adjust to using the new name of the function. `@rustbot` label llvm-main
2025-04-29Rollup merge of #139909 - oli-obk:or-patterns, r=BoxyUwUTrevor Gross-122/+440
implement or-patterns for pattern types These are necessary to represent `NonZeroI32`, as the range for that is `..0 | 1..`. The `rustc_scalar_layout_range_*` attributes avoided this by just implementing wraparound and having a single `1..=-1` range effectively. See https://rust-lang.zulipchat.com/#narrow/channel/481660-t-lang.2Fpattern-types/topic/.60or.20pattern.60.20representation.20in.20type.20system/with/504217694 for some background discussion cc https://github.com/rust-lang/rust/issues/123646 r? `@BoxyUwU`
2025-04-29Rollup merge of #138344 - tgross35:x86-f16-math, r=AmanieuTrevor Gross-7/+3
Enable `reliable_f16_math` on x86 This has been disabled due to an LLVM misoptimization with `powi.f16` [1]. This was fixed upstream and the fix is included in LLVM20, so tests no longer need to be disabled. `f16` still remains disabled on MinGW due to the ABI issue. [1]: https://github.com/llvm/llvm-project/issues/98665 try-job: x86_64-gnu try-job: x86_64-gnu-llvm-19-1 try-job: x86_64-gnu-llvm-20-1
2025-04-29Use a closure instead of three chained iteratorsOli Scherer-72/+58
2025-04-29Fix for async drop ice with partly dropped tupleAndrew Zhogin-9/+15
2025-04-29Add comment to remind filtering unsupported features when adding new onesWANG Rui-0/+3
2025-04-29Filter out LoongArch features not supported by the current LLVM versionWANG Rui-0/+6
2025-04-29Some style nitsOli Scherer-4/+3
2025-04-29Drop AST on a separate thread and prefetch `hir_crate`John Kåre Alsaker-3/+26
2025-04-29Remove global `next_disambiguator` state and handle it with a ↵John Kåre Alsaker-75/+172
`DisambiguatorState` type
2025-04-29Reformat parameters to macros used by with-all-queriesZalathar-6/+15
2025-04-29Rename `rustc_query_append!` to `rustc_with_all_queries!`Zalathar-7/+21
2025-04-29Treat `ManuallyDrop` as `~const Destruct`Oli Scherer-0/+6
2025-04-29Add some commentsJohn Kåre Alsaker-0/+7
2025-04-29mono collector: Reduce \# of locking while walking the graphPiotr Osiewicz-27/+38
While profiling Zed's dev build I've noticed that while most of the time `upstream_monomorphizations` takes a lot of time in monomorpization_collector, in some cases (e.g. build of `editor` itself) the rest of monomorphization_collector_graph_walk dominates it. Most of the time is spent in collect_items_rec. This PR aims to reduce the number of locks taking place; instead of locking output MonoItems once per children of current node, we do so once per *parent*. We also get to reuse locks for mentioned and used items. While this commit does not reduce Wall time of Zed's build, it does shave off `cargo build -j1` from 43s to 41.5s.
2025-04-29miri: algebraic intrinsics: bring back float non-determinismRalf Jung-2/+9
2025-04-29Also match on the lang item in confirmationOli Scherer-10/+5
2025-04-29Always check the lang item firstOli Scherer-16/+8
2025-04-29Replace if/elseif chain with matchOli Scherer-62/+81
2025-04-29Replace the \01__gnu_mcount_nc to LLVM intrinsic for additional ARM targetsBjörn Barwinski-0/+2
2025-04-29Update documentation for `fn target_config`Trevor Gross-5/+4
This was missed as part of [1]. [1]: https://github.com/rust-lang/rust/pull/140323
2025-04-29Enable `target_has_reliable_f16_math` on x86Trevor Gross-7/+3
This has been disabled due to an LLVM misoptimization with `powi.f16` [1]. This was fixed upstream and the fix is included in LLVM20, so tests no longer need to be disabled. `f16` still remains disabled on MinGW due to the ABI issue. [1]: https://github.com/llvm/llvm-project/issues/98665
2025-04-29Auto merge of #137940 - 1c3t3a:alignment-borrows-check, r=saethlinbors-32/+48
Extend the alignment check to borrows The current alignment check does not include checks for creating misaligned references from raw pointers, which is now added in this patch. When inserting the check we need to be careful with references to field projections (e.g. `&(*ptr).a`), in which case the resulting reference must be aligned according to the field type and not the type of the pointer. r? `@saethlin` cc `@RalfJung,` after our discussion in #134424
2025-04-29Delay checking of `#[rustc_no_implicit_autorefs]` for reasonUrgau-4/+11
2025-04-29Add a jobserver proxy to ensure at least one token is always heldJohn Kåre Alsaker-29/+149
2025-04-29Improve pretty-printing of braces.Nicholas Nethercote-17/+35
Most notably, the `FIXME` for suboptimal printing of `use` groups in `tests/ui/macros/stringify.rs` is fixed. And all other test output changes result in pretty printed output being closer to the original formatting in the source code.
2025-04-29Adjust testsMichael Goulet-1/+3
2025-04-29Wf is not coinductiveMichael Goulet-1/+4
2025-04-29Move various token stream things from `rustc_parse` to `rustc_ast`.Nicholas Nethercote-339/+338
Specifically: `TokenCursor`, `TokenTreeCursor`, `LazyAttrTokenStreamImpl`, `FlatToken`, `make_attr_token_stream`, `ParserRange`, `NodeRange`. `ParserReplacement`, and `NodeReplacement`. These are all related to token streams, rather than actual parsing. This will facilitate the simplifications in the next commit.
2025-04-28Move `in_external_macro` to `SyntaxContext`Jason Newcomb-18/+28
2025-04-28Rollup merge of #140402 - lcnr:normalizes-to-certainty-yes, r=compiler-errorsChris Denton-32/+66
only return nested goals for `Certainty::Yes` Ambiguous `NormalizesTo` goals can otherwise repeatedly add the same nested goals to the parent. r? ```@compiler-errors```
2025-04-28Rollup merge of #140323 - tgross35:cfg-unstable-float, r=UrgauChris Denton-27/+192
Implement the internal feature `cfg_target_has_reliable_f16_f128` Support for `f16` and `f128` is varied across targets, backends, and backend versions. Eventually we would like to reach a point where all backends support these approximately equally, but until then we have to work around some of these nuances of support being observable. Introduce the `cfg_target_has_reliable_f16_f128` internal feature, which provides the following new configuration gates: * `cfg(target_has_reliable_f16)` * `cfg(target_has_reliable_f16_math)` * `cfg(target_has_reliable_f128)` * `cfg(target_has_reliable_f128_math)` `reliable_f16` and `reliable_f128` indicate that basic arithmetic for the type works correctly. The `_math` versions indicate that anything relying on `libm` works correctly, since sometimes this hits a separate class of codegen bugs. These options match configuration set by the build script at [1]. The logic for LLVM support is duplicated as-is from the same script. There are a few possible updates that will come as a follow up. The config introduced here is not planned to ever become stable, it is only intended to replace the build scripts for `std` tests and `compiler-builtins` that don't have any way to configure based on the codegen backend. MCP: https://github.com/rust-lang/compiler-team/issues/866 Closes: https://github.com/rust-lang/compiler-team/issues/866 [1]: https://github.com/rust-lang/rust/blob/555e1d0386f024a8359645c3217f4b3eae9be042/library/std/build.rs#L84-L186 --- The second commit makes use of this config to replace `cfg_{f16,f128}{,_math}` in `library/`. I omitted providing a `cfg(bootstrap)` configuration to keep things simpler since the next beta branch is in two weeks. try-job: aarch64-gnu try-job: i686-msvc-1 try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-ext2