Compute explicit MIR params on THIR.
This commit is contained in:
parent
f76594a0bc
commit
445841cda3
5 changed files with 86 additions and 55 deletions
|
@ -78,6 +78,22 @@ thir_with_elements! {
|
|||
blocks: BlockId => Block => "b{}",
|
||||
exprs: ExprId => Expr<'tcx> => "e{}",
|
||||
stmts: StmtId => Stmt<'tcx> => "s{}",
|
||||
params: ParamId => Param<'tcx> => "p{}",
|
||||
}
|
||||
|
||||
/// Description of a type-checked function parameter.
|
||||
#[derive(Clone, Debug, HashStable)]
|
||||
pub struct Param<'tcx> {
|
||||
/// The pattern that appears in the parameter list.
|
||||
pub pat: Box<Pat<'tcx>>,
|
||||
/// The possibly inferred type.
|
||||
pub ty: Ty<'tcx>,
|
||||
/// Span of the explicitly provided type, or None if inferred for closures.
|
||||
pub ty_span: Option<Span>,
|
||||
/// Whether this param is `self`, and how it is bound.
|
||||
pub self_kind: Option<hir::ImplicitSelfKind>,
|
||||
/// HirId for lints.
|
||||
pub hir_id: hir::HirId,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, HashStable)]
|
||||
|
@ -548,6 +564,15 @@ impl<'tcx> Pat<'tcx> {
|
|||
pub fn wildcard_from_ty(ty: Ty<'tcx>) -> Self {
|
||||
Pat { ty, span: DUMMY_SP, kind: PatKind::Wild }
|
||||
}
|
||||
|
||||
pub fn simple_ident(&self) -> Option<Symbol> {
|
||||
match self.kind {
|
||||
PatKind::Binding { name, mode: BindingMode::ByValue, subpattern: None, .. } => {
|
||||
Some(name)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, HashStable)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue