Commit graph

72 commits

Author SHA1 Message Date
Aleksey Kladov
cebeedc66f Next gen IDs for functions
The current system with AstIds has two primaraly drawbacks:

* It is possible to manufacture IDs out of thin air.
  For example, it's possible to create IDs for items which are not
  considered in CrateDefMap due to cfg. Or it is possible to mixup
  structs and unions, because they share ID space.

* Getting the ID of a parent requires a secondary index.

Instead, the plan is to pursue the more traditional approach, where
each items stores the id of the parent declaration. This makes
`FromSource` more awkward, but also more correct: now, to get from an
AST to HIR, we first do this recursively for the parent item, and the
just search the children of the parent for the matching def
2019-11-20 16:22:58 +03:00
Aleksey Kladov
06fa3d8389 Move traits to hir_def 2019-11-20 14:22:38 +03:00
Aleksey Kladov
e1a6e38767 Move Generics to hir_def 2019-11-20 12:34:48 +03:00
Aleksey Kladov
36e3fc9d54 Rename Source::ast -> Source::value 2019-11-20 09:42:30 +03:00
Aleksey Kladov
7e2f4b30db Disable doctests 2019-11-17 18:35:05 +03:00
Aleksey Kladov
892671926b Remove wrong clone 2019-11-16 01:00:00 +03:00
Aleksey Kladov
4c90b7e2ec Sourcify some things
If we want to support macros properly, we need to get rid of those
FileIds everywhere...
2019-11-15 23:24:56 +03:00
Aleksey Kladov
b21829f7ed Remove old impls infrastructure 2019-11-15 21:35:03 +03:00
Aleksey Kladov
ea3540c1a8 Store impls in CrateDefMap 2019-11-15 21:19:32 +03:00
Aleksey Kladov
080dd31f84 Add ImplId 2019-11-15 21:19:32 +03:00
Aleksey Kladov
aeb5e061a8 Reduce visibility 2019-11-15 21:19:32 +03:00
Aleksey Kladov
2f6c0c314b Move scope tests to hir_def 2019-11-15 14:47:26 +03:00
Aleksey Kladov
5766ceab06 Add convenience method for testing 2019-11-15 13:16:30 +03:00
Aleksey Kladov
a28907af8c Privatize modules 2019-11-15 10:42:54 +03:00
Aleksey Kladov
9c7a2aef30 Refactor Module::from_source to properly descend from root file 2019-11-15 10:26:31 +03:00
Aleksey Kladov
1583ab1558 Move body queries to hir_def 2019-11-14 17:37:22 +03:00
Aleksey Kladov
f924ae3b86 Move scopes to hir_def 2019-11-14 11:56:13 +03:00
Aleksey Kladov
4efd345b09 Slightly better naming 2019-11-14 11:33:48 +03:00
Aleksey Kladov
da2ca01eba Handle macro-generated expressions slightly less wrong 2019-11-14 10:30:30 +03:00
Aleksey Kladov
a73b7bb3f6 Move expansion to Expander 2019-11-14 10:04:39 +03:00
Aleksey Kladov
5c720b256f Move parse_path to Expander 2019-11-14 09:58:39 +03:00
Aleksey Kladov
e7880db1d0 Expansion stack scaffold 2019-11-14 09:57:57 +03:00
Aleksey Kladov
c89010df2d Add Expader::to_source 2019-11-14 09:57:57 +03:00
Aleksey Kladov
e7e85c60d2 Move original_file to Expander 2019-11-14 09:55:24 +03:00
Aleksey Kladov
8c8ef1432e Rename MacroResolver -> Expander 2019-11-14 09:38:25 +03:00
Aleksey Kladov
b3175b7077 Move current file to MacroResolver 2019-11-14 09:37:33 +03:00
Aleksey Kladov
debf95eb1b Reduce visibility 2019-11-14 09:24:39 +03:00
Aleksey Kladov
fe5e74e083 Add helpful pointer to module docs 2019-11-12 18:53:26 +03:00
Aleksey Kladov
1c0a3a1a30 Drop obsolete comment 2019-11-12 18:51:37 +03:00
Aleksey Kladov
1a90ad5802 Move expression lowering to hir_def 2019-11-12 18:46:57 +03:00
Aleksey Kladov
d09e5a3d9e Move definition of exprs to hir_def 2019-11-12 15:09:25 +03:00
Aleksey Kladov
f5e1b0f97c Minor refactoring 2019-11-12 12:07:47 +03:00
bors[bot]
ef2a9aedb6
Merge #2205
2205: Implement bulitin line! macro r=matklad a=edwin0cheng

This PR implements bulitin macro `line!` and add basic infra-structure for other bulitin macros:

1. Extend `MacroDefId` to support builtin macros
2. Add a `quote!` macro for simple quasi quoting.

Note that for support others builtin macros, eager macro expansion have to be supported first, this PR not try to handle it. :)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-11 10:53:24 +00:00
Edwin Cheng
4f7df2aac1 Add MacroDefKind 2019-11-11 18:48:16 +08:00
Aleksey Kladov
5bb92c2d1a impl fmt::Display for BuiltinType 2019-11-11 11:59:19 +03:00
Edwin Cheng
c46768d13d Add basic bultin macro infrastructure 2019-11-11 14:13:31 +08:00
Matthias Einwag
d634364462 Overwrite the prelude with one defined in a later dependency
This removes the special casing for the "core" prelude.
Whenever a later dependency also exports a prelude, it will replace
the formerly imported prelude.  The utilized prelude then depends
purely on import order.
2019-11-10 13:15:47 -08:00
Matthias Einwag
8baa05666c Add tests for resolving types in core and std preludes 2019-11-09 17:38:08 -08:00
Matthias Einwag
799903ba16 Resolve core types
This adds support for completion and goto definition of
types defined within the "core" crate. The core crate is
added as a dependency to each crate in the project.

The core crate exported it's own prelude. This caused
now all crates to inherit the core crates prelude instead
of the std crates. In order to avoid the problem the
prelude resolution has been changed to overwrite
an already resolved prelude if this was set to a crate
named core - in order to pick a better prelude like std.

Fixes #2199
2019-11-09 15:22:19 -08:00
Aleksey Kladov
6294fd5ec9 Unfork struct and union ids 2019-11-09 15:34:00 +03:00
Aleksey Kladov
c626a677e8 Touch up nameres doc comment 2019-11-09 00:23:19 +03:00
Aleksey Kladov
657340e078 Reduce visibility 2019-11-09 00:23:11 +03:00
Aleksey Kladov
53945841be Extract path resolution submodule 2019-11-09 00:17:17 +03:00
Aleksey Kladov
785887b382 Simplify
There's only one call-site for the function, so it seems fine to
inline
2019-11-08 23:53:39 +03:00
Aleksey Kladov
dc5e5f610c Reduce visibility 2019-11-08 23:47:52 +03:00
Aleksey Kladov
93d9e8a06f Reduce visibility 2019-11-04 23:37:35 +03:00
Aleksey Kladov
739babc391 Move Namespace enum closer to usage 2019-11-04 23:02:35 +03:00
Aleksey Kladov
d04ecc8419 Reduce visibility 2019-11-04 21:42:25 +03:00
Aleksey Kladov
3603d02134 Reexport relative_path from ra_db 2019-11-04 01:14:17 +03:00
Aleksey Kladov
8922a44395 Add small module-level docs 2019-11-04 00:23:14 +03:00