Reduce the scope of what PointeeType() is intended to do.

I originally thought it would be useful to make this handle _any_ reference-like
type (which would, for example, include types that have lifetime parameters),
but we never ended up using it in this way.

However, it's become clear that it's useful for a slightly different purpose:
Retrieve the pointee type if the input type is a pointer or reference type, but
not in any other case. The other cases we want to exclude include
pointers-to-members, which do have a pointee type but are otherwise quite
different from normal pointers in that we don't associate them with lifetimes.

The modified PointeeType() will come in useful for making sure we handle
pointers-to-members correctly (which will happen in a followup CL). Essentially,
all that this will require is replacing the currently widespread use of
Type::getPointeeType() with PointeeType().

As part of simplifying PointeeType(), we remove the type canonicalization.
Again, I originally thought this would be useful, but it turns out it's
counterproductive for the purposes we now want to use it for.

PiperOrigin-RevId: 432419108
diff --git a/lifetime_annotations/pointee_type.cc b/lifetime_annotations/pointee_type.cc
index 4e8866b..3121014 100644
--- a/lifetime_annotations/pointee_type.cc
+++ b/lifetime_annotations/pointee_type.cc
@@ -6,29 +6,13 @@
 
 namespace devtools_rust {
 
-// If `type` is a reference-like type, returns the type of its pointee.
-// Otherwise, returns a null type.
 clang::QualType PointeeType(clang::QualType type) {
-  if (type.isNull()) {
-    return clang::QualType();
-  }
-
-  // For the purposes of inference, we always use canonical types. Later, if we
-  // need to produce a lifetime annotation for a type that is actually a typedef
-  // for another type, we'll handle that there.
-  type = type.getCanonicalType();
-
   if (auto ptr_type = type->getAs<clang::PointerType>()) {
     return ptr_type->getPointeeType();
   } else if (auto ref_type = type->getAs<clang::ReferenceType>()) {
     return ref_type->getPointeeType();
   }
 
-  // TODO(mboehme): Handle these additional cases:
-  // - For array types, recurse into the element type
-  // - Types with type parameters
-  // - Type arguments for class templates
-
   return clang::QualType();
 }
 
diff --git a/lifetime_annotations/pointee_type.h b/lifetime_annotations/pointee_type.h
index 511d3ae..3197b3d 100644
--- a/lifetime_annotations/pointee_type.h
+++ b/lifetime_annotations/pointee_type.h
@@ -9,8 +9,13 @@
 
 namespace devtools_rust {
 
-// If `type` is a reference-like type, returns the type of its pointee.
+// If `type` is a pointer or reference type, returns the type of its pointee.
 // Otherwise, returns a null type.
+// Unlike `type->getPointeeType()`, this returns a null type if `type`, though
+// it has a pointee type, is not a type for which we infer lifetimes, such as
+// a pointer-to-member type. In other words, this function can be used to
+// succinctly answer the question "does `type` have pointee type and do we infer
+// lifetimes for it".
 clang::QualType PointeeType(clang::QualType type);
 
 }  // namespace devtools_rust