mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 13:33:43 +00:00
convert to use is_local
instead of == LOCAL_CRATE
This commit is contained in:
parent
e91bef2e05
commit
c0de23de81
@ -14,7 +14,7 @@ use self::MapEntry::*;
|
||||
|
||||
use metadata::inline::InlinedItem;
|
||||
use metadata::inline::InlinedItem as II;
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use syntax::abi;
|
||||
use syntax::ast::*;
|
||||
use syntax::ast_util;
|
||||
@ -592,7 +592,7 @@ impl<'ast> Map<'ast> {
|
||||
}
|
||||
|
||||
pub fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span {
|
||||
if def_id.krate == LOCAL_CRATE {
|
||||
if def_id.is_local() {
|
||||
self.opt_span(def_id.node).unwrap_or(fallback)
|
||||
} else {
|
||||
fallback
|
||||
|
@ -1260,7 +1260,7 @@ pub fn list_crate_metadata(bytes: &[u8], out: &mut io::Write) -> io::Result<()>
|
||||
// then we must translate the crate number from that encoded in the external
|
||||
// crate to the correct local crate number.
|
||||
pub fn translate_def_id(cdata: Cmd, did: DefId) -> DefId {
|
||||
if did.krate == LOCAL_CRATE {
|
||||
if did.is_local() {
|
||||
return DefId { krate: cdata.cnum, node: did.node };
|
||||
}
|
||||
|
||||
|
@ -1781,7 +1781,7 @@ fn encode_lang_items(ecx: &EncodeContext, rbml_w: &mut Encoder) {
|
||||
|
||||
for (i, &def_id) in ecx.tcx.lang_items.items() {
|
||||
if let Some(id) = def_id {
|
||||
if id.krate == LOCAL_CRATE {
|
||||
if id.is_local() {
|
||||
rbml_w.start_tag(tag_lang_items_item);
|
||||
rbml_w.wr_tagged_u32(tag_lang_items_item_id, i as u32);
|
||||
rbml_w.wr_tagged_u32(tag_lang_items_item_node_id, id.node as u32);
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
use middle::def::DefFn;
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::subst::{Subst, Substs, EnumeratedItems};
|
||||
use middle::ty::{TransmuteRestriction, ctxt, TyBareFn};
|
||||
use middle::ty::{self, Ty, HasTypeFlags};
|
||||
|
@ -203,7 +203,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
// Check the impl. If the generics on the self
|
||||
// type of the impl require inlining, this method
|
||||
// does too.
|
||||
assert!(impl_did.krate == LOCAL_CRATE);
|
||||
assert!(impl_did.is_local());
|
||||
match self.tcx
|
||||
.map
|
||||
.expect_item(impl_did.node)
|
||||
@ -356,7 +356,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
// reachability, which might result in a compile time loss.
|
||||
fn mark_destructors_reachable(&mut self) {
|
||||
for (_, destructor_def_id) in self.tcx.destructor_for_type.borrow().iter() {
|
||||
if destructor_def_id.krate == LOCAL_CRATE {
|
||||
if destructor_def_id.is_local() {
|
||||
self.reachable_symbols.insert(destructor_def_id.node);
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
debug!("orphan_check: trait_ref={:?}", trait_ref);
|
||||
|
||||
// If the *trait* is local to the crate, ok.
|
||||
if trait_ref.def_id.krate == LOCAL_CRATE {
|
||||
if trait_ref.def_id.is_local() {
|
||||
debug!("trait {:?} is local to current crate",
|
||||
trait_ref.def_id);
|
||||
return Ok(());
|
||||
@ -318,7 +318,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
|
||||
ty::TyEnum(def, _) |
|
||||
ty::TyStruct(def, _) => {
|
||||
def.did.krate == LOCAL_CRATE
|
||||
def.did.is_local()
|
||||
}
|
||||
|
||||
ty::TyBox(_) => { // Box<T>
|
||||
@ -327,7 +327,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
}
|
||||
|
||||
ty::TyTrait(ref tt) => {
|
||||
tt.principal_def_id().krate == LOCAL_CRATE
|
||||
tt.principal_def_id().is_local()
|
||||
}
|
||||
|
||||
ty::TyClosure(..) |
|
||||
|
@ -5468,7 +5468,7 @@ fn lookup_locally_or_in_crate_store<V, F>(descr: &str,
|
||||
None => { }
|
||||
}
|
||||
|
||||
if def_id.krate == LOCAL_CRATE {
|
||||
if def_id.is_local() {
|
||||
panic!("No def'n found for {:?} in tcx.{}", def_id, descr);
|
||||
}
|
||||
let v = load_external();
|
||||
@ -5776,7 +5776,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
expected.ty,
|
||||
found.ty));
|
||||
|
||||
match (expected.def_id.krate == LOCAL_CRATE,
|
||||
match (expected.def_id.is_local(),
|
||||
self.map.opt_span(expected.def_id.node)) {
|
||||
(true, Some(span)) => {
|
||||
self.sess.span_note(span,
|
||||
@ -5793,7 +5793,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
expected.origin_span,
|
||||
&format!("...that was applied to an unconstrained type variable here"));
|
||||
|
||||
match (found.def_id.krate == LOCAL_CRATE,
|
||||
match (found.def_id.is_local(),
|
||||
self.map.opt_span(found.def_id.node)) {
|
||||
(true, Some(span)) => {
|
||||
self.sess.span_note(span,
|
||||
@ -5905,7 +5905,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn trait_impl_polarity(&self, id: DefId) -> Option<ast::ImplPolarity> {
|
||||
if id.krate == LOCAL_CRATE {
|
||||
if id.is_local() {
|
||||
match self.map.find(id.node) {
|
||||
Some(ast_map::NodeItem(item)) => {
|
||||
match item.node {
|
||||
@ -5961,7 +5961,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
|
||||
/// Returns whether this DefId refers to an impl
|
||||
pub fn is_impl(&self, id: DefId) -> bool {
|
||||
if id.krate == LOCAL_CRATE {
|
||||
if id.is_local() {
|
||||
if let Some(ast_map::NodeItem(
|
||||
&ast::Item { node: ast::ItemImpl(..), .. })) = self.map.find(id.node) {
|
||||
true
|
||||
@ -6012,7 +6012,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
pub fn with_path<T, F>(&self, id: DefId, f: F) -> T where
|
||||
F: FnOnce(ast_map::PathElems) -> T,
|
||||
{
|
||||
if id.krate == LOCAL_CRATE {
|
||||
if id.is_local() {
|
||||
self.map.with_path(id.node, f)
|
||||
} else {
|
||||
f(csearch::get_item_path(self, id).iter().cloned().chain(LinkedPath::empty()))
|
||||
@ -6135,7 +6135,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
/// Obtain the representation annotation for a struct definition.
|
||||
pub fn lookup_repr_hints(&self, did: DefId) -> Rc<Vec<attr::ReprAttr>> {
|
||||
memoized(&self.repr_hint_cache, did, |did: DefId| {
|
||||
Rc::new(if did.krate == LOCAL_CRATE {
|
||||
Rc::new(if did.is_local() {
|
||||
self.get_attrs(did).iter().flat_map(|meta| {
|
||||
attr::find_repr_attrs(self.sess.diagnostic(), meta).into_iter()
|
||||
}).collect()
|
||||
@ -6315,7 +6315,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
/// Load primitive inherent implementations if necessary
|
||||
pub fn populate_implementations_for_primitive_if_necessary(&self,
|
||||
primitive_def_id: DefId) {
|
||||
if primitive_def_id.krate == LOCAL_CRATE {
|
||||
if primitive_def_id.is_local() {
|
||||
return
|
||||
}
|
||||
|
||||
@ -6337,7 +6337,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
/// the given type if necessary.
|
||||
pub fn populate_inherent_implementations_for_type_if_necessary(&self,
|
||||
type_id: DefId) {
|
||||
if type_id.krate == LOCAL_CRATE {
|
||||
if type_id.is_local() {
|
||||
return
|
||||
}
|
||||
|
||||
@ -6365,7 +6365,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
/// Populates the type context with all the implementations for the given
|
||||
/// trait if necessary.
|
||||
pub fn populate_implementations_for_trait_if_necessary(&self, trait_id: DefId) {
|
||||
if trait_id.krate == LOCAL_CRATE {
|
||||
if trait_id.is_local() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::subst::{self, Subst};
|
||||
use middle::ty::{BoundRegion, BrAnon, BrNamed};
|
||||
use middle::ty::{ReEarlyBound, BrFresh, ctxt};
|
||||
@ -659,7 +659,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
|
||||
TyParam(ref param_ty) => write!(f, "{}", param_ty),
|
||||
TyEnum(def, substs) | TyStruct(def, substs) => {
|
||||
ty::tls::with(|tcx| {
|
||||
if def.did.krate == LOCAL_CRATE &&
|
||||
if def.did.is_local() &&
|
||||
!tcx.tcache.borrow().contains_key(&def.did) {
|
||||
write!(f, "{}<..>", tcx.item_path_str(def.did))
|
||||
} else {
|
||||
@ -674,7 +674,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> {
|
||||
TyClosure(ref did, ref substs) => ty::tls::with(|tcx| {
|
||||
try!(write!(f, "[closure"));
|
||||
|
||||
if did.krate == LOCAL_CRATE {
|
||||
if did.is_local() {
|
||||
try!(write!(f, "@{:?}", tcx.map.span(did.node)));
|
||||
let mut sep = " ";
|
||||
try!(tcx.with_freevars(did.node, |freevars| {
|
||||
|
@ -27,7 +27,7 @@ use rustc::middle::dataflow::DataFlowContext;
|
||||
use rustc::middle::dataflow::BitwiseOperator;
|
||||
use rustc::middle::dataflow::DataFlowOperator;
|
||||
use rustc::middle::dataflow::KillFrom;
|
||||
use rustc::middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc::middle::def_id::DefId;
|
||||
use rustc::middle::expr_use_visitor as euv;
|
||||
use rustc::middle::free_region::FreeRegionMap;
|
||||
use rustc::middle::mem_categorization as mc;
|
||||
@ -1193,7 +1193,7 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
|
||||
}
|
||||
|
||||
LpDowncast(ref lp, variant_def_id) => {
|
||||
let variant_str = if variant_def_id.krate == LOCAL_CRATE {
|
||||
let variant_str = if variant_def_id.is_local() {
|
||||
ty::tls::with(|tcx| tcx.item_path_str(variant_def_id))
|
||||
} else {
|
||||
format!("{:?}", variant_def_id)
|
||||
@ -1225,7 +1225,7 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> {
|
||||
}
|
||||
|
||||
LpDowncast(ref lp, variant_def_id) => {
|
||||
let variant_str = if variant_def_id.krate == LOCAL_CRATE {
|
||||
let variant_str = if variant_def_id.is_local() {
|
||||
ty::tls::with(|tcx| tcx.item_path_str(variant_def_id))
|
||||
} else {
|
||||
format!("{:?}", variant_def_id)
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
use metadata::{csearch, decoder};
|
||||
use middle::{cfg, def, infer, pat_util, stability, traits};
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::subst::Substs;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::const_eval::{eval_const_expr_partial, ConstVal};
|
||||
@ -2029,7 +2029,7 @@ impl LintPass for MissingDebugImplementations {
|
||||
let debug_def = cx.tcx.lookup_trait_def(debug);
|
||||
let mut impls = NodeSet();
|
||||
debug_def.for_each_impl(cx.tcx, |d| {
|
||||
if d.krate == LOCAL_CRATE {
|
||||
if d.is_local() {
|
||||
if let Some(ty_def) = cx.tcx.node_id_to_type(d.node).ty_to_def_id() {
|
||||
impls.insert(ty_def.node);
|
||||
}
|
||||
@ -2569,7 +2569,7 @@ impl LintPass for DropWithReprExtern {
|
||||
fn check_crate(&mut self, ctx: &Context, _: &ast::Crate) {
|
||||
for dtor_did in ctx.tcx.destructors.borrow().iter() {
|
||||
let (drop_impl_did, dtor_self_type) =
|
||||
if dtor_did.krate == LOCAL_CRATE {
|
||||
if dtor_did.is_local() {
|
||||
let impl_did = ctx.tcx.map.get_parent_did(dtor_did.node);
|
||||
let ty = ctx.tcx.lookup_item_type(impl_did).ty;
|
||||
(impl_did, ty)
|
||||
|
@ -56,7 +56,7 @@ use rustc::lint;
|
||||
use rustc::metadata::csearch;
|
||||
use rustc::metadata::decoder::{DefLike, DlDef, DlField, DlImpl};
|
||||
use rustc::middle::def::*;
|
||||
use rustc::middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc::middle::def_id::DefId;
|
||||
use rustc::middle::pat_util::pat_bindings;
|
||||
use rustc::middle::privacy::*;
|
||||
use rustc::middle::subst::{ParamSpace, FnSpace, TypeSpace};
|
||||
@ -1256,7 +1256,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn get_trait_name(&self, did: DefId) -> Name {
|
||||
if did.krate == LOCAL_CRATE {
|
||||
if did.is_local() {
|
||||
self.ast_map.expect_item(did.node).ident.name
|
||||
} else {
|
||||
csearch::get_trait_name(&self.session.cstore, did)
|
||||
@ -3467,7 +3467,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn is_static_method(this: &Resolver, did: DefId) -> bool {
|
||||
if did.krate == LOCAL_CRATE {
|
||||
if did.is_local() {
|
||||
let sig = match this.ast_map.get(did.node) {
|
||||
ast_map::NodeTraitItem(trait_item) => match trait_item.node {
|
||||
ast::MethodTraitItem(ref sig, _) => sig,
|
||||
|
@ -25,7 +25,6 @@ use build_reduced_graph;
|
||||
use module_to_string;
|
||||
|
||||
use rustc::middle::def::Export;
|
||||
use rustc::middle::def_id::LOCAL_CRATE;
|
||||
use syntax::ast;
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
@ -57,7 +56,7 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
|
||||
// exports for nonlocal crates.
|
||||
|
||||
match module_.def_id.get() {
|
||||
Some(def_id) if def_id.krate == LOCAL_CRATE => {
|
||||
Some(def_id) if def_id.is_local() => {
|
||||
// OK. Continue.
|
||||
debug!("(recording exports for module subtree) recording \
|
||||
exports for local module `{}`",
|
||||
|
@ -546,7 +546,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
}
|
||||
def::DefMethod(decl_id) => {
|
||||
let sub_span = self.span_utils.sub_span_for_meth_name(path.span);
|
||||
let def_id = if decl_id.krate == LOCAL_CRATE {
|
||||
let def_id = if decl_id.is_local() {
|
||||
let ti = self.tcx.impl_or_trait_item(decl_id);
|
||||
match ti.container() {
|
||||
ty::TraitContainer(def_id) => {
|
||||
|
@ -2247,7 +2247,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
|
||||
Ok(id) => id,
|
||||
Err(s) => { ccx.sess().fatal(&s[..]); }
|
||||
};
|
||||
let start_fn = if start_def_id.krate == LOCAL_CRATE {
|
||||
let start_fn = if start_def_id.is_local() {
|
||||
get_item_val(ccx, start_def_id.node)
|
||||
} else {
|
||||
let start_fn_type = csearch::get_type(ccx.tcx(),
|
||||
|
@ -464,7 +464,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
|
||||
// or is a named tuple constructor.
|
||||
let must_monomorphise = if !substs.types.is_empty() || is_default {
|
||||
true
|
||||
} else if def_id.krate == LOCAL_CRATE {
|
||||
} else if def_id.is_local() {
|
||||
let map_node = session::expect(
|
||||
ccx.sess(),
|
||||
tcx.map.find(def_id.node),
|
||||
@ -524,7 +524,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
|
||||
|
||||
// Find the actual function pointer.
|
||||
let mut val = {
|
||||
if def_id.krate == LOCAL_CRATE {
|
||||
if def_id.is_local() {
|
||||
// Internal reference.
|
||||
get_item_val(ccx, def_id.node)
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ use super::{declare_local, VariableKind, VariableAccess};
|
||||
use llvm::{self, ValueRef};
|
||||
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType};
|
||||
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::pat_util;
|
||||
use middle::subst::{self, Substs};
|
||||
use rustc::ast_map;
|
||||
@ -322,7 +322,7 @@ impl<'tcx> TypeMap<'tcx> {
|
||||
output: &mut String) {
|
||||
// First, find out the 'real' def_id of the type. Items inlined from
|
||||
// other crates have to be mapped back to their source.
|
||||
let source_def_id = if def_id.krate == LOCAL_CRATE {
|
||||
let source_def_id = if def_id.is_local() {
|
||||
match cx.external_srcs().borrow().get(&def_id.node).cloned() {
|
||||
Some(source_def_id) => {
|
||||
// The given def_id identifies the inlined copy of a
|
||||
@ -336,7 +336,7 @@ impl<'tcx> TypeMap<'tcx> {
|
||||
};
|
||||
|
||||
// Get the crate hash as first part of the identifier.
|
||||
let crate_hash = if source_def_id.krate == LOCAL_CRATE {
|
||||
let crate_hash = if source_def_id.is_local() {
|
||||
cx.link_meta().crate_hash.clone()
|
||||
} else {
|
||||
cx.sess().cstore.get_crate_hash(source_def_id.krate)
|
||||
|
@ -15,7 +15,7 @@ use super::utils::{DIB, debug_context};
|
||||
use llvm;
|
||||
use llvm::debuginfo::DIScope;
|
||||
use rustc::ast_map;
|
||||
use rustc::middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc::middle::def_id::DefId;
|
||||
use trans::common::CrateContext;
|
||||
|
||||
use std::ffi::CString;
|
||||
@ -58,7 +58,7 @@ pub fn crate_root_namespace<'a>(cx: &'a CrateContext) -> &'a str {
|
||||
pub fn namespace_for_item(cx: &CrateContext, def_id: DefId) -> Rc<NamespaceTreeNode> {
|
||||
cx.tcx().with_path(def_id, |path| {
|
||||
// prepend crate name if not already present
|
||||
let krate = if def_id.krate == LOCAL_CRATE {
|
||||
let krate = if def_id.is_local() {
|
||||
let crate_namespace_name = token::intern(crate_root_namespace(cx));
|
||||
Some(ast_map::PathMod(crate_namespace_name))
|
||||
} else {
|
||||
|
@ -13,7 +13,7 @@
|
||||
use super::namespace::crate_root_namespace;
|
||||
|
||||
use trans::common::CrateContext;
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::subst::{self, Substs};
|
||||
use middle::ty::{self, Ty};
|
||||
|
||||
@ -172,7 +172,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
output: &mut String) {
|
||||
cx.tcx().with_path(def_id, |path| {
|
||||
if qualified {
|
||||
if def_id.krate == LOCAL_CRATE {
|
||||
if def_id.is_local() {
|
||||
output.push_str(crate_root_namespace(cx));
|
||||
output.push_str("::");
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
use super::{FunctionDebugContext, CrateDebugContext};
|
||||
use super::namespace::namespace_for_item;
|
||||
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
|
||||
use llvm;
|
||||
use llvm::debuginfo::{DIScope, DIBuilderRef, DIDescriptor, DIArray};
|
||||
@ -99,7 +99,7 @@ pub fn assert_type_for_node_id(cx: &CrateContext,
|
||||
pub fn get_namespace_and_span_for_item(cx: &CrateContext, def_id: DefId)
|
||||
-> (DIScope, Span) {
|
||||
let containing_scope = namespace_for_item(cx, def_id).scope;
|
||||
let definition_span = if def_id.krate == LOCAL_CRATE {
|
||||
let definition_span = if def_id.is_local() {
|
||||
cx.tcx().map.span(def_id.node)
|
||||
} else {
|
||||
// For external items there is no span information
|
||||
|
@ -55,7 +55,6 @@ use back::abi;
|
||||
use llvm::{self, ValueRef, TypeKind};
|
||||
use middle::check_const;
|
||||
use middle::def;
|
||||
use middle::def_id::{LOCAL_CRATE};
|
||||
use middle::lang_items::CoerceUnsizedTraitLangItem;
|
||||
use middle::subst::{Substs, VecPerParamSpace};
|
||||
use middle::traits;
|
||||
@ -901,7 +900,7 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let const_ty = expr_ty(bcx, ref_expr);
|
||||
|
||||
// For external constants, we don't inline.
|
||||
let val = if did.krate == LOCAL_CRATE {
|
||||
let val = if did.is_local() {
|
||||
// Case 1.
|
||||
|
||||
// The LLVM global has the type of its initializer,
|
||||
|
@ -340,7 +340,7 @@ pub fn get_res_dtor<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let (val, _, _) = monomorphize::monomorphic_fn(ccx, did, substs, None);
|
||||
|
||||
val
|
||||
} else if did.krate == LOCAL_CRATE {
|
||||
} else if did.is_local() {
|
||||
get_item_val(ccx, did.node)
|
||||
} else {
|
||||
let tcx = ccx.tcx();
|
||||
|
@ -12,7 +12,7 @@ use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage};
|
||||
use metadata::csearch;
|
||||
use metadata::inline::InlinedItem;
|
||||
use middle::astencode;
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::subst::Substs;
|
||||
use trans::base::{push_ctxt, trans_item, get_item_val, trans_fn};
|
||||
use trans::common::*;
|
||||
@ -189,7 +189,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId)
|
||||
|
||||
pub fn get_local_instance(ccx: &CrateContext, fn_id: DefId)
|
||||
-> Option<DefId> {
|
||||
if fn_id.krate == LOCAL_CRATE {
|
||||
if fn_id.is_local() {
|
||||
Some(fn_id)
|
||||
} else {
|
||||
instantiate_inline(ccx, fn_id)
|
||||
|
@ -12,7 +12,7 @@ use arena::TypedArena;
|
||||
use back::abi;
|
||||
use back::link;
|
||||
use llvm::{ValueRef, get_params};
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::subst::{Subst, Substs};
|
||||
use middle::subst::VecPerParamSpace;
|
||||
use middle::subst;
|
||||
|
@ -1276,7 +1276,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
|
||||
let trait_did = bound.0.def_id;
|
||||
let ty = this.projected_ty_from_poly_trait_ref(span, bound, assoc_name);
|
||||
|
||||
let item_did = if trait_did.krate == LOCAL_CRATE {
|
||||
let item_did = if trait_did.is_local() {
|
||||
// `ty::trait_items` used below requires information generated
|
||||
// by type collection, which may be in progress at this point.
|
||||
match tcx.map.expect_item(trait_did.node).node {
|
||||
|
@ -427,7 +427,7 @@ pub fn check_item_bodies(ccx: &CrateCtxt) {
|
||||
|
||||
pub fn check_drop_impls(ccx: &CrateCtxt) {
|
||||
for drop_method_did in ccx.tcx.destructors.borrow().iter() {
|
||||
if drop_method_did.krate == LOCAL_CRATE {
|
||||
if drop_method_did.is_local() {
|
||||
let drop_impl_did = ccx.tcx.map.get_parent_did(drop_method_did.node);
|
||||
match dropck::check_drop_impl(ccx.tcx, drop_impl_did) {
|
||||
Ok(()) => {}
|
||||
|
@ -15,7 +15,7 @@ use self::ResolveReason::*;
|
||||
|
||||
use astconv::AstConv;
|
||||
use check::FnCtxt;
|
||||
use middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use middle::def_id::DefId;
|
||||
use middle::pat_util;
|
||||
use middle::ty::{self, Ty, MethodCall, MethodCallee};
|
||||
use middle::ty_fold::{TypeFolder,TypeFoldable};
|
||||
@ -351,7 +351,7 @@ impl ResolveReason {
|
||||
tcx.expr_span(upvar_id.closure_expr_id)
|
||||
}
|
||||
ResolvingClosure(did) => {
|
||||
if did.krate == LOCAL_CRATE {
|
||||
if did.is_local() {
|
||||
tcx.expr_span(did.node)
|
||||
} else {
|
||||
DUMMY_SP
|
||||
|
@ -320,7 +320,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
||||
}
|
||||
_ => {
|
||||
// Destructors only work on nominal types.
|
||||
if impl_did.krate == LOCAL_CRATE {
|
||||
if impl_did.is_local() {
|
||||
{
|
||||
match tcx.map.find(impl_did.node) {
|
||||
Some(ast_map::NodeItem(item)) => {
|
||||
|
@ -295,7 +295,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
|
||||
// can't do `unsafe impl Send for Rc<SomethingLocal>` or
|
||||
// `impl !Send for Box<SomethingLocalAndSend>`.
|
||||
Some(self_def_id) => {
|
||||
if self_def_id.krate == LOCAL_CRATE {
|
||||
if self_def_id.is_local() {
|
||||
None
|
||||
} else {
|
||||
Some(format!(
|
||||
|
@ -150,7 +150,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
||||
|
||||
fn report_overlap_note(&self, impl1: DefId, impl2: DefId) {
|
||||
|
||||
if impl2.krate == LOCAL_CRATE {
|
||||
if impl2.is_local() {
|
||||
span_note!(self.tcx.sess, self.span_of_impl(impl2),
|
||||
"note conflicting implementation here");
|
||||
} else {
|
||||
|
@ -400,7 +400,7 @@ impl<'a, 'tcx> AstConv<'tcx> for ItemCtxt<'a, 'tcx> {
|
||||
assoc_name: ast::Name)
|
||||
-> bool
|
||||
{
|
||||
if trait_def_id.krate == LOCAL_CRATE {
|
||||
if trait_def_id.is_local() {
|
||||
trait_defines_associated_type_named(self.ccx, trait_def_id.node, assoc_name)
|
||||
} else {
|
||||
let trait_def = self.tcx().lookup_trait_def(trait_def_id);
|
||||
|
@ -404,7 +404,7 @@ fn lang_items(tcx: &ty::ctxt) -> Vec<(ast::NodeId,Vec<ty::Variance>)> {
|
||||
|
||||
all.into_iter()
|
||||
.filter(|&(ref d,_)| d.is_some())
|
||||
.filter(|&(ref d,_)| d.as_ref().unwrap().krate == LOCAL_CRATE)
|
||||
.filter(|&(ref d,_)| d.as_ref().unwrap().is_local())
|
||||
.map(|(d, v)| (d.unwrap().node, v))
|
||||
.collect()
|
||||
}
|
||||
@ -740,7 +740,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
-> VarianceTermPtr<'a> {
|
||||
assert_eq!(param_def_id.krate, item_def_id.krate);
|
||||
|
||||
if param_def_id.krate == LOCAL_CRATE {
|
||||
if param_def_id.is_local() {
|
||||
// Parameter on an item defined within current crate:
|
||||
// variance not yet inferred, so return a symbolic
|
||||
// variance.
|
||||
|
Loading…
Reference in New Issue
Block a user