This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ recursion_limit = "5" ] // To reduce noise
2+
3+ //expect incompatible type error when ambiguous traits are in scope
4+ //and not an overflow error on the span in the main function.
5+
6+ struct Ratio < T > ( T ) ;
7+
8+ pub trait Pow {
9+ fn pow ( self ) -> Self ;
10+ }
11+
12+ impl < ' a , T > Pow for & ' a Ratio < T >
13+ where
14+ & ' a T : Pow ,
15+ {
16+ fn pow ( self ) -> Self {
17+ self
18+ }
19+ }
20+
21+ fn downcast < ' a , W : ?Sized > ( ) -> std:: io:: Result < & ' a W > {
22+ todo ! ( )
23+ }
24+
25+ struct Other ;
26+
27+ fn main ( ) -> std:: io:: Result < ( ) > {
28+ let other: Other = downcast ( ) ?; //~ERROR 28:24: 28:35: `?` operator has incompatible types
29+ Ok ( ( ) )
30+ }
Original file line number Diff line number Diff line change 1+ error[E0308]: `?` operator has incompatible types
2+ --> $DIR/issue-100246.rs:28:24
3+ |
4+ LL | let other: Other = downcast()?;
5+ | ^^^^^^^^^^^ expected struct `Other`, found reference
6+ |
7+ = note: `?` operator cannot convert from `&_` to `Other`
8+ = note: expected struct `Other`
9+ found reference `&_`
10+
11+ error: aborting due to previous error
12+
13+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments