]> git.lizzy.rs Git - rust.git/commitdiff
resolve: Allow idents to resolve to primitives in the type namespace
authorGabriel Smith <gsmith@d3engineering.com>
Mon, 18 Nov 2019 19:22:00 +0000 (14:22 -0500)
committerGabriel Smith <gsmith@d3engineering.com>
Mon, 18 Nov 2019 22:01:33 +0000 (17:01 -0500)
src/librustc_resolve/lib.rs

index 8f6bb91f028c3d1d70b8c13bf10eb42e576a8f8a..c49db39643bc799639676cd117a880c54b4497fd 100644 (file)
@@ -1726,6 +1726,14 @@ fn resolve_ident_in_lexical_scope(&mut self,
             }
         }
 
+        if ns == TypeNS {
+            if let Some(prim_ty) = self.primitive_type_table.primitive_types.get(&ident.name) {
+                let binding = (Res::PrimTy(*prim_ty), ty::Visibility::Public,
+                               DUMMY_SP, ExpnId::root()).to_name_binding(self.arenas);
+                return Some(LexicalScopeBinding::Item(binding));
+            }
+        }
+
         None
     }