1
Fork 0

Make assoc types work with ?const opt=out

This commit is contained in:
Deadbeef 2021-07-26 17:25:01 +08:00
parent 8c2a1e8e43
commit 1fa712d0ba
No known key found for this signature in database
GPG key ID: 027DF9338862ADDD
7 changed files with 24 additions and 27 deletions

View file

@ -3261,8 +3261,13 @@ impl<'hir> Node<'hir> {
}
}
/// Returns `Constness::Const` when this node is a const fn/impl/item.
pub fn constness(&self) -> Constness {
/// Returns `Constness::Const` when this node is a const fn/impl/item,
///
/// HACK(fee1-dead): or an associated type in a trait. This works because
/// only typeck cares about const trait predicates, so although the predicates
/// query would return const predicates when it does not need to be const,
/// it wouldn't have any effect.
pub fn constness_for_typeck(&self) -> Constness {
match self {
Node::Item(Item {
kind: ItemKind::Fn(FnSig { header: FnHeader { constness, .. }, .. }, ..),
@ -3280,6 +3285,7 @@ impl<'hir> Node<'hir> {
Node::Item(Item { kind: ItemKind::Const(..), .. })
| Node::TraitItem(TraitItem { kind: TraitItemKind::Const(..), .. })
| Node::TraitItem(TraitItem { kind: TraitItemKind::Type(..), .. })
| Node::ImplItem(ImplItem { kind: ImplItemKind::Const(..), .. }) => Constness::Const,
_ => Constness::NotConst,