about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-12-29Auto merge of #134627 - estebank:issue-133252, r=jackh726bors-1/+39
Avoid ICE in borrowck Provide a fallback in `best_blame_constraint` when `find_constraint_paths_between_regions` doesn't have a result. This code is due a rework to avoid the letf-over `unwrap()`, but avoids the ICE caused by the repro. Fix #133252.
2024-12-28Added a codegen test for optimization with const arraysAlex Gaynor-0/+15
Closes #107208
2024-12-28Auto merge of #131244 - clubby789:match-branches-unreachable, r=DianQKbors-20/+69
Consider empty-unreachable otherwise branches in MatchBranchSimplification Fixes #131219
2024-12-28Auto merge of #134844 - Zalathar:rollup-1225wh9, r=Zalatharbors-75/+468
Rollup of 5 pull requests Successful merges: - #134737 (Implement `default_overrides_default_fields` lint) - #134760 (Migrate `branch-protection-check-IBT` to rmake.rs) - #134829 (Migrate `libs-through-symlink` to rmake.rs) - #134832 (Update `compiler-builtins` to 0.1.140) - #134840 (compiletest: Only pass the post-colon value to `parse_normalize_rule`) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-28Rollup merge of #134840 - Zalathar:normalize, r=jieyouxuStuart Cook-0/+24
compiletest: Only pass the post-colon value to `parse_normalize_rule` Addresses one of the FIXMEs noted in #134759. I started working on the other FIXME, but it became complex enough that I wanted to split it off from this PR. r? jieyouxu
2024-12-28Rollup merge of #134829 - jieyouxu:migrate-libs-through-symlinks, r=lqdStuart Cook-22/+48
Migrate `libs-through-symlink` to rmake.rs Part of https://github.com/rust-lang/rust/issues/121876. This PR migrates `tests/run-make/libs-through-symlink/` to use rmake.rs. - Regression test for #13890. - Original fix PR is #13903. - Document test intent, backlink to #13890 and fix PR #13903. - Fix the test logic: the `Makefile` version seems to not actually be exercising the "library search traverses symlink" logic, because the actual symlinked-to-library is present under the `$(TMPDIR)` directory tree when `bar.rs` is compiled, because the `$(RUSTC)` invocation has an implicit `-L $(TMPDIR)`. The symlink itself was actually broken, i.e. it should've been `ln -nsf $(TMPDIR)/outdir/$(NAME) $(TMPDIR)` but it used `ln -nsf outdir/$(NAME) $(TMPDIR)`. The rmake.rs version now explicitly separates the two directory trees and sets the CWD of the `bar.rs` rustc invocation so that the actual library is *not* present under its CWD tree. I.e. it is now ``` $test_output/ # rustc foo.rs -o actual_lib_dir/libfoo.rlib actual_lib_dir/ libfoo.rlib symlink_lib_dir/ # CWD set; rustc -L . bar.rs libfoo.rlib --> $test_output/actual_lib_dir/libfoo.rlib ``` Partially supersedes #129011. This PR is co-authored with `@Oneirical.` r? compiler
2024-12-28Rollup merge of #134760 - jieyouxu:enable-branch-protection-check-IBT, r=lqdStuart Cook-53/+58
Migrate `branch-protection-check-IBT` to rmake.rs - The Makefile version *never* ran because of Makefile syntax confusion because `ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86_64)` [compares `x86` to `x86_64`, which always evaluates to false](https://github.com/rust-lang/rust/pull/126720#discussion_r1646808973). - The test would've always failed because precompiled std is not built with `-Z cf-protection=branch`, but linkers require all input object files to indicate IBT support in order to enable IBT for the executable, which is not the case for std. - Thus, the test input file is instead changed to a `no_std` program. - The test is currently limited to only `x86_64-unknown-linux-gnu` host, there are various other problems when the test is cross-compiled that I didn't want to fix atm, and is left as an exercise for the `-Z cf-protection` implementers. The GNU property note was added by #110304 in order to address #103001. Partially supersedes #129156. The rmake.rs port was initially authored by `@Rejyr` in #126720. This PR is co-authored with `@Oneirical` and `@Rejyr.` r? `@bjorn3` or reroll try-job: x86_64-mingw-1 try-job: x86_64-mingw-2 try-job: x86_64-msvc try-job: x86_64-apple-1 try-job: x86_64-apple-2
2024-12-28Rollup merge of #134737 - estebank:deive-lint-default-fields-base, ↵Stuart Cook-0/+338
r=compiler-errors Implement `default_overrides_default_fields` lint Detect when a manual `Default` implementation isn't using the existing default field values and suggest using `..` instead: ``` error: `Default` impl doesn't use the declared default field values --> $DIR/manual-default-impl-could-be-derived.rs:14:1 | LL | / impl Default for A { LL | | fn default() -> Self { LL | | A { LL | | y: 0, | | - this field has a default value ... | LL | | } | |_^ | = help: use the default values in the `impl` with `Struct { mandatory_field, .. }` to avoid them diverging over time note: the lint level is defined here --> $DIR/manual-default-impl-could-be-derived.rs:5:9 | LL | #![deny(default_overrides_default_fields)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` r? `@compiler-errors` This is a simpler version of #134441, detecting the simpler case when a field with a default should have not been specified in the manual `Default::default()`, instead using `..` for it. It doesn't provide any suggestions, nor the checks for "equivalences" nor whether the value used in the imp being used would be suitable as a default field value.
2024-12-28Auto merge of #134842 - jieyouxu:disable-flaky-test, r=ibraheemdevbors-0/+4
Disable `backtrace-debuginfo.rs` on windows-gnu This test appears still flaky cf. #117097 on `i686-mingw` as observed in https://github.com/rust-lang/rust/pull/131244#issuecomment-2564086577. r? compiler (or anyone, really)
2024-12-28tests: migrate `branch-protection-check-IBT` to rmake.rs许杰友 Jieyou Xu (Joe)-53/+58
- The Makefile version *never* ran because of Makefile syntax confusion. - The test would've always failed because precompiled std is not built with `-Z cf-protection=branch`, but linkers require all input object files to indicate IBT support in order to enable IBT for the executable, which is not the case for std. - Thus, the test input file is instead changed to a `no_std` + `no_core` program. Co-authored-by: Jerry Wang <jerrylwang123@gmail.com> Co-authored-by: Oneirical <manchot@videotron.ca>
2024-12-28tests: migrate `libs-through-symlink` to rmake.rs许杰友 Jieyou Xu (Joe)-22/+48
- Document test intent, backlink to #13890 and fix PR #13903. - Fix the test logic: the `Makefile` version seems to not actually be exercising the "library search traverses symlink" logic, because the actual symlinked-to-library is present under the directory tree when `bar.rs` is compiled, because the `$(RUSTC)` invocation has an implicit `-L $(TMPDIR)`. The symlink itself was actually broken, i.e. it should've been `ln -nsf $(TMPDIR)/outdir/$(NAME) $(TMPDIR)` but it used `ln -nsf outdir/$(NAME) $(TMPDIR)`. Co-authored-by: Oneirical <manchot@videotron.ca>
2024-12-28Disable `backtrace-debuginfo.rs` on windows-gnu许杰友 Jieyou Xu (Joe)-0/+4
2024-12-28compiletest: Self-test for `normalize-*` with revisionsZalathar-0/+24
2024-12-27Rollup merge of #134834 - dtolnay:unnamedcall, r=compiler-errorsDavid Tolnay-0/+3
Skip parenthesis around tuple struct field calls The pretty-printer previously did not distinguish between named vs unnamed fields when printing a function call containing a struct field. It would print the call as `(self.fun)()` for a named field which is correct, and `(self.0)()` for an unnamed field which is redundant. This PR changes function calls of tuple struct fields to print without parens. **Before:** ```rust struct Tuple(fn()); fn main() { let tuple = Tuple(|| {}); (tuple.0)(); } ``` **After:** ```rust struct Tuple(fn()); fn main() { let tuple = Tuple(|| {}); tuple.0(); } ```
2024-12-27Rollup merge of #134833 - dtolnay:leftmostwithdot, r=compiler-errorsDavid Tolnay-0/+4
Skip parenthesis if `.` makes statement boundary unambiguous There is a rule in the parser that statements and match-arms never end in front of a `.` or `?` token (except when the `.` is really `..` or `..=` or `...`). So some of the leading subexpressions that need parentheses inserted when followed by some other operator like `-` or `+`, do not need parentheses when followed by `.` or `?`. Example: ```rust fn main() { loop {}.to_string() + ""; match () { _ => loop {}.to_string() + "", }; } ``` `-Zunpretty=expanded` before: ```console #![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std; fn main() { (loop {}).to_string() + ""; match () { _ => (loop {}).to_string() + "", }; } ``` After: ```console #![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std; fn main() { loop {}.to_string() + ""; match () { _ => loop {}.to_string() + "", }; } ```
2024-12-27Skip parenthesis around tuple struct field callsDavid Tolnay-1/+1
2024-12-27Add pretty-printer test of tuple field function callDavid Tolnay-0/+3
2024-12-27Skip parenthesis if `.` makes statement boundary unambiguousDavid Tolnay-2/+2
2024-12-27Add test of dot after eager statement boundary exprDavid Tolnay-0/+4
2024-12-27Rollup merge of #134798 - compiler-errors:err-auto, r=jackh726Matthias Krüger-1/+42
Make `ty::Error` implement all auto traits I have no idea what's up with the crashes test I fixed--I really don't want to look into it since it has to do something with borrowck and multiple layers of opaques. I think the underlying idea of allowing error types to implement all auto traits is justified though. Fixes #134796 Fixes #131050 r? lcnr
2024-12-27Rollup merge of #133663 - scottmcm:carrying_mul_add, r=AmanieuMatthias Krüger-0/+137
Add a compiler intrinsic to back `bigint_helper_methods` cc https://github.com/rust-lang/rust/issues/85532 This adds a new `carrying_mul_add` intrinsic, to implement `wide_mul` and `carrying_mul`. It has fallback MIR for all types -- including `u128`, which isn't currently supported on nightly -- so that it'll continue to work on all backends, including CTFE. Then it's overridden in `cg_llvm` to use wider intermediate types, including `i256` for `u128::carrying_mul`.
2024-12-27Override `carrying_mul_add` in cg_llvmScott McMurray-0/+137
2024-12-27Rollup merge of #134806 - notriddle:notriddle/parent-path-is-better, ↵许杰友 Jieyou Xu (Joe)-30/+70
r=GuillaumeGomez rustdoc: use shorter paths as preferred canonical paths This is a solution to [the `std::sync::poison` linking problem](https://github.com/rust-lang/rust/pull/134692#issuecomment-2560373308), and, in general, makes intra-doc links shorter and clearer. > Done. This helped with the search, but not with the things like `MutexGuard`'s doc's reference to `Mutex::lock` being converted to the absolute (unstable) `std::sync::poison::Mutex` path. cc `@tgross35` r? `@GuillaumeGomez`
2024-12-27Rollup merge of #134787 - fmease:spruce-up-queries, r=compiler-errors许杰友 Jieyou Xu (Joe)-2/+2
Spruce up the docs of several queries related to the type/trait system and const eval - Editorial - Proper rustdoc summary/synopsis line by making use of extra paragraphs: Leads to better rendered output on module pages, in search result lists and overall, too - Use rustdoc warning blocks for admonitions of the form "do not call / avoid calling this query directly" - Use intra-doc links of the form ``[`Self::$query`]`` to cross-link queries. Indeed, such links are generally a bit brittle due to the existence of `TyCtxtFeed` which only contains a subset of queries. Therefore the docs of `feedable` queries cannot cross-link to non-`feedable` ones. I'd say it's fine to use intra-doc links despite the potential/unlikely occasional future breakage (if a query with the aforementioned characteristics becomes `feedable`). `Self::` is nicer than `TyCtxt::` (which would be more stable) since it accounts for other contexts like `TyCtxt{Feed,At,Ensure{,WithValue}}` - Informative - Generally add, flesh out and correct some doc comments - Add *Panic* sections (to a few selected queries only). The lists of panics aren't necessarily exhaustive and focus on the more "obvious" or "important" panics. - Where applicable add a paragraph calling attention to the relevant [`#[rustc_*]` TEST attribute](https://rustc-dev-guide.rust-lang.org/compiler-debugging.html#rustc_-test-attributes) The one non-doc change (it's internal and not observable): Be even more defensive in `query constness`'s impl (spiritual follow-up to #134122) (see self review comment). Fixes #133494. r\? **any**(compiler-errors, oli-obk)
2024-12-27Rollup merge of #134759 - Zalathar:normalize, r=jieyouxu许杰友 Jieyou Xu (Joe)-463/+454
compiletest: Remove the `-test` suffix from normalize directives This suffix was an artifact of using the same condition-checking engine as the `ignore-*` and `only-*` directives, but in practice we have only 2 tests that legitimately use a condition, and both of them only care about 32-bit vs 64-bit. This PR detaches `normalize-*` directives from the condition checker, and replaces it with a much simpler system of four explicit `NormalizeKind` values. It then takes advantage of that simplicity to get rid of the `-test` suffix. --- Addresses one of the points of #126372. The new name-checking code is a bit quaint, but I think it's a definite improvement over the status quo. --- The corresponding dev-guide update is https://github.com/rust-lang/rustc-dev-guide/pull/2172. r? jieyouxu
2024-12-27MatchBranchSimplification: Consider empty-unreachable otherwise branchclubby789-39/+42
2024-12-27Add diff test for MatchBranchSimplificationclubby789-0/+46
2024-12-27Spruce up the docs of several queries related to the type/trait system and ↵León Orell Valerian Liehr-2/+2
const eval
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-435/+435
2024-12-26Rollup merge of #131522 - c410-f3r:unlock-rfc-2011, r=chenyukangJacob Pratt-15/+42
[macro_metavar_expr_concat] Fix #128346 Fix #128346 Fix #131393 The syntax is invalid in both issues so I guess that theoretically the compiler should have aborted early. This PR tries to fix a local problem but let me know if there are better options. cc `@petrochenkov` if you are interested
2024-12-27Simplify or delete normalize directives that don't care about bit-widthZalathar-31/+22
2024-12-26Adjust test for slightly changed inlining behaviorMichael Howell-30/+30
2024-12-26rustdoc: use shorter paths as preferred canonical pathsMichael Howell-0/+40
This is a solution to the `std::sync::poison` linking problem, and, in general, makes intra-doc links shorter and clearer.
2024-12-26Make ty::Error implement auto traitsMichael Goulet-1/+42
2024-12-26Rollup merge of #134781 - Zalathar:backtrace, r=SparrowLii,jieyouxuGuillaume Gomez-4/+12
Add more `begin_panic` normalizations to panic backtrace tests Since #123244, these tests have started failing locally on some systems (#133997) due to minor variations in how `begin_panic` is printed in the backtrace. The variation appears to occur on macOS when `rust.debuginfo-level = "line-tables-only"` is set, which is the default in `config.compiler.toml`. It does not occur when the debuginfo level is set to 1. The variation doesn't seem relevant to these tests, so this PR simply adds another custom normalization rule to account for the variation. --- Will conflict with #134759.
2024-12-26Rollup merge of #134664 - estebank:sugg-highlighting, r=jieyouxuGuillaume Gomez-0/+562
Account for removal of multiline span in suggestion When highlighting the removed parts of a suggestion, properly account for spans that cover more than one line. Fix #134485. ![Screenshot of the highlighted output](https://github.com/user-attachments/assets/18bcd9bc-3bec-4b79-a9d7-e4ea4e6289ad)
2024-12-26Rollup merge of #134656 - jieyouxu:migrate-incr-add-rust-src-component, ↵Guillaume Gomez-45/+131
r=wesleywiser Migrate `incr-add-rust-src-component` to rmake This PR partially supersedes #128562, and ports the Makefile-based `tests/run-make/incr-add-rust-src-component` to use rmake.rs infra. Part of #121876. This run-make test is a regression test for https://github.com/rust-lang/rust/issues/70924. It (tries to) checks that if we add the `rust-src` component in between two incremental compiles, that the compiler doesn't ICE on the second invocation. - Original issue:https://github.com/rust-lang/rust/issues/70924 - Fix PR: https://github.com/rust-lang/rust/pull/72767 - PR adding this regression test: https://github.com/rust-lang/rust/pull/72952 However, the Makefile version of this used `$SYSROOT/lib/rustlib/src/rust/src/libstd/lib.rs`, but that actually got moved around and reorganized over the years. As of Dec 2024, the `rust-src` component is more like (specific for our purposes): ``` $SYSROOT/lib/rustlib/src/rust/ library/std/src/lib.rs src/ ``` However, this run-make test is ancient and it exercises incr-comp system logic. I'm not sure if this test would actually catch the original regression. This PR was co-authored with `@Oneirical.` r? incremental try-job: i686-msvc try-job: x86_64-mingw-1 try-job: x86_64-msvc try-job: aarch64-apple
2024-12-26Account for removal of multiline span in suggestionEsteban Küber-0/+562
When highlighting the removed parts of a suggestion, properly account for spans that cover more than one line. Fix #134485.
2024-12-26Auto merge of #134774 - jyn514:rustc-dev-short-backtraces, r=jieyouxubors-1/+3
fix default-backtrace-ice test when running `tests/ui/panics/default-backtrace-ice.rs locally it gave this error: ``` failures: ---- [ui] tests/ui/panics/default-backtrace-ice.rs stdout ---- Saved the actual stderr to "/home/jyn/src/rust3/build/x86_64-unknown-linux-gnu/test/ui/panics/default-backtrace-ice/default-backtrace-ice.stderr" diff of stderr: 7 8 aborting due to `-Z treat-err-as-bug=1` 9 stack backtrace: - (end_short_backtrace) - (begin_short_backtrace) - (end_short_backtrace) - (begin_short_backtrace) + [... omitted 22 frames ...] + ``` (note that you must *not* use --bless; we previously did not have an error annotation to verify it was a full backtrace instead of a short backtrace.) this is a regression from setting RUST_BACKTRACE=1 by default in https://github.com/rust-lang/rust/pull/134743. we need to turn off the new behavior when running UI tests so that they reflect our dist compiler. normally that's done by checking `sess.unstable_opts.ui_testing`, but this happens extremely early in the compiler before we've expanded arg files. do an extremely simple hack that doesn't work in all cases - we don't need it to work in all cases, only when running UI tests. cc https://github.com/rust-lang/rust/pull/129658#issuecomment-2561988081 r? `@jieyouxu`
2024-12-26Add more `begin_panic` normalizations to panic backtrace testsZalathar-4/+12
2024-12-25fix default-backtrace-ice testjyn-1/+3
when running `tests/ui/panics/default-backtrace-ice.rs locally it gave this error: ``` failures: ---- [ui] tests/ui/panics/default-backtrace-ice.rs stdout ---- Saved the actual stderr to "/home/jyn/src/rust3/build/x86_64-unknown-linux-gnu/test/ui/panics/default-backtrace-ice/default-backtrace-ice.stderr" diff of stderr: 7 8 aborting due to `-Z treat-err-as-bug=1` 9 stack backtrace: - (end_short_backtrace) - (begin_short_backtrace) - (end_short_backtrace) - (begin_short_backtrace) + [... omitted 22 frames ...] + ``` this is a regression from setting RUST_BACKTRACE=1 by default. we need to turn off the new behavior when running UI tests so that they reflect our dist compiler. normally that's done by checking `sess.unstable_opts.ui_testing`, but this happens extremely early in the compiler before we've expanded arg files. do an extremely simple hack that doesn't work in all cases - we don't need it to work in all cases, only when running UI tests.
2024-12-25Implement `default_overrides_default_fields` lintEsteban Küber-0/+338
Detect when a manual `Default` implementation isn't using the existing default field values and suggest using `..` instead: ``` error: `Default` impl doesn't use the declared default field values --> $DIR/manual-default-impl-could-be-derived.rs:14:1 | LL | / impl Default for A { LL | | fn default() -> Self { LL | | A { LL | | y: 0, | | - this field has a default value ... | LL | | } | |_^ | = help: use the default values in the `impl` with `Struct { mandatory_field, .. }` to avoid them diverging over time note: the lint level is defined here --> $DIR/manual-default-impl-could-be-derived.rs:5:9 | LL | #![deny(default_overrides_default_fields)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
2024-12-25Auto merge of #134736 - jyn514:msvc-backtraces, r=jieyouxubors-1/+0
Run `tests/ui/backtrace/std-backtrace.rs` on MSVC. The original PR which disabled these, https://github.com/rust-lang/rust/pull/62897, only mentions them being broken on i686. ~~let's still make sure the rest of windows is supported.~~ Let's see if we can enable this for msvc now (32-bit and 64-bit). r? `@jieyouxu` try-job: x86_64-msvc try-job: i686-msvc try-job: i686-mingw try-job: x86_64-mingw-1 try-job: x86_64-mingw-2 try-job: dist-x86_64-msvc try-job: dist-i686-msvc
2024-12-25Run `tests/ui/backtrace/std-backtrace.rs` on MSVC.jyn-1/+0
The original PR which disabled these only mentions them being broken on i686 msvc. Let's try to see if we can reenable this test for msvc (both 32-bit and 64-bit).
2024-12-25Rollup merge of #134750 - Zalathar:coverage-attr-errors, r=jieyouxu许杰友 Jieyou Xu (Joe)-214/+378
Update `#[coverage(..)]` attribute error messages to match the current implementation The allowed positions for `#[coverage(..)]` attributes were expanded by #126721, but the corresponding error messages were never updated to reflect the new behaviour. Part of #134749.
2024-12-25Un-redact one occurrence of "coverage attribute not allowed here"Zalathar-1/+1
2024-12-25Overhaul error messages for disallowed coverage attributesZalathar-62/+124
2024-12-25Expand the main test for where the coverage attribute is allowedZalathar-48/+148
Some of these cases are also implicitly checked by other tests, but it's helpful to also explicitly list them in the main test.
2024-12-25Fully redact the [E0788] error message in tests, to make changes easierZalathar-26/+26
2024-12-25Rollup merge of #134741 - compiler-errors:coroutine-verbose, r=lqdDianQK-5/+5
Actually print all the relevant parts of a coroutine in verbose mode I need to actually see these components, idk why we weren't printing them :)