]> git.lizzy.rs Git - rust.git/commitdiff
Normalize field access types during borrowck
authorMichael Goulet <michael@errs.io>
Sun, 23 Jan 2022 04:04:44 +0000 (20:04 -0800)
committerMichael Goulet <michael@errs.io>
Sun, 23 Jan 2022 04:05:05 +0000 (20:05 -0800)
compiler/rustc_borrowck/src/type_check/mod.rs
src/test/ui/generic-associated-types/issue-93141.rs [new file with mode: 0644]

index b6f5f4998a643b3600a5b836d2ada79f3603cf71..73103643e3e16f2253edb83e036f440c25aa8930 100644 (file)
@@ -758,6 +758,7 @@ fn sanitize_projection(
             },
             ProjectionElem::Field(field, fty) => {
                 let fty = self.sanitize_type(place, fty);
+                let fty = self.cx.normalize(fty, location);
                 match self.field_ty(place, base, field, location) {
                     Ok(ty) => {
                         let ty = self.cx.normalize(ty, location);
diff --git a/src/test/ui/generic-associated-types/issue-93141.rs b/src/test/ui/generic-associated-types/issue-93141.rs
new file mode 100644 (file)
index 0000000..39ca77d
--- /dev/null
@@ -0,0 +1,25 @@
+// check-pass
+
+#![feature(generic_associated_types)]
+
+pub trait Fooey: Sized {
+    type Context<'c> where Self: 'c;
+}
+
+pub struct Handle<E: Fooey>(Option<Box<dyn for<'c> Fn(&mut E::Context<'c>)>>);
+
+fn tuple<T>() -> (Option<T>,) { (Option::None,) }
+
+pub struct FooImpl {}
+impl Fooey for FooImpl {
+    type Context<'c> = &'c ();
+}
+
+impl FooImpl {
+    pub fn fail1() -> Handle<Self> {
+        let (tx,) = tuple();
+        Handle(tx)
+    }
+}
+
+fn main() {}