summaryrefslogtreecommitdiffstats
path: root/tests/ui/generics/post_monomorphization_error_backtrace.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/generics/post_monomorphization_error_backtrace.rs
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/generics/post_monomorphization_error_backtrace.rs')
-rw-r--r--tests/ui/generics/post_monomorphization_error_backtrace.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs
new file mode 100644
index 000000000..1fd9b6b3b
--- /dev/null
+++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs
@@ -0,0 +1,33 @@
+// build-fail
+
+fn assert_zst<T>() {
+ struct F<T>(T);
+ impl<T> F<T> {
+ const V: () = assert!(std::mem::size_of::<T>() == 0);
+ //~^ ERROR: evaluation of `assert_zst::F::<u32>::V` failed [E0080]
+ //~| NOTE: in this expansion of assert!
+ //~| NOTE: the evaluated program panicked
+ //~| ERROR: evaluation of `assert_zst::F::<i32>::V` failed [E0080]
+ //~| NOTE: in this expansion of assert!
+ //~| NOTE: the evaluated program panicked
+ }
+ let _ = F::<T>::V;
+}
+
+fn foo<U>() {
+ assert_zst::<U>()
+ //~^ NOTE: the above error was encountered while instantiating `fn assert_zst::<u32>`
+ //~| NOTE: the above error was encountered while instantiating `fn assert_zst::<i32>`
+}
+
+
+fn bar<V>() {
+ foo::<V>()
+}
+
+fn main() {
+ bar::<()>();
+ bar::<u32>();
+ bar::<u32>();
+ bar::<i32>();
+}