Skip to content

move implicit Sized predicate to end of list - #86011

Merged
bors merged 2 commits into
rust-lang:masterfrom
tlyu:correct-sized-bound-spans
Oct 15, 2021
Merged

move implicit Sized predicate to end of list#86011
bors merged 2 commits into
rust-lang:masterfrom
tlyu:correct-sized-bound-spans

Conversation

@tlyu

@tlyu tlyu commented Jun 4, 2021

Copy link
Copy Markdown
Contributor

In Bounds::predicates(), move the implicit Sized predicate to the
end of the generated list. This means that if there is an explicit
Sized bound, it will be checked first, and any resulting
diagnostics will have a more useful span.

Fixes #85998, at least partially. Based on #85979, but only the last 2 commits are new for this pull request. (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit Sized predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.

I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with Sized bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.

I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.

@estebank this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E0277 wrong span in diagnostic with explicit Sized bound