code: func ParseAbsResource(traversal hcl.Traversal) (AbsResource, tfdiags.Diagnostics) {
  	addr, diags := ParseTarget(traversal)
  	if diags.HasErrors() {
  		return AbsResource{}, diags
  	}
  
  	switch tt := addr.Subject.(type) {
  
  	case AbsResource:
  		return tt, diags
  
  	case AbsResourceInstance: // Catch likely user error with specialized message
  		// Assume that the last element of the traversal must be the index,
  		// since that's required for a valid resource instance address.
  		indexStep := traversal[len(traversal)-1]
  		diags = diags.Append(&hcl.Diagnostic{
  			Severity: hcl.DiagError,
  			Summary:  "Invalid address",
  			Detail:   "A resource address is required. This instance key identifies a specific resource instance, which is not expected here.",
  			Subject:  indexStep.SourceRange().Ptr(),
  		})
  		return AbsResource{}, diags
  
  	case ModuleInstance: // Catch likely user error with specialized message
  		diags = diags.Append(&hcl.Diagnostic{
  			Severity: hcl.DiagError,
  			Summary:  "Invalid address",
  			Detail:   "A resource address is required here. The module path must be followed by a resource specification.",
  			Subject:  traversal.SourceRange().Ptr(),
  		})
  		return AbsResource{}, diags
  
  	default: // Generic message for other address types
  		diags = diags.Append(&hcl.Diagnostic{
  			Severity: hcl.DiagError,
  			Summary:  "Invalid address",
  			Detail:   "A resource address is required here.",
  			Subject:  traversal.SourceRange().Ptr(),
  		})
  		return AbsResource{}, diags
  
  	}
  }
docs: // ParseAbsResource attempts to interpret the given traversal as an absolute
  // resource address, using the same syntax as expected by ParseTarget.
  //
  // If no error diagnostics are returned, the returned target includes the
  // address that was extracted and the source range it was extracted from.
  //
  // If error diagnostics are returned then the AbsResource value is invalid and
  // must not be used.