Skip to content

RFC: Centralize on special types as a way of informing inference about special constraints #10834

Closed
@nikomatsakis

Description

@nikomatsakis

As part of the discussion in #5922, it became clear that there are a number of cases in which we must inform the compiler about special constraints that pertain to specific types. These constraints almost always arise because of unsafe code that does things the compiler can't know about. We don't have a central mechanism for propagating such constraints:

  1. Annotations like #[no_freeze] are used to inform the builtin-bounds.
  2. Except for non-copyable, which has a special type.
  3. Variance currently has no mechanism, so unused lifetime parameters don't necessarily behave like people expect.

I think we should centralize on one mechanism. My current thought is to employ 0-sized types for this. So we would remove the #[no_freeze] annotations and add types like Nonfreezable, as well as CovariantLifetime<'a> and so on. These would be lang items specially recognized by the compiler.

Nominating and adding to the agenda for next week.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions