Skip to content

Commit

Permalink
librustc: replace unimplemented!() with bug!()
Browse files Browse the repository at this point in the history
  • Loading branch information
ben0x539 committed Mar 31, 2016
1 parent dfd0e93 commit 2fa867a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 69 deletions.
138 changes: 70 additions & 68 deletions src/librustc/middle/cstore.rs
Expand Up @@ -336,121 +336,123 @@ pub struct DummyCrateStore;
#[allow(unused_variables)]
impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
// item info
fn stability(&self, def: DefId) -> Option<attr::Stability> { unimplemented!() }
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { unimplemented!() }
fn visibility(&self, def: DefId) -> hir::Visibility { unimplemented!() }
fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }
fn visibility(&self, def: DefId) -> hir::Visibility { bug!("visibility") }
fn closure_kind(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
-> ty::ClosureKind { unimplemented!() }
-> ty::ClosureKind { bug!("closure_kind") }
fn closure_ty(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
-> ty::ClosureTy<'tcx> { unimplemented!() }
fn item_variances(&self, def: DefId) -> ty::ItemVariances { unimplemented!() }
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { unimplemented!() }
-> ty::ClosureTy<'tcx> { bug!("closure_ty") }
fn item_variances(&self, def: DefId) -> ty::ItemVariances { bug!("item_variances") }
fn repr_attrs(&self, def: DefId) -> Vec<attr::ReprAttr> { bug!("repr_attrs") }
fn item_type(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> ty::TypeScheme<'tcx> { unimplemented!() }
fn relative_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
-> ty::TypeScheme<'tcx> { bug!("item_type") }
fn relative_item_path(&self, def: DefId)
-> Vec<hir_map::PathElem> { bug!("relative_item_path") }
fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>> {
unimplemented!()
bug!("visible_parent_map")
}
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { unimplemented!() }
fn item_name(&self, def: DefId) -> ast::Name { unimplemented!() }
fn extern_item_path(&self, def: DefId) -> Vec<hir_map::PathElem> { bug!("extern_item_path") }
fn item_name(&self, def: DefId) -> ast::Name { bug!("item_name") }
fn item_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx> { unimplemented!() }
-> ty::GenericPredicates<'tcx> { bug!("item_predicates") }
fn item_super_predicates(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx> { unimplemented!() }
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { unimplemented!() }
fn item_symbol(&self, def: DefId) -> String { unimplemented!() }
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
fn trait_def(&self, tcx: &TyCtxt<'tcx>, def: DefId)-> ty::TraitDef<'tcx>
{ unimplemented!() }
{ bug!("trait_def") }
fn adt_def(&self, tcx: &TyCtxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
{ unimplemented!() }
fn method_arg_names(&self, did: DefId) -> Vec<String> { unimplemented!() }
{ bug!("adt_def") }
fn method_arg_names(&self, did: DefId) -> Vec<String> { bug!("method_arg_names") }
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }

// trait info
fn implementations_of_trait(&self, def_id: DefId) -> Vec<DefId> { vec![] }
fn provided_trait_methods(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> Vec<Rc<ty::Method<'tcx>>> { unimplemented!() }
-> Vec<Rc<ty::Method<'tcx>>> { bug!("provided_trait_methods") }
fn trait_item_def_ids(&self, def: DefId)
-> Vec<ty::ImplOrTraitItemId> { unimplemented!() }
-> Vec<ty::ImplOrTraitItemId> { bug!("trait_item_def_ids") }

// impl info
fn impl_items(&self, impl_def_id: DefId) -> Vec<ty::ImplOrTraitItemId>
{ unimplemented!() }
{ bug!("impl_items") }
fn impl_trait_ref(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> Option<ty::TraitRef<'tcx>> { unimplemented!() }
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { unimplemented!() }
-> Option<ty::TraitRef<'tcx>> { bug!("impl_trait_ref") }
fn impl_polarity(&self, def: DefId) -> Option<hir::ImplPolarity> { bug!("impl_polarity") }
fn custom_coerce_unsized_kind(&self, def: DefId)
-> Option<ty::adjustment::CustomCoerceUnsized>
{ unimplemented!() }
{ bug!("custom_coerce_unsized_kind") }
fn associated_consts(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> Vec<Rc<ty::AssociatedConst<'tcx>>> { unimplemented!() }
fn impl_parent(&self, def: DefId) -> Option<DefId> { unimplemented!() }
-> Vec<Rc<ty::AssociatedConst<'tcx>>> { bug!("associated_consts") }
fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }

// trait/impl-item info
fn trait_of_item(&self, tcx: &TyCtxt<'tcx>, def_id: DefId)
-> Option<DefId> { unimplemented!() }
-> Option<DefId> { bug!("trait_of_item") }
fn impl_or_trait_item(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> Option<ty::ImplOrTraitItem<'tcx>> { unimplemented!() }
-> Option<ty::ImplOrTraitItem<'tcx>> { bug!("impl_or_trait_item") }

// flags
fn is_const_fn(&self, did: DefId) -> bool { unimplemented!() }
fn is_defaulted_trait(&self, did: DefId) -> bool { unimplemented!() }
fn is_impl(&self, did: DefId) -> bool { unimplemented!() }
fn is_default_impl(&self, impl_did: DefId) -> bool { unimplemented!() }
fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { unimplemented!() }
fn is_static_method(&self, did: DefId) -> bool { unimplemented!() }
fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
fn is_defaulted_trait(&self, did: DefId) -> bool { bug!("is_defaulted_trait") }
fn is_impl(&self, did: DefId) -> bool { bug!("is_impl") }
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
fn is_extern_item(&self, tcx: &TyCtxt<'tcx>, did: DefId) -> bool { bug!("is_extern_item") }
fn is_static_method(&self, did: DefId) -> bool { bug!("is_static_method") }
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool { false }
fn is_typedef(&self, did: DefId) -> bool { unimplemented!() }
fn is_typedef(&self, did: DefId) -> bool { bug!("is_typedef") }

// crate metadata
fn dylib_dependency_formats(&self, cnum: ast::CrateNum)
-> Vec<(ast::CrateNum, LinkagePreference)>
{ unimplemented!() }
{ bug!("dylib_dependency_formats") }
fn lang_items(&self, cnum: ast::CrateNum) -> Vec<(DefIndex, usize)>
{ unimplemented!() }
{ bug!("lang_items") }
fn missing_lang_items(&self, cnum: ast::CrateNum) -> Vec<lang_items::LangItem>
{ unimplemented!() }
fn is_staged_api(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
fn is_explicitly_linked(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
fn is_allocator(&self, cnum: ast::CrateNum) -> bool { unimplemented!() }
fn extern_crate(&self, cnum: ast::CrateNum) -> Option<ExternCrate> { unimplemented!() }
{ bug!("missing_lang_items") }
fn is_staged_api(&self, cnum: ast::CrateNum) -> bool { bug!("is_staged_api") }
fn is_explicitly_linked(&self, cnum: ast::CrateNum) -> bool { bug!("is_explicitly_linked") }
fn is_allocator(&self, cnum: ast::CrateNum) -> bool { bug!("is_allocator") }
fn extern_crate(&self, cnum: ast::CrateNum) -> Option<ExternCrate> { bug!("extern_crate") }
fn crate_attrs(&self, cnum: ast::CrateNum) -> Vec<ast::Attribute>
{ unimplemented!() }
fn crate_name(&self, cnum: ast::CrateNum) -> InternedString { unimplemented!() }
{ bug!("crate_attrs") }
fn crate_name(&self, cnum: ast::CrateNum) -> InternedString { bug!("crate_name") }
fn original_crate_name(&self, cnum: ast::CrateNum) -> InternedString {
unimplemented!()
bug!("original_crate_name")
}
fn crate_hash(&self, cnum: ast::CrateNum) -> Svh { unimplemented!() }
fn crate_disambiguator(&self, cnum: ast::CrateNum) -> InternedString { unimplemented!() }
fn crate_hash(&self, cnum: ast::CrateNum) -> Svh { bug!("crate_hash") }
fn crate_disambiguator(&self, cnum: ast::CrateNum)
-> InternedString { bug!("crate_disambiguator") }
fn crate_struct_field_attrs(&self, cnum: ast::CrateNum)
-> FnvHashMap<DefId, Vec<ast::Attribute>>
{ unimplemented!() }
{ bug!("crate_struct_field_attrs") }
fn plugin_registrar_fn(&self, cnum: ast::CrateNum) -> Option<DefId>
{ unimplemented!() }
{ bug!("plugin_registrar_fn") }
fn native_libraries(&self, cnum: ast::CrateNum) -> Vec<(NativeLibraryKind, String)>
{ unimplemented!() }
fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec<DefId> { unimplemented!() }
{ bug!("native_libraries") }
fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec<DefId> { bug!("reachable_ids") }

// resolve
fn def_key(&self, def: DefId) -> hir_map::DefKey { unimplemented!() }
fn relative_def_path(&self, def: DefId) -> hir_map::DefPath { unimplemented!() }
fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> { unimplemented!() }
fn def_key(&self, def: DefId) -> hir_map::DefKey { bug!("def_key") }
fn relative_def_path(&self, def: DefId) -> hir_map::DefPath { bug!("relative_def_path") }
fn variant_kind(&self, def_id: DefId) -> Option<VariantKind> { bug!("variant_kind") }
fn struct_ctor_def_id(&self, struct_def_id: DefId) -> Option<DefId>
{ unimplemented!() }
{ bug!("struct_ctor_def_id") }
fn tuple_struct_definition_if_ctor(&self, did: DefId) -> Option<DefId>
{ unimplemented!() }
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { unimplemented!() }
fn item_children(&self, did: DefId) -> Vec<ChildItem> { unimplemented!() }
{ bug!("tuple_struct_definition_if_ctor") }
fn struct_field_names(&self, def: DefId) -> Vec<ast::Name> { bug!("struct_field_names") }
fn item_children(&self, did: DefId) -> Vec<ChildItem> { bug!("item_children") }
fn crate_top_level_items(&self, cnum: ast::CrateNum) -> Vec<ChildItem>
{ unimplemented!() }
{ bug!("crate_top_level_items") }

// misc. metadata
fn maybe_get_item_ast(&'tcx self, tcx: &TyCtxt<'tcx>, def: DefId)
-> FoundAst<'tcx> { unimplemented!() }
-> FoundAst<'tcx> { bug!("maybe_get_item_ast") }
fn maybe_get_item_mir(&self, tcx: &TyCtxt<'tcx>, def: DefId)
-> Option<Mir<'tcx>> { unimplemented!() }
-> Option<Mir<'tcx>> { bug!("maybe_get_item_mir") }
fn is_item_mir_available(&self, def: DefId) -> bool {
unimplemented!()
bug!("is_item_mir_available")
}

// This is basically a 1-based range of ints, which is a little
Expand All @@ -460,18 +462,18 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn used_link_args(&self) -> Vec<String> { vec![] }

// utility functions
fn metadata_filename(&self) -> &str { unimplemented!() }
fn metadata_section_name(&self, target: &Target) -> &str { unimplemented!() }
fn metadata_filename(&self) -> &str { bug!("metadata_filename") }
fn metadata_section_name(&self, target: &Target) -> &str { bug!("metadata_section_name") }
fn encode_type(&self,
tcx: &TyCtxt<'tcx>,
ty: Ty<'tcx>,
def_id_to_string: fn(&TyCtxt<'tcx>, DefId) -> String)
-> Vec<u8> {
unimplemented!()
bug!("encode_type")
}
fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<PathBuf>)>
{ vec![] }
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource { unimplemented!() }
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource { bug!("used_crate_source") }
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
fn encode_metadata(&self,
tcx: &TyCtxt<'tcx>,
Expand All @@ -481,7 +483,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
reachable: &NodeSet,
mir_map: &MirMap<'tcx>,
krate: &hir::Crate) -> Vec<u8> { vec![] }
fn metadata_encoding_version(&self) -> &[u8] { unimplemented!() }
fn metadata_encoding_version(&self) -> &[u8] { bug!("metadata_encoding_version") }
}


Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/resolve_lifetime.rs
Expand Up @@ -822,7 +822,7 @@ fn early_bound_lifetime_names(generics: &hir::Generics) -> Vec<ast::Name> {
collector.visit_lifetime(bound);
}
}
&hir::WherePredicate::EqPredicate(_) => unimplemented!()
&hir::WherePredicate::EqPredicate(_) => bug!("unimplemented")
}
}
}
Expand Down

0 comments on commit 2fa867a

Please sign in to comment.