Skip to content

Create a new trait CrateDefType to retrieve definiton type #80

Closed
rust-lang/rust
#126366
@celinval

Description

@celinval

The goal would be to provide a trait to allow users to access tcx.type_of() for definitions that have a type, such as FnDef, InstanceDef, StaticDef...

Something like:

trait CrateDefType : CrateDef {
  fn ty(&self) -> Ty {
    with(|cx| cx.type_of(self.def_id()))
  }
}

I think this should be a separate trait, since not every CrateDef has a type. Thus, only the ones that do should implement the new trait.

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