about summary refs log tree commit diff
path: root/tests/ui/borrowck/copy-overflow.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-22 11:32:36 +0000
committerbors <bors@rust-lang.org>2025-07-22 11:32:36 +0000
commit35487a2e7c80012129c38f55c970109a1538c91f (patch)
tree9e370f22e084dea144b776d617d10c23ac655f9e /tests/ui/borrowck/copy-overflow.rs
parentc0b282f0ccdab7523cdb8dfa41b23bed5573da76 (diff)
parent749f895d95e1c2da2e82fa47b7311353cd7db7fc (diff)
downloadrust-35487a2e7c80012129c38f55c970109a1538c91f.tar.gz
rust-35487a2e7c80012129c38f55c970109a1538c91f.zip
Auto merge of #144294 - matthiaskrgr:rollup-ybvall3, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#142454 (Add modern AVR mcus like avr128db28 and attiny3224)
 - rust-lang/rust#142924 (tidy: move rustdoc js stuff into a tidy extra check)
 - rust-lang/rust#143373 (Unquerify maybe_unused_trait_imports.)
 - rust-lang/rust#144082 (tests: cover more `exported_private_dependencies` cases)
 - rust-lang/rust#144126 (Fix empty target_config in apply_rust_config bootstrap)
 - rust-lang/rust#144164 ( opt-dist: add an option for setting path to stage0 root)
 - rust-lang/rust#144265 (Dont ICE on copy error being suppressed due to overflow)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests/ui/borrowck/copy-overflow.rs')
-rw-r--r--tests/ui/borrowck/copy-overflow.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/borrowck/copy-overflow.rs b/tests/ui/borrowck/copy-overflow.rs
new file mode 100644
index 00000000000..5aa1afdee68
--- /dev/null
+++ b/tests/ui/borrowck/copy-overflow.rs
@@ -0,0 +1,16 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/144165>.
+
+// We were previously suppressing the copy error in the `Clone` impl because we assumed
+// that the only way we get `Copy` ambiguity errors was due to incoherent impls. This is
+// not true, since ambiguities can be encountered due to overflows (among other ways).
+
+struct S<T: 'static>(Option<&'static T>);
+
+impl<T: 'static> Copy for S<T> where S<T>: Copy + Clone {}
+impl<T: 'static> Clone for S<T> {
+    fn clone(&self) -> Self {
+        *self
+        //~^ ERROR cannot move out of `*self` which is behind a shared reference
+    }
+}
+fn main() {}