File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/issue-50687-ice-on-borrow.rs:40:17
3+ |
4+ LL | let _: () = Borrow::borrow(&owned);
5+ | -- ^^^^^^^^^^^^^^^^^^^^^^
6+ | | |
7+ | | expected `()`, found reference
8+ | | help: consider dereferencing the borrow: `*Borrow::borrow(&owned)`
9+ | expected due to this
10+ |
11+ = note: expected unit type `()`
12+ found reference `&_`
13+
14+ error: aborting due to previous error
15+
16+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments