From: Sriram Raghunathan <[email protected]>
* This patch improves the as_string API for the PathProbe with detailed
log about the Candidate. The log resolves the candidate type with
available APIs, and resolves the type string from the ty class as_string
and builds the stringstream to return.
Fixes Rust-GCC/gccrs#5078
gcc/rust/ChangeLog:
* typecheck/rust-hir-path-probe.cc: (PathProbeCandidate::as_string):
Implement.
Signed-off-by: Sriram Raghunathan <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/7ca6e9af90ed332b9cc446c0e868f6875470a0eb
The commit has been mentioned in the following issue(s):
- Rust-GCC/gccrs#5078: https://github.com/Rust-GCC/gccrs/issues/5078
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/5090
gcc/rust/typecheck/rust-hir-path-probe.cc | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/typecheck/rust-hir-path-probe.cc
b/gcc/rust/typecheck/rust-hir-path-probe.cc
index ca8c1468b..6b47fb8ff 100644
--- a/gcc/rust/typecheck/rust-hir-path-probe.cc
+++ b/gcc/rust/typecheck/rust-hir-path-probe.cc
@@ -60,7 +60,24 @@ PathProbeCandidate::PathProbeCandidate (CandidateType type,
TyTy::BaseType *ty,
std::string
PathProbeCandidate::as_string () const
{
- return "PathProbe candidate TODO - as_string";
+ if (is_error ())
+ return "PathProbe kind=Error";
+
+ std::stringstream ss;
+ ss << "PathProbe kind=";
+ if (is_enum_candidate ())
+ ss << "Enum";
+ else if (is_impl_candidate ())
+ ss << "Impl";
+ else if (is_trait_candidate ())
+ ss << (is_full_trait_item_candidate () ? "Trait" : "TraitImpl");
+ else
+ ss << "Unknown";
+
+ DefId id = get_defid ();
+ ss << ", type=" << (ty != nullptr ? ty->as_string () : "<null>")
+ << ", crate=" << id.crateNum << ", local=" << id.localDefId;
+ return ss.str ();
}
bool
base-commit: 4c39865583026c74b70e8f6bfe9644a739386b11
--
2.56.1