code: func AppendProtoDiag(diags []*proto.Diagnostic, d interface{}) []*proto.Diagnostic {
  	switch d := d.(type) {
  	case cty.PathError:
  		ap := PathToAttributePath(d.Path)
  		diags = append(diags, &proto.Diagnostic{
  			Severity:  proto.Diagnostic_ERROR,
  			Summary:   d.Error(),
  			Attribute: ap,
  		})
  	case error:
  		diags = append(diags, &proto.Diagnostic{
  			Severity: proto.Diagnostic_ERROR,
  			Summary:  d.Error(),
  		})
  	case string:
  		diags = append(diags, &proto.Diagnostic{
  			Severity: proto.Diagnostic_WARNING,
  			Summary:  d,
  		})
  	case *proto.Diagnostic:
  		diags = append(diags, d)
  	case []*proto.Diagnostic:
  		diags = append(diags, d...)
  	}
  	return diags
  }
docs: // AppendProtoDiag appends a new diagnostic from a warning string or an error.
  // This panics if d is not a string or error.