| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
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.
|
|
fix rustdoc ui test
|
|
more than one lifetimes of the function's inputs
|
|
Tweak wording of fn call with wrong number of args
|
|
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
|
|
|
|
|
|
|
|
Tweak output for bare `dyn Trait` in arguments
Fix #35825.
|
|
|
|
Fix #35825.
|
|
Suggest `collect`ing into `Vec<_>`
Fix #105510.
|
|
|
|
|
|
|
|
relying on the span making it obvious
|
|
available
|
|
|
|
Recurse into nested impl-trait when computing variance.
Fixes https://github.com/rust-lang/rust/issues/105251
|
|
When *any* of the suggested impls is an exact match, *only* show the
exact matches. This is particularly relevant for integer types.
fix fmt
|
|
|
|
|
|
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`
|
|
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.
|
|
|
|
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases
r? ````@lcnr````
fixes #99840
|
|
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`.
|
|
|
|
|
|
Move tests
r? `@petrochenkov`
|
|
unsound cases
|
|
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.
|
|
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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.
|
|
Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate`
Fixes #103824
|
|
|
|
|