From d1b2d29528b7794b41e66fc2136e395a02f8529b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:35 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/auto-traits/issue-83857-ub.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/ui/auto-traits/issue-83857-ub.rs (limited to 'tests/ui/auto-traits/issue-83857-ub.rs') diff --git a/tests/ui/auto-traits/issue-83857-ub.rs b/tests/ui/auto-traits/issue-83857-ub.rs new file mode 100644 index 000000000..626e60c37 --- /dev/null +++ b/tests/ui/auto-traits/issue-83857-ub.rs @@ -0,0 +1,33 @@ +#![allow(suspicious_auto_trait_impls)] +// Tests that we don't incorrectly allow overlap between a builtin auto trait +// impl and a user written one. See #83857 for more details + +struct Always(T, U); +unsafe impl Send for Always {} +struct Foo(Always); + +trait False {} +unsafe impl Send for Foo {} + +trait WithAssoc { + type Output; +} +impl WithAssoc for T { + type Output = Self; +} +impl WithAssoc for Foo { + type Output = Box; +} + +fn generic(v: Foo, f: fn( as WithAssoc>::Output) -> i32) { + //~^ ERROR `Foo` cannot be sent between threads safely + f(foo(v)); +} + +fn foo(x: T) -> ::Output { + x +} + +fn main() { + generic(Foo(Always(0, ())), |b| *b); +} -- cgit v1.2.3