fix RUST_LOG ICE caused by printing a default impl's DefId
This commit is contained in:
parent
7b295eea42
commit
55767702ec
9 changed files with 24 additions and 15 deletions
|
|
@ -245,7 +245,6 @@ pub trait CrateStore {
|
|||
|
||||
// flags
|
||||
fn is_const_fn(&self, did: DefId) -> bool;
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool;
|
||||
fn is_dllimport_foreign_item(&self, def: DefId) -> bool;
|
||||
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
|
||||
|
||||
|
|
@ -364,7 +363,6 @@ impl CrateStore for DummyCrateStore {
|
|||
|
||||
// flags
|
||||
fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
|
||||
fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false }
|
||||
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
// Always use types for non-local impls, where types are always
|
||||
// available, and filename/line-number is mostly uninteresting.
|
||||
let use_types = !impl_def_id.is_local() || {
|
||||
let use_types = !self.is_default_impl(impl_def_id) && (!impl_def_id.is_local() || {
|
||||
// Otherwise, use filename/line-number if forced.
|
||||
let force_no_types = FORCE_IMPL_FILENAME_LINE.with(|f| f.get());
|
||||
!force_no_types && {
|
||||
|
|
@ -226,7 +226,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::queries::impl_trait_ref::try_get(self, DUMMY_SP, impl_def_id).is_ok() &&
|
||||
ty::queries::type_of::try_get(self, DUMMY_SP, impl_def_id).is_ok()
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
if !use_types {
|
||||
return self.push_impl_path_fallback(buffer, impl_def_id);
|
||||
|
|
|
|||
|
|
@ -774,6 +774,9 @@ define_maps! { <'tcx>
|
|||
/// True if this is a foreign item (i.e., linked via `extern { ... }`).
|
||||
[] is_foreign_item: IsForeignItem(DefId) -> bool,
|
||||
|
||||
/// True if this is a default impl (aka impl Foo for ..)
|
||||
[] is_default_impl: ItemSignature(DefId) -> bool,
|
||||
|
||||
/// Get a map with the variance of every item; use `item_variance`
|
||||
/// instead.
|
||||
[] crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ pub fn borrowck_mir(bcx: &mut BorrowckCtxt,
|
|||
attributes: &[ast::Attribute]) {
|
||||
let tcx = bcx.tcx;
|
||||
let def_id = tcx.hir.local_def_id(id);
|
||||
debug!("borrowck_mir({}) UNIMPLEMENTED", tcx.item_path_str(def_id));
|
||||
debug!("borrowck_mir({:?}) UNIMPLEMENTED", def_id);
|
||||
|
||||
// It is safe for us to borrow `mir_validated()`: `optimized_mir`
|
||||
// steals it, but it forces the `borrowck` query.
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ provide! { <'tcx> tcx, def_id, cdata
|
|||
closure_type => { cdata.closure_ty(def_id.index, tcx) }
|
||||
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
|
||||
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
|
||||
is_default_impl => { cdata.is_default_impl(def_id.index) }
|
||||
describe_def => { cdata.get_def(def_id.index) }
|
||||
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
|
||||
stability => { cdata.get_stability(def_id.index) }
|
||||
|
|
@ -176,11 +177,6 @@ impl CrateStore for cstore::CStore {
|
|||
self.get_crate_data(did.krate).is_const_fn(did.index)
|
||||
}
|
||||
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool {
|
||||
self.dep_graph.read(DepNode::MetaData(impl_did));
|
||||
self.get_crate_data(impl_did.krate).is_default_impl(impl_did.index)
|
||||
}
|
||||
|
||||
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool
|
||||
{
|
||||
self.do_is_statically_included_foreign_item(def_id)
|
||||
|
|
@ -403,7 +399,7 @@ impl CrateStore for cstore::CStore {
|
|||
}
|
||||
|
||||
self.dep_graph.read(DepNode::MetaData(def_id));
|
||||
debug!("item_body({}): inlining item", tcx.item_path_str(def_id));
|
||||
debug!("item_body({:?}): inlining item", def_id);
|
||||
|
||||
self.get_crate_data(def_id.krate).item_body(tcx, def_id.index)
|
||||
}
|
||||
|
|
@ -515,4 +511,4 @@ impl CrateStore for cstore::CStore {
|
|||
drop(visible_parent_map);
|
||||
self.visible_parent_map.borrow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
|
|||
|
||||
/// Qualify a whole const, static initializer or const fn.
|
||||
fn qualify_const(&mut self) -> Qualif {
|
||||
debug!("qualifying {} {}", self.mode, self.tcx.item_path_str(self.def_id));
|
||||
debug!("qualifying {} {:?}", self.mode, self.def_id);
|
||||
|
||||
let mir = self.mir;
|
||||
|
||||
|
|
|
|||
|
|
@ -744,7 +744,7 @@ impl MirPass for TypeckMir {
|
|||
mir: &mut Mir<'tcx>) {
|
||||
let item_id = src.item_id();
|
||||
let def_id = tcx.hir.local_def_id(item_id);
|
||||
debug!("run_pass: {}", tcx.item_path_str(def_id));
|
||||
debug!("run_pass: {:?}", def_id);
|
||||
|
||||
if tcx.sess.err_count() > 0 {
|
||||
// compiling a broken program can obviously result in a
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
impl_trait_ref,
|
||||
impl_polarity,
|
||||
is_foreign_item,
|
||||
is_default_impl,
|
||||
..*providers
|
||||
};
|
||||
}
|
||||
|
|
@ -1545,3 +1546,14 @@ fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
_ => bug!("is_foreign_item applied to non-local def-id {:?}", def_id)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_default_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
def_id: DefId)
|
||||
-> bool {
|
||||
match tcx.hir.get_if_local(def_id) {
|
||||
Some(hir_map::NodeItem(&hir::Item { node: hir::ItemDefaultImpl(..), .. }))
|
||||
=> true,
|
||||
Some(_) => false,
|
||||
_ => bug!("is_default_impl applied to non-local def-id {:?}", def_id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
|||
}
|
||||
|
||||
// If this is a defaulted impl, then bail out early here
|
||||
if tcx.sess.cstore.is_default_impl(did) {
|
||||
if tcx.is_default_impl(did) {
|
||||
return ret.push(clean::Item {
|
||||
inner: clean::DefaultImplItem(clean::DefaultImpl {
|
||||
// FIXME: this should be decoded
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue