Skip to content

Commit

Permalink
Rollup merge of rust-lang#102059 - compiler-errors:issue-101984, r=ja…
Browse files Browse the repository at this point in the history
…ckh726

Use rebind instead of dummy binder in `SameTypeModuloInfer` relation

Lazy binder usage (sorry, my fault) + assertion in `Binder::dummy`

Fixes rust-lang#101984
  • Loading branch information
Dylan-DPC authored Sep 21, 2022
2 parents 77d063b + 83e6128 commit 39bb2a7
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 39bb2a7

Please sign in to comment.