about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-10-10Auto merge of #116548 - nnethercote:assert-long-condition, r=matthewjasperbors-0/+13
Improve handling of assertion failures with very long conditions It's not perfectly clear what the best behaviour is here, but I think this is an improvement. r? `@matthewjasper` cc `@m-ou-se`
2023-10-10Auto merge of #116366 - estebank:issue-103982, r=oli-obkbors-0/+161
Suggest labeling block if `break` is in bare block Fix #103982.
2023-10-09Account for macrosEsteban Küber-0/+112
2023-10-10Don't `escape_debug` the condition of `assert!`.Nicholas Nethercote-1/+2
The assertion in `assert-long-condition.rs` used to be fail like this, all on one line: ``` thread 'main' panicked at 'assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18\n + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0', tests/ui/macros/assert-long-condition.rs:7:5 ``` The `\n` and subsequent indent is because the condition is pretty-printed, and the pretty-printer inserts a newline. Printing the newline in this way is arguably reasonable given that the message appears within single quotes, which is very similar to a string literal. However, after the assertion printing improvements that were released in 1.73, the assertion now fails like this: ``` thread 'main' panicked at tests/ui/macros/assert-long-condition.rs:7:5: assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18\n + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0 ``` Now that there are no single quotes around the pretty-printed condition, the `\n` is quite strange. This commit gets rid of the `\n`, by removing the `escape_debug` done on the pretty-printed message. This results in the following: ``` thread 'main' panicked at tests/ui/macros/assert-long-condition.rs:7:5: assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0 ``` The overly-large indent is still strange, but that's a separate pretty-printing issue. This change helps with #108341.
2023-10-10Add a ui test with an assertion that has a really long condition.Nicholas Nethercote-0/+12
The `\n` in the output is a little surprising. The next commit will deal with it.
2023-10-09Auto merge of #116497 - compiler-errors:impl-span, r=cjgillotbors-64/+114
Extend `impl`'s `def_span` to include its where clauses Typically, we highlight the def-span of an impl in a diagnostic due to either: 1. coherence error 2. trait evaluation cycle 3. invalid implementation of built-in trait I find that an impl's where clauses are very often required to understanding why these errors come about, which is unfortunate since where clauses may be located on different lines and don't show up in the error. This PR expands the def-span of impls to include these where clauses. r? cjgillot since you've touched this code a while back to make some spans shorter, but you can also reassign to wg-diagnostics or compiler if you're busy or have no strong opinions.
2023-10-09fixEsteban Küber-1/+0
2023-10-09Move some tests aroundEsteban Küber-0/+0
2023-10-09Suggest labeling block if `break` is in bare blockEsteban Küber-0/+50
Fix #103982.
2023-10-09Auto merge of #116569 - matthiaskrgr:rollup-ni0jdd6, r=matthiaskrgrbors-419/+1338
Rollup of 6 pull requests Successful merges: - #115882 (improve the suggestion of `generic_bound_failure`) - #116537 (Fix suggestion span involving wrongly placed generic arg on variant) - #116543 (In smir `find_crates` returns `Vec<Crate>` instead of `Option<Crate>`) - #116549 (Simplify some mir passes by using let chains) - #116556 (Sync rustc_codegen_cranelift) - #116561 (Add a test for fixed ICE) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-09Rollup merge of #116561 - ouz-a:testfor_115517, r=compiler-errorsMatthias Krüger-0/+26
Add a test for fixed ICE Addresses https://github.com/rust-lang/rust/issues/115517#issuecomment-1730164116 Closes #115517 r? ``@compiler-errors``
2023-10-09Rollup merge of #116543 - ouz-a:crate_return_vec, r=oli-obkMatthias Krüger-2/+2
In smir `find_crates` returns `Vec<Crate>` instead of `Option<Crate>` Addresses https://github.com/rust-lang/project-stable-mir/issues/40 r? `@oli-obk`
2023-10-09Rollup merge of #116537 - gurry:116473-ice-sugg-overlap, r=compiler-errorsMatthias Krüger-0/+351
Fix suggestion span involving wrongly placed generic arg on variant Fixes #116473 The span computation was wrong. It went from the end of the variant to the end of the (wrongly placed) args. However, the variant lived in a different expansion and this resulted in a nonsensical span that overlaps with another and thereby leads to the ICE. In the fix I've changed span computation to not be based on the location of the variant, but purely on the location of the args. I simply extend the start of the args span 2 positions to the left and that includes the `::` and that's all we need apparently. This approach produces a correct span regardless of which macro/expansion the args reside in and where the variant is.
2023-10-09Rollup merge of #115882 - aliemjay:diag-name-region-1, r=compiler-errorsMatthias Krüger-417/+959
improve the suggestion of `generic_bound_failure` - Fixes #115375 - suggest the bound in the correct scope: trait or impl header vs assoc item. See `tests/ui/suggestions/lifetimes/type-param-bound-scope.rs` - don't suggest a lifetime name that conflicts with the other late-bound regions of the function: ```rust type Inv<'a> = *mut &'a (); fn check_bound<'a, T: 'a>(_: T, _: Inv<'a>) {} fn test<'a, T>(_: &'a str, t: T, lt: Inv<'_>) { // suggests a new name `'a` check_bound(t, lt); //~ ERROR } ```
2023-10-09Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmeasebors-0/+141
[rustdoc] Show enum discrimant if it is a C-like variant Fixes https://github.com/rust-lang/rust/issues/101337. We currently display values for associated constant items in traits: ![image](https://github.com/rust-lang/rust/assets/3050060/03e566ec-c670-47b4-8ca2-b982baa7a0f4) And we also display constant values like [here](file:///home/imperio/rust/rust/build/x86_64-unknown-linux-gnu/doc/std/f32/consts/constant.E.html). I think that for coherency, we should display values of C-like enum variants. With this change, it looks like this: ![image](https://github.com/rust-lang/rust/assets/3050060/b53fbbe0-bdb1-4289-8537-f2dd4988e9ac) As for the display of the constant value itself, I used what we already have to keep coherency. We display the C-like variants value in the following scenario: 1. It is a C-like variant with a value set => all the time 2. It is a C-like variant without a value set: All other variants are C-like variants and at least one them has its value set. Here is the result in code: ```rust // Ax and Bx value will be displayed. enum A { Ax = 12, Bx, } // Ax and Bx value will not be displayed enum B { Ax, Bx, } // Bx value will not be displayed enum C { Ax(u32), Bx, } // Bx value will not be displayed, Cx value will be displayed. #[repr(u32)] enum D { Ax(u32), Bx, Cx = 12, } ``` r? `@notriddle`
2023-10-09Add more complex test cases for enum discriminant displayGuillaume Gomez-0/+19
2023-10-09Extend impl's def_span to include where clausesMichael Goulet-64/+114
2023-10-09add testOğuz Ağcayazı-0/+26
2023-10-09return crates instead of a crateOğuz Ağcayazı-2/+2
2023-10-09Auto merge of #116533 - cjgillot:skip-trivial-mir, r=oli-obkbors-1/+1
Do not run optimizations on trivial MIR. Fixes https://github.com/rust-lang/rust/issues/116513 The bug was introduced in https://github.com/rust-lang/rust/pull/110728, which put the check too early in the query chain. cc `@oli-obk` `@ouz-a`
2023-10-09Fix suggestion span involving wrongly placed generic arg on enum variantsGurinder Singh-0/+351
When the variant and the (wrongly placed) args are at separate source locations such as being in different macos or one in a macro and the other somwhere outside of it, the arg spans we computed spanned the entire distance between such locations and were hence invalid. .
2023-10-09Auto merge of #116096 - cjgillot:debuginfo-fndef-size, r=nikicbors-0/+18
Make FnDef 1-ZST in LLVM debuginfo. Discussed in https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/LLVM.20HEAD.20llvm.2Edbg.2Edeclare.2Falloca.20size.20mismatch r? `@nikic`
2023-10-08Ignore MSVC in test.Camille GILLOT-0/+1
2023-10-08Make FnDef 1-ZST in LLVM debuginfo.Camille GILLOT-0/+17
2023-10-08Auto merge of #116515 - petrochenkov:nolegflavor, r=lqdbors-6/+6
linker: Remove unstable legacy CLI linker flavors
2023-10-08Do not run optimizations on trivial MIR.Camille GILLOT-1/+1
2023-10-08Auto merge of #116183 - cjgillot:debug-dse-always, r=oli-obkbors-800/+731
Always preserve DebugInfo in DeadStoreElimination. This is a version of #106852 that does not check the current crate's debuginfo flag, and always attempts to preserve debuginfo. I haven't figured out how to handle mixing debuginfo levels for std, the one for the test, and the one for the CI target just right to merge #106852, so this can at least fix the debuginfo issue. Fixes https://github.com/rust-lang/rust/issues/103655
2023-10-08remove trailing dotsAli MJ Al-Nasrawy-128/+128
2023-10-08always show and explain sub regionAli MJ Al-Nasrawy-302/+439
2023-10-08improve the suggestion of generic_bound_failureAli MJ Al-Nasrawy-75/+480
2023-10-08Auto merge of #116514 - petrochenkov:nogccld, r=lqdbors-12/+0
linker: Remove `-Zgcc-ld` option It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now. r? `@lqd`
2023-10-08Auto merge of #116509 - Enselic:rustc-test-op, r=Mark-Simulacrumbors-69/+33
tests/run-make: Move RUSTC_TEST_OP to tools.mk and use in more places
2023-10-08linker: Remove `-Zgcc-ld` optionVadim Petrochenkov-12/+0
It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now
2023-10-07linker: Remove unstable legacy CLI linker flavorsVadim Petrochenkov-6/+6
2023-10-07Add cross-crate C-like variant testGuillaume Gomez-0/+60
2023-10-07Update enum-variant-value testGuillaume Gomez-2/+49
2023-10-07Auto merge of #115583 - RalfJung:packed-unsized, r=lcnrbors-11/+64
fix detecting references to packed unsized fields Fixes https://github.com/rust-lang/rust/issues/115396 This is a breaking change, but permitted as a soundness fix.
2023-10-07tests/run-make: Use RUSTC_TEST_OP in more placesMartin Nordholts-56/+11
2023-10-07tests/run-make: Move RUSTC_TEST_OP to tools.mkMartin Nordholts-12/+22
To reduce duplication. A follow-up commit will begin using it in even more places.
2023-10-07tests/run-make: Remove wrong blessing adviceMartin Nordholts-1/+0
run-make tests are not special but can be blessed like other tests, like this: ./x.py test --bless tests/run-make/unknown-mod-stdin
2023-10-06Rollup merge of #116458 - bjorn3:fix_global_asm_test, r=workingjubileeJubilee-1/+8
Properly export function defined in test which uses global_asm!() Currently the test passes with the LLVM backend as the codegen unit partitioning logic happens to place both the global_asm!() and the function which calls the function defined by the global_asm!() in the same CGU. With the Cranelift backend it breaks however as it will place all assembly in separate codegen units to be passed to an external linker.
2023-10-06Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkinJubilee-22/+136
Detect missing `=>` after match guard during parsing ``` error: expected one of `,`, `:`, or `}`, found `.` --> $DIR/missing-fat-arrow.rs:25:14 | LL | Some(a) if a.value == b { | - while parsing this struct LL | a.value = 1; | -^ expected one of `,`, `:`, or `}` | | | while parsing this struct field | help: try naming a field | LL | a: a.value = 1; | ++ help: you might have meant to start a match arm after the match guard | LL | Some(a) if a.value == b => { | ++ ``` Fix #78585.
2023-10-06Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiserbors-314/+349
Show more information when multiple `impl`s apply - When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s). ``` error[E0283]: type annotations needed --> $DIR/multiple-impl-apply.rs:34:9 | LL | let y = x.into(); | ^ ---- type must be known at this point | note: multiple `impl`s satisfying `_: From<Baz>` found --> $DIR/multiple-impl-apply.rs:14:1 | LL | impl From<Baz> for Bar { | ^^^^^^^^^^^^^^^^^^^^^^ ... LL | impl From<Baz> for Foo { | ^^^^^^^^^^^^^^^^^^^^^^ = note: required for `Baz` to implement `Into<_>` help: consider giving `y` an explicit type | LL | let y: /* Type */ = x.into(); | ++++++++++++ ``` - Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user. - Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases. ``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/cross-return-site-inference.rs:38:16 | LL | return Err(From::from("foo")); | ^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | LL | return Err(</* self type */ as From>::from("foo")); | +++++++++++++++++++ + ``` Fix #88284.
2023-10-06Fix windows test that has different stderr outputEsteban Küber-8/+10
2023-10-06Bless incremental tests.Camille GILLOT-10/+10
2023-10-06Preserve DebugInfo in DeadStoreElimination.Camille GILLOT-790/+721
2023-10-06Auto merge of #115304 - Enselic:trailing-gt, r=cjgillotbors-0/+24
Allow file names to end with '>' The [`rustc_span::FileName`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_span/enum.FileName.html) enum already differentiates between real files and "fake" files such as `<anon>`. We do not need to artificially forbid real file names from ending in `>`. Closes #73419
2023-10-06Rollup merge of #116475 - notriddle:notriddle/impl-trait-null, r=GuillaumeGomezGuillaume Gomez-5/+20
rustdoc-search: fix bug with multi-item impl trait Preview searches: - https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=-%3E%20globalctxt - https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=globalctxt
2023-10-06Rollup merge of #116329 - RalfJung:swap-comments, r=scottmcmGuillaume Gomez-1/+2
update some comments around swap() Based on ``@eddyb's`` comment [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/461#issuecomment-1742156410). And then I noticed the wrong capitalization for Miri and fixed it in some other places as well.
2023-10-06Use pushsection/popsectionbjorn3-2/+2