mir-borrowck: Move is_static_mut() to ty/utils.rs
This commit is contained in:
parent
8efbf7a4f0
commit
0bb77bdb54
2 changed files with 24 additions and 22 deletions
|
|
@ -10,8 +10,9 @@
|
|||
|
||||
//! misc. type-system utilities too small to deserve their own file
|
||||
|
||||
use hir::def::Def;
|
||||
use hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use hir::map::DefPathData;
|
||||
use hir::map::{DefPathData, Node};
|
||||
use hir;
|
||||
use ich::NodeIdHashingMode;
|
||||
use middle::const_val::ConstVal;
|
||||
|
|
@ -648,6 +649,26 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
_ => bug!(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the node pointed to by def_id is a mutable static item
|
||||
pub fn is_static_mut(&self, def_id: DefId) -> bool {
|
||||
if let Some(node) = self.hir.get_if_local(def_id) {
|
||||
match node {
|
||||
Node::NodeItem(&hir::Item {
|
||||
node: hir::ItemStatic(_, hir::MutMutable, _), ..
|
||||
}) => true,
|
||||
Node::NodeForeignItem(&hir::ForeignItem {
|
||||
node: hir::ForeignItemStatic(_, mutbl), ..
|
||||
}) => mutbl,
|
||||
_ => false
|
||||
}
|
||||
} else {
|
||||
match self.describe_def(def_id) {
|
||||
Some(Def::Static(_, mutbl)) => mutbl,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TypeIdHasher<'a, 'gcx: 'a+'tcx, 'tcx: 'a, W> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue