Uh oh!
There was an error while loading. Please reload this page.
Modify existing bounds if they exist - #107555
Conversation
compiler-errors
left a comment
There was a problem hiding this comment.
This looks good other than perhaps some of the logic can be simplified. Could you do that? Otherwise r=me, should be fine to land regardless.
Ping me if you give up on trying to simplify stuff and I can approve.
There was a problem hiding this comment.
There's gotta be a way to simplify this, perhaps by avoiding these combinators... Could you maybe make this logic a bit simpler?
There was a problem hiding this comment.
Couldn't get rid of an and_then, but does this look cleaner to you?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
What happens if we have like...
T: Trait<A> + Trait<B>
and then we suggest to restrict T: Trait<B, Output = C>
What will that do?
There was a problem hiding this comment.
Wouldn't the associated type prevent multiple trait impls on the same type anyways? So Trait<A> + Trait<B> would error for other reasons before suggesting to constrain the bounds?
There was a problem hiding this comment.
e.g.
trait Foo<T> {
type Output;
fn bar() -> Self::Output;
}
fn test<T>() -> i32 where T: Foo<()>, T: Foo<i32> {
<T as Foo<()>>::bar()
}
There was a problem hiding this comment.
But I guess that already suggests .. , Output = i32> correctly
edward-shen
commented
Feb 6, 2023
Changes:
|
compiler-errors
commented
Feb 6, 2023
Anywho @bors r+ rollup |
bors
commented
Feb 6, 2023
…suggestion, r=compiler-errors Modify existing bounds if they exist Fixesrust-lang#107335. This implementation is kinda gross but I don't really see a better way to do it. This primarily does two things: Modifies `suggest_constraining_type_param` to accept a new parameter that indicates a span to be replaced instead of added, if presented, and limit the additive suggestions to either suggest a new bound on an existing bound (see newly added unit test) or add the generics argument if a generics argument wasn't found. The former change is required to retain the capability to add an entirely new bounds if it was entirely omitted. r? `@compiler-errors`
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#100599 (Add compiler error E0523 long description and test) - rust-lang#107471 (rustdoc: do not include empty default-settings tag in HTML) - rust-lang#107555 (Modify existing bounds if they exist) - rust-lang#107662 (Turn projections into copies in CopyProp.) - rust-lang#107695 (Add test for Future inflating arg size to 3x ) - rust-lang#107700 (Run the tools builder on all PRs) - rust-lang#107706 (Mark 'atomic_mut_ptr' methods const) - rust-lang#107709 (Fix problem noticed in PR106859 with char -> u8 suggestion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes#107335.
This implementation is kinda gross but I don't really see a better way to do it.
This primarily does two things: Modifies
suggest_constraining_type_paramto accept a new parameter that indicates a span to be replaced instead of added, if presented, and limit the additive suggestions to either suggest a new bound on an existing bound (see newly added unit test) or add the generics argument if a generics argument wasn't found.The former change is required to retain the capability to add an entirely new bounds if it was entirely omitted.
r? @compiler-errors