]> git.lizzy.rs Git - rust.git/commitdiff
Better binder treatment
authorMichael Goulet <michael@errs.io>
Tue, 20 Sep 2022 16:39:39 +0000 (16:39 +0000)
committerMichael Goulet <michael@errs.io>
Tue, 20 Sep 2022 16:39:39 +0000 (16:39 +0000)
compiler/rustc_infer/src/infer/error_reporting/mod.rs
src/test/ui/suggestions/issue-101984.rs [new file with mode: 0644]
src/test/ui/suggestions/issue-101984.stderr [new file with mode: 0644]

index 546ab82bc238a75ca4f3f88361da2486014bcc45..18255a5089c8d6544d48276610c9120c7a8c9f50 100644 (file)
@@ -2765,7 +2765,7 @@ fn binders<T>(
     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 (file)
index 0000000..5f7ecb7
--- /dev/null
@@ -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 (file)
index 0000000..c744c62
--- /dev/null
@@ -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`.