version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
"autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure_derive"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.1.0"
dependencies = [
"crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "libc"
-version = "0.2.45"
+version = "0.2.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "parking_lot"
-version = "0.6.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "parking_lot"
-version = "0.7.0"
+version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
-[[package]]
-name = "parking_lot_core"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
[[package]]
name = "parking_lot_core"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_db 0.1.0",
"ra_editor 0.1.0",
"ra_hir 0.1.0",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "salsa 0.9.0 (git+https://github.com/matklad/salsa.git?branch=transitive-untracked)",
+ "salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
"unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.1.0"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_editor 0.1.0",
"ra_syntax 0.1.0",
name = "ra_db"
version = "0.1.0"
dependencies = [
- "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_editor 0.1.0",
"ra_syntax 0.1.0",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "salsa 0.9.0 (git+https://github.com/matklad/salsa.git?branch=transitive-untracked)",
+ "salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
]
"ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"flexi_logger 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_arena 0.1.0",
"ra_db 0.1.0",
"ra_editor 0.1.0",
"ra_syntax 0.1.0",
"relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "salsa 0.9.0 (git+https://github.com/matklad/salsa.git?branch=transitive-untracked)",
+ "salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
]
"cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"flexi_logger 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
"gen_lsp_server 0.1.0",
"im 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_analysis 0.1.0",
"ra_editor 0.1.0",
"ra_syntax 0.1.0",
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_text_edit 0.1.0",
- "rowan 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rowan 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"test_utils 0.1.0",
"text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
dependencies = [
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
-version = "0.6.1"
+version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_os 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_chacha"
-version = "0.1.0"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "rand_os"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "rand_pcg"
version = "0.1.1"
[[package]]
name = "rand_xorshift"
-version = "0.1.0"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rowan"
-version = "0.1.3"
+version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"smol_str 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-demangle"
-version = "0.1.11"
+version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
[[package]]
name = "salsa"
-version = "0.9.0"
-source = "git+https://github.com/matklad/salsa.git?branch=transitive-untracked#a2198f1f8a1d09894b842035a1af6b0b4c133c93"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "failure 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)",
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.1.0"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "failure 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"teraron 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00"
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
-"checksum failure 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e945b93ec214c6e97b520ec6c5d80267fc97af327658ee5b9f35984626e51fbf"
-"checksum failure_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7c395a14ab27b42704e85bf2435c5c51f334ad7a96e16fe23c6e63a1cad6cc12"
+"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
+"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum flexi_logger 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dda06444ccc8b0a6da19d939989b4a4e83f328710ada449eedaed48c8b903cd"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum join_to_string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7bddc885f3fd69dd4b5d747c2efe6dd2c36d795ea9938281ed50910e32c95e31"
"checksum languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c01845f71b8b3b3557a8179af4434a4b2570829da12371f05272d28183a06ce"
"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
-"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74"
+"checksum libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)" = "023a4cd09b2ff695f9734c1934145a315594b7986398496841c7031a5a1bbdbd"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
"checksum num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5a69d464bdc213aaaff628444e99578ede64e9c854025aa43b9796530afa9238"
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
-"checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"
-"checksum parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9723236a9525c757d9725b993511e3fc941e33f27751942232f0058298297edf"
-"checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c"
+"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54f0c72a98d8ab3c99560bfd16df8059cc10e1f9a8e83e6e3b97718dd766e9c3"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
-"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a"
-"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a"
+"checksum rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b65e163105a6284f841bd23100a015895f54340e88a5ffc9ca7b8b33827cfce0"
+"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
+"checksum rand_os 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de5ac4de1c2973e1391dc305cb0fbf8788cb58068e98255439b7485a77022273"
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
-"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3"
+"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
"checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473"
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2"
"checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c48677d8a9247a4e0d1f3f9cb4b0a8e29167fdc3c04f383a5e669cd7a960ae0f"
-"checksum rowan 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a9ccca91953e9c549cac18e8f41daa5d49dad1c9a4c9bb977ac42718bb34e1bf"
-"checksum rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "01b90379b8664dd83460d59bdc5dd1fd3172b8913788db483ed1325171eab2f7"
+"checksum rowan 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c218b4430ab922850b71b14fa9bca224425097f935f6155c0b6a4b1f398a54f0"
+"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
-"checksum salsa 0.9.0 (git+https://github.com/matklad/salsa.git?branch=transitive-untracked)" = "<none>"
+"checksum salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "442ef4acdb48c0e24ddaf4f3b62555af2d1da7047f2f26acd54ae73010aa0c02"
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
debug = true
[patch.'crates-io']
-salsa = { git = "https://github.com/matklad/salsa.git", branch = "transitive-untracked" }
relative-path = "0.4.0"
rayon = "1.0.2"
fst = "0.3.1"
-salsa = "0.9.0"
+salsa = "0.9.1"
rustc-hash = "1.0"
parking_lot = "0.7.0"
unicase = "2.2.0"
);
}
+ #[test]
+ fn test_struct_field_completion_self() {
+ check_ref_completion(
+ r"
+ struct A { the_field: u32 }
+ impl A {
+ fn foo(self) {
+ self.<|>
+ }
+ }
+ ",
+ r#"the_field"#,
+ );
+ }
+
#[test]
fn test_no_struct_field_completion_for_method_call() {
check_ref_completion(
fn type_for_field() for hir::db::TypeForFieldQuery;
fn struct_data() for hir::db::StructDataQuery;
fn enum_data() for hir::db::EnumDataQuery;
+ fn impls_in_module() for hir::db::ImplsInModuleQuery;
}
}
}
use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER};
use ra_db::mock::FileMap;
-use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FilePosition, FileRange, SourceRootId};
+use crate::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, FilePosition, FileRange, SourceRootId};
/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis
/// from a set of in-memory files.
let source_root = SourceRootId(0);
let mut change = AnalysisChange::new();
change.add_root(source_root, true);
+ let mut crate_graph = CrateGraph::default();
for (path, contents) in self.files.into_iter() {
assert!(path.starts_with('/'));
let path = RelativePathBuf::from_path(&path[1..]).unwrap();
let file_id = file_map.add(path.clone());
+ if path == "/lib.rs" || path == "/main.rs" {
+ crate_graph.add_crate_root(file_id);
+ }
change.add_file(source_root, file_id, path, Arc::new(contents));
}
+ change.set_crate_graph(crate_graph);
// change.set_file_resolver(Arc::new(file_map));
host.apply_change(change);
host
fn test_resolve_crate_root() {
let mock = MockAnalysis::with_files(
"
- //- /lib.rs
+ //- /bar.rs
mod foo;
- //- /foo.rs
+ //- /bar/foo.rs
// emtpy <|>
",
);
- let root_file = mock.id_of("/lib.rs");
- let mod_file = mock.id_of("/foo.rs");
+ let root_file = mock.id_of("/bar.rs");
+ let mod_file = mock.id_of("/bar/foo.rs");
let mut host = mock.analysis_host();
assert!(host.analysis().crate_for(mod_file).unwrap().is_empty());
[dependencies]
relative-path = "0.4.0"
-salsa = "0.9.0"
+salsa = "0.9.1"
rustc-hash = "1.0"
parking_lot = "0.7.0"
ra_syntax = { path = "../ra_syntax" }
.visit(decl::<ast::TypeDef>)
.visit(decl::<ast::ConstDef>)
.visit(decl::<ast::StaticDef>)
- .visit(|im: ast::ImplItem| {
+ .visit(|im: ast::ImplBlock| {
let target_type = im.target_type()?;
let target_trait = im.target_trait();
let label = match target_trait {
StructureNode { parent: None, label: "T", navigation_range: [81; 82), node_range: [76; 88), kind: TYPE_DEF },
StructureNode { parent: None, label: "S", navigation_range: [96; 97), node_range: [89; 108), kind: STATIC_DEF },
StructureNode { parent: None, label: "C", navigation_range: [115; 116), node_range: [109; 127), kind: CONST_DEF },
- StructureNode { parent: None, label: "impl E", navigation_range: [134; 135), node_range: [129; 138), kind: IMPL_ITEM },
- StructureNode { parent: None, label: "impl fmt::Debug for E", navigation_range: [160; 161), node_range: [140; 164), kind: IMPL_ITEM }]"#,
+ StructureNode { parent: None, label: "impl E", navigation_range: [134; 135), node_range: [129; 138), kind: IMPL_BLOCK },
+ StructureNode { parent: None, label: "impl fmt::Debug for E", navigation_range: [160; 161), node_range: [140; 164), kind: IMPL_BLOCK }]"#,
&structure,
)
}
arrayvec = "0.4.10"
log = "0.4.5"
relative-path = "0.4.0"
-salsa = "0.9.0"
+salsa = "0.9.1"
rustc-hash = "1.0"
parking_lot = "0.7.0"
ena = "0.11"
nameres::{ItemMap, InputModuleItems}},
ty::{InferenceResult, Ty},
adt::{StructData, EnumData},
+ impl_block::ModuleImplBlocks,
};
salsa::query_group! {
type ModuleTreeQuery;
use fn crate::module::imp::module_tree;
}
+
+ fn impls_in_module(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<ModuleImplBlocks>> {
+ type ImplsInModuleQuery;
+ use fn crate::impl_block::impls_in_module;
+ }
}
}
ast::{self, AstNode, DocCommentsOwner, NameOwner},
};
-use crate::{DefId, DefKind, HirDatabase, ty::InferenceResult, Module};
+use crate::{DefId, DefKind, HirDatabase, ty::InferenceResult, Module, Crate, impl_block::ImplBlock};
pub use self::scope::FnScopes;
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Function {
def_id: DefId,
}
Function { def_id }
}
+ pub fn def_id(&self) -> DefId {
+ self.def_id
+ }
+
pub fn syntax(&self, db: &impl HirDatabase) -> ast::FnDefNode {
let def_loc = self.def_id.loc(db);
assert!(def_loc.kind == DefKind::Function);
pub fn module(&self, db: &impl HirDatabase) -> Cancelable<Module> {
self.def_id.module(db)
}
+
+ pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> {
+ self.def_id.krate(db)
+ }
+
+ /// The containing impl block, if this is a method.
+ pub fn impl_block(&self, db: &impl HirDatabase) -> Cancelable<Option<ImplBlock>> {
+ self.def_id.impl_block(db)
+ }
}
#[derive(Debug, Clone)]
use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, SourceFile, AstNode, ast};
use ra_arena::{Arena, RawId, impl_arena_id};
-use crate::{HirDatabase, PerNs, ModuleId, Module, Def, Function, Struct, Enum};
+use crate::{HirDatabase, PerNs, ModuleId, Module, Def, Function, Struct, Enum, ImplBlock, Crate};
/// hir makes a heavy use of ids: integer (u32) handlers to various things. You
/// can think of id as a pointer (but without a lifetime) or a file descriptor
let loc = self.loc(db);
Module::new(db, loc.source_root_id, loc.module_id)
}
+
+ /// Returns the containing crate.
+ pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> {
+ Ok(self.module(db)?.krate(db))
+ }
+
+ /// Returns the containing impl block, if this is an impl item.
+ pub fn impl_block(self, db: &impl HirDatabase) -> Cancelable<Option<ImplBlock>> {
+ let loc = self.loc(db);
+ let module_impls = db.impls_in_module(loc.source_root_id, loc.module_id)?;
+ Ok(ImplBlock::containing(module_impls, self))
+ }
}
impl DefLoc {
--- /dev/null
+use std::sync::Arc;
+use rustc_hash::FxHashMap;
+
+use ra_arena::{Arena, RawId, impl_arena_id};
+use ra_syntax::ast::{self, AstNode};
+use ra_db::{LocationIntener, Cancelable, SourceRootId};
+
+use crate::{
+ DefId, DefLoc, DefKind, SourceItemId, SourceFileItems,
+ Module, Function,
+ db::HirDatabase,
+ type_ref::TypeRef,
+ module::{ModuleSourceNode, ModuleId},
+};
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ImplBlock {
+ module_impl_blocks: Arc<ModuleImplBlocks>,
+ impl_id: ImplId,
+}
+
+impl ImplBlock {
+ pub(crate) fn containing(
+ module_impl_blocks: Arc<ModuleImplBlocks>,
+ def_id: DefId,
+ ) -> Option<ImplBlock> {
+ let impl_id = *module_impl_blocks.impls_by_def.get(&def_id)?;
+ Some(ImplBlock {
+ module_impl_blocks,
+ impl_id,
+ })
+ }
+
+ fn impl_data(&self) -> &ImplData {
+ &self.module_impl_blocks.impls[self.impl_id]
+ }
+
+ pub fn target_trait(&self) -> Option<&TypeRef> {
+ self.impl_data().target_trait.as_ref()
+ }
+
+ pub fn target_type(&self) -> &TypeRef {
+ &self.impl_data().target_type
+ }
+
+ pub fn items(&self) -> &[ImplItem] {
+ &self.impl_data().items
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ImplData {
+ target_trait: Option<TypeRef>,
+ target_type: TypeRef,
+ items: Vec<ImplItem>,
+}
+
+impl ImplData {
+ pub(crate) fn from_ast(
+ db: &impl AsRef<LocationIntener<DefLoc, DefId>>,
+ file_items: &SourceFileItems,
+ module: &Module,
+ node: ast::ImplBlock,
+ ) -> Self {
+ let target_trait = node.target_type().map(TypeRef::from_ast);
+ let target_type = TypeRef::from_ast_opt(node.target_type());
+ let file_id = module.source().file_id();
+ let items = if let Some(item_list) = node.item_list() {
+ item_list
+ .impl_items()
+ .map(|item_node| {
+ let kind = match item_node {
+ ast::ImplItem::FnDef(..) => DefKind::Function,
+ ast::ImplItem::ConstDef(..) => DefKind::Item,
+ ast::ImplItem::TypeDef(..) => DefKind::Item,
+ };
+ let item_id = file_items.id_of_unchecked(item_node.syntax());
+ let def_loc = DefLoc {
+ kind,
+ source_root_id: module.source_root_id,
+ module_id: module.module_id,
+ source_item_id: SourceItemId {
+ file_id,
+ item_id: Some(item_id),
+ },
+ };
+ let def_id = def_loc.id(db);
+ match item_node {
+ ast::ImplItem::FnDef(..) => ImplItem::Method(Function::new(def_id)),
+ ast::ImplItem::ConstDef(..) => ImplItem::Const(def_id),
+ ast::ImplItem::TypeDef(..) => ImplItem::Type(def_id),
+ }
+ })
+ .collect()
+ } else {
+ Vec::new()
+ };
+ ImplData {
+ target_trait,
+ target_type,
+ items,
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum ImplItem {
+ Method(Function),
+ // these don't have their own types yet
+ Const(DefId),
+ Type(DefId),
+ // Existential
+}
+
+impl ImplItem {
+ pub fn def_id(&self) -> DefId {
+ match self {
+ ImplItem::Method(f) => f.def_id(),
+ ImplItem::Const(def_id) => *def_id,
+ ImplItem::Type(def_id) => *def_id,
+ }
+ }
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
+pub struct ImplId(pub RawId);
+impl_arena_id!(ImplId);
+
+/// Collection of impl blocks is a two-step process: First we collect the blocks
+/// per-module; then we build an index of all impl blocks in the crate. This
+/// way, we avoid having to do this process for the whole crate whenever someone
+/// types in any file; as long as the impl blocks in the file don't change, we
+/// don't need to do the second step again.
+///
+/// (The second step does not yet exist currently.)
+#[derive(Debug, PartialEq, Eq)]
+pub struct ModuleImplBlocks {
+ impls: Arena<ImplId, ImplData>,
+ impls_by_def: FxHashMap<DefId, ImplId>,
+}
+
+impl ModuleImplBlocks {
+ fn new() -> Self {
+ ModuleImplBlocks {
+ impls: Arena::default(),
+ impls_by_def: FxHashMap::default(),
+ }
+ }
+
+ fn collect(&mut self, db: &impl HirDatabase, module: Module) -> Cancelable<()> {
+ let module_source_node = module.source().resolve(db);
+ let node = match &module_source_node {
+ ModuleSourceNode::SourceFile(node) => node.borrowed().syntax(),
+ ModuleSourceNode::Module(node) => node.borrowed().syntax(),
+ };
+
+ let source_file_items = db.file_items(module.source().file_id());
+
+ for impl_block_ast in node.children().filter_map(ast::ImplBlock::cast) {
+ let impl_block = ImplData::from_ast(db, &source_file_items, &module, impl_block_ast);
+ let id = self.impls.alloc(impl_block);
+ for impl_item in &self.impls[id].items {
+ self.impls_by_def.insert(impl_item.def_id(), id);
+ }
+ }
+
+ Ok(())
+ }
+}
+
+pub(crate) fn impls_in_module(
+ db: &impl HirDatabase,
+ source_root_id: SourceRootId,
+ module_id: ModuleId,
+) -> Cancelable<Arc<ModuleImplBlocks>> {
+ let mut result = ModuleImplBlocks::new();
+ let module = Module::new(db, source_root_id, module_id)?;
+ result.collect(db, module)?;
+ Ok(Arc::new(result))
+}
/// hir::Crate describes a single crate. It's the main inteface with which
/// crate's dependencies interact. Mostly, it should be just a proxy for the
/// root module.
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Crate {
crate_id: CrateId,
}
mod adt;
mod type_ref;
mod ty;
+mod impl_block;
use crate::{
db::HirDatabase,
function::{Function, FnScopes},
adt::{Struct, Enum},
ty::Ty,
+ impl_block::{ImplBlock, ImplItem},
};
pub use self::function::FnSignatureInfo;
let file_id = db.add_file(&mut source_root, "/main.rs", text);
db.query_mut(ra_db::SourceRootQuery)
.set(WORKSPACE, Arc::new(source_root.clone()));
+
+ let mut crate_graph = CrateGraph::default();
+ crate_graph.add_crate_root(file_id);
+ db.set_crate_graph(crate_graph);
(db, source_root, file_id)
}
fn type_for_field() for db::TypeForFieldQuery;
fn struct_data() for db::StructDataQuery;
fn enum_data() for db::EnumDataQuery;
+ fn impls_in_module() for db::ImplsInModuleQuery;
}
}
}
})
}
+ /// Returns an iterator of all children of this module.
+ pub fn children<'a>(&'a self) -> impl Iterator<Item = (Name, Module)> + 'a {
+ self.module_id
+ .children(&self.tree)
+ .map(move |(name, module_id)| {
+ (
+ name,
+ Module {
+ module_id,
+ ..self.clone()
+ },
+ )
+ })
+ }
+
/// Returns the crate this module is part of.
pub fn krate(&self, db: &impl HirDatabase) -> Option<Crate> {
let root_id = self.module_id.crate_root(&self.tree);
ast::ModuleItem::TypeDef(it) => {
self.items.push(ModuleItem::new(file_id, file_items, it)?)
}
- ast::ModuleItem::ImplItem(_) => {
+ ast::ModuleItem::ImplBlock(_) => {
// impls don't define items
}
ast::ModuleItem::UseItem(it) => self.add_use_item(file_items, it),
"u128" => KnownName::U128,
"f32" => KnownName::F32,
"f64" => KnownName::F64,
+ "Self" => KnownName::Self_,
_ => return None,
};
Some(name)
// const ISIZE: Name = Name::new("isize")
// ```
// but const-fn is not that powerful yet.
-#[derive(Debug)]
+#[derive(Debug, PartialEq, Eq)]
pub(crate) enum KnownName {
Isize,
I8,
F32,
F64,
+
+ Self_,
}
self.kind == PathKind::Plain && self.segments.len() == 1
}
+ /// `true` if this path is just a standalone `self`
+ pub fn is_self(&self) -> bool {
+ self.kind == PathKind::Self_ && self.segments.len() == 0
+ }
+
/// If this path is a single identifier, like `foo`, return its name.
pub fn as_ident(&self) -> Option<&Name> {
if self.kind != PathKind::Plain || self.segments.len() > 1 {
};
use crate::{
- Def, DefId, FnScopes, Module, Function, Struct, Enum, Path, Name, AsName,
+ Def, DefId, FnScopes, Module, Function, Struct, Enum, Path, Name, AsName, ImplBlock,
db::HirDatabase,
type_ref::{TypeRef, Mutability},
+ name::KnownName,
};
/// The ID of a type variable.
pub(crate) fn from_hir(
db: &impl HirDatabase,
module: &Module,
+ impl_block: Option<&ImplBlock>,
type_ref: &TypeRef,
) -> Cancelable<Self> {
Ok(match type_ref {
TypeRef::Tuple(inner) => {
let inner_tys = inner
.iter()
- .map(|tr| Ty::from_hir(db, module, tr))
+ .map(|tr| Ty::from_hir(db, module, impl_block, tr))
.collect::<Cancelable<Vec<_>>>()?;
Ty::Tuple(inner_tys.into())
}
- TypeRef::Path(path) => Ty::from_hir_path(db, module, path)?,
+ TypeRef::Path(path) => Ty::from_hir_path(db, module, impl_block, path)?,
TypeRef::RawPtr(inner, mutability) => {
- let inner_ty = Ty::from_hir(db, module, inner)?;
+ let inner_ty = Ty::from_hir(db, module, impl_block, inner)?;
Ty::RawPtr(Arc::new(inner_ty), *mutability)
}
TypeRef::Array(_inner) => Ty::Unknown, // TODO
TypeRef::Slice(inner) => {
- let inner_ty = Ty::from_hir(db, module, inner)?;
+ let inner_ty = Ty::from_hir(db, module, impl_block, inner)?;
Ty::Slice(Arc::new(inner_ty))
}
TypeRef::Reference(inner, mutability) => {
- let inner_ty = Ty::from_hir(db, module, inner)?;
+ let inner_ty = Ty::from_hir(db, module, impl_block, inner)?;
Ty::Ref(Arc::new(inner_ty), *mutability)
}
TypeRef::Placeholder => Ty::Unknown,
TypeRef::Fn(params) => {
let mut inner_tys = params
.iter()
- .map(|tr| Ty::from_hir(db, module, tr))
+ .map(|tr| Ty::from_hir(db, module, impl_block, tr))
.collect::<Cancelable<Vec<_>>>()?;
let return_ty = inner_tys
.pop()
})
}
+ pub(crate) fn from_hir_opt(
+ db: &impl HirDatabase,
+ module: &Module,
+ impl_block: Option<&ImplBlock>,
+ type_ref: Option<&TypeRef>,
+ ) -> Cancelable<Self> {
+ type_ref
+ .map(|t| Ty::from_hir(db, module, impl_block, t))
+ .unwrap_or(Ok(Ty::Unknown))
+ }
+
pub(crate) fn from_hir_path(
db: &impl HirDatabase,
module: &Module,
+ impl_block: Option<&ImplBlock>,
path: &Path,
) -> Cancelable<Self> {
if let Some(name) = path.as_ident() {
return Ok(Ty::Uint(uint_ty));
} else if let Some(float_ty) = primitive::FloatTy::from_name(name) {
return Ok(Ty::Float(float_ty));
+ } else if name.as_known_name() == Some(KnownName::Self_) {
+ return Ty::from_hir_opt(db, module, None, impl_block.map(|i| i.target_type()));
}
}
pub(crate) fn from_ast_opt(
db: &impl HirDatabase,
module: &Module,
+ impl_block: Option<&ImplBlock>,
node: Option<ast::TypeRef>,
) -> Cancelable<Self> {
- node.map(|n| Ty::from_ast(db, module, n))
+ node.map(|n| Ty::from_ast(db, module, impl_block, n))
.unwrap_or(Ok(Ty::Unknown))
}
pub(crate) fn from_ast(
db: &impl HirDatabase,
module: &Module,
+ impl_block: Option<&ImplBlock>,
node: ast::TypeRef,
) -> Cancelable<Self> {
- Ty::from_hir(db, module, &TypeRef::from_ast(node))
+ Ty::from_hir(db, module, impl_block, &TypeRef::from_ast(node))
}
pub fn unit() -> Self {
fn type_for_fn(db: &impl HirDatabase, f: Function) -> Cancelable<Ty> {
let syntax = f.syntax(db);
let module = f.module(db)?;
+ let impl_block = f.impl_block(db)?;
let node = syntax.borrowed();
// TODO we ignore type parameters for now
let input = node
.param_list()
.map(|pl| {
pl.params()
- .map(|p| Ty::from_ast_opt(db, &module, p.type_ref()))
+ .map(|p| Ty::from_ast_opt(db, &module, impl_block.as_ref(), p.type_ref()))
.collect()
})
.unwrap_or_else(|| Ok(Vec::new()))?;
let output = if let Some(type_ref) = node.ret_type().and_then(|rt| rt.type_ref()) {
- Ty::from_ast(db, &module, type_ref)?
+ Ty::from_ast(db, &module, impl_block.as_ref(), type_ref)?
} else {
Ty::unit()
};
),
};
let module = def_id.module(db)?;
+ let impl_block = def_id.impl_block(db)?;
let type_ref = if let Some(tr) = variant_data.get_field_type_ref(&field) {
tr
} else {
return Ok(Ty::Unknown);
};
- Ty::from_hir(db, &module, &type_ref)
+ Ty::from_hir(db, &module, impl_block.as_ref(), &type_ref)
}
/// The result of type inference: A mapping from expressions and patterns to types.
struct InferenceContext<'a, D: HirDatabase> {
db: &'a D,
scopes: Arc<FnScopes>,
+ /// The self param for the current method, if it exists.
+ self_param: Option<LocalSyntaxPtr>,
module: Module,
+ impl_block: Option<ImplBlock>,
var_unification_table: InPlaceUnificationTable<TypeVarId>,
type_of: FxHashMap<LocalSyntaxPtr, Ty>,
+ /// The return type of the function being inferred.
+ return_ty: Ty,
}
impl<'a, D: HirDatabase> InferenceContext<'a, D> {
- fn new(db: &'a D, scopes: Arc<FnScopes>, module: Module) -> Self {
+ fn new(
+ db: &'a D,
+ scopes: Arc<FnScopes>,
+ module: Module,
+ impl_block: Option<ImplBlock>,
+ ) -> Self {
InferenceContext {
type_of: FxHashMap::default(),
var_unification_table: InPlaceUnificationTable::new(),
+ self_param: None, // set during parameter typing
+ return_ty: Ty::Unknown, // set in collect_fn_signature
db,
scopes,
module,
+ impl_block,
}
}
self.type_of.insert(LocalSyntaxPtr::new(node), ty);
}
+ fn make_ty(&self, type_ref: &TypeRef) -> Cancelable<Ty> {
+ Ty::from_hir(self.db, &self.module, self.impl_block.as_ref(), type_ref)
+ }
+
+ fn make_ty_opt(&self, type_ref: Option<&TypeRef>) -> Cancelable<Ty> {
+ Ty::from_hir_opt(self.db, &self.module, self.impl_block.as_ref(), type_ref)
+ }
+
fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool {
match (ty1, ty2) {
(Ty::Unknown, ..) => true,
let ty = self.resolve_ty_as_possible(ty.clone());
return Ok(Some(ty));
};
+ } else if path.is_self() {
+ // resolve `self` param
+ let self_param = ctry!(self.self_param);
+ let ty = ctry!(self.type_of.get(&self_param));
+ let ty = self.resolve_ty_as_possible(ty.clone());
+ return Ok(Some(ty));
};
// resolve in module
}
ast::Expr::CastExpr(e) => {
let _inner_ty = self.infer_expr_opt(e.expr(), &Expectation::none())?;
- let cast_ty = Ty::from_ast_opt(self.db, &self.module, e.type_ref())?;
+ let cast_ty = Ty::from_ast_opt(
+ self.db,
+ &self.module,
+ self.impl_block.as_ref(),
+ e.type_ref(),
+ )?;
let cast_ty = self.insert_type_vars(cast_ty);
// TODO do the coercion...
cast_ty
for stmt in node.statements() {
match stmt {
ast::Stmt::LetStmt(stmt) => {
- let decl_ty = Ty::from_ast_opt(self.db, &self.module, stmt.type_ref())?;
+ let decl_ty = Ty::from_ast_opt(
+ self.db,
+ &self.module,
+ self.impl_block.as_ref(),
+ stmt.type_ref(),
+ )?;
let decl_ty = self.insert_type_vars(decl_ty);
let ty = if let Some(expr) = stmt.initializer() {
let expr_ty = self.infer_expr(expr, &Expectation::has_type(decl_ty))?;
self.write_ty(node.syntax(), ty.clone());
Ok(ty)
}
+
+ fn collect_fn_signature(&mut self, node: ast::FnDef) -> Cancelable<()> {
+ if let Some(param_list) = node.param_list() {
+ if let Some(self_param) = param_list.self_param() {
+ let self_type = if let Some(type_ref) = self_param.type_ref() {
+ let ty = self.make_ty(&TypeRef::from_ast(type_ref))?;
+ self.insert_type_vars(ty)
+ } else {
+ // TODO this should be handled by desugaring during HIR conversion
+ let ty = self.make_ty_opt(self.impl_block.as_ref().map(|i| i.target_type()))?;
+ let ty = match self_param.flavor() {
+ ast::SelfParamFlavor::Owned => ty,
+ ast::SelfParamFlavor::Ref => Ty::Ref(Arc::new(ty), Mutability::Shared),
+ ast::SelfParamFlavor::MutRef => Ty::Ref(Arc::new(ty), Mutability::Mut),
+ };
+ self.insert_type_vars(ty)
+ };
+ if let Some(self_kw) = self_param.self_kw() {
+ let self_param = LocalSyntaxPtr::new(self_kw.syntax());
+ self.self_param = Some(self_param);
+ self.type_of.insert(self_param, self_type);
+ }
+ }
+ for param in param_list.params() {
+ let pat = if let Some(pat) = param.pat() {
+ pat
+ } else {
+ continue;
+ };
+ let ty = if let Some(type_ref) = param.type_ref() {
+ let ty = self.make_ty(&TypeRef::from_ast(type_ref))?;
+ self.insert_type_vars(ty)
+ } else {
+ // missing type annotation
+ self.new_type_var()
+ };
+ self.type_of.insert(LocalSyntaxPtr::new(pat.syntax()), ty);
+ }
+ }
+
+ self.return_ty = if let Some(type_ref) = node.ret_type().and_then(|n| n.type_ref()) {
+ let ty = self.make_ty(&TypeRef::from_ast(type_ref))?;
+ self.insert_type_vars(ty)
+ } else {
+ Ty::unit()
+ };
+
+ Ok(())
+ }
}
pub fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceResult>> {
let function = Function::new(def_id); // TODO: consts also need inference
let scopes = function.scopes(db);
let module = function.module(db)?;
- let mut ctx = InferenceContext::new(db, scopes, module);
+ let impl_block = function.impl_block(db)?;
+ let mut ctx = InferenceContext::new(db, scopes, module, impl_block);
let syntax = function.syntax(db);
let node = syntax.borrowed();
- if let Some(param_list) = node.param_list() {
- for param in param_list.params() {
- let pat = if let Some(pat) = param.pat() {
- pat
- } else {
- continue;
- };
- if let Some(type_ref) = param.type_ref() {
- let ty = Ty::from_ast(db, &ctx.module, type_ref)?;
- let ty = ctx.insert_type_vars(ty);
- ctx.type_of.insert(LocalSyntaxPtr::new(pat.syntax()), ty);
- } else {
- // TODO self param
- let type_var = ctx.new_type_var();
- ctx.type_of
- .insert(LocalSyntaxPtr::new(pat.syntax()), type_var);
- };
- }
- }
-
- let ret_ty = if let Some(type_ref) = node.ret_type().and_then(|n| n.type_ref()) {
- let ty = Ty::from_ast(db, &ctx.module, type_ref)?;
- ctx.insert_type_vars(ty)
- } else {
- Ty::unit()
- };
+ ctx.collect_fn_signature(node)?;
if let Some(block) = node.body() {
- ctx.infer_block(block, &Expectation::has_type(ret_ty))?;
+ ctx.infer_block(block, &Expectation::has_type(ctx.return_ty.clone()))?;
}
Ok(Arc::new(ctx.resolve_all()))
);
}
+#[test]
+fn infer_self() {
+ check_inference(
+ r#"
+struct S;
+
+impl S {
+ fn test(&self) {
+ self;
+ }
+ fn test2(self: &Self) {
+ self;
+ }
+}
+"#,
+ "0007_self.txt",
+ );
+}
+
fn infer(content: &str) -> String {
let (db, _, file_id) = MockDatabase::with_single_file(content);
let source_file = db.source_file(file_id);
--- /dev/null
+[50; 54) 'self': &S
+[34; 38) 'self': &S
+[40; 61) '{ ... }': ()
+[88; 109) '{ ... }': ()
+[98; 102) 'self': &S
+[75; 79) 'self': &S
SyntaxKind::TYPE_DEF => SymbolKind::TypeParameter,
SyntaxKind::STATIC_DEF => SymbolKind::Constant,
SyntaxKind::CONST_DEF => SymbolKind::Constant,
- SyntaxKind::IMPL_ITEM => SymbolKind::Object,
+ SyntaxKind::IMPL_BLOCK => SymbolKind::Object,
_ => SymbolKind::Variable,
}
}
}
}
-impl<'a> ImplItem<'a> {
+impl<'a> ImplBlock<'a> {
pub fn target_type(self) -> Option<TypeRef<'a>> {
match self.target() {
(Some(t), None) | (_, Some(t)) => Some(t),
}
}
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
+pub enum SelfParamFlavor {
+ /// self
+ Owned,
+ /// &self
+ Ref,
+ /// &mut self
+ MutRef,
+}
+
+impl<'a> SelfParam<'a> {
+ pub fn flavor(&self) -> SelfParamFlavor {
+ let borrowed = self.syntax().children().any(|n| n.kind() == AMP);
+ if borrowed {
+ // check for a `mut` coming after the & -- `mut &self` != `&mut self`
+ if self
+ .syntax()
+ .children()
+ .skip_while(|n| n.kind() != AMP)
+ .any(|n| n.kind() == MUT_KW)
+ {
+ SelfParamFlavor::MutRef
+ } else {
+ SelfParamFlavor::Ref
+ }
+ } else {
+ SelfParamFlavor::Owned
+ }
+ }
+}
+
#[test]
fn test_doc_comment_of_items() {
let file = SourceFileNode::parse(
}
}
-// ImplItem
+// ImplBlock
#[derive(Debug, Clone, Copy,)]
-pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
+pub struct ImplBlockNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
-pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>;
+pub type ImplBlock<'a> = ImplBlockNode<RefRoot<'a>>;
-impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplItemNode<R1>> for ImplItemNode<R2> {
- fn eq(&self, other: &ImplItemNode<R1>) -> bool { self.syntax == other.syntax }
+impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplBlockNode<R1>> for ImplBlockNode<R2> {
+ fn eq(&self, other: &ImplBlockNode<R1>) -> bool { self.syntax == other.syntax }
}
-impl<R: TreeRoot<RaTypes>> Eq for ImplItemNode<R> {}
-impl<R: TreeRoot<RaTypes>> Hash for ImplItemNode<R> {
+impl<R: TreeRoot<RaTypes>> Eq for ImplBlockNode<R> {}
+impl<R: TreeRoot<RaTypes>> Hash for ImplBlockNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
-impl<'a> AstNode<'a> for ImplItem<'a> {
+impl<'a> AstNode<'a> for ImplBlock<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
- IMPL_ITEM => Some(ImplItem { syntax }),
+ IMPL_BLOCK => Some(ImplBlock { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
-impl<R: TreeRoot<RaTypes>> ImplItemNode<R> {
- pub fn borrowed(&self) -> ImplItem {
- ImplItemNode { syntax: self.syntax.borrowed() }
+impl<R: TreeRoot<RaTypes>> ImplBlockNode<R> {
+ pub fn borrowed(&self) -> ImplBlock {
+ ImplBlockNode { syntax: self.syntax.borrowed() }
}
- pub fn owned(&self) -> ImplItemNode {
- ImplItemNode { syntax: self.syntax.owned() }
+ pub fn owned(&self) -> ImplBlockNode {
+ ImplBlockNode { syntax: self.syntax.owned() }
}
}
+impl<'a> ImplBlock<'a> {
+ pub fn item_list(self) -> Option<ItemList<'a>> {
+ super::child_opt(self)
+ }
+}
+
+// ImplItem
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum ImplItem<'a> {
+ FnDef(FnDef<'a>),
+ TypeDef(TypeDef<'a>),
+ ConstDef(ConstDef<'a>),
+}
+
+impl<'a> AstNode<'a> for ImplItem<'a> {
+ fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
+ match syntax.kind() {
+ FN_DEF => Some(ImplItem::FnDef(FnDef { syntax })),
+ TYPE_DEF => Some(ImplItem::TypeDef(TypeDef { syntax })),
+ CONST_DEF => Some(ImplItem::ConstDef(ConstDef { syntax })),
+ _ => None,
+ }
+ }
+ fn syntax(self) -> SyntaxNodeRef<'a> {
+ match self {
+ ImplItem::FnDef(inner) => inner.syntax(),
+ ImplItem::TypeDef(inner) => inner.syntax(),
+ ImplItem::ConstDef(inner) => inner.syntax(),
+ }
+ }
+}
+
impl<'a> ImplItem<'a> {}
// ImplTraitType
impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {}
impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {}
-impl<'a> ItemList<'a> {}
+impl<'a> ItemList<'a> {
+ pub fn impl_items(self) -> impl Iterator<Item = ImplItem<'a>> + 'a {
+ super::children(self)
+ }
+}
// Label
#[derive(Debug, Clone, Copy,)]
FnDef(FnDef<'a>),
TraitDef(TraitDef<'a>),
TypeDef(TypeDef<'a>),
- ImplItem(ImplItem<'a>),
+ ImplBlock(ImplBlock<'a>),
UseItem(UseItem<'a>),
ExternCrateItem(ExternCrateItem<'a>),
ConstDef(ConstDef<'a>),
FN_DEF => Some(ModuleItem::FnDef(FnDef { syntax })),
TRAIT_DEF => Some(ModuleItem::TraitDef(TraitDef { syntax })),
TYPE_DEF => Some(ModuleItem::TypeDef(TypeDef { syntax })),
- IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })),
+ IMPL_BLOCK => Some(ModuleItem::ImplBlock(ImplBlock { syntax })),
USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })),
EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })),
CONST_DEF => Some(ModuleItem::ConstDef(ConstDef { syntax })),
ModuleItem::FnDef(inner) => inner.syntax(),
ModuleItem::TraitDef(inner) => inner.syntax(),
ModuleItem::TypeDef(inner) => inner.syntax(),
- ModuleItem::ImplItem(inner) => inner.syntax(),
+ ModuleItem::ImplBlock(inner) => inner.syntax(),
ModuleItem::UseItem(inner) => inner.syntax(),
ModuleItem::ExternCrateItem(inner) => inner.syntax(),
ModuleItem::ConstDef(inner) => inner.syntax(),
}
}
+// SelfKw
+#[derive(Debug, Clone, Copy,)]
+pub struct SelfKwNode<R: TreeRoot<RaTypes> = OwnedRoot> {
+ pub(crate) syntax: SyntaxNode<R>,
+}
+pub type SelfKw<'a> = SelfKwNode<RefRoot<'a>>;
+
+impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SelfKwNode<R1>> for SelfKwNode<R2> {
+ fn eq(&self, other: &SelfKwNode<R1>) -> bool { self.syntax == other.syntax }
+}
+impl<R: TreeRoot<RaTypes>> Eq for SelfKwNode<R> {}
+impl<R: TreeRoot<RaTypes>> Hash for SelfKwNode<R> {
+ fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
+}
+
+impl<'a> AstNode<'a> for SelfKw<'a> {
+ fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
+ match syntax.kind() {
+ SELF_KW => Some(SelfKw { syntax }),
+ _ => None,
+ }
+ }
+ fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
+}
+
+impl<R: TreeRoot<RaTypes>> SelfKwNode<R> {
+ pub fn borrowed(&self) -> SelfKw {
+ SelfKwNode { syntax: self.syntax.borrowed() }
+ }
+ pub fn owned(&self) -> SelfKwNode {
+ SelfKwNode { syntax: self.syntax.owned() }
+ }
+}
+
+
+impl<'a> SelfKw<'a> {}
+
// SelfParam
#[derive(Debug, Clone, Copy,)]
pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
}
-impl<'a> SelfParam<'a> {}
+impl<'a> SelfParam<'a> {
+ pub fn type_ref(self) -> Option<TypeRef<'a>> {
+ super::child_opt(self)
+ }
+
+ pub fn self_kw(self) -> Option<SelfKw<'a>> {
+ super::child_opt(self)
+ }
+}
// SlicePat
#[derive(Debug, Clone, Copy,)]
"STATIC_DEF",
"CONST_DEF",
"TRAIT_DEF",
- "IMPL_ITEM",
+ "IMPL_BLOCK",
"TYPE_DEF",
"MACRO_CALL",
"TOKEN_TREE",
options: [ "ItemList" ]
),
"ItemList": (
+ collections: [["impl_items", "ImplItem"]],
traits: [ "FnDefOwner", "ModuleItemOwner" ],
),
"ConstDef": ( traits: [
"AttrsOwner",
"DocCommentsOwner"
] ),
- "ImplItem": (),
+ "ImplBlock": (options: ["ItemList"]),
"ParenType": (options: ["TypeRef"]),
"TupleType": ( collections: [["fields", "TypeRef"]] ),
],
),
"ModuleItem": (
- enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeDef", "ImplItem",
+ enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeDef", "ImplBlock",
"UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ]
),
+ "ImplItem": (
+ enum: ["FnDef", "TypeDef", "ConstDef"]
+ ),
"TupleExpr": (),
"ArrayExpr": (),
["params", "Param"]
]
),
- "SelfParam": (),
+ "SelfParam": (options: ["TypeRef", "SelfKw"]),
+ "SelfKw": (),
"Param": (
options: [ "Pat", "TypeRef" ],
),
// test unsafe_default_impl
// unsafe default impl Foo {}
IMPL_KW => {
- traits::impl_item(p);
- IMPL_ITEM
+ traits::impl_block(p);
+ IMPL_BLOCK
}
_ => {
return if has_mods {
m.complete(p, ITEM_LIST);
}
-// test impl_item
+// test impl_block
// impl Foo {}
-pub(super) fn impl_item(p: &mut Parser) {
+pub(super) fn impl_block(p: &mut Parser) {
assert!(p.at(IMPL_KW));
p.bump();
if choose_type_params_over_qpath(p) {
// TODO: never type
// impl ! {}
- // test impl_item_neg
+ // test impl_block_neg
// impl !Send for X {}
p.eat(EXCL);
impl_type(p);
ITEM_LIST => {
let parent = node.parent().unwrap();
match parent.kind() {
- IMPL_ITEM => grammar::impl_item_list,
+ IMPL_BLOCK => grammar::impl_item_list,
TRAIT_DEF => grammar::trait_item_list,
MODULE => grammar::mod_item_list,
_ => return None,
STATIC_DEF,
CONST_DEF,
TRAIT_DEF,
- IMPL_ITEM,
+ IMPL_BLOCK,
TYPE_DEF,
MACRO_CALL,
TOKEN_TREE,
STATIC_DEF => &SyntaxInfo { name: "STATIC_DEF" },
CONST_DEF => &SyntaxInfo { name: "CONST_DEF" },
TRAIT_DEF => &SyntaxInfo { name: "TRAIT_DEF" },
- IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" },
+ IMPL_BLOCK => &SyntaxInfo { name: "IMPL_BLOCK" },
TYPE_DEF => &SyntaxInfo { name: "TYPE_DEF" },
MACRO_CALL => &SyntaxInfo { name: "MACRO_CALL" },
TOKEN_TREE => &SyntaxInfo { name: "TOKEN_TREE" },
SOURCE_FILE@[0; 183)
- IMPL_ITEM@[0; 182)
+ IMPL_BLOCK@[0; 182)
IMPL_KW@[0; 4)
WHITESPACE@[4; 5)
PATH_TYPE@[5; 13)
COMMA@[54; 55)
err: `expected SEMI`
WHITESPACE@[55; 56)
- IMPL_ITEM@[56; 60)
+ IMPL_BLOCK@[56; 60)
IMPL_KW@[56; 60)
err: `expected type`
err: `expected `{``
SOURCE_FILE@[0; 38)
- IMPL_ITEM@[0; 14)
+ IMPL_BLOCK@[0; 14)
IMPL_KW@[0; 4)
TYPE_PARAM_LIST@[4; 14)
L_ANGLE@[4; 5)
err: `expected trait or type`
err: `expected `{``
WHITESPACE@[14; 15)
- IMPL_ITEM@[15; 37)
+ IMPL_BLOCK@[15; 37)
IMPL_KW@[15; 19)
TYPE_PARAM_LIST@[19; 22)
L_ANGLE@[19; 20)
err: `expected a loop`
err: `expected SEMI`
WHITESPACE@[22; 23)
- IMPL_ITEM@[23; 27)
+ IMPL_BLOCK@[23; 27)
IMPL_KW@[23; 27)
err: `expected type`
err: `expected `{``
SOURCE_FILE@[0; 87)
- IMPL_ITEM@[0; 12)
+ IMPL_BLOCK@[0; 12)
IMPL_KW@[0; 4)
WHITESPACE@[4; 5)
PATH_TYPE@[5; 9)
L_CURLY@[10; 11)
R_CURLY@[11; 12)
WHITESPACE@[12; 13)
- IMPL_ITEM@[13; 33)
+ IMPL_BLOCK@[13; 33)
IMPL_KW@[13; 17)
WHITESPACE@[17; 18)
PATH_TYPE@[18; 24)
L_CURLY@[31; 32)
R_CURLY@[32; 33)
WHITESPACE@[33; 34)
- IMPL_ITEM@[34; 38)
+ IMPL_BLOCK@[34; 38)
IMPL_KW@[34; 38)
err: `expected trait or type`
err: `expected `{``
WHITESPACE@[38; 39)
- IMPL_ITEM@[39; 54)
+ IMPL_BLOCK@[39; 54)
IMPL_KW@[39; 43)
WHITESPACE@[43; 44)
PATH_TYPE@[44; 51)
L_CURLY@[52; 53)
R_CURLY@[53; 54)
WHITESPACE@[54; 55)
- IMPL_ITEM@[55; 70)
+ IMPL_BLOCK@[55; 70)
IMPL_KW@[55; 59)
WHITESPACE@[59; 60)
PATH_TYPE@[60; 66)
err: `expected trait or type`
err: `expected `{``
WHITESPACE@[70; 71)
- IMPL_ITEM@[71; 86)
+ IMPL_BLOCK@[71; 86)
IMPL_KW@[71; 75)
WHITESPACE@[75; 76)
PATH_TYPE@[76; 83)
SOURCE_FILE@[0; 83)
- IMPL_ITEM@[0; 82)
+ IMPL_BLOCK@[0; 82)
IMPL_KW@[0; 4)
WHITESPACE@[4; 5)
PATH_TYPE@[5; 6)
SOURCE_FILE@[0; 128)
- IMPL_ITEM@[0; 127)
+ IMPL_BLOCK@[0; 127)
IMPL_KW@[0; 4)
WHITESPACE@[4; 5)
PATH_TYPE@[5; 6)
SOURCE_FILE@[0; 69)
- IMPL_ITEM@[0; 68)
+ IMPL_BLOCK@[0; 68)
IMPL_KW@[0; 4)
WHITESPACE@[4; 5)
PATH_TYPE@[5; 6)
SOURCE_FILE@[0; 89)
- IMPL_ITEM@[0; 88)
+ IMPL_BLOCK@[0; 88)
IMPL_KW@[0; 4)
WHITESPACE@[4; 5)
PATH_TYPE@[5; 6)
SOURCE_FILE@[0; 27)
- IMPL_ITEM@[0; 26)
+ IMPL_BLOCK@[0; 26)
UNSAFE_KW@[0; 6)
WHITESPACE@[6; 7)
DEFAULT_KW@[7; 14)
--- /dev/null
+impl !Send for X {}
--- /dev/null
+SOURCE_FILE@[0; 20)
+ IMPL_BLOCK@[0; 19)
+ IMPL_KW@[0; 4)
+ WHITESPACE@[4; 5)
+ EXCL@[5; 6)
+ PATH_TYPE@[6; 10)
+ PATH@[6; 10)
+ PATH_SEGMENT@[6; 10)
+ NAME_REF@[6; 10)
+ IDENT@[6; 10) "Send"
+ WHITESPACE@[10; 11)
+ FOR_KW@[11; 14)
+ WHITESPACE@[14; 15)
+ PATH_TYPE@[15; 16)
+ PATH@[15; 16)
+ PATH_SEGMENT@[15; 16)
+ NAME_REF@[15; 16)
+ IDENT@[15; 16) "X"
+ WHITESPACE@[16; 17)
+ ITEM_LIST@[17; 19)
+ L_CURLY@[17; 18)
+ R_CURLY@[18; 19)
+ WHITESPACE@[19; 20)
+++ /dev/null
-impl !Send for X {}
+++ /dev/null
-SOURCE_FILE@[0; 20)
- IMPL_ITEM@[0; 19)
- IMPL_KW@[0; 4)
- WHITESPACE@[4; 5)
- EXCL@[5; 6)
- PATH_TYPE@[6; 10)
- PATH@[6; 10)
- PATH_SEGMENT@[6; 10)
- NAME_REF@[6; 10)
- IDENT@[6; 10) "Send"
- WHITESPACE@[10; 11)
- FOR_KW@[11; 14)
- WHITESPACE@[14; 15)
- PATH_TYPE@[15; 16)
- PATH@[15; 16)
- PATH_SEGMENT@[15; 16)
- NAME_REF@[15; 16)
- IDENT@[15; 16) "X"
- WHITESPACE@[16; 17)
- ITEM_LIST@[17; 19)
- L_CURLY@[17; 18)
- R_CURLY@[18; 19)
- WHITESPACE@[19; 20)
--- /dev/null
+impl Foo {}
--- /dev/null
+SOURCE_FILE@[0; 12)
+ IMPL_BLOCK@[0; 11)
+ IMPL_KW@[0; 4)
+ WHITESPACE@[4; 5)
+ PATH_TYPE@[5; 8)
+ PATH@[5; 8)
+ PATH_SEGMENT@[5; 8)
+ NAME_REF@[5; 8)
+ IDENT@[5; 8) "Foo"
+ WHITESPACE@[8; 9)
+ ITEM_LIST@[9; 11)
+ L_CURLY@[9; 10)
+ R_CURLY@[10; 11)
+ WHITESPACE@[11; 12)
+++ /dev/null
-impl Foo {}
+++ /dev/null
-SOURCE_FILE@[0; 12)
- IMPL_ITEM@[0; 11)
- IMPL_KW@[0; 4)
- WHITESPACE@[4; 5)
- PATH_TYPE@[5; 8)
- PATH@[5; 8)
- PATH_SEGMENT@[5; 8)
- NAME_REF@[5; 8)
- IDENT@[5; 8) "Foo"
- WHITESPACE@[8; 9)
- ITEM_LIST@[9; 11)
- L_CURLY@[9; 10)
- R_CURLY@[10; 11)
- WHITESPACE@[11; 12)
SOURCE_FILE@[0; 19)
- IMPL_ITEM@[0; 18)
+ IMPL_BLOCK@[0; 18)
UNSAFE_KW@[0; 6)
WHITESPACE@[6; 7)
IMPL_KW@[7; 11)
SOURCE_FILE@[0; 20)
- IMPL_ITEM@[0; 19)
+ IMPL_BLOCK@[0; 19)
DEFAULT_KW@[0; 7)
WHITESPACE@[7; 8)
IMPL_KW@[8; 12)
ITEM_LIST@[91; 93)
L_CURLY@[91; 92)
R_CURLY@[92; 93)
-