From 168bdf1a7887f261be2b11b00c5c4bf6597d8a11 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Wed, 29 Jan 2025 17:10:39 +0000 Subject: [PATCH 1/3] gccrs: fix bad generic substitution on trait impls When we pass generic types as the Self on traits they need to be handled via a special case on fntypes, ADT's and placeholders as the type params won't necessarily match up because of the implicit Self. Fixes Rust-GCC#3382 gcc/rust/ChangeLog: * typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): special case gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3382.rs: New test. Signed-off-by: Philip Herron --- .../typecheck/rust-substitution-mapper.cc | 4 +- gcc/testsuite/rust/compile/issue-3382.rs | 61 +++++++++++++++++++ gcc/testsuite/rust/compile/nr2/exclude | 1 + 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/rust/compile/issue-3382.rs diff --git a/gcc/rust/typecheck/rust-substitution-mapper.cc b/gcc/rust/typecheck/rust-substitution-mapper.cc index 394dfe40db44..233efa2bac7a 100644 --- a/gcc/rust/typecheck/rust-substitution-mapper.cc +++ b/gcc/rust/typecheck/rust-substitution-mapper.cc @@ -192,7 +192,7 @@ SubstMapperInternal::visit (TyTy::FnType &type) { TyTy::SubstitutionArgumentMappings adjusted = type.adjust_mappings_for_this (mappings); - if (adjusted.is_error ()) + if (adjusted.is_error () && !mappings.trait_item_mode ()) return; TyTy::BaseType *concrete = type.handle_substitions (adjusted); @@ -205,7 +205,7 @@ SubstMapperInternal::visit (TyTy::ADTType &type) { TyTy::SubstitutionArgumentMappings adjusted = type.adjust_mappings_for_this (mappings); - if (adjusted.is_error ()) + if (adjusted.is_error () && !mappings.trait_item_mode ()) return; TyTy::BaseType *concrete = type.handle_substitions (adjusted); diff --git a/gcc/testsuite/rust/compile/issue-3382.rs b/gcc/testsuite/rust/compile/issue-3382.rs new file mode 100644 index 000000000000..6f4382f1b523 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3382.rs @@ -0,0 +1,61 @@ +#[lang = "sized"] +trait Sized {} + +enum Result { + #[lang = "Ok"] + Ok(T), + #[lang = "Err"] + Err(E), +} + +#[lang = "try"] +pub trait Try { + /// The type of this value when viewed as successful. + // #[unstable(feature = "try_trait", issue = "42327")] + type Ok; + /// The type of this value when viewed as failed. + // #[unstable(feature = "try_trait", issue = "42327")] + type Error; + + /// Applies the "?" operator. A return of `Ok(t)` means that the + /// execution should continue normally, and the result of `?` is the + /// value `t`. A return of `Err(e)` means that execution should branch + /// to the innermost enclosing `catch`, or return from the function. + /// + /// If an `Err(e)` result is returned, the value `e` will be "wrapped" + /// in the return type of the enclosing scope (which must itself implement + /// `Try`). Specifically, the value `X::from_error(From::from(e))` + /// is returned, where `X` is the return type of the enclosing function. + #[lang = "into_result"] + #[unstable(feature = "try_trait", issue = "42327")] + fn into_result(self) -> Result; + + /// Wrap an error value to construct the composite result. For example, + /// `Result::Err(x)` and `Result::from_error(x)` are equivalent. + #[lang = "from_error"] + #[unstable(feature = "try_trait", issue = "42327")] + fn from_error(v: Self::Ok) -> Self; + + /// Wrap an OK value to construct the composite result. For example, + /// `Result::Ok(x)` and `Result::from_ok(x)` are equivalent. + #[lang = "from_ok"] + #[unstable(feature = "try_trait", issue = "42327")] + fn from_ok(v: Self::Error) -> Self; +} + +impl Try for Result { + type Ok = T; + type Error = E; + + fn into_result(self) -> Result { + self + } + + fn from_ok(v: T) -> Self { + Result::Ok(v) + } + + fn from_error(v: E) -> Self { + Result::Err(v) + } +} diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index e5e5c12a978a..c080adb36169 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -151,4 +151,5 @@ issue-3030.rs traits12.rs try-trait.rs issue-3174.rs +issue-3382.rs # please don't delete the trailing newline From a0e217b90b540e24b05e0663b38cf05b671e8584 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 31 Jan 2025 17:09:48 +0000 Subject: [PATCH 2/3] WIP WIP WIP --- gcc/rust/backend/rust-compile-expr.cc | 5 ++ gcc/rust/backend/rust-compile-resolve-path.cc | 21 +++-- .../errors/privacy/rust-privacy-reporter.cc | 10 ++- gcc/rust/typecheck/rust-hir-path-probe.cc | 12 +-- .../typecheck/rust-hir-type-check-path.cc | 81 +++++++++++++++---- .../typecheck/rust-substitution-mapper.cc | 4 + gcc/rust/typecheck/rust-type-util.cc | 6 +- gcc/rust/typecheck/rust-tyty.cc | 22 +++-- 8 files changed, 122 insertions(+), 39 deletions(-) diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 79383301f353..bf528a136fd5 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -1211,6 +1211,8 @@ CompileExpr::visit (HIR::CallExpr &expr) { rust_assert (tyty->get_kind () == TyTy::TypeKind::ADT); TyTy::ADTType *adt = static_cast (tyty); + rust_debug ("111 XXXXXXXXXXXXXXXXXXXXXXX"); + adt->debug (); tree compiled_adt_type = TyTyResolveCompile::compile (ctx, tyty); // what variant is it? @@ -1273,6 +1275,9 @@ CompileExpr::visit (HIR::CallExpr &expr) return; } + rust_debug_loc (expr.get_locus (), "XXXXXXXXXX ADT CTOR"); + debug_tree (compiled_adt_type); + HIR::Expr &discrim_expr = variant->get_discriminant (); tree discrim_expr_node = CompileExpr::Compile (discrim_expr, ctx); tree folded_discrim_expr = fold_expr (discrim_expr_node); diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 07fa9b2acbf4..bb87af8e8d00 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -297,16 +297,25 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, trait->get_mappings ().get_defid (), &trait_ref); rust_assert (ok); - TyTy::BaseType *receiver = nullptr; - ok = ctx->get_tyctx ()->lookup_receiver (mappings.get_hirid (), - &receiver); - rust_assert (ok); - receiver = receiver->destructure (); - // the type resolver can only resolve type bounds to their trait // item so its up to us to figure out if this path should resolve // to an trait-impl-block-item or if it can be defaulted to the // trait-impl-item's definition + // + // because we know this is resolved to a trait item we can actually + // just grab the Self type parameter here for the receiver to match + // the appropriate impl block + + rust_assert (lookup->is ()); + auto fn = lookup->as (); + rust_assert (fn->get_num_type_params () > 0); + auto &self = fn->get_substs ().at (0); + auto receiver = self.get_param_ty (); + + rust_debug ("XXXXXXXXXX"); + lookup->debug (); + receiver->debug (); + auto candidates = Resolver::PathProbeImplTrait::Probe (receiver, final_segment, trait_ref); diff --git a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc index 9c9f2cf850ed..77b03f59c728 100644 --- a/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc +++ b/gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc @@ -243,10 +243,12 @@ PrivacyReporter::check_base_type_privacy (Analysis::NodeMapping &node_mappings, static_cast (ty)->get_fields ()) recursive_check (param.get_tyty ()); return; - case TyTy::PLACEHOLDER: - return recursive_check ( - // FIXME: Can we use `resolve` here? Is that what we should do? - static_cast (ty)->resolve ()); + case TyTy::PLACEHOLDER: { + const auto p = static_cast (ty); + if (!p->can_resolve ()) + return; + return recursive_check (p->resolve ()); + } case TyTy::PROJECTION: return recursive_check ( static_cast (ty)->get ()); diff --git a/gcc/rust/typecheck/rust-hir-path-probe.cc b/gcc/rust/typecheck/rust-hir-path-probe.cc index 16976c34989d..cdb2c58588bb 100644 --- a/gcc/rust/typecheck/rust-hir-path-probe.cc +++ b/gcc/rust/typecheck/rust-hir-path-probe.cc @@ -212,8 +212,8 @@ PathProbeType::visit (HIR::TypeAlias &alias) { HirId tyid = alias.get_mappings ().get_hirid (); TyTy::BaseType *ty = nullptr; - bool ok = query_type (tyid, &ty); - rust_assert (ok); + if (!query_type (tyid, &ty)) + return; PathProbeCandidate::ImplItemCandidate impl_item_candidate{&alias, current_impl}; @@ -232,8 +232,8 @@ PathProbeType::visit (HIR::ConstantItem &constant) { HirId tyid = constant.get_mappings ().get_hirid (); TyTy::BaseType *ty = nullptr; - bool ok = query_type (tyid, &ty); - rust_assert (ok); + if (!query_type (tyid, &ty)) + return; PathProbeCandidate::ImplItemCandidate impl_item_candidate{&constant, current_impl}; @@ -252,8 +252,8 @@ PathProbeType::visit (HIR::Function &function) { HirId tyid = function.get_mappings ().get_hirid (); TyTy::BaseType *ty = nullptr; - bool ok = query_type (tyid, &ty); - rust_assert (ok); + if (!query_type (tyid, &ty)) + return; PathProbeCandidate::ImplItemCandidate impl_item_candidate{&function, current_impl}; diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc index 5f05deb4bc20..381bfe432358 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-path.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc @@ -76,7 +76,7 @@ TypeCheckExpr::visit (HIR::QualifiedPathInExpression &expr) // lookup the associated item from the specified bound HIR::PathExprSegment &item_seg = expr.get_segments ().at (0); - HIR::PathIdentSegment item_seg_identifier = item_seg.get_segment (); + HIR::PathIdentSegment &item_seg_identifier = item_seg.get_segment (); TyTy::TypeBoundPredicateItem item = specified_bound.lookup_associated_item (item_seg_identifier.as_string ()); if (item.is_error ()) @@ -416,28 +416,77 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id, for (size_t i = offset; i < segments.size (); i++) { HIR::PathExprSegment &seg = segments.at (i); + HIR::PathIdentSegment &item_seg_identifier = seg.get_segment (); bool probe_impls = !receiver_is_generic; - - // probe the path is done in two parts one where we search impls if no - // candidate is found then we search extensions from traits - auto candidates - = PathProbeType::Probe (prev_segment, seg.get_segment (), probe_impls, - false /*probe_bounds*/, - true /*ignore_mandatory_trait_items*/); + std::set candidates = {}; + + // // is this segment a Trait TODO + // if (prev_segment->is () + // && prev_segment->num_specified_bounds () == 1) + // { + // rust_debug ("attempting trait lookup magic man "); + // TyTy::TyVar infer_var_tyvar + // = TyTy::TyVar::get_implicit_infer_var (seg.get_locus ()); + // TyTy::BaseType *new_seg = infer_var_tyvar.get_tyty (); + // new_seg->inherit_bounds (*prev_segment); + + // auto &pred = new_seg->get_specified_bounds ().at (0); + // TyTy::TypeBoundPredicateItem item + // = pred.lookup_associated_item (item_seg_identifier.as_string ()); + // if (!item.is_error ()) + // { + // PathProbeCandidate::CandidateType candidate_type; + // switch (item.get_raw_item ()->get_trait_item_type ()) + // { + // case TraitItemReference::TraitItemType::FN: + // candidate_type + // = PathProbeCandidate::CandidateType::TRAIT_FUNC; + // break; + // case TraitItemReference::TraitItemType::CONST: + // candidate_type + // = PathProbeCandidate::CandidateType::TRAIT_ITEM_CONST; + // break; + // case TraitItemReference::TraitItemType::TYPE: + // candidate_type + // = PathProbeCandidate::CandidateType::TRAIT_TYPE_ALIAS; + // break; + + // case TraitItemReference::TraitItemType::ERROR: + // default: + // rust_unreachable (); + // break; + // } + + // auto item_ty = item.get_tyty_for_receiver (new_seg); + // auto trait_item_candidate + // = PathProbeCandidate::TraitItemCandidate{ + // item.get_parent ()->get (), item.get_raw_item (), nullptr}; + // auto candidate + // = PathProbeCandidate{candidate_type, item_ty, item.get_locus (), + // trait_item_candidate}; + // candidates = {std::move (candidate)}; + // } + // else + + // probe the path is done in two parts one where we search impls + // if no candidate is found then we search extensions from traits + candidates = PathProbeType::Probe (prev_segment, seg.get_segment (), + probe_impls, false /*probe_bounds*/, + true /*ignore_mandatory_trait_items*/); if (candidates.size () == 0) { candidates - = PathProbeType::Probe (prev_segment, seg.get_segment (), false, + = PathProbeType::Probe (prev_segment, seg.get_segment (), + false /*probe_impls*/, true /*probe_bounds*/, false /*ignore_mandatory_trait_items*/); + } - if (candidates.size () == 0) - { - rust_error_at ( - seg.get_locus (), - "failed to resolve path segment using an impl Probe"); - return; - } + if (candidates.size () == 0) + { + rust_error_at (seg.get_locus (), + "failed to resolve path segment using an impl Probe"); + return; } if (candidates.size () > 1) diff --git a/gcc/rust/typecheck/rust-substitution-mapper.cc b/gcc/rust/typecheck/rust-substitution-mapper.cc index 233efa2bac7a..49c450535215 100644 --- a/gcc/rust/typecheck/rust-substitution-mapper.cc +++ b/gcc/rust/typecheck/rust-substitution-mapper.cc @@ -194,6 +194,8 @@ SubstMapperInternal::visit (TyTy::FnType &type) = type.adjust_mappings_for_this (mappings); if (adjusted.is_error () && !mappings.trait_item_mode ()) return; + if (adjusted.is_error () && mappings.trait_item_mode ()) + adjusted = mappings; TyTy::BaseType *concrete = type.handle_substitions (adjusted); if (concrete != nullptr) @@ -207,6 +209,8 @@ SubstMapperInternal::visit (TyTy::ADTType &type) = type.adjust_mappings_for_this (mappings); if (adjusted.is_error () && !mappings.trait_item_mode ()) return; + if (adjusted.is_error () && mappings.trait_item_mode ()) + adjusted = mappings; TyTy::BaseType *concrete = type.handle_substitions (adjusted); if (concrete != nullptr) diff --git a/gcc/rust/typecheck/rust-type-util.cc b/gcc/rust/typecheck/rust-type-util.cc index 50892a3365c9..b797188bca7f 100644 --- a/gcc/rust/typecheck/rust-type-util.cc +++ b/gcc/rust/typecheck/rust-type-util.cc @@ -217,8 +217,10 @@ coercion_site (HirId id, TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, rust_debug ("coerce_default_unify(a={%s}, b={%s})", receiver->debug_str ().c_str (), expected->debug_str ().c_str ()); TyTy::BaseType *coerced - = unify_site (id, lhs, TyTy::TyWithLocation (receiver, rhs.get_locus ()), - locus); + = unify_site_and (id, lhs, + TyTy::TyWithLocation (receiver, rhs.get_locus ()), locus, + true /*emit_error*/, true /*commit*/, true /*infer*/, + true /*cleanup*/); context->insert_autoderef_mappings (id, std::move (result.adjustments)); return coerced; } diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 116c1abdf8e8..193217ba761c 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -2226,12 +2226,24 @@ void ClosureType::setup_fn_once_output () const { // lookup the lang items - auto fn_once_lang_item = LangItem::Kind::FN_ONCE; - auto fn_once_output_lang_item = LangItem::Kind::FN_ONCE_OUTPUT; + auto fn_once_lookup = mappings.lookup_lang_item (LangItem::Kind::FN_ONCE); + auto fn_once_output_lookup + = mappings.lookup_lang_item (LangItem::Kind::FN_ONCE_OUTPUT); + if (!fn_once_lookup) + { + rust_fatal_error (UNKNOWN_LOCATION, + "Missing required % lang item"); + return; + } + if (!fn_once_output_lookup) + { + rust_fatal_error (UNKNOWN_LOCATION, + "Missing required % lang item"); + return; + } - DefId &trait_id = mappings.lookup_lang_item (fn_once_lang_item).value (); - DefId &trait_item_id - = mappings.lookup_lang_item (fn_once_output_lang_item).value (); + DefId &trait_id = fn_once_lookup.value (); + DefId &trait_item_id = fn_once_output_lookup.value (); // resolve to the trait HIR::Item *item = mappings.lookup_defid (trait_id).value (); From eb3e1be1118ee3aff8372c9f1aad92e5a4587ab1 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 31 Jan 2025 22:38:21 +0000 Subject: [PATCH 3/3] WIP --- gcc/rust/backend/rust-compile-base.cc | 4 +-- gcc/rust/backend/rust-compile-context.h | 6 +++-- gcc/rust/backend/rust-compile-expr.cc | 11 +++++++- gcc/rust/backend/rust-compile-item.cc | 27 ++++++++++++++++++- gcc/rust/backend/rust-compile-item.h | 4 +-- gcc/rust/backend/rust-compile-resolve-path.cc | 17 ++++++++---- 6 files changed, 56 insertions(+), 13 deletions(-) diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index a4d0d062accc..5600c0223cc0 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -757,7 +757,7 @@ HIRCompileBase::compile_function ( ctx->add_statement (ret_var_stmt); - ctx->push_fn (fndecl, return_address, tyret); + ctx->push_fn (fndecl, return_address, tyret, fntype); compile_function_body (fndecl, *function_body, tyret); tree bind_tree = ctx->pop_block (); @@ -825,7 +825,7 @@ HIRCompileBase::compile_constant_item ( address_is_taken, locus, &ret_var_stmt); ctx->add_statement (ret_var_stmt); - ctx->push_fn (fndecl, return_address, resolved_type); + ctx->push_fn (fndecl, return_address, resolved_type, resolved_type); if (is_block_expr) { diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 18d27f484296..0e5ddfe5fc21 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -37,6 +37,7 @@ struct fncontext tree fndecl; ::Bvariable *ret_addr; TyTy::BaseType *retty; + TyTy::BaseType *fnty; }; struct CustomDeriveInfo @@ -275,9 +276,10 @@ class Context return true; } - void push_fn (tree fn, ::Bvariable *ret_addr, TyTy::BaseType *retty) + void push_fn (tree fn, ::Bvariable *ret_addr, TyTy::BaseType *retty, + TyTy::BaseType *fntype) { - fn_stack.push_back (fncontext{fn, ret_addr, retty}); + fn_stack.push_back (fncontext{fn, ret_addr, retty, fntype}); } void pop_fn () { fn_stack.pop_back (); } diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index bf528a136fd5..8e9f139ce509 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -1278,11 +1278,20 @@ CompileExpr::visit (HIR::CallExpr &expr) rust_debug_loc (expr.get_locus (), "XXXXXXXXXX ADT CTOR"); debug_tree (compiled_adt_type); + const auto &c = ctx->peek_fn (); + c.fnty->debug (); + HIR::Expr &discrim_expr = variant->get_discriminant (); tree discrim_expr_node = CompileExpr::Compile (discrim_expr, ctx); tree folded_discrim_expr = fold_expr (discrim_expr_node); tree qualifier = folded_discrim_expr; + if (compiled_adt_type == error_mark_node) + { + rust_debug_loc (expr.get_fnexpr ().get_locus (), + "XXX this is broken!!"); + } + tree enum_root_files = TYPE_FIELDS (compiled_adt_type); tree payload_root = DECL_CHAIN (enum_root_files); @@ -2503,7 +2512,7 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr, ctx->add_statement (ret_var_stmt); - ctx->push_fn (fndecl, return_address, tyret); + ctx->push_fn (fndecl, return_address, tyret, fn_tyty); if (is_block_expr) { diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index 60159b63fd5b..f341a0471663 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -19,6 +19,8 @@ #include "rust-compile-item.h" #include "rust-compile-implitem.h" #include "rust-compile-extern.h" +#include "rust-substitution-mapper.h" +#include "rust-type-util.h" #include "rust-immutable-name-resolution-context.h" namespace Rust { @@ -159,6 +161,17 @@ CompileItem::visit (HIR::Function &function) rust_assert (fntype_tyty->get_kind () == TyTy::TypeKind::FNDEF); TyTy::FnType *fntype = static_cast (fntype_tyty); + + if (concrete && fntype->has_substitutions_defined ()) + { + rust_assert (concrete->get_kind () == TyTy::TypeKind::FNDEF); + TyTy::FnType *concrete_fnty = static_cast (fntype_tyty); + + rust_debug ("XPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"); + fntype->debug (); + concrete_fnty->debug (); + } + if (fntype->has_substitutions_defined ()) { // we cant do anything for this only when it is used and a concrete type @@ -168,7 +181,19 @@ CompileItem::visit (HIR::Function &function) else { rust_assert (concrete->get_kind () == TyTy::TypeKind::FNDEF); - fntype = static_cast (concrete); + TyTy::BaseType *infer + = Resolver::SubstMapper::InferSubst (fntype, function.get_locus ()); + TyTy::BaseType *resolved + = Resolver::unify_site (function.get_mappings ().get_hirid (), + TyTy::TyWithLocation (infer), + TyTy::TyWithLocation (concrete), + function.get_locus ()); + + rust_debug ("UUUUUUUUUUUUU"); + resolved->debug (); + + rust_assert (resolved->is ()); + fntype = resolved->as (); fntype->monomorphize (); } } diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 70660e16147c..1c6534b93405 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -36,8 +36,8 @@ class CompileItem : private HIRCompileBase, protected HIR::HIRStmtVisitor CompileItem compiler (ctx, concrete, ref_locus); item->accept_vis (compiler); - if (compiler.reference == error_mark_node) - rust_debug ("failed to compile item: %s", item->as_string ().c_str ()); + // if (compiler.reference == error_mark_node) + // rust_debug ("failed to compile item: %s", item->as_string ().c_str ()); return compiler.reference; } diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index bb87af8e8d00..6bf9cac54b94 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -349,12 +349,19 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, rust_assert (ok); if (!lookup->has_substitutions_defined ()) - return CompileInherentImplItem::Compile (impl_item, ctx, - nullptr, true, - expr_locus); + { + rust_debug ("XXXXXXXXX YYY 1"); + return CompileInherentImplItem::Compile (impl_item, ctx, + nullptr, true, + expr_locus); + } else - return CompileInherentImplItem::Compile (impl_item, ctx, lookup, - true, expr_locus); + { + rust_debug ("XXXXXXXXX YYY 2"); + return CompileInherentImplItem::Compile (impl_item, ctx, + lookup, true, + expr_locus); + } } } }