Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit warning when bound is trivially false #100090

Closed

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Aug 3, 2022

We really should be rejecting bounds that are global, even if they have higher-ranked lifetimes. We have the ability to prove whether for<'a> &'a mut String: Clone is true or not, so there's no reason to silently allow this to typecheck, especially because it's inconsistent with a non-HRTB like &'static mut String: Clone and is the source of ICEs.

For now, though, just add a warning, so that when an ICE does occur (because sometimes it will), then the user knows what might've caused it.

This is a revival of #95611.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 3, 2022
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 3, 2022
@compiler-errors
Copy link
Member Author

r? types

@jackh726
Copy link
Member

jackh726 commented Aug 7, 2022

Let's specifically r? @nikomatsakis, since he has some specific thoughts on this :)

(Though I personally do think a warning is good)

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

Warnings here...aren't great.

@@ -0,0 +1,14 @@
warning: the where-clause bound `<T as Broken>::Assoc: Foo` is impossible to satisfy
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit unfortunate that the bound we say is not the bound that's written.

@@ -0,0 +1,26 @@
warning: the where-clause bound `[for<'r> fn(&'r ())]: Copy` is impossible to satisfy
Copy link
Member

Choose a reason for hiding this comment

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

This is certainly not great.

@bors
Copy link
Contributor

bors commented Aug 22, 2022

☔ The latest upstream changes (presumably #100676) made this pull request unmergeable. Please resolve the merge conflicts.

@QuineDot
Copy link

We really should be rejecting bounds that are global, even if they have higher-ranked lifetimes.

As per RFC 2056, they should not be rejected. The HRTB's this targets can currently be used to achieve trivial bounds without #[feature(trivial_bounds)]. The motivating example in that comment is the inability to omit unsatisfiable trait members, i.e. it works around a practical problem. Until true trivial bounds are allowed on stable, it's arguably a more sensible workaround than leaving the bound off entirely -- especially once such a refined implementation can in other cases be called / relied upon.

Warning makes sense though.

@nikomatsakis
Copy link
Contributor

I agree with warning, but I feel strongly that we should not be rejecting where-clauses that are known to be false. As @QuineDot noted, RFC 2056 decided against it, and I think that is well motivated.

@compiler-errors compiler-errors 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, 2022
@compiler-errors compiler-errors deleted the trivially-false-bound branch August 11, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

None yet

8 participants