diff options
| author | Michael Goulet <michael@errs.io> | 2022-09-20 16:39:39 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-09-20 16:39:39 +0000 |
| commit | 83e6128b577649384ef4bd137223bcffe5c8a5b0 (patch) | |
| tree | 026681193f99aef7ae81a7dd4e73c86a01322207 | |
| parent | 4136b59b7da8866762761ed29405a5c5f58a5e3d (diff) | |
| download | rust-83e6128b577649384ef4bd137223bcffe5c8a5b0.tar.gz rust-83e6128b577649384ef4bd137223bcffe5c8a5b0.zip | |
Better binder treatment
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/mod.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-101984.rs | 27 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-101984.stderr | 14 |
3 files changed, 42 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 546ab82bc23..18255a5089c 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -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( diff --git a/src/test/ui/suggestions/issue-101984.rs b/src/test/ui/suggestions/issue-101984.rs new file mode 100644 index 00000000000..5f7ecb77e0e --- /dev/null +++ b/src/test/ui/suggestions/issue-101984.rs @@ -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() {} diff --git a/src/test/ui/suggestions/issue-101984.stderr b/src/test/ui/suggestions/issue-101984.stderr new file mode 100644 index 00000000000..c744c62d11f --- /dev/null +++ b/src/test/ui/suggestions/issue-101984.stderr @@ -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`. |
