-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Remove default bounds on ~
objects and procs
#10296
Comments
First, +1. I find the current state pretty confusing, perhaps because
I'm not sure what you mean by |
cc me |
👍. I had no idea default bounds were a thing, or that |
@pcwalton ran into something a little related yesterday. All of the runtime's I/O structures are wrappers around some This may just be a reflection of the runtime's decision to use trait objects instead of generics, but it would make some use cases a little harder. That being said, I'd almost want to lean on the side of consistence and not have any funny bounds inferred for you when you didn't want them. |
@alexcrichton yes, some cases get more verbose. Are these many different traits or a single trait? In the latter case, you can certainly make a typedef as well:
|
Sadly there's a fair number of traits (all in |
@alexcrichton I was about to suggest that (moving the bound to the trait itself) |
We discussed this in today's meeting, and we decided that these default bounds should go. |
In #10553 it was pointed out that a |
Incidentally, this issue caused me a bunch of pain when I was trying to implement a generic trait over objects that contained references (In my case, The error message didn't really explain what I was doing wrong, and there wasn't an easy way to opt out of the In any event, I agree that |
This is needed to make progress on rust-lang#10296 as the default bounds will no longer include Send. I believe that this was the originally intended syntax for procs, and it just hasn't been necessary up until now.
This is needed to make progress on #10296 as the default bounds will no longer include Send. I believe that this was the originally intended syntax for procs, and it just hasn't been necessary up until now.
See #10296 for the rationale, and commits for the implementation.
manual_let_else: let/else is not divergent by default The divergent `else` block of a `let`/`else` statement does not make the `let/else` statement itself divergent. Fixes rust-lang#10296 changelog: [`manual_let_else`]: do not consider `let`/`else` to be divergent by default
Today we do some amount of defaulting to cover two special cases:
This means that you must write
~Trait:
andproc:
to bypass these defaults.I think we should consider removing these defaults and be consistent: no bounds means no bounds.
Arguments in favor of defaults:
~Trait
objects andproc
Arguments against:
We don't generally default other places in the language
proc:Send
and~Trait:Send
read quite clearly to meThe fact that
proc:
is even an option is not obvious, leading people to the false conclusion that one cannot e.g. close over borrowed values in a procThere are other use cases for
~Trait
andproc
that don't involve sendingDefaults are somewhat confusing in the face of DST. Consider these types:
Wouldn't you think that
Foo<Trait>
andBar<~Trait>
should be equivalent?I would, but they're not.
The text was updated successfully, but these errors were encountered: