|
1 | 1 | //! Miscellaneous type-system utilities that are too small to deserve their own modules. |
2 | 2 |
|
3 | | -use crate::hir::def::Def; |
| 3 | +use crate::hir; |
4 | 4 | use crate::hir::def_id::DefId; |
5 | 5 | use crate::hir::map::DefPathData; |
6 | | -use crate::hir::{self, Node}; |
7 | 6 | use crate::mir::interpret::{sign_extend, truncate}; |
8 | 7 | use crate::ich::NodeIdHashingMode; |
9 | 8 | use crate::traits::{self, ObligationCause}; |
@@ -615,32 +614,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { |
615 | 614 |
|
616 | 615 | /// Returns `true` if the node pointed to by `def_id` is a static item, and its mutability. |
617 | 616 | pub fn is_static(&self, def_id: DefId) -> Option<hir::Mutability> { |
618 | | - if let Some(node) = self.hir().get_if_local(def_id) { |
619 | | - match node { |
620 | | - Node::Item(&hir::Item { |
621 | | - node: hir::ItemKind::Static(_, mutbl, _), .. |
622 | | - }) => Some(mutbl), |
623 | | - Node::ForeignItem(&hir::ForeignItem { |
624 | | - node: hir::ForeignItemKind::Static(_, is_mutbl), .. |
625 | | - }) => |
626 | | - Some(if is_mutbl { |
627 | | - hir::Mutability::MutMutable |
628 | | - } else { |
629 | | - hir::Mutability::MutImmutable |
630 | | - }), |
631 | | - _ => None |
632 | | - } |
633 | | - } else { |
634 | | - match self.describe_def(def_id) { |
635 | | - Some(Def::Static(_, is_mutbl)) => |
636 | | - Some(if is_mutbl { |
637 | | - hir::Mutability::MutMutable |
638 | | - } else { |
639 | | - hir::Mutability::MutImmutable |
640 | | - }), |
641 | | - _ => None |
642 | | - } |
643 | | - } |
| 617 | + self.static_mutability(def_id) |
644 | 618 | } |
645 | 619 |
|
646 | 620 | /// Expands the given impl trait type, stopping if the type is recursive. |
|
0 commit comments