[release-branch.go1.15] xerrors: avoid infinite loop in test (detailed).Error method

For golang/go#40573

Change-Id: I5daaec48301cdedb2efcfadaf1dcd41cb8e96b01
Reviewed-on: https://go-review.googlesource.com/c/xerrors/+/246640
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
(cherry picked from commit 5ec99f83aff198f5fbd629d6c8d8eb38a04218ca)
Reviewed-on: https://go-review.googlesource.com/c/xerrors/+/247217
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/fmt_test.go b/fmt_test.go
index 7bf96a7..1e3c060 100644
--- a/fmt_test.go
+++ b/fmt_test.go
@@ -395,7 +395,7 @@
 
 type detailed struct{}
 
-func (e detailed) Error() string { return fmt.Sprint(e) }
+func (e detailed) Error() string { panic("should have called FormatError") }
 
 func (detailed) FormatError(p xerrors.Printer) (next error) {
 	p.Printf("out of %s", "peanuts")