about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2021-12-21 13:23:59 +0800
committerDeadbeef <ent3rm4n@gmail.com>2021-12-21 13:25:43 +0800
commitaaaad5b46bd90047fce43672d7848c6c75ceea35 (patch)
tree4f825fdfa51633e57603e083c44437e38eabcf7a /src
parent99b0799608b670be5fd6d4303489689c3d52c99c (diff)
downloadrust-aaaad5b46bd90047fce43672d7848c6c75ceea35.tar.gz
rust-aaaad5b46bd90047fce43672d7848c6c75ceea35.zip
Fix bad caching of `~const Drop` bounds
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/rfc-2632-const-trait-impl/issue-92111.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-92111.rs b/src/test/ui/rfc-2632-const-trait-impl/issue-92111.rs
new file mode 100644
index 00000000000..d30f4edd4b2
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/issue-92111.rs
@@ -0,0 +1,29 @@
+// Regression test for #92111.
+//
+// The issue was that we normalize trait bounds before caching
+// results of selection. Checking that `impl NoDrop for S` requires
+// checking `S: !Drop` because it cannot overlap with the blanket
+// impl. Then we save the (unsatisfied) result from checking `S: Drop`.
+// Then the call to `a` checks whether `S: ~const Drop` but we normalize
+// it to `S: Drop` which the cache claims to be unsatisfied.
+//
+// check-pass
+
+#![feature(const_trait_impl)]
+#![feature(const_fn_trait_bound)]
+
+pub trait Tr {}
+
+#[allow(drop_bounds)]
+impl<T: Drop> Tr for T {}
+
+#[derive(Debug)]
+pub struct S(i32);
+
+impl Tr for S {}
+
+const fn a<T: ~const Drop>(t: T) {}
+
+fn main() {
+    a(S(0));
+}