]> git.lizzy.rs Git - rust.git/blob - tests/ui/coherence/coherence-wasm-bindgen.rs
Auto merge of #106853 - TimNN:undo-remap, r=oli-obk
[rust.git] / tests / ui / coherence / coherence-wasm-bindgen.rs
1 // Capture a coherence pattern from wasm-bindgen that we discovered as part of
2 // future-compatibility warning #56105. This pattern currently receives a lint
3 // warning but we probably want to support it long term.
4 //
5 // Key distinction: we are implementing once for `A` (take ownership) and one
6 // for `&A` (borrow).
7 //
8 // c.f. #56105
9
10 #![deny(coherence_leak_check)]
11
12 trait IntoWasmAbi {
13     fn some_method(&self) {}
14 }
15
16 trait FromWasmAbi {}
17 trait RefFromWasmAbi {}
18 trait ReturnWasmAbi {}
19
20 impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn Fn(A) -> R + 'b)
21 where
22     A: FromWasmAbi,
23     R: ReturnWasmAbi,
24 {
25 }
26
27 // Explicitly writing the bound lifetime.
28 impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn for<'x> Fn(&'x A) -> R + 'b)
29 where
30     A: RefFromWasmAbi,
31     R: ReturnWasmAbi,
32 {
33     //~^^^^^ ERROR conflicting implementation
34     //~| WARNING this was previously accepted
35 }
36
37 fn main() {}