about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-08-13Remove duplicated rustdoc ui testGuillaume Gomez-8/+0
2024-08-12Auto merge of #128371 - andjo403:rangeAttribute, r=nikicbors-24/+159
Add range attribute to scalar function results and arguments as LLVM 19 adds the range attribute this starts to use it for better optimization. hade been interesting to see a perf run with the https://github.com/rust-lang/rust/pull/127513 closes https://github.com/rust-lang/rust/issues/50156 cc https://github.com/rust-lang/rust/issues/49572 shall be fixed but not possible to see as there is asserts that already trigger the optimization.
2024-08-12Auto merge of #128862 - cblh:fix/128855, r=scottmcmbors-0/+14
fix: #128855 Ensure `Guard`'s `drop` method is removed at `opt-level=s` for `… fix: #128855 …Copy` types Added `#[inline]` to the `drop` method in the `Guard` implementation to ensure that the method is removed by the compiler at optimization level `opt-level=s` for `Copy` types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance. r​? `@scottmcm`
2024-08-12Auto merge of #126793 - saethlin:mono-rawvec, r=scottmcmbors-312/+559
Apply "polymorphization at home" to RawVec The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times. This uncovered https://github.com/rust-lang/rust-clippy/issues/12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
2024-08-11Fix debuginfo providers/testsBen Kimock-22/+22
2024-08-11Auto merge of #128677 - nikic:llvm19rc2, r=cuviperbors-0/+0
Update to LLVM 19 rc2 Update from ~rc1 to rc2. Fixes https://github.com/rust-lang/rust/issues/128555.
2024-08-11Add range attribute to scalar function results and argumentsAndreas Jonson-24/+159
2024-08-11Auto merge of #122362 - Zoxc:rustc_driver_static_std, ↵bors-17/+113
r=oli-obk,lqd,bjorn3,Kobzol Link `std` statically in `rustc_driver` This makes `rustc_driver` statically link to `std`. This is done by not passing `-C prefer-dynamic` when building `rustc_driver`. However building `rustc-main` won't work currently as it tries to dynamically link to both `rustc_driver` and `std` resulting in a crate graph with `std` duplicated. To fix that new command line option `-Z prefer_deps_of_dynamic` is added which prevents linking to a dylib if there's a static variant of it already statically linked into another dylib dependency. The main motivation for this change is to enable `#[global_allocator]` to be used in `rustc_driver` allowing overriding the allocator used in rustc on all platforms. --- Instead of adding `-Z prefer_deps_of_dynamic`, this PR is changed to crate opt-in to the linking change via the `rustc_private` feature instead, as that would be typically needed to link to `rustc_driver` anyway. --- try-job: aarch64-apple try-job: x86_64-msvc try-job: i686-mingw try-job: dist-x86_64-msvc try-job: aarch64-gnu
2024-08-11Auto merge of #128916 - jieyouxu:dump-ice-dump-ice, r=compiler-errorsbors-113/+173
Tidy up `dump-ice-to-disk` and make assertion failures dump ICE messages For the future traveler: **if you did a `git blame` and found this PR that last modified `dump-ice-to-disk` because the test failed in a completely unrelated PR, then I'm afraid our ICE dump may have regressed or somehow behaves differently on `i686-mingw`.** A bit of clean up to the `dump-ice-to-disk` test. - Fixes/updates the top-level comment. - Add a FIXME pointing to #128911 for flakiness. - Instead of trying to manually cleanup `rustc-ice*.txt` dumps, run each test instance in a separate temp directory. - Explicitly make `RUSTC_ICE` unavailable in one of the `-Zmetrics-dir` test case to not have interference from environment. - Make assertion failures (on ICE dump line count mismatch) extremely verbose to help debug why this test is flakey in CI (#128911). Contains a fix by `@saethlin` in #128909, should wait until that is merged then rebase on top. try-job: aarch64-gnu try-job: aarch64-apple try-job: x86_64-msvc try-job: i686-mingw try-job: test-various
2024-08-11tests: ignore `dump-ice-to-disk` on windows许杰友 Jieyou Xu (Joe)-3/+4
2024-08-11Auto merge of #128959 - matthiaskrgr:rollup-6jdqi3l, r=matthiaskrgrbors-449/+476
Rollup of 6 pull requests Successful merges: - #120314 (core: optimise Debug impl for ascii::Char) - #128536 (Preliminary cleanup of `WitnessPat` hoisting/printing) - #128592 (Promote aarch64-apple-darwin to Tier 1) - #128762 (Use more slice patterns inside the compiler) - #128875 (rm `import.used`) - #128882 (make LocalWaker::will_wake consistent with Waker::will_wake) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-11Rollup merge of #128882 - RalfJung:local-waker-will-wake, r=cuviperMatthias Krüger-1/+7
make LocalWaker::will_wake consistent with Waker::will_wake This mirrors https://github.com/rust-lang/rust/pull/119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (https://github.com/rust-lang/rust/pull/118960).
2024-08-11Rollup merge of #128875 - bvanjoi:cleanup-import-used, r=petrochenkovMatthias Krüger-15/+16
rm `import.used` By the way, `import_used_map` will only be used during `build_reduced_graph` and `finalize`, so it can be split from `Resolver` in the future. r? ``@petrochenkov``
2024-08-11Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errorsMatthias Krüger-221/+191
Use more slice patterns inside the compiler Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'. r? ghost
2024-08-11Rollup merge of #128592 - evelynharthbrooke:master, r=Mark-SimulacrumMatthias Krüger-8/+4
Promote aarch64-apple-darwin to Tier 1 This promotes aarch64-apple-darwin to Tier 1 status as per rust-lang/rfcs#3671 and tracking issue #73908. Not sure what else is necessary for this to impement the aforementioned RFC, however I figured I'd try. I did read in previous issues and PRs that the necessary infrastructure was already in place for the aarch64-apple-darwin target, and the RFC mentions the same. So this should be all thats necessary in order for the target to be promoted. This is a recreation of my previous PR because I accidentally did an incorrect git rebase which caused unnecessary changes to various commit SHAs. So this PR is a recreation of my previous PR without said stumble. My bad.
2024-08-11Rollup merge of #128536 - Zalathar:print-cleanup, r=NadrierilMatthias Krüger-185/+216
Preliminary cleanup of `WitnessPat` hoisting/printing Follow-up to #128430. The eventual goal is to remove `print::Pat` entirely, but in the course of working towards that I made so many small improvements that it seems wise to let those be reviewed/merged on their own first. Best reviewed commit-by-commit, most of which should be pretty simple and straightforward. r? ``@Nadrieril``
2024-08-11Rollup merge of #120314 - mina86:i, r=Mark-SimulacrumMatthias Krüger-19/+42
core: optimise Debug impl for ascii::Char Rather than writing character at a time, optimise Debug implementation for core::ascii::Char such that it writes the entire representation with a single write_str call. With that, add tests for Display and Debug. Issue: https://github.com/rust-lang/rust/issues/110998
2024-08-11Keep rustc's std copyJohn Kåre Alsaker-12/+1
2024-08-11tests: tidy up `dump-ice-to-disk` and make assertion failures extremely verbose许杰友 Jieyou Xu (Joe)-113/+172
2024-08-11Exclude just `std` from rustc depsJohn Kåre Alsaker-9/+5
2024-08-11Update the unstable bookJohn Kåre Alsaker-0/+11
2024-08-11Don't statically link `std` into `rustc_driver` for `windows-gnu`John Kåre Alsaker-4/+30
2024-08-11Ask the user to use `feature(rustc_private)` when linking to `rustc_driver`John Kåre Alsaker-8/+23
2024-08-11Link `std` statically in `rustc_driver`John Kåre Alsaker-11/+70
2024-08-10Auto merge of #128572 - compiler-errors:fix-elaborate-box-derefs-on-debug, ↵bors-8/+77
r=saethlin Fix `ElaborateBoxDerefs` on debug varinfo Slightly simplifies the `ElaborateBoxDerefs` pass to fix cases where it was applying the wrong projections to debug var infos containing places that deref boxes. From what I can tell[^1], we don't actually have any tests (or code anywhere, really) that exercise `debug x => *(...: Box<T>)`, and it's very difficult to trigger this in surface Rust, so I wrote a custom MIR test. What happens is that the pass was turning `*(SOME_PLACE: Box<T>)` into `*(*((((SOME_PLACE).0: Unique<T>).0: NonNull<T>).0: *const T))` in debug var infos. In particular, notice the *double deref*, which was wrong. This is the root cause of #128554, so this PR fixes #128554 as well. The reason that async closures was affected is because of the way that we compute the [`ByMove` body](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs), which resulted in `*(...: Box<T>)` in debug var info. But this really has nothing to do with async closures. [^1]: Validated by literally replacing the `if elem == PlaceElem::Deref && base_ty.is_box() { ... }` innards with a `panic!()`, which compiled all of stage2 without panicking.
2024-08-10Auto merge of #128400 - petrochenkov:nowhole3, r=bjorn3bors-13/+2
linker: Remove the "`--whole-archive` in test mode" backcompat hack Fixes https://github.com/rust-lang/rust/issues/116910.
2024-08-10Auto merge of #128927 - GuillaumeGomez:rollup-ei2lr0f, r=GuillaumeGomezbors-191/+368
Rollup of 8 pull requests Successful merges: - #128273 (Improve `Ord` violation help) - #128807 (run-make: explaing why fmt-write-bloat is ignore-windows) - #128903 (rustdoc-json-types `Discriminant`: fix typo) - #128905 (gitignore: Add Zed and Helix editors) - #128908 (diagnostics: do not warn when a lifetime bound infers itself) - #128909 (Fix dump-ice-to-disk for RUSTC_ICE=0 users) - #128910 (Differentiate between methods and associated functions in diagnostics) - #128923 ([rustdoc] Stop showing impl items for negative impls) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-10Rollup merge of #128923 - GuillaumeGomez:negative-impls-items, r=fmeaseGuillaume Gomez-19/+53
[rustdoc] Stop showing impl items for negative impls Fixes https://github.com/rust-lang/rust/issues/128799. As discussed with `@fmease,` they have a broader patch in progress, so this (small) PR will at least allow for them to have a regression test. :) r? `@fmease`
2024-08-10Rollup merge of #128910 - estebank:assoc-fn, r=compiler-errorsGuillaume Gomez-72/+79
Differentiate between methods and associated functions in diagnostics Accurately refer to assoc fn without receiver as assoc fn instead of methods. Add `AssocItem::descr` method to centralize where we call methods and associated functions.
2024-08-10Rollup merge of #128909 - saethlin:run-make-ice-yes, r=jieyouxuGuillaume Gomez-1/+1
Fix dump-ice-to-disk for RUSTC_ICE=0 users Before this change, the test fails if you run it with `RUSTC_ICE=0`.
2024-08-10Rollup merge of #128908 - notriddle:notriddle/self-inferred-lifetime-bounds, ↵Guillaume Gomez-6/+97
r=compiler-errors diagnostics: do not warn when a lifetime bound infers itself Fixes #119228
2024-08-10Rollup merge of #128905 - mrkajetanp:gitignore-editors, r=jieyouxuGuillaume Gomez-0/+2
gitignore: Add Zed and Helix editors Just adding two extra code editors to .gitignore. Reference: https://helix-editor.com/ https://zed.dev/
2024-08-10Rollup merge of #128903 - kraktus:patch-3, r=aDotInTheVoidGuillaume Gomez-1/+1
rustdoc-json-types `Discriminant`: fix typo "when to complex" should obviously be "too complex"
2024-08-10Rollup merge of #128807 - ChrisDenton:bloat, r=jieyouxuGuillaume Gomez-3/+6
run-make: explaing why fmt-write-bloat is ignore-windows The trouble here is that libc doesn't exist on Windows. Well it kinda does but it isn't called that so we substitute a name that works. Ideally finding necessary libs for the platform would be done at a higher level but until then this should work. try-job: x86_64-msvc try-job: x86_64-mingw try-job: i686-msvc try-job: i686-mingw
2024-08-10Rollup merge of #128273 - Voultapher:improve-ord-violation-help, ↵Guillaume Gomez-89/+129
r=workingjubilee Improve `Ord` violation help Recent experience in #128083 showed that the panic message when an Ord violation is detected by the new sort implementations can be confusing. So this PR aims to improve it, together with minor bug fixes in the doc comments for sort*, sort_unstable* and select_nth_unstable*. Is it possible to get these changes into the 1.81 release? It doesn't change behavior and would greatly help when users encounter this panic for the first time, which they may after upgrading to 1.81. Tagging `@orlp`
2024-08-10Add regression tests for negative impls not showing their itemsGuillaume Gomez-0/+26
2024-08-10Stop showing impl items for negative implsGuillaume Gomez-19/+27
2024-08-10Auto merge of #122792 - Nadrieril:stabilize-min-exh-pats2, r=fee1-deadbors-935/+1061
Stabilize `min_exhaustive_patterns` ## Stabilisation report I propose we stabilize the [`min_exhaustive_patterns`](https://github.com/rust-lang/rust/issues/119612) language feature. With this feature, patterns of empty types are considered unreachable when matched by-value. This allows: ```rust enum Void {} fn foo() -> Result<u32, Void>; fn main() { let Ok(x) = foo(); // also match foo() { Ok(x) => ..., } } ``` This is a subset of the long-unstable [`exhaustive_patterns`](https://github.com/rust-lang/rust/issues/51085) feature. That feature is blocked because omitting empty patterns is tricky when *not* matched by-value. This PR stabilizes the by-value case, which is not tricky. The not-by-value cases (behind references, pointers, and unions) stay as they are today, e.g. ```rust enum Void {} fn foo() -> Result<u32, &Void>; fn main() { let Ok(x) = foo(); // ERROR: missing `Err(_)` } ``` The consequence on existing code is some extra "unreachable pattern" warnings. This is fully backwards-compatible. ### Comparison with today's rust This proposal only affects match checking of empty types (i.e. types with no valid values). Non-empty types behave the same with or without this feature. Note that everything below is phrased in terms of `match` but applies equallly to `if let` and other pattern-matching expressions. To be precise, a visibly empty type is: - an enum with no variants; - the never type `!`; - a struct with a *visible* field of a visibly empty type (and no #[non_exhaustive] annotation); - a tuple where one of the types is visibly empty; - en enum with all variants visibly empty (and no `#[non_exhaustive]` annotation); - a `[T; N]` with `N != 0` and `T` visibly empty; - all other types are nonempty. (An extra change was proposed below: that we ignore #[non_exhaustive] for structs since adding fields cannot turn an empty struct into a non-empty one) For normal types, exhaustiveness checking requires that we list all variants (or use a wildcard). For empty types it's more subtle: in some cases we require a `_` pattern even though there are no valid values that can match it. This is where the difference lies regarding this feature. #### Today's rust Under today's rust, a `_` is required for all empty types, except specifically: if the matched expression is of type `!` (the never type) or `EmptyEnum` (where `EmptyEnum` is an enum with no variants), then the `_` is not required. ```rust let foo: Result<u32, !> = ...; match foo { Ok(x) => ..., Err(_) => ..., // required } let foo: Result<u32, &!> = ...; match foo { Ok(x) => ..., Err(_) => ..., // required } let foo: &! = ...; match foo { _ => ..., // required } fn blah(foo: (u32, !)) { match foo { _ => ..., // required } } unsafe { let ptr: *const ! = ...; match *ptr {} // allowed let ptr: *const (u32, !) = ...; match *ptr { (x, _) => { ... } // required } let ptr: *const Result<u32, !> = ...; match *ptr { Ok(x) => { ... } Err(_) => { ... } // required } } ``` #### After this PR After this PR, a pattern of an empty type can be omitted if (and only if): - the match scrutinee expression has type `!` or `EmptyEnum` (like before); - *or* the empty type is matched by value (that's the new behavior). In all other cases, a `_` is required to match on an empty type. ```rust let foo: Result<u32, !> = ...; match foo { Ok(x) => ..., // `Err` not required } let foo: Result<u32, &!> = ...; match foo { Ok(x) => ..., Err(_) => ..., // required because `!` is under a dereference } let foo: &! = ...; match foo { _ => ..., // required because `!` is under a dereference } fn blah(foo: (u32, !)) { match foo {} // allowed } unsafe { let ptr: *const ! = ...; match *ptr {} // allowed let ptr: *const (u32, !) = ...; match *ptr { (x, _) => { ... } // required because the matched place is under a (pointer) dereference } let ptr: *const Result<u32, !> = ...; match *ptr { Ok(x) => { ... } Err(_) => { ... } // required because the matched place is under a (pointer) dereference } } ``` ### Documentation The reference does not say anything specific about exhaustiveness checking, hence there is nothing to update there. The nomicon does, I opened https://github.com/rust-lang/nomicon/pull/445 to reflect the changes. ### Tests The relevant tests are in `tests/ui/pattern/usefulness/empty-types.rs`. ### Unresolved Questions None that I know of. try-job: dist-aarch64-apple
2024-08-10rm `import.used`bohan-15/+16
2024-08-10Auto merge of #128746 - compiler-errors:cache-super-outlives, r=lcnrbors-26/+42
Cache supertrait outlives of impl header for soundness check This caches the results of computing the transitive supertraits of an impl and filtering it to its outlives obligations. This is purely an optimization to improve https://github.com/rust-lang/rust/pull/124336.
2024-08-10Fixes in various placesNadrieril-4/+12
2024-08-10Test that 0/unknown-length arrays are nonemptyNadrieril-47/+144
2024-08-10Update std and compilerNadrieril-4/+8
2024-08-10Update testsNadrieril-841/+878
2024-08-10Stabilize `min_exhaustive_patterns`Nadrieril-39/+19
2024-08-10Auto merge of #128740 - compiler-errors:generic-preds, r=estebankbors-6/+6
Stop unnecessarily taking GenericPredicates by `&self` This results in overcapturing in edition 2024, and is unnecessary since `GenericPredicates: Copy`.
2024-08-10Auto merge of #128714 - camelid:wf-struct-exprs, r=BoxyUwUbors-56/+560
WF-check struct field types at construction site Fixes #126272. Fixes #127299. Rustc of course already WF-checked the field types at the definition site, but for error tainting of consts to work properly, there needs to be an error emitted at the use site. Previously, with no use-site error, we proceeded with CTFE and ran into ICEs since we are running code with type errors. Emitting use-site errors also brings struct-like constructors more in line with fn-like constructors since they already emit use-site errors for WF issues. r? `@BoxyUwU`
2024-08-10test(std): Add codegen test for array::from_fn optimizationburlinchen-0/+13
This commit adds a new test file 'array-from_fn.rs' to the codegen test suite. The test checks the behavior of std::array::from_fn under different optimization levels: 1. At opt-level=0 (debug build), it verifies that the core::array::Guard is present in the generated code. 2. At opt-level=s (size optimization), it ensures that the Guard is optimized out. This test helps ensure that the compiler correctly optimizes array::from_fn calls in release builds while maintaining safety checks in debug builds.
2024-08-10Auto merge of #128584 - DianQK:tests-for-llvm-19, r=nikicbors-0/+67
Add a set of tests for LLVM 19 Close #107681. Close #118306. Close #126585. r? compiler
2024-08-10Differentiate between methods and associated functionsEsteban Küber-72/+79
Accurately refer to assoc fn without receiver as assoc fn instead of methods. Add `AssocItem::descr` method to centralize where we call methods and associated functions.