about summary refs log tree commit diff
path: root/src/test/ui/impl-trait
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-11331/+0
2023-01-08Mention signature rather than fn pointers when comparing impl/trait methodsMichael Goulet-18/+18
2023-01-06Rollup merge of #106533 - ↵Michael Goulet-1/+1
TaKO8Ki:use-smaller-span-for-missing-lifetime/generic-args, r=compiler-errors Use smaller spans for missing lifetime/generic args We can remove ident from suggestions.
2023-01-06use smaller spans for missing lifetime/generic argsTakayuki Maeda-1/+1
fix rustdoc ui test
2023-01-05Suggests adding named lifetime when the return contains value borrowed from ↵yanchen4791-31/+3
more than one lifetimes of the function's inputs
2023-01-04Rollup merge of #106478 - estebank:tweak-fn-mismatch, r=compiler-errorsMichael Goulet-1/+1
Tweak wording of fn call with wrong number of args
2023-01-04Rollup merge of #105846 - compiler-errors:issue-105838, r=jackh726Michael Goulet-0/+60
Account for return-position `impl Trait` in trait in `opt_suggest_box_span` RPITITs are the only types where their opaque bounds might normalize to some other self type than the opaque type itself. To avoid needing to do normalization, let's just match on either alias kind. Ideally, we'd just get rid of `opt_suggest_box_span`. It's kind of a wart on type-checking `if`/`match`. I've recently refactored this expression for being confusing/wrong, but moving it into the error path is pretty hard. Fixes #105838
2023-01-05Tweak wording of fn call with wrong number of argsEsteban Küber-1/+1
2022-12-30Suppress errors due to TypeError not coercing with inference variablesMichael Goulet-12/+4
2022-12-17Account for RPITITs in opt_suggest_box_spanMichael Goulet-0/+60
2022-12-15Rollup merge of #105727 - estebank:use-impl-trait, r=oli-obkMatthias Krüger-4/+0
Tweak output for bare `dyn Trait` in arguments Fix #35825.
2022-12-15Trim paths in E0599Esteban Küber-16/+16
2022-12-14Tweak output for bare `dyn Trait` in argumentsEsteban Küber-4/+0
Fix #35825.
2022-12-14Rollup merge of #105523 - estebank:suggest-collect-vec, r=compiler-errorsMatthias Krüger-2/+2
Suggest `collect`ing into `Vec<_>` Fix #105510.
2022-12-13review commentsEsteban Küber-3/+3
2022-12-13Suggest `: Type` instead of `: _`Esteban Küber-3/+3
2022-12-13Suggest `collect`ing into `Vec<_>`Esteban Küber-1/+1
2022-12-13Inform the user which trait is meant in the diagnostic itself instead of ↵Oli Scherer-1/+1
relying on the span making it obvious
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-12/+2
available
2022-12-10Introduce `with_forced_trimmed_paths`Esteban Küber-2/+2
2022-12-06Rollup merge of #105254 - cjgillot:issue-105251, r=oli-obkMatthias Krüger-0/+28
Recurse into nested impl-trait when computing variance. Fixes https://github.com/rust-lang/rust/issues/105251
2022-12-05Tweak "the following other types implement trait"Esteban Küber-9/+4
When *any* of the suggested impls is an exact match, *only* show the exact matches. This is particularly relevant for integer types. fix fmt
2022-12-04Recurse into nested impl-trait when computing variance.Camille GILLOT-0/+28
2022-12-04Use parent function WfCheckingContext to check RPITIT.Camille GILLOT-0/+24
2022-11-28Rollup merge of #104936 - cjgillot:self-rpit-orig-too, r=oli-obkMatthias Krüger-0/+66
Ignore bivariant parameters in test_type_match. https://github.com/rust-lang/rust/pull/103491 made opaque types bivariant with respect of some of their lifetime parameters. Because of this bivariance, some lifetime variables were not unified to anything during borrowck, and were considered as unequal by borrowck type test. This PR makes type test ignore the bivariant parameters in test_type_match. Fixes https://github.com/rust-lang/rust/issues/104815 r? `@oli-obk`
2022-11-26Pretty-print generators with their `generator_kind`Arpad Borsos-5/+5
After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally. This now reverses that change so that async fn/blocks are pretty-printed as `[$movability `async` $something@$source-position]` in various diagnostics, and updates the tests that this touches.
2022-11-26Ignore bivariant parameters in test_type_match.Camille GILLOT-0/+66
2022-11-22Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnrManish Goregaokar-46/+59
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ````@lcnr```` fixes #99840
2022-11-22Rollup merge of #104295 - compiler-errors:rpitit-generics-parity, r=eholkDylan DPC-0/+29
Check generics parity before collecting return-position `impl Trait`s in trait The only thing is that this duplicates the error message for number of generics mismatch, but we already deduplicate that error message in Cargo. I could add a flag to delay the error if the reviewer cares. Fixes #104281 Also drive-by adds a few comments to the `collect_trait_impl_trait_tys` method, and removes an unused argument from `compare_number_of_generics`.
2022-11-22Delay bug to deduplicate diagnosticsMichael Goulet-11/+1
2022-11-22Check generics parity between impl and trait before collecting RPITITsMichael Goulet-0/+39
2022-11-22Rollup merge of #104656 - c410-f3r:moar-errors, r=petrochenkovMatthias Krüger-0/+41
Move tests r? `@petrochenkov`
2022-11-21Allow opaque types in trait impl headers and rely on coherence to reject ↵Oli Scherer-46/+59
unsound cases
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-10/+151
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-20Move testsCaio-0/+41
2022-11-19Rollup merge of #104593 - compiler-errors:rpitit-object-safety-spans, ↵Matthias Krüger-6/+6
r=fee1-dead Improve spans for RPITIT object-safety errors No reason why we can't point at the `impl Trait` that causes the object-safety violation. Also [drive-by: Add is_async fn to hir::IsAsync](https://github.com/rust-lang/rust/pull/104593/commits/c4165f3a965e258531928180195637455299c6f3), which touches clippy too.
2022-11-19Improve spans for RPITIT object-safety errorsMichael Goulet-6/+6
2022-11-18Add testMichael Goulet-0/+47
2022-11-15Rollup merge of #104258 - compiler-errors:tait-closure-deduce, r=oli-obkMatthias Krüger-0/+15
Deduce closure signature from a type alias `impl Trait`'s supertraits r? `@oli-obk` Basically pass the TAIT's bounds through the same method that we're using to deduce a signature from infer var closure bounds. Does this need a new FCP? I see it as a logical extension of #101834, but happy to rfcbot a new one if it does.
2022-11-13Create bidirectional bounds between original and duplicated parameters.Camille GILLOT-4/+1
2022-11-12Make impl_trait_projections a feature gate.Camille GILLOT-2/+146
2022-11-12Bless ui tests.Camille GILLOT-4/+4
2022-11-12Auto merge of #104310 - Dylan-DPC:rollup-wgt1z4a, r=Dylan-DPCbors-0/+135
Rollup of 7 pull requests Successful merges: - #102049 (Add the `#[derive_const]` attribute) - #103970 (Unhide unknown spans) - #104206 (Remove `save_and_restore_in_snapshot_flag`, use `ObligationCtxt` more) - #104214 (Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures) - #104267 (rustdoc: use checkbox instead of switch for settings toggles) - #104302 (Update cargo) - #104303 (UI tests can be assigned to T-compiler) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-11Visit opaque types during type collection too.Camille GILLOT-228/+25
2022-11-11Resolve lifetimes using the regular logic for RPIT.Camille GILLOT-25/+202
2022-11-10Deduce closure signature from TAIT supertraitsMichael Goulet-0/+15
2022-11-09Emit error in `collecting_trait_impl_trait_tys` on mismatched signaturesNilstrieb-0/+135
Previously, a `delay_span_bug` was isssued, failing normalization. This create a `TyKind::Error` in the signature, which caused `compare_predicate_entailment` to swallow its signature mismatch error, causing ICEs because no error was emitted.
2022-11-08Rollup merge of #103827 - compiler-errors:rpitit-substs-compat, r=wesleywiserManish Goregaokar-0/+102
Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate` Fixes #103824
2022-11-08selection failure: recompute applicable implslcnr-5/+8
2022-11-01Fix ICE in default impl error reportingMichael Goulet-0/+49