about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-04-24Rollup merge of #123794 - oli-obk:define_opaque_types2, r=lcnrLeón Orell Valerian Liehr-0/+281
More DefineOpaqueTypes::Yes This accepts more code on stable. It is now possible to have match arms return a function item `foo::<ConcreteType>` and a function item `foo::<OpaqueTypeInDefiningScope>` in another, and that will constrain `OpaqueTypeInDefiningScope` to have the hidden type `ConcreteType`. So the following function will now compile, but on master it errors with a type mismatch on the second match arm ```rust // The function item whose generic params we want to merge. fn foo<T>(t: T) -> T { t } // Helper ensuring we can constrain `T` on `F` without explicitly specifying it fn bind<T, F: FnOnce(T) -> T>(_: T, f: F) -> F { f } fn k() -> impl Sized { let x = match true { true => { // `f` is `FnDef(foo, [infer_var])` let f = foo; // Get a value of an opaque type on stable let t = k(); // this returns `FnDef(foo, [k::return])` bind(t, f) } false => foo::<()>, }; todo!() } ``` r? ``@compiler-errors`` cc https://github.com/rust-lang/rust/issues/116652
2024-04-24Rollup merge of #123316 - Enselic:sigpipe-inherit-variants, r=fmeaseLeón Orell Valerian Liehr-8/+39
Test `#[unix_sigpipe = "inherit"]` with both `SIG_DFL` and `SIG_IGN` Extend our `#[unix_sigpipe = "inherit"]` test so that it detects if `SIGPIPE` wrongly ends up being `SIG_DFL` when the parent has `SIG_IGN`. We have no current test for this particular case. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-04-24Register hidden types when equating function definitions in coercionOli Scherer-45/+5
2024-04-24Add some FnDef LUB coercion testsOli Scherer-0/+321
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-727/+1095
And suggest adding the `#[coroutine]` to the closure
2024-04-24Add explicit syntax for coroutines instead of relying on closures having ↵Oli Scherer-2/+2
`yield` expressions
2024-04-24Auto merge of #122053 - erikdesjardins:alloca, r=nikicbors-192/+205
Stop using LLVM struct types for alloca The alloca type has no semantic meaning, only the size (and alignment, but we specify it explicitly) matter. Using `[N x i8]` is a more direct way to specify that we want `N` bytes, and avoids relying on LLVM's struct layout. It is likely that a future LLVM version will change to an untyped alloca representation. Split out from #121577. r? `@ghost`
2024-04-23properly fill a promoted's required_constsRalf Jung-3/+91
then we can also make all_required_consts_are_checked a constant instead of a function
2024-04-23compute required_consts before promotion, and add promoteds that may failRalf Jung-45/+1
2024-04-23promotion: do not promote const-fn calls in const when that may fail without ↵Ralf Jung-224/+109
the entire const failing
2024-04-23Auto merge of #124302 - matthiaskrgr:rollup-2aya8n8, r=matthiaskrgrbors-6/+149
Rollup of 3 pull requests Successful merges: - #124003 (Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics)) - #124169 (Don't fatal when calling `expect_one_of` when recovering arg in `parse_seq`) - #124286 (Subtree sync for rustc_codegen_cranelift) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-23Rollup merge of #124169 - compiler-errors:parser-fatal, r=oli-obkMatthias Krüger-0/+25
Don't fatal when calling `expect_one_of` when recovering arg in `parse_seq` In `parse_seq`, when parsing a sequence of token-separated items, if we don't see a separator, we try to parse another item eagerly in order to give a good diagnostic and recover from a missing separator: https://github.com/rust-lang/rust/blob/d1a0fa5ed3ffe52d72f761d3c95cbeb0a9cdfe66/compiler/rustc_parse/src/parser/mod.rs#L900-L901 If parsing the item itself calls `expect_one_of`, then we will fatal because of #58903: https://github.com/rust-lang/rust/blob/d1a0fa5ed3ffe52d72f761d3c95cbeb0a9cdfe66/compiler/rustc_parse/src/parser/mod.rs#L513-L516 For `precise_capturing` feature I implemented, we do end up calling `expected_one_of`: https://github.com/rust-lang/rust/blob/d1a0fa5ed3ffe52d72f761d3c95cbeb0a9cdfe66/compiler/rustc_parse/src/parser/ty.rs#L712-L714 This leads the compiler to fatal *before* having emitted the first error, leading to absolutely no useful information for the user about what happened in the parser. This PR makes it so that we stop doing that. Fixes #124195
2024-04-23Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyoMatthias Krüger-6/+124
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics) This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226. Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it. r? ``@scottmcm``
2024-04-23Auto merge of #124295 - fmease:rollup-i3apkc6, r=fmeasebors-154/+1161
Rollup of 7 pull requests Successful merges: - #120929 (Wrap dyn type with parentheses in suggestion) - #122591 (Suggest using type args directly instead of equality constraint) - #122598 (deref patterns: lower deref patterns to MIR) - #123048 (alloc::Layout: explicitly document size invariant on the type level) - #123993 (Do `check_coroutine_obligations` once per typeck root) - #124218 (Allow nesting subdiagnostics in #[derive(Subdiagnostic)]) - #124285 (Mark ``@RUSTC_BUILTIN`` search path usage as unstable) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-23Rollup merge of #124218 - Xiretza:subsubdiagnostics, r=davidtwcoLeón Orell Valerian Liehr-2/+12
Allow nesting subdiagnostics in #[derive(Subdiagnostic)]
2024-04-23Rollup merge of #123993 - compiler-errors:coroutine-obl, r=lcnrLeón Orell Valerian Liehr-51/+82
Do `check_coroutine_obligations` once per typeck root We only need to do `check_coroutine_obligations` once per typeck root, especially since the new solver can't really (easily) associate which obligations correspond to which coroutines. This requires us to move the checks for sized coroutine fields into `mir_coroutine_witnesses`, but that's fine imo. r? lcnr
2024-04-23Rollup merge of #122598 - Nadrieril:full-derefpats, r=matthewjasperLeón Orell Valerian Liehr-80/+322
deref patterns: lower deref patterns to MIR This lowers deref patterns to MIR. This is a bit tricky because this is the first kind of pattern that requires storing a value in a temporary. Thanks to https://github.com/rust-lang/rust/pull/123324 false edges are no longer a problem. The thing I'm not confident about is the handling of fake borrows. This PR ignores any fake borrows inside a deref pattern. We are guaranteed to at least fake borrow the place of the first pointer value, which could be enough, but I'm not certain.
2024-04-23Rollup merge of #122591 - gurry:122162-impl-type-binding-suggestion, r=fmeaseLeón Orell Valerian Liehr-18/+593
Suggest using type args directly instead of equality constraint When type arguments are written erroneously using an equality constraint we suggest specifying them directly without the equality constraint. Fixes #122162 Changes the diagnostic in the issue from: ```rust error[E0229]: associated type bindings are not allowed here 9 | impl std::cmp::PartialEq<Rhs = T> for S { | ^^^^^^^ associated type not allowed here | ``` to ```rust error[E0229]: associated type bindings are not allowed here 9 | impl std::cmp::PartialEq<Rhs = T> for S { | ^^^^^^^ associated type not allowed here | help: to use `T` as a generic argument specify it directly | | impl std::cmp::PartialEq<T> for S { | ~ ```
2024-04-23Rollup merge of #120929 - long-long-float:wrap-dyn-in-suggestion, r=fmeaseLeón Orell Valerian Liehr-3/+152
Wrap dyn type with parentheses in suggestion Close #120223 Fix wrong suggestion that is grammatically incorrect. Specifically, I added parentheses to dyn types that need lifetime bound. ``` help: consider adding an explicit lifetime bound | 4 | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static, | + +++++++++++ ```
2024-04-23Auto merge of #122317 - compiler-errors:fulfill-method-probe, r=lcnrbors-112/+147
Use fulfillment in method probe, not evaluation This PR reworks method probing to use fulfillment instead of a `for`-loop of `evaluate_predicate` calls, and moves normalization from method candidate assembly into the `consider_probe`, where it's applied to *all* candidates. This last part coincidentally fixes https://github.com/rust-lang/rust/issues/121643#issuecomment-1975371248. Regarding *why* this large rewrite is done: In general, it's an anti-pattern to do `for o in obligations { evaluate(o); }` because it's not compatible with the way that the new solver emits alias-relate obligations which constrain variables that may show up in other predicates. r? lcnr
2024-04-23Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, r=davidtwcoMatthias Krüger-26/+101
Disallow ambiguous attributes on expressions This implements the suggestion in [#15701](https://github.com/rust-lang/rust/issues/15701#issuecomment-2033124217) to disallow ambiguous outer attributes on expressions. This should resolve one of the concerns blocking the stabilization of `stmt_expr_attributes`.
2024-04-23Rollup merge of #124067 - RalfJung:weak-lang-items, r=davidtwcoMatthias Krüger-51/+76
weak lang items are not allowed to be #[track_caller] For instance the panic handler will be called via this import ```rust extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } ``` A `#[track_caller]` would add an extra argument and thus make this the wrong signature. The 2nd commit is a consistency rename; based on the docs [here](https://doc.rust-lang.org/unstable-book/language-features/lang-items.html) and [here](https://rustc-dev-guide.rust-lang.org/lang-items.html) I figured "lang item" is more widely used. (In the compiler output, "lang item" and "language item" seem to be pretty even.)
2024-04-23Rollup merge of #123050 - RalfJung:panic_str, r=m-ou-seMatthias Krüger-2/+2
panic_str only exists for the migration to 2021 panic macros The only caller is `expect_failed`, which is already a cold inline(never) function, so inlining into that function should be fine. (And indeed `panic_str` was `#[inline]` anyway.) The existence of panic_str risks someone calling it when they should call `panic` instead, and I can't see a reason why this footgun should exist. I also extended the comment in `panic` to explain why it needs a `'static` string -- I know I've wondered about this in the past and it took me quite a while to understand.
2024-04-23try to fix unnecessarily fragile smir testRalf Jung-2/+2
2024-04-23Rollup merge of #124220 - RalfJung:interpret-wrong-vtable, r=oli-obkMatthias Krüger-1/+1
Miri: detect wrong vtables in wide pointers Fixes https://github.com/rust-lang/miri/issues/3497. Needed to catch the UB that https://github.com/rust-lang/rust/pull/123572 will start exploiting. r? `@oli-obk`
2024-04-23Rollup merge of #124200 - scrabsha:sasha/->, r=compiler-errors,fmeaseMatthias Krüger-4/+121
Improve handling of expr->field errors The current message for "`->` used for field access" is the following: ```rust error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `->` --> src/main.rs:2:6 | 2 | a->b; | ^^ expected one of 8 possible tokens ``` ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7f8b6f4433aa7866124123575456f54e)) This PR tries to address this by adding a dedicated error message and recovery. The proposed error message is: ``` error: `->` used for field access or method call --> ./tiny_test.rs:2:6 | 2 | a->b; | ^^ help: try using `.` instead | = help: the `.` operator will dereference the value if needed ``` (feel free to bikeshed it as much as necessary)
2024-04-23Rollup merge of #124197 - GuillaumeGomez:move-duplicated-code, r=notriddleMatthias Krüger-119/+89
Move duplicated code in functions in `tests/rustdoc-gui/notable-trait.goml` It also allowed me to add some new common test like: ``` assert-position: ( "//*[`@class='tooltip` popover']", {"x": |popover_x|} ) ``` r? `@notriddle`
2024-04-23Rollup merge of #124057 - gurry:124031-ice-layout-errored, r=compiler-errorsMatthias Krüger-1/+16
Fix ICE when ADT tail has type error Fixes #124031
2024-04-23Rollup merge of #123680 - compiler-errors:gen-kw, r=NadrierilMatthias Krüger-5/+78
Deny gen keyword in `edition_2024_compat` lints Splits the `keyword_idents` lint into two -- `keyword_idents_2018` and `keyword_idents_2024` -- since each corresponds to a future-compat warning in a different edition. Group these together into a new `keyword_idents` lint group, and add the latter to the `rust_2024_compatibility` so that `gen` is ready for the 2024 edition. cc `@traviscross` `@ehuss`
2024-04-22also update windows slack-protector testsErik Desjardins-44/+16
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+219
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-22Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnayGuillaume Gomez-73/+46
Stabilize generic `NonZero`. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-04-22Rollup merge of #124217 - Zalathar:pre-branch, r=oli-obkGuillaume Gomez-0/+817
coverage: Prepare for improved branch coverage When trying to rebase my new branch coverage work (including #124154) on top of the introduction of MC/DC coverage (#123409), I found it a lot harder than anticipated. With the benefit of hindsight, the branch coverage code and MC/DC code have become more interdependent than I'm happy with. This PR therefore disentangles them a bit, so that it will be easier for both areas of code to evolve independently without interference. --- This PR also includes a few extra branch coverage tests that I had sitting around from my current branch coverage work. They mostly just demonstrate that certain language constructs listed in #124118 currently don't have branch coverage support. ``@rustbot`` label +A-code-coverage
2024-04-22Stabilize generic `NonZero`.Markus Reiter-73/+46
2024-04-22Deny gen keyword in edition_2024_compat lintsMichael Goulet-5/+78
2024-04-22Improve handling of expr->field errorsSasha Pourcelot-4/+121
The current message for "`->` used for field access" is the following: ```rust error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `->` --> src/main.rs:2:6 | 2 | a->b; | ^^ expected one of 8 possible tokens ``` (playground link[1]) This PR tries to address this by adding a dedicated error message and recovery. The proposed error message is: ``` error: `->` used for field access or method call --> ./tiny_test.rs:2:6 | 2 | a->b; | ^^ help: try using `.` instead | = help: the `.` operator will dereference the value if needed ``` (feel free to bikeshed it as much as necessary) [1]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7f8b6f4433aa7866124123575456f54e Signed-off-by: Sasha Pourcelot <sasha.pourcelot@protonmail.com>
2024-04-23Wrap dyn type with parentheses in suggestionlong-long-float-3/+152
2024-04-22Auto merge of #115120 - icedrocket:ignore-strip-on-msvc, r=michaelwoeristerbors-0/+52
Ignore `-C strip` on MSVC tl;dr - Define `-Cstrip` to only ever affect the binary; no other build artifacts. This is necessary to improve cross-platform behavior consistency: if someone wanted debug information to be contained only in separate files on all platforms, they would set `-Cstrip=symbols` and `-Csplit-debuginfo=packed`, but this would result in no PDB files on MSVC. Resolves #114215
2024-04-22coverage: Add a mir-opt test for branch coverage of match armsZalathar-0/+165
2024-04-22coverage: Move mir-opt coverage tests into a subdirectoryZalathar-0/+0
2024-04-22coverage: Branch coverage tests for match armsZalathar-0/+401
2024-04-22coverage: Branch coverage test for if-let and let-chainsZalathar-0/+161
2024-04-22coverage: Branch coverage test for let-elseZalathar-0/+90
2024-04-22Auto merge of #124250 - matthiaskrgr:rollup-b8tqsup, r=matthiaskrgrbors-0/+124
Rollup of 3 pull requests Successful merges: - #124240 (add a couple tests for fixed ICEs.) - #124245 (bootstrap: Promote some build_steps comments to docs) - #124246 (Add comma at one place in `abs()` documentation) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-22Rollup merge of #124240 - matthiaskrgr:tests_sunday, r=compiler-errorsMatthias Krüger-0/+124
add a couple tests for fixed ICEs. Fixes https://github.com/rust-lang/rust/issues/121413 Fixes https://github.com/rust-lang/rust/issues/121463 Fixes https://github.com/rust-lang/rust/issues/114463
2024-04-22Auto merge of #124236 - matthiaskrgr:n-ice, r=jieyouxubors-0/+62
crashes: add a couple more ICE tests
2024-04-22Auto merge of #124112 - beetrees:incremental-os-str, r=Nadrierilbors-0/+27
Fix ICE when there is a non-Unicode entry in the incremental crate directory Fix the ICE that occurs when there is a non-Unicode entry in the incremental crate directory by replacing uses of `to_string_lossy` + `assert_no_characters_lost` with `to_str`. The added test would cause the compiler to ICE before this PR.
2024-04-22Fix ICE when ADT tail has type errorGurinder Singh-1/+16
2024-04-21Use sup instead of eq when unifying self typeMichael Goulet-69/+46
2024-04-21Restore error messagingMichael Goulet-8/+6