about summary refs log tree commit diff
path: root/src/tools
AgeCommit message (Collapse)AuthorLines
2025-02-23Fix parser inline tests codegen panicsniller-g-13/+10
When running `cargo codegen` the cwd="rust-analyzer" however when running `cargo test` the cwd="rust-analyzer/xtask" which makes the codegen panic
2025-02-23Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, ↵Jacob Pratt-5/+5
r=saethlin,traviscross Greatly simplify lifetime captures in edition 2024 Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-23Rollup merge of #137383 - folkertdev:stabilize-unsigned-is-multiple-of, ↵Matthias Krüger-1/+0
r=Noratrieb stabilize `unsigned_is_multiple_of` tracking issue: https://github.com/rust-lang/rust/issues/128101 fcp completed in: https://github.com/rust-lang/rust/issues/128101#issuecomment-2674880635 ### Public API A version of this for all the unsigned types ```rust fn is_multiple_of(lhs: u64, rhs: u64) -> bool { match rhs { // prevent division by zero 0 => lhs == 0, _ => lhs % rhs == 0, } } ```
2025-02-23Rollup merge of #137256 - workingjubilee:untangle-vector-abi-assumptions, ↵Matthias Krüger-1/+1
r=bjorn3,RalfJung compiler: untangle SIMD alignment assumptions There were a number of puzzling assumptions being made about SIMD types and their layout that I have corrected in this diff. These are mostly no-op edits in actual fact, but they do subtly alter a pair of checks in our invariant-checking and union layout computation that rested on those peculiar assumptions. Those unfortunately stand in the way of any further actual fixes. I submit this for review, even though it's not clearly motivated without its followups, because it should still be possible to independently conclude whether this is correct.
2025-02-23Rollup merge of #137180 - compiler-errors:sym-regions, r=oli-obkMatthias Krüger-6/+9
Give `global_asm` a fake body to store typeck results, represent `sym fn` as a hir expr to fix `sym fn` operands with lifetimes There are a few intertwined problems with `sym fn` operands in both inline and global asm macros. Specifically, unlike other anon consts, they may evaluate to a type with free regions in them without actually having an item-level type annotation to give them a "proper" type. This is in contrast to named constants, which always have an item-level type annotation, or unnamed constants which are constrained by their position (e.g. a const arg in a turbofish, or a const array length). Today, we infer the type of the operand by looking at the HIR typeck results; however, those results are region-erased, so during borrowck we ICE since we don't expect to encounter erased regions. We can't just fill this type with something like `'static`, since we may want to use real (free) regions: ```rust fn foo<'a>() { asm!("/* ... */", sym bar::<&'a ()>); } ``` The first idea may be to represent `sym fn` operands using *inline* consts instead of anon consts. This makes sense, since inline consts can reference regions from the parent body (like the `'a` in the example above). However, this introduces a problem with `global_asm!`, which doesn't *have* a parent body; inline consts *must* be associated with a parent body since they are not a body owner of their own. In #116087, I attempted to fix this by using two separate `sym` operands for global and inline asm. However, this led to a lot of confusion and also some unattractive code duplication. In this PR, I adjust the lowering of `global_asm!` so that it's lowered in a "fake" HIR body. This body contains a single expression which is `ExprKind::InlineAsm`; we don't *use* this HIR body, but it's used in typeck and borrowck so that we can properly infer and validate the the lifetimes of `sym fn` operands. I then adjust the lowering of `sym fn` to instead be represented with a HIR expression. This is both because it's no longer necessary to represent this operand as an anon const, since it's *just* a path expression, and also more importantly to sidestep yet another ICE (https://github.com/rust-lang/rust/issues/137179), which has to do with the existing code breaking an invariant of def-id creation and anon consts. Specifically, we are not allowed to synthesize a def-id for an anon const when that anon const contains expressions with def-ids whose parent is *not* that anon const. This is somewhat related to https://github.com/rust-lang/rust/pull/130443#issuecomment-2445678945, which is also a place in the compiler where synthesizing anon consts leads to def-id parenting issue. As a side-effect, this consolidates the type checking for inline and global asm, so it allows us to simplify `InlineAsmCtxt` a bit. It also allows us to delete a bit of hacky code from anon const `type_of` which was there to detect `sym fn` operands specifically. This also could be generalized to support `const` asm operands with types with lifetimes in them. Since we specifically reject these consts today, I'm not going to change the representation of those consts (but they'd just be turned into inline consts). r? oli-obk -- mostly b/c you're patient and also understand the breadth of the code that this touches, please reassign if you don't want to review this. Fixes #111709 Fixes #96304 Fixes #137179
2025-02-23Rollup merge of #137121 - bend-n:master, r=NoratriebMatthias Krüger-3/+0
stabilize `(const_)ptr_sub_ptr` Tracking issue: #95892 Closes #95892 FCP Completed: https://github.com/rust-lang/rust/issues/95892#issuecomment-2561139730 r? ````@Noratrieb````
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-5/+5
2025-02-22Merge pull request #19182 from ShoyuVanilla/issue-19177Chayim Refael Friedman-7/+47
fix: Binding wrong associated type when lowering bounds like `T: Trait<Assoc = U>`
2025-02-22Update cargoWeihang Lo-0/+0
2025-02-22Allow "package/feature" format feature flagShirayama Kazatsuyu-1/+3
2025-02-22Auto merge of #136428 - EnzymeAD:enable-autodiff, r=oli-obkbors-0/+0
test building enzyme in CI 1) This PR fixes a significant compile-time regression, by only running the expensive autodiff pipeline, if the users pass the newly introduced Enable value to the `-Zautodiff=` flag. It updates the test(s) accordingly. It gives a nice error if users forget that. 2) It fixes macos support by explicitly linking against the Enzyme build folder. This doesn't cover CI macos yet. 3) It fixes the issue that setting ENZYME_RUNPASS was ignored by enzyme and in fact did not schedule enzyme's opt pass. 4) It also re-enables support for various other values for the autodiff flag, which were ignored since the refactor. 5) I merged some improvements to Enzyme core, which means we do not longer depend on LLVM being build with the Plugin Interface enabled. 6) Unrelated to other fixes, this changes `rustc_autodiff` to `EncodeCrossCrate::Yes`. It is not enough on it's own to enable usage of Enzyme in libraries, but it is for sure a piece of the fixes needed to get this to work. try-job: x86_64-gnu r? `@oli-obk` Tracking: - https://github.com/rust-lang/rust/issues/124509
2025-02-22Merge pull request #19203 from lnicola/rust-src-pathLaurențiu Nicola-8/+6
minor: Switch back to RUST_SRC_PATH
2025-02-22Switch back to RUST_SRC_PATHLaurențiu Nicola-8/+6
2025-02-21toc for other editorsJosh Rotenberg-0/+2
2025-02-22Auto merge of #137406 - matthiaskrgr:rollup-9nknrsb, r=matthiaskrgrbors-97/+74
Rollup of 8 pull requests Successful merges: - #136458 (Do not deduplicate list of associated types provided by dyn principal) - #136474 ([`compiletest`-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing) - #136592 (Make sure we don't overrun the stack in canonicalizer) - #136787 (Remove `lifetime_capture_rules_2024` feature) - #137207 (Add #[track_caller] to Duration Div impl) - #137245 (Tweak E0277 when predicate comes indirectly from ?) - #137257 (Ignore fake borrows for packed field check) - #137399 (fix ICE in layout computation with unnormalizable const) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-21update enzyme submodule and usersManuel Drehwald-0/+0
2025-02-22Make a fake body to store typeck results for global_asmMichael Goulet-2/+5
2025-02-22Make asm a named fieldMichael Goulet-4/+4
2025-02-22Rollup merge of #136474 - jieyouxu:src-base, r=clubby789Matthias Krüger-97/+74
[`compiletest`-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing Reference for overall changes: https://github.com/rust-lang/rust/pull/136437 Part **3** of **7** of the *`compiletest`-related cleanups* PR series. ### Summary - Remove `--src-base` compiletest in favor of new flags `--src-root` and `--src-test-suite-root` which more accurately conveys the intent. `--src-base` previously actually meant `--src-test-suite-root` and has caused multiple confusions. - Use `--src-root` to have bootstrap directly feed source root path to compiletest, instead of doing a hacky directory parent search heuristic (`find_rust_src_root`) that somehow returns an `Option<PathBuf>`. ### Review advice Best reviewed commit-by-commit. r? bootstrap
2025-02-21Auto merge of #137348 - compiler-errors:span-trim, r=estebankbors-145/+100
More sophisticated span trimming for suggestions Previously #136958 only cared about prefixes or suffixes. Now it detects more cases where a suggestion is "sandwiched" by unchanged code on the left or the right. Would be cool if we could detect several insertions, like `ACE` going to `ABCDE`, extracting `B` and `D`, but that seems unwieldy. r? `@estebank`
2025-02-21Auto merge of #137397 - matthiaskrgr:rollup-ls2pilo, r=matthiaskrgrbors-109/+96
Rollup of 10 pull requests Successful merges: - #132876 (rustdoc book: acknowledge --document-hidden-items) - #136148 (Optionally add type names to `TypeId`s.) - #136609 (libcore/net: `IpAddr::as_octets()`) - #137336 (Stabilise `os_str_display`) - #137350 (Move methods from Map to TyCtxt, part 3.) - #137353 (Implement `read_buf` for WASI stdin) - #137361 (Refactor `OperandRef::extract_field` to prep for MCP838) - #137367 (Do not exempt nonexistent platforms from platform policy) - #137374 (Stacker now handles miri using a noop impl itself) - #137392 (remove few unused fields) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-21Rollup merge of #137367 - workingjubilee:remove-stray-line, r=jieyouxuMatthias Krüger-1/+0
Do not exempt nonexistent platforms from platform policy In #137324 I approved the change of the i586-pc-qnx platform to i686 with this extra line included. I noticed it but thought it was a bootstrap problem of some sort. Nonetheless, removing this line doesn't seem to change anything. r? `@Noratrieb`
2025-02-21Rollup merge of #137350 - nnethercote:remove-Map-3, r=ZalatharMatthias Krüger-108/+96
Move methods from Map to TyCtxt, part 3. A follow-up to #137162. r? `@Zalathar`
2025-02-22compiletest: introduce and use `--src-root` and `--src-test-suite-root`许杰友 Jieyou Xu (Joe)-97/+74
Instead of only having `--src-base` and `src_base` which *actually* refers to the directory containing the test suite and not the sources root. More importantly, kill off `find_rust_src_root` when we can simply pass that info from bootstrap.
2025-02-21stabilize `unsigned_is_multiple_of`Folkert de Vries-1/+0
2025-02-21Add testsbjorn3-0/+40
2025-02-21fixandylokandy-1/+1
2025-02-21feat: update insta inline snapshot when clicks 'Update Test' runnableandylokandy-16/+13
2025-02-21Fix review commentsbjorn3-7/+7
2025-02-21Rollup merge of #137305 - nnethercote:rustc_middle-2, r=lcnrMatthias Krüger-1/+1
Tweaks in and around `rustc_middle` A bunch of tiny improvements I found while working on bigger things. r? ```@lcnr```
2025-02-21Rollup merge of #137299 - nnethercote:simplify-PostOrder-customization, ↵Matthias Krüger-1/+1
r=compiler-errors Simplify `Postorder` customization. `Postorder` has a `C: Customization<'tcx>` parameter, that gives it flexibility about how it computes successors. But in practice, there are only two `impls` of `Customization`, and one is for the unit type. This commit simplifies things by removing the generic parameter and replacing it with an `Option`. r? ````@saethlin````
2025-02-21Implement vpmaxq_u8 on aarch64bjorn3-13/+83
2025-02-21Do not exempt nonexistent platforms from platform policyJubilee Young-1/+0
2025-02-20rust-analyzer: use new function in (incorrect) layout computationJubilee Young-1/+1
This is only to fix the build.
2025-02-21Move methods from Map to TyCtxt, part 3.Nicholas Nethercote-108/+96
Continuing the work from #137162. Every method gains a `hir_` prefix.
2025-02-21Trim suggestion part before generating highlightsMichael Goulet-24/+20
2025-02-21More sophisticated span trimmingMichael Goulet-121/+80
2025-02-20Rollup merge of #137324 - flba-eb:rename_qnx_target_name_i586, r=workingjubileeJubilee-0/+1
Make x86 QNX target name consistent with other Rust targets Rename target to be consistent with other Rust targets: Use `i686` instead of `i586` See also - #136495 - #109173 CC: `@jonathanpallant` `@japaric` `@gh-tr` `@samkearney`
2025-02-20Rollup merge of #136985 - zachs18:backend-repr-remove-uninhabited, ↵Jubilee-6/+6
r=workingjubilee Do not ignore uninhabited types for function-call ABI purposes. (Remove BackendRepr::Uninhabited) Accepted MCP: https://github.com/rust-lang/compiler-team/issues/832 Fixes #135802 Do not consider the inhabitedness of a type for function call ABI purposes. * Remove the [`rustc_abi::BackendRepr::Uninhabited`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/enum.BackendRepr.html) variant * Instead calculate the `BackendRepr` of uninhabited types "normally" (as though they were not uninhabited "at the top level", but still considering inhabitedness of variants to determine enum layout, etc) * Add an `uninhabited: bool` field to [`rustc_abi::LayoutData`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/struct.LayoutData.html) so inhabitedness of a `LayoutData` can still be queried when necessary (e.g. when determining if an enum variant needs a tag value allocated to it). This should not affect type layouts (size/align/field offset); this should only affect function call ABI, and only of uninhabited types. cc ``@RalfJung``
2025-02-20Rollup merge of #136608 - kulst:ptx_target_features, r=bjorn3Jubilee-2/+17
Pass through of target features to llvm-bitcode-linker and handling them When using the llvm-bitcode-linker (`linker-flavor=llbc`) target-features are not passed through and are not handled by it. The llvm-bitcode-linker is mainly used as a self contained linker to link llvm bitcode for the nvptx64 target. It uses `llvm-link`, `opt` and `llc` internally. To produce a `.ptx` file of a specific ptx-version it is necessary to pass the version to llc with the `--mattr` option. Without explicitly setting it, the emitted `.ptx`-version is the minimum supported version of the `--target-cpu`. I would like to be able to explicitly set the ptx version as [some llvm problems only occur in earlier `.ptx`-versions](https://github.com/llvm/llvm-project/issues/112998). Therefore this pull request adds support for passing target features to llvm-bitcode-linker and handling them. I was not quite sure if adding these features to `rustc_target/src/target_features.rs` is necessary or not. If so I will gladly add these. r? ``@kjetilkjeka``
2025-02-20Rollup merge of #131651 - Patryk27:avr-unknown-unknown, r=tgross35Jubilee-0/+10
Create a generic AVR target: avr-none This commit removes the `avr-unknown-gnu-atmega328` target and replaces it with a more generic `avr-none` variant that must be specialized using `-C target-cpu` (e.g. `-C target-cpu=atmega328p`). Seizing the day, I'm adding myself as the maintainer of this target - I've been already fixing the bugs anyway, might as well make it official 🙂 Related discussions: - https://github.com/rust-lang/rust/pull/131171 - https://github.com/rust-lang/compiler-team/issues/800 try-job: x86_64-gnu-debug
2025-02-21Rename `ClearCrossCrate::assert_crate_local`.Nicholas Nethercote-1/+1
As `unwrap_crate_local`, because it follows exactly the standard form of an `unwrap` function.
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-6/+6
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-20Update style.mdBenjamin Brienen-1/+1
fix dead link
2025-02-20Merge pull request #19189 from Veykril/push-qutznxznnwqnLukas Wirth-3/+3
minor: Improve unset `OUT_DIR` error message
2025-02-20Improve unset OUT_DIR error messageLukas Wirth-3/+3
2025-02-20Make x86 QNX target name consistent with other Rust targetsFlorian Bartels-0/+1
2025-02-20Merge pull request #19190 from BenjaminBrienen/patch-4Laurențiu Nicola-3/+2
Update editor_features.md
2025-02-21Resolve some FIXME from socketpair testtiif-6/+2
2025-02-20Update editor_features.mdBenjamin Brienen-3/+2
fix typos in snippets