Skip to content

Distinguish "declared" and "inferred" Places #1341

@sharkdp

Description

@sharkdp

A Place is currently either Place::Unbound, Place::Type(type, Boundness::PossiblyUnbound or Place::Type(type, Boundness::Bound):

pub(crate) enum Boundness {
    Bound,
    PossiblyUnbound,
}

pub(crate) enum Place<'db> {
    Type(Type<'db>, Boundness),
    Unbound,
}

There is currently no way of tracking if a Place originated from a declaration or if its type has been inferred. However, we still use e.g. Place::Type(type, Boundness::Bound) to mean "definitely declared" in various places. For example, the place_from_declarations query also returns a Place (wrapped in PlaceFromDeclarationsResult -> PlaceAndQualifiers -> Place).

Similarly, the Member return type of various member-access functions currently tracks the "declared vs inferred" information separately.

We should attempt to refactor Place to generally contain metadata about the origin of a particular type.

Related issue: #1051

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalAn internal refactor or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions