Skip to content

Use structured suggestion for restricting bounds - #65192

Merged
bors merged 16 commits into
rust-lang:masterfrom
estebank:restrict-bound
Oct 19, 2019
Merged

Use structured suggestion for restricting bounds#65192
bors merged 16 commits into
rust-lang:masterfrom
estebank:restrict-bound

Conversation

@estebank

@estebankestebank commented Oct 7, 2019

Copy link
Copy Markdown
Contributor

When a trait bound is not met and restricting a type parameter would
make the restriction hold, use a structured suggestion pointing at an
appropriate place (type param in param list or where clause).

Account for opaque parameters where instead of suggesting extending
the where clause, we suggest appending the new restriction:
fn foo(impl Trait + UnmetTrait). Fix#64565, fix#41817, fix#24354,
cc #26026, cc #37808, cc #24159, fix#37138, fix#24354, cc #20671.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 7, 2019
@rust-highfive

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I noted on Discord, I think this method is way too complicated not be be divided along the important match arms (or the places that involve early returns) (and it doesn't fit on a single page...). However, if you insist on keeping it all in one method then let's at least use a .filter(...) here to reduce the drift rightwards.

Comment threadsrc/librustc/traits/error_reporting.rs Outdated
@estebank
estebankforce-pushed the restrict-bound branch 3 times, most recently from 9dd6fa6 to 7409942CompareOctober 10, 2019 20:22
@estebank

This comment has been minimized.

@Centril

This comment has been minimized.

@estebank

This comment has been minimized.

Comment threadsrc/librustc/traits/error_reporting.rs Outdated
Comment threadsrc/librustc/traits/error_reporting.rs Outdated
Comment threadsrc/librustc/traits/error_reporting.rs Outdated
Comment threadsrc/librustc/traits/error_reporting.rs Outdated
Comment threadsrc/test/ui/issues/issue-38821.stderr Outdated
Comment threadsrc/librustc/traits/error_reporting.rs Outdated
Comment threadsrc/librustc/traits/error_reporting.rs Outdated
Comment threadsrc/librustc/traits/error_reporting.rs Outdated
@matthewjaspermatthewjasper added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 13, 2019
@estebankestebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 15, 2019
@rust-highfive

This comment has been minimized.

When a trait bound is not met and restricting a type parameter would
make the restriction hold, use a structured suggestion pointing at an
appropriate place (type param in param list or `where` clause).
Account for opaque parameters where instead of suggesting extending
the `where` clause, we suggest appending the new restriction:
`fn foo(impl Trait + UnmetTrait)`.
@estebank

Copy link
Copy Markdown
ContributorAuthor

@matthewjasper all your comments have been addressed.

@matthewjasper

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Oct 19, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit c6dce78 has been approved by matthewjasper

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 19, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 19, 2019
…asper
Use structured suggestion for restricting bounds
When a trait bound is not met and restricting a type parameter would
make the restriction hold, use a structured suggestion pointing at an
appropriate place (type param in param list or `where` clause).
Account for opaque parameters where instead of suggesting extending
the `where` clause, we suggest appending the new restriction:
`fn foo(impl Trait + UnmetTrait)`. Fixrust-lang#64565, fixrust-lang#41817, fixrust-lang#24354,
cc rust-lang#26026, cc rust-lang#37808, cc rust-lang#24159, fixrust-lang#37138, fixrust-lang#24354, cc rust-lang#20671.
@CentrilCentril mentioned this pull request Oct 19, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 19, 2019
…asper
Use structured suggestion for restricting bounds
When a trait bound is not met and restricting a type parameter would
make the restriction hold, use a structured suggestion pointing at an
appropriate place (type param in param list or `where` clause).
Account for opaque parameters where instead of suggesting extending
the `where` clause, we suggest appending the new restriction:
`fn foo(impl Trait + UnmetTrait)`. Fixrust-lang#64565, fixrust-lang#41817, fixrust-lang#24354,
cc rust-lang#26026, cc rust-lang#37808, cc rust-lang#24159, fixrust-lang#37138, fixrust-lang#24354, cc rust-lang#20671.
@CentrilCentril mentioned this pull request Oct 19, 2019
bors added a commit that referenced this pull request Oct 19, 2019
Rollup of 5 pull requests
Successful merges:
- #64007 (Add check for overlapping ranges to unreachable patterns lint)
- #65192 (Use structured suggestion for restricting bounds)
- #65226 (BTreeSet symmetric_difference & union optimized)
- #65448 (rustc_codegen_ssa: remove some unnecessary Box special-casing.)
- #65505 (Rc: value -> allocation)
Failed merges:
r? @ghost
@bors
bors merged commit c6dce78 into rust-lang:masterOct 19, 2019
@estebank
estebank deleted the restrict-bound branch November 9, 2023 05:18
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

6 participants

@estebank@rust-highfive@Centril@matthewjasper@bors@tesuji