about summary refs log tree commit diff
path: root/src/test/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2022-11-01Remap RPITIT substs properlyMichael Goulet-0/+24
2022-11-01Check for substs compatibility for RPITITsMichael Goulet-0/+29
2022-10-30Rollup merge of #93582 - WaffleLapkin:rpitirpit, r=compiler-errorsDylan DPC-75/+256
Allow `impl Fn() -> impl Trait` in return position _This was originally proposed as part of #93082 which was [closed](https://github.com/rust-lang/rust/pull/93082#issuecomment-1027225715) due to allowing `impl Fn() -> impl Trait` in argument position._ This allows writing the following function signatures: ```rust fn f0() -> impl Fn() -> impl Trait; fn f3() -> &'static dyn Fn() -> impl Trait; ``` These signatures were already allowed for common traits and associated types, there is no reason why `Fn*` traits should be special in this regard. `impl Trait` in both `f0` and `f3` means "new existential type", just like with `-> impl Iterator<Item = impl Trait>` and such. Arrow in `impl Fn() ->` is right-associative and binds from right to left, it's tested by [this test](https://github.com/WaffleLapkin/rust/blob/a819fecb8dea438fc70488ddec30a61e52942672/src/test/ui/impl-trait/impl_fn_associativity.rs). There even is a test that `f0` compiles: https://github.com/rust-lang/rust/blob/2f004d2d401682e553af3984ebd9a3976885e752/src/test/ui/impl-trait/nested_impl_trait.rs#L25-L28 But it was changed in [PR 48084 (lines)](https://github.com/rust-lang/rust/pull/48084/files#diff-ccecca938872d65ffe8cd1c3ef1956e309fac83bcda547d8b16b89257e53a437R37) to test the opposite, probably unintentionally given [PR 48084 (lines)](https://github.com/rust-lang/rust/pull/48084/files#diff-5a02f1ed43debed1fd24f7aad72490064f795b9420f15d847bac822aa4621a1cR476-R477). r? `@nikomatsakis` ---- This limitation is especially annoying with async code, since it forces one to write this: ```rust trait AsyncFn3<A, B, C>: Fn(A, B, C) -> <Self as AsyncFn3<A, B, C>>::Future { type Future: Future<Output = Self::Out>; type Out; } impl<A, B, C, Fut, F> AsyncFn3<A, B, C> for F where F: Fn(A, B, C) -> Fut, Fut: Future, { type Future = Fut; type Out = Fut::Output; } fn async_closure() -> impl AsyncFn3<i32, i32, i32, Out = u32> { |a, b, c| async move { (a + b + c) as u32 } } ``` Instead of: ```rust fn async_closure() -> impl Fn(i32, i32, i32) -> impl Future<Output = u32> { |a, b, c| async move { (a + b + c) as u32 } } ```
2022-10-28Rollup merge of #103608 - compiler-errors:rpitit-early-lt, r=cjgillotMatthias Krüger-0/+23
Remap early bound lifetimes in return-position `impl Trait` in traits too Fixes part of #103457 r? ``@cjgillot,`` though feel free to reassign, just thought you'd have sufficient context to review.
2022-10-27Remap early bound lifetimes tooMichael Goulet-0/+23
2022-10-26No need to probe when relating opaques in nll_relateMichael Goulet-0/+24
2022-10-25Name impl trait in region bound suggestionMichael Goulet-16/+16
2022-10-25adopt to compiler changesMaybe Waffle-9/+20
2022-10-25--blessMaybe Waffle-89/+106
2022-10-25Add even more tests for `impl Fn() -> impl Trait`Maybe Waffle-1/+53
2022-10-25Add more tests for `impl Fn() -> impl Trait`Maybe Waffle-0/+106
2022-10-25Allow `impl Fn() -> impl Trait` in return positionMaybe Waffle-66/+61
This allows writing the following function signatures: ```rust fn f0() -> impl Fn() -> impl Trait; fn f3() -> &'static dyn Fn() -> impl Trait; ``` These signatures were already allowed for common traits and associated types, there is no reason why `Fn*` traits should be special in this regard.
2022-10-24Delay span bug when we can't map lifetimes back in collect_trait_impl_trait_tysMichael Goulet-0/+37
2022-10-23Rollup merge of #103414 - compiler-errors:rpit-print-lt, r=cjgillotMichael Howell-2/+2
Pretty print lifetimes captured by RPIT This specifically makes the output in #103409 change from: ```diff error: `impl` item signature doesn't match `trait` item signature --> $DIR/signature-mismatch.rs:15:5 | LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>; | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` ... LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` | = note: expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` - found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>` + found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output error: aborting due to previous error ``` Along with the UI tests in this PR, which I think are all improvements! r? `@oli-obk` though feel free to re-roll
2022-10-23Rollup merge of #103368 - compiler-errors:normalization-ambiguity-bug, r=oli-obkMatthias Krüger-0/+135
Delay ambiguity span bug in normalize query iff not rustdoc Oli and I decided that the compiler debt of adding another usage of `tcx.sess.opts.actually_rustdoc` is fine, because we don't really want to add more complexity to the normalize query, and moving rustdoc to use fulfill normalization (`fully_normalize`, i.e. not use the normalize query) is unnecessary overhead given that it's skipping binders and stuff. r? oli-obk Fixes #102827 Fixes #103181
2022-10-22Pretty print lifetimes captured by RPITMichael Goulet-2/+2
2022-10-21testsMichael Goulet-0/+135
2022-10-21Handle RPITITs properly in register_hidden_typeMichael Goulet-13/+50
2022-10-20Auto merge of #103205 - spastorino:fix-rpits-lifetime-remapping, r=cjgillotbors-0/+23
Do anonymous lifetimes remapping correctly for nested rpits Closes #103141 r? `@cjgillot` `@nikomatsakis` This fixes a stable to stable regression that in my opinion is `P-critical` so, we probably want to backport it all the way up to stable.
2022-10-20Auto merge of #102417 - oli-obk:opaque_lifetimes2, r=jackh726bors-2/+6
Require lifetime bounds for opaque types in order to allow hidden types to capture said lifetimes fixes #96996 cc `@aliemjay`
2022-10-19Do anonymous lifetimes remapping correctly for nested rpitsSantiago Pastorino-0/+23
2022-10-18Clean up query descriptionsnils-4/+4
Use the same tense everywhere and prefer display over debug, as these descriptions are user facing.
2022-10-15Fix subst issues with RPITITMichael Goulet-0/+18
2022-10-14Require lifetime bounds for opaque types in order to allow hidden types to ↵Oli Scherer-2/+6
capture said lifetimes
2022-10-13Auto merge of #102700 - oli-obk:0xDEAD_TAIT, r=compiler-errorsbors-4/+11
Check hidden types in dead code fixes #99490 r? `@compiler-errors` best reviewed commit by commit
2022-10-12Add broken test for AFIT with RPITITMichael Goulet-0/+33
2022-10-07Unconditionally encode hidden types in typeck resultsOli Scherer-4/+11
2022-10-05Fix test for default body with implMichael Goulet-4/+10
2022-10-05Support default-body trait functions with RPITITMichael Goulet-0/+15
2022-10-04Rollup merge of #102648 - Rageking8:add-test-for-#102605, r=compiler-errorsMatthias Krüger-0/+56
Add test for #102605 Fixes #102605
2022-10-04Rollup merge of #102568 - compiler-errors:lint-unsatisfied-opaques, r=oli-obkDylan DPC-0/+108
Lint against nested opaque types that don't satisfy associated type bounds See the test failures for examples of places where this lint would fire. r? `@oli-obk`
2022-10-04add test for #102605Rageking8-0/+56
2022-10-02Avoid ICE in printing RPITIT typeMichael Goulet-0/+38
2022-10-02Make it a lint for all opaque typesMichael Goulet-0/+108
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-6/+6
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01bless ui testsMaybe Waffle-6/+6
2022-09-30Auto merge of #102164 - compiler-errors:rpitit-foreign, r=TaKO8Kibors-0/+20
Serialize return-position `impl Trait` in trait hidden values in foreign libraries Fixes #101630
2022-09-26address reviewb-naber-5/+5
2022-09-25Auto merge of #95474 - oli-obk:tait_ub, r=jackh726bors-0/+64
Neither require nor imply lifetime bounds on opaque type for well formedness The actual hidden type can live arbitrarily longer than any individual lifetime and arbitrarily shorter than all but one of the lifetimes. fixes #86218 fixes #84305 This is a **breaking change** but it is a necessary soundness fix
2022-09-25Rollup merge of #102194 - fee1-dead-contrib:improve-const-drop, r=oli-obkfee1-dead-3/+3
Note the type when unable to drop values in compile time
2022-09-24Note the type when unable to drop values in compile timeDeadbeef-3/+3
2022-09-23Report diagnostics at the actually actionable siteOli Scherer-11/+38
2022-09-23Showcase a broken diagnosticOli Scherer-4/+4
2022-09-23Serialize RPITIT values in libsMichael Goulet-0/+20
2022-09-22Calculate ProjectionTy::trait_def_id correctlyMichael Goulet-0/+59
2022-09-21Improve diagnostic for adding more bounds to opaque typesOli Scherer-4/+6
2022-09-21Reproduce sad diagnosticOli Scherer-0/+35
2022-09-13Auto merge of #101086 - cjgillot:thir-param, r=oli-obkbors-0/+10
Compute information about function parameters on THIR This avoids some manipulation of typeck results while building MIR.
2022-09-13Simplify MIR building entry.Camille GILLOT-0/+10
2022-09-13Auto merge of #101615 - compiler-errors:rpitit-perf, r=oli-obkbors-10/+5
Make `compare_predicate_entailment` no longer a query Make `compare_predicate_entailment` so it's no longer a query (again), and splits out the new logic (that equates the return types to infer RPITITs) into its own query. This means that this new query (now called `collect_trait_impl_trait_tys`) is no longer executed for non-RPITIT cases. This should improve perf (https://github.com/rust-lang/rust/pull/101224#issuecomment-1241682203), though in practice we see that these some crates remain from the primary regressions list on the original report... They are all <= 0.43% regression and seemingly only on the incr-full scenario for all of them. I am at a loss for what might be causing this regression other than what I fixed here, since we don't introduce much new non-RPITIT logic except for some `def_kind` query calls in some places, for example, like projection. Maybe that's it? ---- Originally this PR was opened to test enabling `cache_on_disk` (62164aaaa11) but that didn't turn out to be very useful (https://github.com/rust-lang/rust/pull/101615#issuecomment-1242403205), so that led me to just split the query (and rename the PR).