summary refs log tree commit diff
path: root/src/test/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2022-09-19fix RPIT ICE for implicit HRTB when missing dynSantiago Pastorino-0/+43
2022-08-30Auto merge of #99860 - oli-obk:revert_97346, r=pnkfelixbors-57/+47
Revert "Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, … …r=oli-obk" This reverts commit c703d11dccb4a895c7aead3b2fcd8cea8c483184, reversing changes made to 64eb9ab869bc3f9ef3645302fbf22e706eea16cf. it didn't apply cleanly, so now it works the same for RPIT and for TAIT instead of just working for RPIT, but we should keep those in sync anyway. It also exposed a TAIT bug (see the feature gated test that now ICEs). r? `@pnkfelix` fixes #99536
2022-08-11Add regression test for issue 100187Santiago Pastorino-0/+12
2022-08-05Auto merge of #95977 - FabianWolff:issue-92790-dead-tuple, r=estebankbors-1/+1
Warn about dead tuple struct fields Continuation of #92972. Fixes #92790. The language team has already commented on this in https://github.com/rust-lang/rust/pull/92972#issuecomment-1021511970; I have incorporated their requests here. Specifically, there is now a new allow-by-default `unused_tuple_struct_fields` lint (name bikesheddable), and fields of unit type are ignored (https://github.com/rust-lang/rust/pull/92972#issuecomment-1021815408), so error messages look like this: ``` error: field is never read: `1` --> $DIR/tuple-struct-field.rs:6:21 | LL | struct Wrapper(i32, [u8; LEN], String); | ^^^^^^^^^ | help: change the field to unit type to suppress this warning while preserving the field numbering | LL | struct Wrapper(i32, (), String); | ~~ ``` r? `@joshtriplett`
2022-08-04Completely remove captures flagSantiago Pastorino-0/+7
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-1/+1
2022-07-28Rollup merge of #99714 - ouz-a:issue_57961, r=oli-obkDylan DPC-0/+15
Fix regression introduced with #99383 Fixes #99642
2022-07-27add tests and commentouz-a-0/+15
2022-07-27Rollup merge of #99079 - compiler-errors:issue-99073, r=oli-obkYuki Okushi-21/+20
Check that RPITs constrained by a recursive call in a closure are compatible Fixes #99073 Adapts a similar visitor pattern to `find_opaque_ty_constraints` (that we use to check TAITs), but with some changes: 0. Only walk the "OnlyBody" children, instead of all items in the RPIT's defining scope 1. Only walk through the body's children if we found a constraining usage 2. Don't actually do any inference, just do a comparison and error if they're mismatched ---- r? `@oli-obk` -- you know all this impl-trait stuff best... is this the right approach? I can explain the underlying issue better if you'd like, in case that might reveal a better solution. Not sure if it's possible to gather up the closure's defining usages of the RPIT while borrowck'ing the outer function, that might be a better place to put this check...
2022-07-26Rollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-deadDylan DPC-17/+17
Use full type name instead of just saying `impl Trait` in "captures lifetime" error I think this is very useful, especially when there's >1 `impl Trait`, and it just means passing around a bit more info that we already have access to.
2022-07-26Check that RPITs constrained by a recursive call in a closure are compatibleMichael Goulet-21/+20
2022-07-26Use real opaque type instead of just saying impl TraitMichael Goulet-17/+17
2022-07-25Restore Opaque behavior to coherence checkMichael Goulet-1/+1
2022-07-21orphan check: opaque types are an errorlcnr-1/+1
2022-07-20Rollup merge of #99383 - ouz-a:issue_57961, r=oli-obkDylan DPC-7/+17
Formalize defining_use_anchor This tackles issue #57961 Introduces new enum called `DefiningAnchor` that replaces `Option<LocalDefId>` of `defining_use_anchor`. Now every use of it is explicit and exhaustively matched, catching errors like one in the linked issue. This is not a perfect fix but it's a step in the right direction. r? `@oli-obk`
2022-07-20take opaq typesouz-a-7/+17
2022-07-19Do not allow typeck children items to constrain outer RPITsMichael Goulet-0/+54
2022-07-16Do not constraint TAITs when checking impl/trait item compatibilityMichael Goulet-0/+41
2022-07-08Auto merge of #98816 - estebank:implicit-sized, r=oli-obkbors-6/+6
Track implicit `Sized` obligations in type params When we evaluate `ty::GenericPredicates` we introduce the implicit `Sized` predicate of type params, but we do so with only the `Predicate` its `Span` as context, we don't have an `Obligation` or `ObligationCauseCode` we could influence. To try and carry this information through, we add a new field to `ty::GenericPredicates` that tracks both which predicates come from a type param and whether that param has any bounds already (to use in suggestions). We also suggest adding a `?Sized` bound if appropriate on E0599. Address part of #98539.
2022-07-08Auto merge of #98614 - oli-obk:take_unsound_opaque_types, r=wesleywiserbors-98/+15
don't succeed `evaluate_obligation` query if new opaque types were registered fixes #98608 fixes #98604 The root cause of all this is that in type flag computation we entirely ignore nongeneric things like struct fields and the signature of function items. So if a flag had to be set for a struct if it is set for a field, that will only happen if the field is generic, as only the generic parameters are checked. I now believe we cannot use type flags to handle opaque types. They seem like the wrong tool for this. Instead, this PR replaces the previous logic by adding a new variant of `EvaluatedToOk`: `EvaluatedToOkModuloOpaqueTypes`, which says that there were some opaque types that got hidden types bound, but that binding may not have been legal (because we don't know if the opaque type was in its defining scope or not).
2022-07-07Track implicit `Sized` obligations in type paramsEsteban Küber-6/+6
Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting the HIR Generics. (Fix #98539)
2022-07-07Shorten span for closures.Camille GILLOT-18/+18
2022-07-01Auto merge of #98781 - GuillaumeGomez:rollup-798kb8u, r=GuillaumeGomezbors-4/+0
Rollup of 5 pull requests Successful merges: - #97249 (`<details>`/`<summary>` UI fixes) - #98418 (Allow macOS to build LLVM as shared library) - #98460 (Use CSS variables to handle theming) - #98497 (Improve some inference diagnostics) - #98708 (rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests) Failed merges: - #98761 (more `need_type_info` improvements) r? `@ghost` `@rustbot` modify labels: rollup
2022-07-01Only label place where type is needed if span is meaningfulMichael Goulet-4/+0
2022-07-01Shorten def_span for more items.Camille GILLOT-5/+3
2022-07-01Remove type flag based opaque type workaroundOli Scherer-98/+15
2022-06-29Make RPIT and TAIT work exactly the sameOli Scherer-54/+36
2022-06-27Remove a back-compat hack on lazy TAITYuki Okushi-6/+18
2022-06-27Auto merge of #98221 - cjgillot:single-coh, r=lcnrbors-20/+20
Perform coherence checking per impl. r? `@ghost`
2022-06-26Rollup merge of #98371 - compiler-errors:better-opaque-printing, r=oli-obkYuki Okushi-0/+45
Fix printing `impl trait` under binders Before, we would render `impl for<'a> Trait<'a>` like `impl Trait<for<'a> 'a>`, lol.
2022-06-25Rollup merge of #98298 - TaKO8Ki:point-to-type-param-definition, ↵Matthias Krüger-6/+6
r=compiler-errors Point to type parameter definition when not finding variant, method and associated item fixes #77391
2022-06-24Fix printing impl trait under bindersMichael Goulet-0/+45
2022-06-24Rollup merge of #98280 - compiler-errors:better-call-closure-on-type-err, ↵Yuki Okushi-0/+33
r=estebank Improve suggestion for calling fn-like expr on type mismatch 1.) Suggest calling values of with RPIT types (and probably TAIT) when we expect `Ty` and have `impl Fn() -> Ty` 2.) Suggest calling closures even when they're not assigned to a local variable first 3.) Drive-by fix of a pretty-printing bug (`impl Fn()-> Ty` => `impl Fn() -> Ty`) r? ```@estebank```
2022-06-23Rollup merge of #98259 - jyn514:improve-obligation-errors, r=estebankMichael Goulet-10/+40
Greatly improve error reporting for futures and generators in `note_obligation_cause_code` Most futures don't go through this code path, because they're caught by `maybe_note_obligation_cause_for_async_await`. But all generators do, and `maybe_note` is imperfect and doesn't catch all futures. Improve the error message for those it misses. At some point, we may want to consider unifying this with the code for `maybe_note_async_await`, so that `async_await` notes all parent constraints, and `note_obligation` can point to yield points. But both functions are quite complicated, and it's not clear to me how to combine them; this seems like a good incremental improvement. Helps with https://github.com/rust-lang/rust/issues/97332. r? ``@estebank`` cc ``@eholk`` ``@compiler-errors``
2022-06-22Perform coherence checking per impl.Camille GILLOT-20/+20
2022-06-22point to type param definition when not finding variant, method and assoc typeTakayuki Maeda-6/+6
use `def_ident_span` , `body_owner_def_id` instead of `in_progress_typeck_results`, `guess_head_span` use `body_id.owner` directly add description to label
2022-06-21Point at return expression for RPIT-related errorMichael Goulet-0/+6
2022-06-21Improve suggestion for calling closure on type mismatchMichael Goulet-0/+33
2022-06-19Greatly improve error reporting for futures and generators in ↵Joshua Nelson-10/+40
`note_obligation_cause_code` Most futures don't go through this code path, because they're caught by `maybe_note_obligation_cause_for_async_await`. But all generators do, and `maybe_note` is imperfect and doesn't catch all futures. Improve the error message for those it misses. At some point, we may want to consider unifying this with the code for `maybe_note_async_await`, so that `async_await` notes all parent constraints, and `note_obligation` can point to yield points. But both functions are quite complicated, and it's not clear to me how to combine them; this seems like a good incremental improvement.
2022-06-16 fix one more case of trailing spaceklensy-2/+2
2022-06-16diagnostics: fix trailing spaceklensy-1/+1
2022-06-11Rollup merge of #96868 - nrc:turbo-stable, r=jhpratt,nbdd0121,nagisaDylan DPC-81/+25
Stabilize explicit_generic_args_with_impl_trait This is a stabilisation PR for `explicit_generic_args_with_impl_trait`. * [tracking issue](https://github.com/rust-lang/rust/issues/83701) - [Stabilisation report](https://github.com/rust-lang/rust/issues/83701#issuecomment-1109949897) - [FCP entered](https://github.com/rust-lang/rust/issues/83701#issuecomment-1120285703) * [implementation PR](https://github.com/rust-lang/rust/pull/86176) * [Reference PR](https://github.com/rust-lang/reference/pull/1212) * There is no mention of using the turbofish operator in the book (other than an entry in the operator list in the appendix), so there is no documentation to change/add there, unless we felt like we should add a section on using turbofish, but that seems orthogonal to `explicit_generic_args_with_impl_trait`
2022-06-07Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakisbors-285/+18
Remove migrate borrowck mode Closes #58781 Closes #43234 # Stabilization proposal This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile. Tracking issue: #43234 RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable). ## Motivation Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors. The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition. In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker. In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver. While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff. ## What is stabilized As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise. There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl. As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions. ## What isn't stabilized This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck. ## Tests Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll` ## History * On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234) * On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271) * On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094) * On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825) * On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862) * On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083) * On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681) * On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114) * On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221) * On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-06Deactivate feature gate explicit_generic_args_with_impl_traitNick Cameron-81/+25
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-06-03Fully stabilize NLLJack Huey-285/+18
2022-06-03Fail gracefully when encountering an HRTB in APIT.Camille GILLOT-0/+22
2022-06-03Auto merge of #89862 - lcnr:path-generics-diagnostics, r=estebankbors-30/+89
rewrite error handling for unresolved inference vars Pretty much completely rewrites `fn emit_inference_failure_err`. This new setup should hopefully be easier to extend and is already a lot better when looking for generic arguments. Because this is a rewrite there are still some parts which are lacking, these are tracked in #94483 and will be fixed in later PRs. r? `@estebank` `@petrochenkov`
2022-06-03Auto merge of #97497 - c410-f3r:z-errors, r=petrochenkovbors-0/+15
Move some tests to more reasonable places r? `@petrochenkov`
2022-06-02add new `emit_inference_failure_err`lcnr-30/+89
2022-05-28Move some tests to more reasonable placesCaio-0/+15