Auto merge of #108301 - Dylan-DPC:rollup-70zpkt0, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #108000 (lint: don't suggest MaybeUninit::assume_init for uninhabited types) - #108105 (Explain the default panic hook better) - #108141 (Add rpitit queries) - #108272 (docs: wrong naming convention in struct keyword doc) - #108285 (remove unstable `pick_stable_methods_before_any_unstable` flag) - #108289 (Name placeholder in some region errors) - #108290 (Add a test for default trait method with RPITITs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
bda32a4023
27 changed files with 429 additions and 323 deletions
|
@ -849,6 +849,13 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_fn_output(self, def_id: LocalDefId) -> Option<&'hir FnRetTy<'hir>> {
|
||||
match self.tcx.hir_owner(OwnerId { def_id }) {
|
||||
Some(Owner { node, .. }) => node.fn_decl().map(|fn_decl| &fn_decl.output),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_variant(self, id: HirId) -> &'hir Variant<'hir> {
|
||||
match self.find(id) {
|
||||
Some(Node::Variant(variant)) => variant,
|
||||
|
|
|
@ -121,13 +121,13 @@ pub fn provide(providers: &mut Providers) {
|
|||
let node = owner.node();
|
||||
Some(Owner { node, hash_without_bodies: owner.nodes.hash_without_bodies })
|
||||
};
|
||||
providers.local_def_id_to_hir_id = |tcx, id| {
|
||||
providers.opt_local_def_id_to_hir_id = |tcx, id| {
|
||||
let owner = tcx.hir_crate(()).owners[id].map(|_| ());
|
||||
match owner {
|
||||
Some(match owner {
|
||||
MaybeOwner::Owner(_) => HirId::make_owner(id),
|
||||
MaybeOwner::Phantom => bug!("No HirId for {:?}", id),
|
||||
MaybeOwner::NonOwner(hir_id) => hir_id,
|
||||
}
|
||||
})
|
||||
};
|
||||
providers.hir_owner_nodes = |tcx, id| tcx.hir_crate(()).owners[id.def_id].map(|i| &i.nodes);
|
||||
providers.hir_owner_parent = |tcx, id| {
|
||||
|
|
|
@ -85,11 +85,10 @@ rustc_queries! {
|
|||
desc { |tcx| "getting HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
}
|
||||
|
||||
/// Gives access to the HIR ID for the given `LocalDefId` owner `key`.
|
||||
/// Gives access to the HIR ID for the given `LocalDefId` owner `key` if any.
|
||||
///
|
||||
/// This can be conveniently accessed by methods on `tcx.hir()`.
|
||||
/// Avoid calling this query directly.
|
||||
query local_def_id_to_hir_id(key: LocalDefId) -> hir::HirId {
|
||||
/// Definitions that were generated with no HIR, would be feeded to return `None`.
|
||||
query opt_local_def_id_to_hir_id(key: LocalDefId) -> Option<hir::HirId>{
|
||||
desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
}
|
||||
|
||||
|
@ -767,6 +766,26 @@ rustc_queries! {
|
|||
desc { |tcx| "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) }
|
||||
}
|
||||
|
||||
/// Given `fn_def_id` of a trait or of an impl that implements a given trait:
|
||||
/// if `fn_def_id` is the def id of a function defined inside a trait, then it creates and returns
|
||||
/// the associated items that correspond to each impl trait in return position for that trait.
|
||||
/// if `fn_def_id` is the def id of a function defined inside an impl that implements a trait, then it
|
||||
/// creates and returns the associated items that correspond to each impl trait in return position
|
||||
/// of the implemented trait.
|
||||
query associated_items_for_impl_trait_in_trait(fn_def_id: DefId) -> &'tcx [DefId] {
|
||||
desc { |tcx| "creating associated items for impl trait in trait returned by `{}`", tcx.def_path_str(fn_def_id) }
|
||||
cache_on_disk_if { fn_def_id.is_local() }
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
/// Given an impl trait in trait `opaque_ty_def_id`, create and return the corresponding
|
||||
/// associated item.
|
||||
query associated_item_for_impl_trait_in_trait(opaque_ty_def_id: LocalDefId) -> LocalDefId {
|
||||
desc { |tcx| "creates the associated item corresponding to the opaque type `{}`", tcx.def_path_str(opaque_ty_def_id.to_def_id()) }
|
||||
cache_on_disk_if { true }
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
/// Given an `impl_id`, return the trait it implements.
|
||||
/// Return `None` if this is an inherent impl.
|
||||
query impl_trait_ref(impl_id: DefId) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
|
||||
|
|
|
@ -2451,6 +2451,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn local_def_id_to_hir_id(self, local_def_id: LocalDefId) -> HirId {
|
||||
self.opt_local_def_id_to_hir_id(local_def_id).unwrap()
|
||||
}
|
||||
|
||||
pub fn trait_solver_next(self) -> bool {
|
||||
self.sess.opts.unstable_opts.trait_solver == rustc_session::config::TraitSolver::Next
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue