Skip to content

Remove default bounds on ~ objects and procs #10296

Closed
@nikomatsakis

Description

@nikomatsakis

Today we do some amount of defaulting to cover two special cases:

~Trait =>  ~Trait:Send
proc   =>  proc:Send

This means that you must write ~Trait: and proc: 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:

  • Less typing for the common case of sendable ~Trait objects and proc

Arguments against:

  • We don't generally default other places in the language

  • proc:Send and ~Trait:Send read quite clearly to me

  • The 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 proc

  • There are other use cases for ~Trait and proc that don't involve sending

  • Defaults are somewhat confusing in the face of DST. Consider these types:

    struct Foo<A> { x: ~A }
    struct Bar<A> { x: A }
    

    Wouldn't you think that Foo<Trait> and Bar<~Trait> should be equivalent?
    I would, but they're not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions