about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2025-01-24Auto merge of #135272 - BoxyUwU:generic_arg_infer_reliability_2, ↵bors-182/+189
r=compiler-errors Forbid usage of `hir` `Infer` const/ty variants in ambiguous contexts The feature `generic_arg_infer` allows providing `_` as an argument to const generics in order to infer them. This introduces a syntactic ambiguity as to whether generic arguments are type or const arguments. In order to get around this we introduced a fourth `GenericArg` variant, `Infer` used to represent `_` as an argument to generic parameters when we don't know if its a type or a const argument. This made hir visitors that care about `TyKind::Infer` or `ConstArgKind::Infer` very error prone as checking for `TyKind::Infer`s in `visit_ty` would find *some* type infer arguments but not *all* of them as they would sometimes be lowered to `GenericArg::Infer` instead. Additionally the `visit_infer` method would previously only visit `GenericArg::Infer` not *all* infers (e.g. `TyKind::Infer`), this made it very easy to override `visit_infer` and expect it to visit all infers when in reality it would only visit *some* infers. --- This PR aims to fix those issues by making the `TyKind` and `ConstArgKind` types generic over whether the infer types/consts are represented by `Ty/ConstArgKind::Infer` or out of line (e.g. by a `GenericArg::Infer` or accessible by overiding `visit_infer`). We then make HIR Visitors convert all const args and types to the versions where infer vars are stored out of line and call `visit_infer` in cases where a `Ty`/`Const` would previously have had a `Ty/ConstArgKind::Infer` variant: API Summary ```rust enum AmbigArg {} enum Ty/ConstArgKind<Unambig = ()> { ... Infer(Unambig), } impl Ty/ConstArg { fn try_as_ambig_ty/ct(self) -> Option<Ty/ConstArg<AmbigArg>>; } impl Ty/ConstArg<AmbigArg> { fn as_unambig_ty/ct(self) -> Ty/ConstArg; } enum InferKind { Ty(Ty), Const(ConstArg), Ambig(InferArg), } trait Visitor { ... fn visit_ty/const_arg(&mut self, Ty/ConstArg<AmbigArg>) -> Self::Result; fn visit_infer(&mut self, id: HirId, sp: Span, kind: InferKind) -> Self::Result; } // blanket impl'd, not meant to be overriden trait VisitorExt { fn visit_ty/const_arg_unambig(&mut self, Ty/ConstArg) -> Self::Result; } fn walk_unambig_ty/const_arg(&mut V, Ty/ConstArg) -> Self::Result; fn walk_ty/const_arg(&mut V, Ty/ConstArg<AmbigArg>) -> Self::Result; ``` The end result is that `visit_infer` visits *all* infer args and is also the *only* way to visit an infer arg, `visit_ty` and `visit_const_arg` can now no longer encounter a `Ty/ConstArgKind::Infer`. Representing this in the type system means that it is now very difficult to mess things up, either accessing `TyKind::Infer` "just works" and you won't miss *some* type infers- or it doesn't work and you have to look at `visit_infer` or some `GenericArg::Infer` which forces you to think about the full complexity involved. Unfortunately there is no lint right now about explicitly matching on uninhabited variants, I can't find the context for why this is the case :woman_shrugging: I'm not convinced the framing of un/ambig ty/consts is necessarily the right one but I'm not sure what would be better. I somewhat like calling them full/partial types based on the fact that `Ty<Partial>`/`Ty<Full>` directly specifies how many of the type kinds are actually represented compared to `Ty<Ambig>` which which leaves that to the reader to figure out based on the logical consequences of it the type being in an ambiguous position. --- tool changes have been modified in their own commits for easier reviewing by anyone getting cc'd from subtree changes. I also attempted to split out "bug fixes arising from the refactoring" into their own commit so they arent lumped in with a big general refactor commit Fixes #112110
2025-01-24Auto merge of #135978 - matthiaskrgr:rollup-ni16gqr, r=matthiaskrgrbors-15/+29
Rollup of 8 pull requests Successful merges: - #133605 (Add extensive set of drop order tests) - #135489 (remove pointless allowed_through_unstable_modules on TryFromSliceError) - #135757 (Add NuttX support for AArch64 and ARMv7-A targets) - #135799 (rustdoc-json: Rename `Path::name` to `path`, and give it the path again.) - #135865 (For E0223, suggest associated functions that are similar to the path, even if the base type has multiple inherent impl blocks.) - #135890 (Implement `VecDeque::pop_front_if` & `VecDeque::pop_back_if`) - #135914 (Remove usages of `QueryNormalizer` in the compiler) - #135936 (fix reify-intrinsic test) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-24Rollup merge of #135865 - zachs18:maybe_report_similar_assoc_fn_more, ↵Matthias Krüger-1/+0
r=compiler-errors For E0223, suggest associated functions that are similar to the path, even if the base type has multiple inherent impl blocks. Currently, the "help: there is an associated function with a similar name `from_utf8`" suggestion for `String::from::utf8` is only given if `String` has exactly one inherent `impl` item. This PR makes the suggestion be emitted even if the base type has multiple inherent `impl` items. Example: ```rust struct Foo; impl Foo { fn bar_baz() {} } impl Foo {} // load-bearing fn main() { Foo::bar::baz; } ``` Nightly/stable output: ```rust error[E0223]: ambiguous associated type --> f.rs:7:5 | 7 | Foo::bar::baz; | ^^^^^^^^ | help: if there were a trait named `Example` with associated type `bar` implemented for `Foo`, you could use the fully-qualified path | 7 | <Foo as Example>::bar::baz; | ~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0223`. ``` Output with this PR, or without the load-bearing empty impl on nightly/stable: ```rust error[E0223]: ambiguous associated type --> f.rs:7:5 | 7 | Foo::bar::baz; | ^^^^^^^^ | help: there is an associated function with a similar name: `bar_baz` | 7 | Foo::bar_baz; | ~~~~~~~ error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0223`. ``` Ideally, this suggestion would also work for non-ADT types like ~~`str::char::indices`~~ (edit: latest commit makes this work with primitives) or `<dyn Any>::downcast::mut_unchecked`, but that seemed to be a harder change. `@rustbot` label +A-diagnostics
2025-01-24Rollup merge of #135799 - aDotInTheVoid:skrrt-skrrt-revrrt, r=GuillaumeGomezMatthias Krüger-11/+15
rustdoc-json: Rename `Path::name` to `path`, and give it the path again. Closes: #135600. Reverts #134880 (Effectively, but not actually, as the `FORMAT_VERSION` needs to be bumped, changed docs/tests). CC `@AS1100K.` Also CC `@obi1kenobi` `@LukeMathWalker` Still needs before being merge-ready: - [x] Tests for cross-crate paths - [x] (Maybe) Document what the field does. - [x] Decide if the field rename is good (https://github.com/rust-lang/rust/pull/135799#issuecomment-2605937831) - [ ] Squash commits. r? `@GuillaumeGomez`
2025-01-24Rollup merge of #135757 - no1wudi:master, r=compiler-errorsMatthias Krüger-2/+12
Add NuttX support for AArch64 and ARMv7-A targets This patch adds tier 3 support for AArch64 and ARMv7-A targets in NuttX, including: - AArch64 target: aarch64-unknown-nuttx - ARMv7-A target: armv7a-nuttx-eabi, armv7a-nuttx-eabihf - Thumbv7-A target: thumbv7a-nuttx-eabi, thumbv7a-nuttx-eabihf
2025-01-24Rollup merge of #135489 - RalfJung:TryFromSliceError, r=tgross35Matthias Krüger-1/+2
remove pointless allowed_through_unstable_modules on TryFromSliceError This got added in https://github.com/rust-lang/rust/pull/132482 but the PR does not explain why. `@lukas-code` do you still remember? Also Cc `@Noratrieb` as reviewer of that PR. If I understand the issue description correctly, all paths under which this type is exported are stable now: `core::array::TryFromSliceError` and `std::array::TryFromSliceError`. If that is the case, we shouldn't have the attribute; it's a terrible hack that should only be used when needed to maintain backward compatibility. Getting some historic information right is IMO *not* sufficient justification to risk accidentally exposing this type via more unstable paths today or in the future.
2025-01-24Auto merge of #135959 - matthiaskrgr:rollup-0jenyfw, r=matthiaskrgrbors-5/+202
Rollup of 7 pull requests Successful merges: - #135366 (Enable `unreachable_pub` lint in `test` and `proc_macro` crates) - #135638 (Make it possible to build GCC on CI) - #135648 (support wasm inline assembly in `naked_asm!`) - #135827 (CI: free disk with in-tree script instead of GitHub Action) - #135855 (Only assert the `Parser` size on specific arches) - #135878 (ci: use 8 core arm runner for dist-aarch64-linux) - #135905 (Enable kernel sanitizers for aarch64-unknown-none-softfloat) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-24Rollup merge of #135878 - marcoieni:dist-aarch64-linux-8c, r=KobzolMatthias Krüger-1/+3
ci: use 8 core arm runner for dist-aarch64-linux try-job: dist-aarch64-linux
2025-01-24Rollup merge of #135827 - marcoieni:free-space-script, r=KobzolMatthias Krüger-0/+142
CI: free disk with in-tree script instead of GitHub Action
2025-01-24Rollup merge of #135638 - Kobzol:gcc-ci, r=onur-ozkanMatthias Krüger-4/+57
Make it possible to build GCC on CI This is the first step towards eventually enabling download of precompiled GCC from our CI. Currently, we prebuild `libgccjit` on CI and cache it in Docker. This PR improves the bootstrap GCC step to make it work on CI, and also to make it faster by using sccache. After this change, an actual build on CI should take only 2-3 minutes. Note that this PR does not yet remove the `build-gccjit.sh` script and replace it with the bootstrap step, I'll leave that to a follow-up PR. The added `flex` package and the ZSTD library fix were needed to make GCC build on CI. CC ``````@GuillaumeGomez`````` r? ``````@onur-ozkan``````
2025-01-23Give E0223 similar-item suggestion test more descriptive name.Zachary S-1/+0
2025-01-23Rollup merge of #135880 - bjorn3:misc_driver_refactors, r=oli-obkMatthias Krüger-62/+35
Get rid of RunCompiler The various `set_*` methods that have been removed can be replaced by setting the respective fields in the `Callbacks::config` implementation. `set_using_internal_features` was often forgotten and it's equivalent is now done automatically.
2025-01-23Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushiMatthias Krüger-0/+23
Implement `ByteStr` and `ByteString` types Approved ACP: https://github.com/rust-lang/libs-team/issues/502 Tracking issue: https://github.com/rust-lang/rust/issues/134915 These types represent human-readable strings that are conventionally, but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using escape sequences, and the `Display` impl uses the Unicode replacement character. This is a minimal implementation of these types and associated trait impls. It does not add any helper methods to other types such as `[u8]` or `Vec<u8>`. I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`, when those would be the second implementation for a type (counting the `T` impl), to avoid potential inference failures. We can attempt to add more impls later in standalone commits, and run them through crater. In addition to the `bstr` feature, I've added a `bstr_internals` feature for APIs provided by `core` for use by `alloc` but not currently intended for stabilization. This API and its implementation are based *heavily* on the `bstr` crate by Andrew Gallant (`@BurntSushi).` r? `@BurntSushi`
2025-01-23Auto merge of #135921 - matthiaskrgr:rollup-5mzn76m, r=matthiaskrgrbors-68/+41
Rollup of 9 pull requests Successful merges: - #134746 (Don't ICE in coerce when autoderef fails to structurally normalize non-WF type in new solver) - #135552 ([AIX] Lint on structs that have a different alignment in AIX's C ABI) - #135779 (CI: free disk on linux arm runner) - #135790 (Update windows-gnu targets to set `DebuginfoKind::DWARF`) - #135879 (fix outdated file path ref in llvm) - #135883 (Remove erroneous `unsafe` in `BTreeSet::upper_bound_mut`) - #135884 (remove implied end of slice) - #135887 (improvements on `build_steps::test` implementation) - #135898 (rustdoc-json-types: Finalize dyn compatibility renaming) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-23Remove RunCompilerbjorn3-10/+10
It has become nothing other than a wrapper around run_compiler.
2025-01-23Remove set_make_codegen_backend and set_file_loaderbjorn3-14/+12
They can both be set inside the config callback too.
2025-01-23Remove the need to manually call set_using_internal_featuresbjorn3-43/+18
2025-01-23Auto merge of #135494 - yotamofek:rustdoc-fmt-from_fn, r=fmeasebors-172/+127
Refactor `fmt::Display` impls in rustdoc This PR does a couple of things, with the intention of cleaning up and streamlining some of the `fmt::Display` impls in rustdoc: 1. Use the unstable [`fmt::from_fn`](https://github.com/rust-lang/rust/issues/117729) instead of open-coding it. 2. ~~Replace bespoke implementations of `Itertools::format` with the method itself.~~ 4. Some more minor cleanups - DRY, remove unnecessary calls to `Symbol::as_str()`, replace some `format!()` calls with lazier options The changes are mostly cosmetic but some of them might have a slight positive effect on performance.
2025-01-23Rollup merge of #135898 - aDotInTheVoid:dyndoc, r=fmeaseMatthias Krüger-2/+1
rustdoc-json-types: Finalize dyn compatibility renaming Followup to #131595. Part of #130852. Inspired by #135858 (does the same thing but for the rustdoc-types docs). r? ````@fmease````
2025-01-23Rollup merge of #135887 - onur-ozkan:testing-improvements, r=jieyouxuMatthias Krüger-65/+37
improvements on `build_steps::test` implementation Reviewing commits one-by-one should make it easier to understand.
2025-01-23Rollup merge of #135879 - onur-ozkan:invalid-file-path, r=jieyouxuMatthias Krüger-1/+1
fix outdated file path ref in llvm This was added years ago and is outdated today.
2025-01-23Rollup merge of #135779 - marcoieni:free-disk-arm-runner, r=KobzolMatthias Krüger-0/+2
CI: free disk on linux arm runner try-job: aarch64-gnu
2025-01-23make `hir::Ty/ConstArg` methods generic where applicableBoxy-2/+2
2025-01-23`visit_x_unambig`Boxy-12/+12
2025-01-23The clipper :3cBoxy-168/+165
2025-01-23Rustdog :3cBoxy-10/+20
2025-01-23Make `hir::TyKind::TraitObject` use tagged ptrBoxy-7/+7
2025-01-23Auto merge of #135461 - jieyouxu:migrate-jobserver-errors, r=Noratriebbors-1/+66
tests: Port `jobserver-error` to rmake.rs Part of #121876. This PR ports `tests/run-make/jobserver-error` to rmake.rs, and is basically #128789 slightly adjusted. The complexity involved here is mostly how to get `/dev/null/` piping to fd 3 working with std `Command`, whereas with a shell this is much easier (as is evident with the `Makefile` version). Supersedes #128789. This PR is co-authored with `@Oneirical` and `@coolreader18.` try-job: aarch64-gnu try-job: i686-gnu-1 try-job: x86_64-gnu-debug try-job: x86_64-gnu-llvm-18-1
2025-01-23Auto merge of #135164 - Kobzol:run-make-test-glibc-symbols, r=jieyouxubors-1/+17
Add test for checking used glibc symbols This test checks that we do not use too new glibc symbols in the compiler on x64 GNU Linux, in order not to break our [glibc promises](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html). One thing that isn't solved in the PR yet is to make sure that this test will only run on `dist` CI, more specifically on the `dist-x86_64-linux` runner, in the opt-dist post-optimization tests (it can fail elsewhere, that doesn't matter). Any suggestions on how to do that are welcome. Fixes: https://github.com/rust-lang/rust/issues/134037 r? `@jieyouxu`
2025-01-22Auto merge of #135896 - matthiaskrgr:rollup-g6rv7za, r=matthiaskrgrbors-3/+10
Rollup of 9 pull requests Successful merges: - #132983 (Edit dangling pointers ) - #135409 (Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block) - #135557 (Point at invalid utf-8 span on user's source code) - #135596 (Properly note when query stack is being cut off) - #135794 (Detect missing fields with default values and suggest `..`) - #135814 (ci: use ghcr buildkit image) - #135826 (Misc. `rustc_resolve` cleanups) - #135837 (Remove test panic from File::open) - #135856 (Library: Finalize dyn compatibility renaming) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-22rustdoc-json-types: Finalize dyn compatibility renamingAlona Enraght-Moony-2/+1
2025-01-22Rollup merge of #135814 - marcoieni:use-buildkit-ghcr, r=KobzolMatthias Krüger-2/+7
ci: use ghcr buildkit image
2025-01-22Rollup merge of #135557 - estebank:wtf8, r=fee1-deadMatthias Krüger-1/+3
Point at invalid utf-8 span on user's source code ``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: byte `193` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-22rustdoc-json: Rename `Path::name` to `path`, and give it path (again).Alona Enraght-Moony-11/+15
Closes https://github.com/rust-lang/rust/issues/135600 Effectivly reverts https://github.com/rust-lang/rust/pull/134880
2025-01-22Rollup merge of #135858 - fmease:rustdoc-mv-obj-save-dyn-compat-ii, ↵Matthias Krüger-2/+1
r=GuillaumeGomez rustdoc: Finalize dyn compatibility renaming Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME. Follow-up to #131594. Part of #130852.
2025-01-22Rollup merge of #135850 - alexcrichton:update-wasm-component-ld, r=jieyouxuMatthias Krüger-1/+1
Update the `wasm-component-ld` tool This commit updates the `wasm-component-ld` tool from 0.5.11 to 0.5.12. This pulls in a fix for the binary adapters that are included with this tool for an issue described in bytecodealliance/wasmtime#10058. Some other dependencies have additionally been updated in the meantime of `wasm-component-ld` but there should otherwise be no major changes.
2025-01-22reduce number of `prepare_cargo_test` argsonur-ozkan-8/+7
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-01-22resolve clippy FIXMEonur-ozkan-52/+14
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-01-22make bootstrap self test to use bootstrap cargoonur-ozkan-15/+26
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-01-22fix outdated file path ref in llvmonur-ozkan-1/+1
This was added years ago and is outdated today. Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-01-22ci: use 8 core arm runner for dist-aarch64-linuxMarcoIeni-1/+3
2025-01-22Run the glibc run-make test in opt-distJakub Beránek-1/+2
2025-01-22Use `structurally_normalize` instead of manual `normalizes-to` goalsBoxy-1/+1
2025-01-22rustdoc: extract duplicated code into methodYotam Ofek-72/+45
2025-01-22rustdoc: use std's (unstable) `fmt::from_fn` instead of open-coding itYotam Ofek-91/+73
2025-01-22rustdoc: pass around decoration info by refYotam Ofek-9/+9
2025-01-22tests: port `jobserver-error.rs` to rmake.rs许杰友 Jieyou Xu (Joe)-1/+0
Co-authored-by: Noa <coolreader18@gmail.com> Co-authored-by: Oneirical <manchot@videotron.ca>
2025-01-22run-make-support: add `set_aux_fd` helper许杰友 Jieyou Xu (Joe)-0/+66
Co-authored-by: Noa <coolreader18@gmail.com> Co-authored-by: Oneirical <manchot@videotron.ca>
2025-01-22rustdoc: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-2/+1
2025-01-22Auto merge of #135848 - matthiaskrgr:rollup-sftciqm, r=matthiaskrgrbors-11/+11
Rollup of 8 pull requests Successful merges: - #132232 (CI: build FreeBSD artifacts on FreeBSD 13.4) - #135706 (Move `supertrait_def_ids` into the elaborate module like all other fns) - #135750 (Add an example of using `carrying_mul_add` to write wider multiplication) - #135793 (Ignore `mermaid.min.js`) - #135810 (Add Kobzol on vacation) - #135821 (fix OsString::from_encoded_bytes_unchecked description) - #135824 (tests: delete `cat-and-grep-sanity-check`) - #135833 (Add fixme and test for issue #135289) Failed merges: - #135816 (Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors) r? `@ghost` `@rustbot` modify labels: rollup