Skip to content

Commit 75cc9cd

Browse files
committed
Add test for #100246.
1 parent fb8636f commit 75cc9cd

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/test/ui/typeck/issue-100246.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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`.

0 commit comments

Comments
 (0)