ParamEnv
should be const when ImplItem
is within a const impl.
This commit is contained in:
parent
8710a2e169
commit
87cd1ce6c1
4 changed files with 58 additions and 30 deletions
|
@ -3228,33 +3228,6 @@ impl<'hir> Node<'hir> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns `Constness::Const` when this node is a const fn/impl/item.
|
||||
pub fn constness_for_typeck(&self) -> Constness {
|
||||
match self {
|
||||
Node::Item(Item {
|
||||
kind: ItemKind::Fn(FnSig { header: FnHeader { constness, .. }, .. }, ..),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(TraitItem {
|
||||
kind: TraitItemKind::Fn(FnSig { header: FnHeader { constness, .. }, .. }, ..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(ImplItem {
|
||||
kind: ImplItemKind::Fn(FnSig { header: FnHeader { constness, .. }, .. }, ..),
|
||||
..
|
||||
})
|
||||
| Node::Item(Item { kind: ItemKind::Impl(Impl { constness, .. }), .. }) => *constness,
|
||||
|
||||
Node::Item(Item { kind: ItemKind::Const(..), .. })
|
||||
| Node::Item(Item { kind: ItemKind::Static(..), .. })
|
||||
| Node::TraitItem(TraitItem { kind: TraitItemKind::Const(..), .. })
|
||||
| Node::AnonConst(_)
|
||||
| Node::ImplItem(ImplItem { kind: ImplItemKind::Const(..), .. }) => Constness::Const,
|
||||
|
||||
_ => Constness::NotConst,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
|
||||
match self {
|
||||
Node::Item(i) => Some(OwnerNode::Item(i)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue