Auto merge of #120951 - matthiaskrgr:rollup-0nnm7dv, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #110483 (Create try_new function for ThinBox) - #120740 (Make cmath.rs a single file) - #120872 (hir: Refactor getters for HIR parents) - #120880 (add note on comparing vtables / function pointers) - #120885 (interpret/visitor: ensure we only see normalized types) - #120888 (assert_unsafe_precondition cleanup) - #120897 (Encode `coroutine_for_closure` for foreign crates) - #120937 ([docs] Update armv6k-nintendo-3ds platform docs for outdated info) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
084ce5bdb5
98 changed files with 524 additions and 534 deletions
|
@ -2749,14 +2749,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
arg_idx: Option<usize>,
|
||||
) -> Option<Ty<'tcx>> {
|
||||
let tcx = self.tcx();
|
||||
let hir = tcx.hir();
|
||||
|
||||
let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), ident, .. }) =
|
||||
tcx.hir_node(fn_hir_id)
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let i = hir.get_parent(fn_hir_id).expect_item().expect_impl();
|
||||
let i = tcx.parent_hir_node(fn_hir_id).expect_item().expect_impl();
|
||||
|
||||
let trait_ref =
|
||||
self.instantiate_mono_trait_ref(i.of_trait.as_ref()?, self.ast_ty_to_ty(i.self_ty));
|
||||
|
|
|
@ -224,11 +224,8 @@ pub(crate) fn placeholder_type_error_diag<'tcx>(
|
|||
is_fn = true;
|
||||
|
||||
// Check if parent is const or static
|
||||
let parent_id = tcx.hir().parent_id(hir_ty.hir_id);
|
||||
let parent_node = tcx.hir_node(parent_id);
|
||||
|
||||
is_const_or_static = matches!(
|
||||
parent_node,
|
||||
tcx.parent_hir_node(hir_ty.hir_id),
|
||||
Node::Item(&hir::Item {
|
||||
kind: hir::ItemKind::Const(..) | hir::ItemKind::Static(..),
|
||||
..
|
||||
|
@ -1085,7 +1082,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<ty::PolyFnSig<
|
|||
|
||||
ImplItem(hir::ImplItem { kind: ImplItemKind::Fn(sig, _), generics, .. }) => {
|
||||
// Do not try to infer the return type for a impl method coming from a trait
|
||||
if let Item(hir::Item { kind: ItemKind::Impl(i), .. }) = tcx.hir().get_parent(hir_id)
|
||||
if let Item(hir::Item { kind: ItemKind::Impl(i), .. }) = tcx.parent_hir_node(hir_id)
|
||||
&& i.of_trait.is_some()
|
||||
{
|
||||
icx.astconv().ty_of_fn(
|
||||
|
|
|
@ -51,7 +51,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
// of a const parameter type, e.g. `struct Foo<const N: usize, const M: [u8; N]>` is not allowed.
|
||||
None
|
||||
} else if tcx.features().generic_const_exprs {
|
||||
let parent_node = tcx.hir().get_parent(hir_id);
|
||||
let parent_node = tcx.parent_hir_node(hir_id);
|
||||
if let Node::Variant(Variant { disr_expr: Some(constant), .. }) = parent_node
|
||||
&& constant.hir_id == hir_id
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
Some(parent_def_id.to_def_id())
|
||||
}
|
||||
} else {
|
||||
let parent_node = tcx.hir().get_parent(hir_id);
|
||||
let parent_node = tcx.parent_hir_node(hir_id);
|
||||
match parent_node {
|
||||
// HACK(eddyb) this provides the correct generics for repeat
|
||||
// expressions' count (i.e. `N` in `[x; N]`), and explicit
|
||||
|
|
|
@ -315,8 +315,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
// We create bi-directional Outlives predicates between the original
|
||||
// and the duplicated parameter, to ensure that they do not get out of sync.
|
||||
if let Node::Item(&Item { kind: ItemKind::OpaqueTy(..), .. }) = node {
|
||||
let opaque_ty_id = tcx.hir().parent_id(hir_id);
|
||||
let opaque_ty_node = tcx.hir_node(opaque_ty_id);
|
||||
let opaque_ty_node = tcx.parent_hir_node(hir_id);
|
||||
let Node::Ty(&Ty { kind: TyKind::OpaqueDef(_, lifetimes, _), .. }) = opaque_ty_node else {
|
||||
bug!("unexpected {opaque_ty_node:?}")
|
||||
};
|
||||
|
|
|
@ -732,7 +732,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
let Some(def_id) = def_id.as_local() else { continue };
|
||||
let hir_id = self.tcx.local_def_id_to_hir_id(def_id);
|
||||
// Ensure that the parent of the def is an item, not HRTB
|
||||
let parent_id = self.tcx.hir().parent_id(hir_id);
|
||||
let parent_id = self.tcx.parent_hir_id(hir_id);
|
||||
if !parent_id.is_owner() {
|
||||
struct_span_code_err!(
|
||||
self.tcx.dcx(),
|
||||
|
|
|
@ -30,7 +30,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
|||
);
|
||||
};
|
||||
|
||||
let parent_node_id = tcx.hir().parent_id(hir_id);
|
||||
let parent_node_id = tcx.parent_hir_id(hir_id);
|
||||
let parent_node = tcx.hir_node(parent_node_id);
|
||||
|
||||
let (generics, arg_idx) = match parent_node {
|
||||
|
@ -79,7 +79,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
|||
}
|
||||
|
||||
Node::TypeBinding(binding @ &TypeBinding { hir_id: binding_id, .. })
|
||||
if let Node::TraitRef(trait_ref) = tcx.hir_node(tcx.hir().parent_id(binding_id)) =>
|
||||
if let Node::TraitRef(trait_ref) = tcx.parent_hir_node(binding_id) =>
|
||||
{
|
||||
let Some(trait_def_id) = trait_ref.trait_def_id() else {
|
||||
return Ty::new_error_with_message(
|
||||
|
|
|
@ -135,7 +135,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
// Here we check if the reference to the generic type
|
||||
// is from the 'of_trait' field of the enclosing impl
|
||||
|
||||
let parent = self.tcx.hir().get_parent(self.path_segment.hir_id);
|
||||
let parent = self.tcx.parent_hir_node(self.path_segment.hir_id);
|
||||
let parent_item = self.tcx.hir_node_by_def_id(
|
||||
self.tcx.hir().get_parent_item(self.path_segment.hir_id).def_id,
|
||||
);
|
||||
|
@ -770,9 +770,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
num = num_trait_generics_except_self,
|
||||
);
|
||||
|
||||
if let Some(parent_node) = self.tcx.hir().opt_parent_id(self.path_segment.hir_id)
|
||||
&& let hir::Node::Expr(expr) = self.tcx.hir_node(parent_node)
|
||||
{
|
||||
if let hir::Node::Expr(expr) = self.tcx.parent_hir_node(self.path_segment.hir_id) {
|
||||
match &expr.kind {
|
||||
hir::ExprKind::Path(qpath) => self
|
||||
.suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue