]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-50687-ice-on-borrow.rs
Require Drop impls to have the same constness on its bounds as the bounds on the...
[rust.git] / src / test / ui / issues / issue-50687-ice-on-borrow.rs
1 // This previously caused an ICE at:
2 // librustc/traits/structural_impls.rs:180: impossible case reached
3
4 #![no_main]
5
6 use std::borrow::Borrow;
7 use std::io;
8 use std::io::Write;
9
10 trait Constraint {}
11
12 struct Container<T> {
13     t: T,
14 }
15
16 struct Borrowed;
17 struct Owned;
18
19 impl<'a, T> Write for &'a Container<T>
20 where
21     T: Constraint,
22     &'a T: Write,
23 {
24     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
25         Ok(buf.len())
26     }
27
28     fn flush(&mut self) -> io::Result<()> {
29         Ok(())
30     }
31 }
32
33 impl Borrow<Borrowed> for Owned {
34     fn borrow(&self) -> &Borrowed {
35         &Borrowed
36     }
37 }
38
39 fn func(owned: Owned) {
40     let _: () = Borrow::borrow(&owned); //~ ERROR mismatched types
41 }