Skip to content

Commit 83e6128

Browse files
Better binder treatment
1 parent 4136b59 commit 83e6128

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2765,7 +2765,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
27652765
where
27662766
T: relate::Relate<'tcx>,
27672767
{
2768-
Ok(ty::Binder::dummy(self.relate(a.skip_binder(), b.skip_binder())?))
2768+
Ok(a.rebind(self.relate(a.skip_binder(), b.skip_binder())?))
27692769
}
27702770

27712771
fn consts(
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use std::marker::PhantomData;
2+
3+
type Component = fn(&());
4+
5+
struct Wrapper {
6+
router: Router<(Component, Box<Self>)>,
7+
}
8+
9+
struct Match<C>(PhantomData<C>);
10+
11+
struct Router<T>(PhantomData<T>);
12+
13+
impl<T> Router<T> {
14+
pub fn at(&self) -> Result<Match<&T>, ()> {
15+
todo!()
16+
}
17+
}
18+
19+
impl Wrapper {
20+
fn at(&self, path: &str) -> Result<(Component, Box<Self>), ()> {
21+
let (cmp, router) = self.router.at()?;
22+
//~^ ERROR mismatched types
23+
todo!()
24+
}
25+
}
26+
27+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-101984.rs:21:13
3+
|
4+
LL | let (cmp, router) = self.router.at()?;
5+
| ^^^^^^^^^^^^^ ----------------- this expression has type `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>`
6+
| |
7+
| expected struct `Match`, found tuple
8+
|
9+
= note: expected struct `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>`
10+
found tuple `(_, _)`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)