Skip to content

Commit

Permalink
Better binder treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Sep 20, 2022
1 parent 4136b59 commit 83e6128
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
where
T: relate::Relate<'tcx>,
{
Ok(ty::Binder::dummy(self.relate(a.skip_binder(), b.skip_binder())?))
Ok(a.rebind(self.relate(a.skip_binder(), b.skip_binder())?))
}

fn consts(
Expand Down
27 changes: 27 additions & 0 deletions src/test/ui/suggestions/issue-101984.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::marker::PhantomData;

type Component = fn(&());

struct Wrapper {
router: Router<(Component, Box<Self>)>,
}

struct Match<C>(PhantomData<C>);

struct Router<T>(PhantomData<T>);

impl<T> Router<T> {
pub fn at(&self) -> Result<Match<&T>, ()> {
todo!()
}
}

impl Wrapper {
fn at(&self, path: &str) -> Result<(Component, Box<Self>), ()> {
let (cmp, router) = self.router.at()?;
//~^ ERROR mismatched types
todo!()
}
}

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/suggestions/issue-101984.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/issue-101984.rs:21:13
|
LL | let (cmp, router) = self.router.at()?;
| ^^^^^^^^^^^^^ ----------------- this expression has type `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>`
| |
| expected struct `Match`, found tuple
|
= note: expected struct `Match<&(for<'r> fn(&'r ()), Box<Wrapper>)>`
found tuple `(_, _)`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

0 comments on commit 83e6128

Please sign in to comment.