Clean generic impls code
This commit is contained in:
parent
579adf8c72
commit
4aba7de2a7
8 changed files with 508 additions and 435 deletions
163
src/Cargo.lock
163
src/Cargo.lock
|
@ -226,7 +226,7 @@ dependencies = [
|
||||||
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crates-io 0.18.0",
|
"crates-io 0.18.0",
|
||||||
"crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"curl 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"curl 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -247,8 +247,8 @@ dependencies = [
|
||||||
"libgit2-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libgit2-sys 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-workspace-hack 1.0.0",
|
|
||||||
"rustfix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustfix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -351,18 +351,20 @@ name = "clippy"
|
||||||
version = "0.0.212"
|
version = "0.0.212"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"clippy-mini-macro-test 0.2.0",
|
"clippy-mini-macro-test 0.2.0",
|
||||||
"clippy_lints 0.0.212",
|
"clippy_lints 0.0.212",
|
||||||
"compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-workspace-hack 1.0.0",
|
|
||||||
"rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -604,11 +606,6 @@ name = "crossbeam-utils"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-utils"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-hash"
|
name = "crypto-hash"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
@ -1794,8 +1791,7 @@ dependencies = [
|
||||||
"rls-rustc 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rls-rustc 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-workspace-hack 1.0.0",
|
"rustfmt-nightly 0.9.0 (git+https://github.com/rust-lang-nursery/rustfmt?rev=7e3dc8fae7ed84cc1879ef4e0bc6f00dfe059e1b)",
|
||||||
"rustfmt-nightly 0.9.0",
|
|
||||||
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1853,6 +1849,7 @@ name = "rls-vfs"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"racer 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1903,14 +1900,6 @@ dependencies = [
|
||||||
"rustc-ap-rustc_data_structures 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-ap-rustc_data_structures 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-arena"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"rustc-ap-rustc_data_structures 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-ap-rustc_cratesio_shim"
|
name = "rustc-ap-rustc_cratesio_shim"
|
||||||
version = "209.0.0"
|
version = "209.0.0"
|
||||||
|
@ -1920,15 +1909,6 @@ dependencies = [
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-rustc_cratesio_shim"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-ap-rustc_data_structures"
|
name = "rustc-ap-rustc_data_structures"
|
||||||
version = "209.0.0"
|
version = "209.0.0"
|
||||||
|
@ -1947,24 +1927,6 @@ dependencies = [
|
||||||
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-rustc_data_structures"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-rustc_cratesio_shim 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-serialize 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-ap-rustc_errors"
|
name = "rustc-ap-rustc_errors"
|
||||||
version = "209.0.0"
|
version = "209.0.0"
|
||||||
|
@ -1978,19 +1940,6 @@ dependencies = [
|
||||||
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-rustc_errors"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-rustc_data_structures 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-serialize 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-syntax_pos 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-ap-rustc_target"
|
name = "rustc-ap-rustc_target"
|
||||||
version = "209.0.0"
|
version = "209.0.0"
|
||||||
|
@ -2002,27 +1951,11 @@ dependencies = [
|
||||||
"rustc-ap-serialize 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-ap-serialize 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-rustc_target"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-rustc_cratesio_shim 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-serialize 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-ap-serialize"
|
name = "rustc-ap-serialize"
|
||||||
version = "209.0.0"
|
version = "209.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-serialize"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-ap-syntax"
|
name = "rustc-ap-syntax"
|
||||||
version = "209.0.0"
|
version = "209.0.0"
|
||||||
|
@ -2038,21 +1971,6 @@ dependencies = [
|
||||||
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-syntax"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-rustc_data_structures 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-rustc_errors 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-rustc_target 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-serialize 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-syntax_pos 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-ap-syntax_pos"
|
name = "rustc-ap-syntax_pos"
|
||||||
version = "209.0.0"
|
version = "209.0.0"
|
||||||
|
@ -2066,19 +1984,6 @@ dependencies = [
|
||||||
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-ap-syntax_pos"
|
|
||||||
version = "211.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-arena 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-rustc_data_structures 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-ap-serialize 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.8"
|
version = "0.1.8"
|
||||||
|
@ -2126,14 +2031,6 @@ name = "rustc-serialize"
|
||||||
version = "0.3.24"
|
version = "0.3.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-workspace-hack"
|
|
||||||
version = "1.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_allocator"
|
name = "rustc_allocator"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
@ -2564,6 +2461,32 @@ dependencies = [
|
||||||
"serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustfmt-nightly"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "git+https://github.com/rust-lang-nursery/rustfmt?rev=7e3dc8fae7ed84cc1879ef4e0bc6f00dfe059e1b#7e3dc8fae7ed84cc1879ef4e0bc6f00dfe059e1b"
|
||||||
|
dependencies = [
|
||||||
|
"cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"isatty 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rustc-ap-rustc_target 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rustc-ap-syntax 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rustc-ap-syntax_pos 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustfmt-nightly"
|
name = "rustfmt-nightly"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -2580,9 +2503,9 @@ dependencies = [
|
||||||
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-ap-rustc_target 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-ap-rustc_target 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-ap-syntax 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-ap-syntax 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-ap-syntax_pos 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-ap-syntax_pos 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3197,6 +3120,10 @@ name = "yaml-rust"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[patch.unused]]
|
||||||
|
name = "rustc-workspace-hack"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c6d463cbe7ed28720b5b489e7c083eeb8f90d08be2a0d6bb9e1ffea9ce1afa"
|
"checksum aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c6d463cbe7ed28720b5b489e7c083eeb8f90d08be2a0d6bb9e1ffea9ce1afa"
|
||||||
"checksum ammonia 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd4c682378117e4186a492b2252b9537990e1617f44aed9788b9a1149de45477"
|
"checksum ammonia 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd4c682378117e4186a492b2252b9537990e1617f44aed9788b9a1149de45477"
|
||||||
|
@ -3237,7 +3164,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum crossbeam-epoch 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "285987a59c4d91388e749850e3cb7b3a92299668528caaacd08005b8f238c0ea"
|
"checksum crossbeam-epoch 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "285987a59c4d91388e749850e3cb7b3a92299668528caaacd08005b8f238c0ea"
|
||||||
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
|
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
|
||||||
"checksum crossbeam-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea52fab26a99d96cdff39d0ca75c9716125937f5dba2ab83923aaaf5928f684a"
|
"checksum crossbeam-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea52fab26a99d96cdff39d0ca75c9716125937f5dba2ab83923aaaf5928f684a"
|
||||||
"checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015"
|
|
||||||
"checksum crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "09de9ee0fc255ace04c7fa0763c9395a945c37c8292bb554f8d48361d1dcf1b4"
|
"checksum crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "09de9ee0fc255ace04c7fa0763c9395a945c37c8292bb554f8d48361d1dcf1b4"
|
||||||
"checksum curl 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "893713db705eab9847e050268507b0e2a2aad64e90a831874bd4e8e0d67f9523"
|
"checksum curl 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "893713db705eab9847e050268507b0e2a2aad64e90a831874bd4e8e0d67f9523"
|
||||||
"checksum curl-sys 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "de9cf174efdf90b5887c4e2e900769373c89c5e18152e8f3ed75b501a6f1c0fb"
|
"checksum curl-sys 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "de9cf174efdf90b5887c4e2e900769373c89c5e18152e8f3ed75b501a6f1c0fb"
|
||||||
|
@ -3367,21 +3293,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
|
"checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
|
||||||
"checksum rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ecbc8541b4c341d6271eae10f869dd9d36db871afe184f5b6f9bffbd6ed0373f"
|
"checksum rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ecbc8541b4c341d6271eae10f869dd9d36db871afe184f5b6f9bffbd6ed0373f"
|
||||||
"checksum rustc-ap-arena 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b098827864368459cbc7a79fbc54eafb92df7e00a46c0cda352b5a21583ee436"
|
"checksum rustc-ap-arena 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b098827864368459cbc7a79fbc54eafb92df7e00a46c0cda352b5a21583ee436"
|
||||||
"checksum rustc-ap-arena 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eec75ed880706dd9a05bc770c327ed142fa7d4b648d9757fbc71d821d68448a5"
|
|
||||||
"checksum rustc-ap-rustc_cratesio_shim 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4d923dea14fb085bca743fb982f6a3bc11c0d5d30b822bcf6fa16e9464a56c"
|
"checksum rustc-ap-rustc_cratesio_shim 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef4d923dea14fb085bca743fb982f6a3bc11c0d5d30b822bcf6fa16e9464a56c"
|
||||||
"checksum rustc-ap-rustc_cratesio_shim 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f5d54615bedbae65a976e0835edf0de90dd962ec818c0149fe181d5cd81da9e"
|
|
||||||
"checksum rustc-ap-rustc_data_structures 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c6a5c9edc6b4ae035cdc03af7d8662d39fad7879c5501d103e7087dfaebc80"
|
"checksum rustc-ap-rustc_data_structures 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c6a5c9edc6b4ae035cdc03af7d8662d39fad7879c5501d103e7087dfaebc80"
|
||||||
"checksum rustc-ap-rustc_data_structures 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7c51cc6e79eab25c7ea84a7e104e81e6f44cca32709df54c2cdb4e7059d7843"
|
|
||||||
"checksum rustc-ap-rustc_errors 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1e9bdc597abd95cebce0c14c1da58943a9e5b8255530a0fec30659d144eb0b"
|
"checksum rustc-ap-rustc_errors 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1e9bdc597abd95cebce0c14c1da58943a9e5b8255530a0fec30659d144eb0b"
|
||||||
"checksum rustc-ap-rustc_errors 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff050095b7afb254506591ee7d3a5d0fb9c03c16f8c2741b588178085e563d49"
|
|
||||||
"checksum rustc-ap-rustc_target 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "142ddef3dc12dda2bcd3412f0d96d3745413a8fbc2f224f0cc97afa04c071d89"
|
"checksum rustc-ap-rustc_target 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "142ddef3dc12dda2bcd3412f0d96d3745413a8fbc2f224f0cc97afa04c071d89"
|
||||||
"checksum rustc-ap-rustc_target 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "53c7a8c21c3b05f24998fa6ab9ded6269810a2f3ae12ff301c432c1e9fa8e111"
|
|
||||||
"checksum rustc-ap-serialize 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b08f8f175b038a82caa7e51fc52b72ff96cfe8c1429755da30380dbd4199c7f"
|
"checksum rustc-ap-serialize 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b08f8f175b038a82caa7e51fc52b72ff96cfe8c1429755da30380dbd4199c7f"
|
||||||
"checksum rustc-ap-serialize 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4713c2c0c26a45ead8fb16fee88e16fecf999588ae6920847cbaeb19565b7f"
|
|
||||||
"checksum rustc-ap-syntax 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c802e0e1fbc64eddc21e0798527eb1f5fdbd5781d119bd2c44b6130afdc81cc"
|
"checksum rustc-ap-syntax 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c802e0e1fbc64eddc21e0798527eb1f5fdbd5781d119bd2c44b6130afdc81cc"
|
||||||
"checksum rustc-ap-syntax 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "768e2698f912913be2ccd355b2dea62c978efc356f75db1400605f3642905d53"
|
|
||||||
"checksum rustc-ap-syntax_pos 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "008d47cc54ed12a2784217b9e6630a7fa1c8dc3591a283f65ad4b7fa307d49d5"
|
"checksum rustc-ap-syntax_pos 209.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "008d47cc54ed12a2784217b9e6630a7fa1c8dc3591a283f65ad4b7fa307d49d5"
|
||||||
"checksum rustc-ap-syntax_pos 211.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a280dc8919aa7f684832ba3eeab2f6c96dbe2e2e4f6a922f7f0bdb3a9dd9e641"
|
|
||||||
"checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649"
|
"checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649"
|
||||||
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
|
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
|
||||||
"checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306"
|
"checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306"
|
||||||
|
@ -3389,6 +3307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
||||||
"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a"
|
"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a"
|
||||||
"checksum rustfix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "756567f00f7d89c9f89a5c401b8b1caaa122e27240b9eaadd0bb52ee0b680b1b"
|
"checksum rustfix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "756567f00f7d89c9f89a5c401b8b1caaa122e27240b9eaadd0bb52ee0b680b1b"
|
||||||
|
"checksum rustfmt-nightly 0.9.0 (git+https://github.com/rust-lang-nursery/rustfmt?rev=7e3dc8fae7ed84cc1879ef4e0bc6f00dfe059e1b)" = "<none>"
|
||||||
"checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637"
|
"checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637"
|
||||||
"checksum schannel 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "dc1fabf2a7b6483a141426e1afd09ad543520a77ac49bd03c286e7696ccfd77f"
|
"checksum schannel 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "dc1fabf2a7b6483a141426e1afd09ad543520a77ac49bd03c286e7696ccfd77f"
|
||||||
"checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28"
|
"checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28"
|
||||||
|
|
|
@ -15,9 +15,9 @@ use rustc::ty::subst::Subst;
|
||||||
use rustc::infer::InferOk;
|
use rustc::infer::InferOk;
|
||||||
use rustc::middle::cstore::CrateStore;
|
use rustc::middle::cstore::CrateStore;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use syntax_pos::DUMMY_SP;
|
|
||||||
|
|
||||||
use core::DocAccessLevels;
|
use self::def_ctor::{get_def_ctor_from_def_id, get_def_ctor_from_node_id};
|
||||||
|
use self::finder_trait::Finder;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -34,186 +34,16 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_with_def_id(&self, def_id: DefId) -> Vec<Item> {
|
pub fn get_with_def_id(&self, def_id: DefId) -> Vec<Item> {
|
||||||
let ty = self.cx.tcx.type_of(def_id);
|
get_def_ctor_from_def_id(&self.cx, def_id, &|def_ctor| {
|
||||||
|
|
||||||
let def_ctor: fn(DefId) -> Def = match ty.sty {
|
|
||||||
ty::TyAdt(adt, _) => match adt.adt_kind() {
|
|
||||||
AdtKind::Struct => Def::Struct,
|
|
||||||
AdtKind::Enum => Def::Enum,
|
|
||||||
AdtKind::Union => Def::Union,
|
|
||||||
}
|
|
||||||
ty::TyInt(_) |
|
|
||||||
ty::TyUint(_) |
|
|
||||||
ty::TyFloat(_) |
|
|
||||||
ty::TyStr |
|
|
||||||
ty::TyBool |
|
|
||||||
ty::TyChar => return self.get_auto_trait_impls(def_id, &move |_: DefId| {
|
|
||||||
match ty.sty {
|
|
||||||
ty::TyInt(x) => Def::PrimTy(hir::TyInt(x)),
|
|
||||||
ty::TyUint(x) => Def::PrimTy(hir::TyUint(x)),
|
|
||||||
ty::TyFloat(x) => Def::PrimTy(hir::TyFloat(x)),
|
|
||||||
ty::TyStr => Def::PrimTy(hir::TyStr),
|
|
||||||
ty::TyBool => Def::PrimTy(hir::TyBool),
|
|
||||||
ty::TyChar => Def::PrimTy(hir::TyChar),
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}, None),
|
|
||||||
_ => {
|
|
||||||
debug!("Unexpected type {:?}", def_id);
|
|
||||||
return Vec::new()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
self.get_auto_trait_impls(def_id, &def_ctor, None)
|
self.get_auto_trait_impls(def_id, &def_ctor, None)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_with_node_id(&self, id: ast::NodeId, name: String) -> Vec<Item> {
|
pub fn get_with_node_id(&self, id: ast::NodeId, name: String) -> Vec<Item> {
|
||||||
let item = &self.cx.tcx.hir.expect_item(id).node;
|
get_def_ctor_from_node_id(&self.cx, id, name, &|def_ctor, name| {
|
||||||
let did = self.cx.tcx.hir.local_def_id(id);
|
let did = self.cx.tcx.hir.local_def_id(id);
|
||||||
|
|
||||||
let def_ctor = match *item {
|
|
||||||
hir::ItemKind::Struct(_, _) => Def::Struct,
|
|
||||||
hir::ItemKind::Union(_, _) => Def::Union,
|
|
||||||
hir::ItemKind::Enum(_, _) => Def::Enum,
|
|
||||||
_ => panic!("Unexpected type {:?} {:?}", item, id),
|
|
||||||
};
|
|
||||||
|
|
||||||
self.get_auto_trait_impls(did, &def_ctor, Some(name))
|
self.get_auto_trait_impls(did, &def_ctor, Some(name))
|
||||||
}
|
})
|
||||||
|
|
||||||
fn get_real_ty<F>(&self,
|
|
||||||
def_id: DefId,
|
|
||||||
def_ctor: &F,
|
|
||||||
real_name: &Option<Ident>,
|
|
||||||
generics: &ty::Generics,
|
|
||||||
) -> hir::Ty
|
|
||||||
where F: Fn(DefId) -> Def {
|
|
||||||
let path = get_path_for_type(self.cx.tcx, def_id, def_ctor);
|
|
||||||
let mut segments = path.segments.into_vec();
|
|
||||||
let last = segments.pop().unwrap();
|
|
||||||
|
|
||||||
segments.push(hir::PathSegment::new(
|
|
||||||
real_name.unwrap_or(last.ident),
|
|
||||||
self.generics_to_path_params(generics.clone()),
|
|
||||||
false,
|
|
||||||
));
|
|
||||||
|
|
||||||
let new_path = hir::Path {
|
|
||||||
span: path.span,
|
|
||||||
def: path.def,
|
|
||||||
segments: HirVec::from_vec(segments),
|
|
||||||
};
|
|
||||||
|
|
||||||
hir::Ty {
|
|
||||||
id: ast::DUMMY_NODE_ID,
|
|
||||||
node: hir::TyKind::Path(hir::QPath::Resolved(None, P(new_path))),
|
|
||||||
span: DUMMY_SP,
|
|
||||||
hir_id: hir::DUMMY_HIR_ID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_blanket_impls<F>(
|
|
||||||
&self,
|
|
||||||
def_id: DefId,
|
|
||||||
def_ctor: &F,
|
|
||||||
name: Option<String>,
|
|
||||||
generics: &ty::Generics,
|
|
||||||
) -> Vec<Item>
|
|
||||||
where F: Fn(DefId) -> Def {
|
|
||||||
let ty = self.cx.tcx.type_of(def_id);
|
|
||||||
let mut traits = Vec::new();
|
|
||||||
if self.cx.access_levels.borrow().is_doc_reachable(def_id) {
|
|
||||||
let real_name = name.clone().map(|name| Ident::from_str(&name));
|
|
||||||
let param_env = self.cx.tcx.param_env(def_id);
|
|
||||||
for &trait_def_id in self.cx.all_traits.iter() {
|
|
||||||
if !self.cx.access_levels.borrow().is_doc_reachable(trait_def_id) ||
|
|
||||||
self.cx.generated_synthetics
|
|
||||||
.borrow_mut()
|
|
||||||
.get(&(def_id, trait_def_id))
|
|
||||||
.is_some() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
self.cx.tcx.for_each_relevant_impl(trait_def_id, ty, |impl_def_id| {
|
|
||||||
self.cx.tcx.infer_ctxt().enter(|infcx| {
|
|
||||||
let t_generics = infcx.tcx.generics_of(impl_def_id);
|
|
||||||
let trait_ref = infcx.tcx.impl_trait_ref(impl_def_id).unwrap();
|
|
||||||
|
|
||||||
match infcx.tcx.type_of(impl_def_id).sty {
|
|
||||||
::rustc::ty::TypeVariants::TyParam(_) => {},
|
|
||||||
_ => return,
|
|
||||||
}
|
|
||||||
|
|
||||||
let substs = infcx.fresh_substs_for_item(DUMMY_SP, def_id);
|
|
||||||
let ty = ty.subst(infcx.tcx, substs);
|
|
||||||
let param_env = param_env.subst(infcx.tcx, substs);
|
|
||||||
|
|
||||||
let impl_substs = infcx.fresh_substs_for_item(DUMMY_SP, impl_def_id);
|
|
||||||
let trait_ref = trait_ref.subst(infcx.tcx, impl_substs);
|
|
||||||
|
|
||||||
// Require the type the impl is implemented on to match
|
|
||||||
// our type, and ignore the impl if there was a mismatch.
|
|
||||||
let cause = traits::ObligationCause::dummy();
|
|
||||||
let eq_result = infcx.at(&cause, param_env)
|
|
||||||
.eq(trait_ref.self_ty(), ty);
|
|
||||||
if let Ok(InferOk { value: (), obligations }) = eq_result {
|
|
||||||
// FIXME(eddyb) ignoring `obligations` might cause false positives.
|
|
||||||
drop(obligations);
|
|
||||||
|
|
||||||
let may_apply = infcx.predicate_may_hold(&traits::Obligation::new(
|
|
||||||
cause.clone(),
|
|
||||||
param_env,
|
|
||||||
trait_ref.to_predicate(),
|
|
||||||
));
|
|
||||||
if !may_apply {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
self.cx.generated_synthetics.borrow_mut()
|
|
||||||
.insert((def_id, trait_def_id));
|
|
||||||
let trait_ = hir::TraitRef {
|
|
||||||
path: get_path_for_type(infcx.tcx,
|
|
||||||
trait_def_id,
|
|
||||||
hir::def::Def::Trait),
|
|
||||||
ref_id: ast::DUMMY_NODE_ID,
|
|
||||||
};
|
|
||||||
let provided_trait_methods =
|
|
||||||
infcx.tcx.provided_trait_methods(trait_def_id)
|
|
||||||
.into_iter()
|
|
||||||
.map(|meth| meth.ident.to_string())
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let ty = self.get_real_ty(def_id, def_ctor, &real_name, generics);
|
|
||||||
let predicates = infcx.tcx.predicates_of(impl_def_id);
|
|
||||||
|
|
||||||
traits.push(Item {
|
|
||||||
source: infcx.tcx.def_span(impl_def_id).clean(self.cx),
|
|
||||||
name: None,
|
|
||||||
attrs: Default::default(),
|
|
||||||
visibility: None,
|
|
||||||
def_id: self.next_def_id(impl_def_id.krate),
|
|
||||||
stability: None,
|
|
||||||
deprecation: None,
|
|
||||||
inner: ImplItem(Impl {
|
|
||||||
unsafety: hir::Unsafety::Normal,
|
|
||||||
generics: (t_generics, &predicates).clean(self.cx),
|
|
||||||
provided_trait_methods,
|
|
||||||
trait_: Some(trait_.clean(self.cx)),
|
|
||||||
for_: ty.clean(self.cx),
|
|
||||||
items: infcx.tcx.associated_items(impl_def_id)
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.clean(self.cx),
|
|
||||||
polarity: None,
|
|
||||||
synthetic: false,
|
|
||||||
blanket_impl: Some(infcx.tcx.type_of(impl_def_id)
|
|
||||||
.clean(self.cx)),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
debug!("{:?} => {}", trait_ref, may_apply);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
traits
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_auto_trait_impls<F>(
|
pub fn get_auto_trait_impls<F>(
|
||||||
|
@ -263,7 +93,6 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
def_ctor,
|
def_ctor,
|
||||||
tcx.require_lang_item(lang_items::SyncTraitLangItem),
|
tcx.require_lang_item(lang_items::SyncTraitLangItem),
|
||||||
).into_iter())
|
).into_iter())
|
||||||
.chain(self.get_blanket_impls(def_id, def_ctor, name, &generics).into_iter())
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -365,56 +194,6 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generics_to_path_params(&self, generics: ty::Generics) -> hir::GenericArgs {
|
|
||||||
let mut args = vec![];
|
|
||||||
|
|
||||||
for param in generics.params.iter() {
|
|
||||||
match param.kind {
|
|
||||||
ty::GenericParamDefKind::Lifetime => {
|
|
||||||
let name = if param.name == "" {
|
|
||||||
hir::ParamName::Plain(keywords::StaticLifetime.ident())
|
|
||||||
} else {
|
|
||||||
hir::ParamName::Plain(ast::Ident::from_interned_str(param.name))
|
|
||||||
};
|
|
||||||
|
|
||||||
args.push(hir::GenericArg::Lifetime(hir::Lifetime {
|
|
||||||
id: ast::DUMMY_NODE_ID,
|
|
||||||
span: DUMMY_SP,
|
|
||||||
name: hir::LifetimeName::Param(name),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
ty::GenericParamDefKind::Type {..} => {
|
|
||||||
args.push(hir::GenericArg::Type(self.ty_param_to_ty(param.clone())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hir::GenericArgs {
|
|
||||||
args: HirVec::from_vec(args),
|
|
||||||
bindings: HirVec::new(),
|
|
||||||
parenthesized: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ty_param_to_ty(&self, param: ty::GenericParamDef) -> hir::Ty {
|
|
||||||
debug!("ty_param_to_ty({:?}) {:?}", param, param.def_id);
|
|
||||||
hir::Ty {
|
|
||||||
id: ast::DUMMY_NODE_ID,
|
|
||||||
node: hir::TyKind::Path(hir::QPath::Resolved(
|
|
||||||
None,
|
|
||||||
P(hir::Path {
|
|
||||||
span: DUMMY_SP,
|
|
||||||
def: Def::TyParam(param.def_id),
|
|
||||||
segments: HirVec::from_vec(vec![
|
|
||||||
hir::PathSegment::from_ident(Ident::from_interned_str(param.name))
|
|
||||||
]),
|
|
||||||
}),
|
|
||||||
)),
|
|
||||||
span: DUMMY_SP,
|
|
||||||
hir_id: hir::DUMMY_HIR_ID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find_auto_trait_generics(
|
fn find_auto_trait_generics(
|
||||||
&self,
|
&self,
|
||||||
did: DefId,
|
did: DefId,
|
||||||
|
@ -531,7 +310,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
// Desired order is 'larger, smaller', so flip then
|
// Desired order is 'larger, smaller', so flip then
|
||||||
if self.region_name(r1) != self.region_name(r2) {
|
if self.region_name(r1) != self.region_name(r2) {
|
||||||
finished
|
finished
|
||||||
.entry(self.region_name(r2).unwrap())
|
.entry(self.region_name(r2).expect("no region_name found"))
|
||||||
.or_insert_with(|| Vec::new())
|
.or_insert_with(|| Vec::new())
|
||||||
.push(r1);
|
.push(r1);
|
||||||
}
|
}
|
||||||
|
@ -566,7 +345,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
(&RegionTarget::Region(r1), &RegionTarget::Region(r2)) => {
|
(&RegionTarget::Region(r1), &RegionTarget::Region(r2)) => {
|
||||||
if self.region_name(r1) != self.region_name(r2) {
|
if self.region_name(r1) != self.region_name(r2) {
|
||||||
finished
|
finished
|
||||||
.entry(self.region_name(r2).unwrap())
|
.entry(self.region_name(r2).expect("no region name found"))
|
||||||
.or_insert_with(|| Vec::new())
|
.or_insert_with(|| Vec::new())
|
||||||
.push(r1) // Larger, smaller
|
.push(r1) // Larger, smaller
|
||||||
}
|
}
|
||||||
|
@ -663,7 +442,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
.flat_map(|(ty, mut bounds)| {
|
.flat_map(|(ty, mut bounds)| {
|
||||||
if let Some(data) = ty_to_fn.get(&ty) {
|
if let Some(data) = ty_to_fn.get(&ty) {
|
||||||
let (poly_trait, output) =
|
let (poly_trait, output) =
|
||||||
(data.0.as_ref().unwrap().clone(), data.1.as_ref().cloned());
|
(data.0.as_ref().expect("as_ref failed").clone(), data.1.as_ref().cloned());
|
||||||
let new_ty = match &poly_trait.trait_ {
|
let new_ty = match &poly_trait.trait_ {
|
||||||
&Type::ResolvedPath {
|
&Type::ResolvedPath {
|
||||||
ref path,
|
ref path,
|
||||||
|
@ -672,7 +451,8 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
ref is_generic,
|
ref is_generic,
|
||||||
} => {
|
} => {
|
||||||
let mut new_path = path.clone();
|
let mut new_path = path.clone();
|
||||||
let last_segment = new_path.segments.pop().unwrap();
|
let last_segment = new_path.segments.pop()
|
||||||
|
.expect("segments were empty");
|
||||||
|
|
||||||
let (old_input, old_output) = match last_segment.args {
|
let (old_input, old_output) = match last_segment.args {
|
||||||
GenericArgs::AngleBracketed { types, .. } => (types, None),
|
GenericArgs::AngleBracketed { types, .. } => (types, None),
|
||||||
|
@ -830,7 +610,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
let mut for_generics = self.extract_for_generics(tcx, orig_p.clone());
|
let mut for_generics = self.extract_for_generics(tcx, orig_p.clone());
|
||||||
|
|
||||||
assert!(bounds.len() == 1);
|
assert!(bounds.len() == 1);
|
||||||
let mut b = bounds.pop().unwrap();
|
let mut b = bounds.pop().expect("bounds were empty");
|
||||||
|
|
||||||
if b.is_sized_bound(self.cx) {
|
if b.is_sized_bound(self.cx) {
|
||||||
has_sized.insert(ty.clone());
|
has_sized.insert(ty.clone());
|
||||||
|
@ -860,7 +640,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let poly_trait = b.get_poly_trait().unwrap();
|
let poly_trait = b.get_poly_trait().expect("Cannot get poly trait");
|
||||||
|
|
||||||
if is_fn {
|
if is_fn {
|
||||||
ty_to_fn
|
ty_to_fn
|
||||||
|
@ -913,7 +693,10 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
// FIXME: Remove this scope when NLL lands
|
// FIXME: Remove this scope when NLL lands
|
||||||
{
|
{
|
||||||
let args =
|
let args =
|
||||||
&mut new_trait_path.segments.last_mut().unwrap().args;
|
&mut new_trait_path.segments
|
||||||
|
.last_mut()
|
||||||
|
.expect("segments were empty")
|
||||||
|
.args;
|
||||||
|
|
||||||
match args {
|
match args {
|
||||||
// Convert somethiung like '<T as Iterator::Item> = u8'
|
// Convert somethiung like '<T as Iterator::Item> = u8'
|
||||||
|
@ -1077,60 +860,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This is an ugly hack, but it's the simplest way to handle synthetic impls without greatly
|
impl<'a, 'tcx: 'a, 'rcx: 'a> Finder<'a, 'tcx, 'rcx> for AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||||
// refactoring either librustdoc or librustc. In particular, allowing new DefIds to be
|
fn get_cx(&self) -> &DocContext<'a, 'tcx, 'rcx> {
|
||||||
// registered after the AST is constructed would require storing the defid mapping in a
|
&self.cx
|
||||||
// RefCell, decreasing the performance for normal compilation for very little gain.
|
|
||||||
//
|
|
||||||
// Instead, we construct 'fake' def ids, which start immediately after the last DefId in
|
|
||||||
// DefIndexAddressSpace::Low. In the Debug impl for clean::Item, we explicitly check for fake
|
|
||||||
// def ids, as we'll end up with a panic if we use the DefId Debug impl for fake DefIds
|
|
||||||
fn next_def_id(&self, crate_num: CrateNum) -> DefId {
|
|
||||||
let start_def_id = {
|
|
||||||
let next_id = if crate_num == LOCAL_CRATE {
|
|
||||||
self.cx
|
|
||||||
.tcx
|
|
||||||
.hir
|
|
||||||
.definitions()
|
|
||||||
.def_path_table()
|
|
||||||
.next_id(DefIndexAddressSpace::Low)
|
|
||||||
} else {
|
|
||||||
self.cx
|
|
||||||
.cstore
|
|
||||||
.def_path_table(crate_num)
|
|
||||||
.next_id(DefIndexAddressSpace::Low)
|
|
||||||
};
|
|
||||||
|
|
||||||
DefId {
|
|
||||||
krate: crate_num,
|
|
||||||
index: next_id,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut fake_ids = self.cx.fake_def_ids.borrow_mut();
|
|
||||||
|
|
||||||
let def_id = fake_ids.entry(crate_num).or_insert(start_def_id).clone();
|
|
||||||
fake_ids.insert(
|
|
||||||
crate_num,
|
|
||||||
DefId {
|
|
||||||
krate: crate_num,
|
|
||||||
index: DefIndex::from_array_index(
|
|
||||||
def_id.index.as_array_index() + 1,
|
|
||||||
def_id.index.address_space(),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
MAX_DEF_ID.with(|m| {
|
|
||||||
m.borrow_mut()
|
|
||||||
.entry(def_id.krate.clone())
|
|
||||||
.or_insert(start_def_id);
|
|
||||||
});
|
|
||||||
|
|
||||||
self.cx.all_fake_def_ids.borrow_mut().insert(def_id);
|
|
||||||
|
|
||||||
def_id.clone()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
170
src/librustdoc/clean/blanket_impl.rs
Normal file
170
src/librustdoc/clean/blanket_impl.rs
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
use rustc::hir;
|
||||||
|
use rustc::traits;
|
||||||
|
use rustc::ty::ToPredicate;
|
||||||
|
use rustc::ty::subst::Subst;
|
||||||
|
use rustc::infer::InferOk;
|
||||||
|
use syntax_pos::DUMMY_SP;
|
||||||
|
|
||||||
|
use core::DocAccessLevels;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use self::def_ctor::{get_def_ctor_from_def_id, get_def_ctor_from_node_id};
|
||||||
|
use self::finder_trait::Finder;
|
||||||
|
|
||||||
|
pub struct BlanketImplFinder<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||||
|
pub cx: &'a core::DocContext<'a, 'tcx, 'rcx>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
|
||||||
|
pub fn new(cx: &'a core::DocContext<'a, 'tcx, 'rcx>) -> Self {
|
||||||
|
BlanketImplFinder { cx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_with_def_id(&self, def_id: DefId) -> Vec<Item> {
|
||||||
|
get_def_ctor_from_def_id(&self.cx, def_id, &|def_ctor| {
|
||||||
|
self.get_blanket_impls(def_id, &def_ctor, None)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_with_node_id(&self, id: ast::NodeId, name: String) -> Vec<Item> {
|
||||||
|
get_def_ctor_from_node_id(&self.cx, id, name, &|def_ctor, name| {
|
||||||
|
let did = self.cx.tcx.hir.local_def_id(id);
|
||||||
|
self.get_blanket_impls(did, &def_ctor, Some(name))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_blanket_impls<F>(
|
||||||
|
&self,
|
||||||
|
def_id: DefId,
|
||||||
|
def_ctor: &F,
|
||||||
|
name: Option<String>,
|
||||||
|
) -> Vec<Item>
|
||||||
|
where F: Fn(DefId) -> Def {
|
||||||
|
let mut impls = Vec::new();
|
||||||
|
if self.cx
|
||||||
|
.tcx
|
||||||
|
.get_attrs(def_id)
|
||||||
|
.lists("doc")
|
||||||
|
.has_word("hidden")
|
||||||
|
{
|
||||||
|
debug!(
|
||||||
|
"get_blanket_impls(def_id={:?}, def_ctor=...): item has doc('hidden'), \
|
||||||
|
aborting",
|
||||||
|
def_id
|
||||||
|
);
|
||||||
|
return impls;
|
||||||
|
}
|
||||||
|
if self.cx.access_levels.borrow().is_doc_reachable(def_id) {
|
||||||
|
let generics = self.cx.tcx.generics_of(def_id);
|
||||||
|
let ty = self.cx.tcx.type_of(def_id);
|
||||||
|
let real_name = name.clone().map(|name| Ident::from_str(&name));
|
||||||
|
let param_env = self.cx.tcx.param_env(def_id);
|
||||||
|
for &trait_def_id in self.cx.all_traits.iter() {
|
||||||
|
if !self.cx.access_levels.borrow().is_doc_reachable(trait_def_id) ||
|
||||||
|
self.cx.generated_synthetics
|
||||||
|
.borrow_mut()
|
||||||
|
.get(&(def_id, trait_def_id))
|
||||||
|
.is_some() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
self.cx.tcx.for_each_relevant_impl(trait_def_id, ty, |impl_def_id| {
|
||||||
|
self.cx.tcx.infer_ctxt().enter(|infcx| {
|
||||||
|
let t_generics = infcx.tcx.generics_of(impl_def_id);
|
||||||
|
let trait_ref = infcx.tcx.impl_trait_ref(impl_def_id)
|
||||||
|
.expect("Cannot get impl trait");
|
||||||
|
|
||||||
|
match infcx.tcx.type_of(impl_def_id).sty {
|
||||||
|
::rustc::ty::TypeVariants::TyParam(_) => {},
|
||||||
|
_ => return,
|
||||||
|
}
|
||||||
|
|
||||||
|
let substs = infcx.fresh_substs_for_item(DUMMY_SP, def_id);
|
||||||
|
let ty = ty.subst(infcx.tcx, substs);
|
||||||
|
let param_env = param_env.subst(infcx.tcx, substs);
|
||||||
|
|
||||||
|
let impl_substs = infcx.fresh_substs_for_item(DUMMY_SP, impl_def_id);
|
||||||
|
let trait_ref = trait_ref.subst(infcx.tcx, impl_substs);
|
||||||
|
|
||||||
|
// Require the type the impl is implemented on to match
|
||||||
|
// our type, and ignore the impl if there was a mismatch.
|
||||||
|
let cause = traits::ObligationCause::dummy();
|
||||||
|
let eq_result = infcx.at(&cause, param_env)
|
||||||
|
.eq(trait_ref.self_ty(), ty);
|
||||||
|
if let Ok(InferOk { value: (), obligations }) = eq_result {
|
||||||
|
// FIXME(eddyb) ignoring `obligations` might cause false positives.
|
||||||
|
drop(obligations);
|
||||||
|
|
||||||
|
let may_apply = infcx.predicate_may_hold(&traits::Obligation::new(
|
||||||
|
cause.clone(),
|
||||||
|
param_env,
|
||||||
|
trait_ref.to_predicate(),
|
||||||
|
));
|
||||||
|
if !may_apply {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.cx.generated_synthetics.borrow_mut()
|
||||||
|
.insert((def_id, trait_def_id));
|
||||||
|
let trait_ = hir::TraitRef {
|
||||||
|
path: get_path_for_type(infcx.tcx,
|
||||||
|
trait_def_id,
|
||||||
|
hir::def::Def::Trait),
|
||||||
|
ref_id: ast::DUMMY_NODE_ID,
|
||||||
|
};
|
||||||
|
let provided_trait_methods =
|
||||||
|
infcx.tcx.provided_trait_methods(trait_def_id)
|
||||||
|
.into_iter()
|
||||||
|
.map(|meth| meth.ident.to_string())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let ty = self.get_real_ty(def_id, def_ctor, &real_name, generics);
|
||||||
|
let predicates = infcx.tcx.predicates_of(impl_def_id);
|
||||||
|
|
||||||
|
impls.push(Item {
|
||||||
|
source: infcx.tcx.def_span(impl_def_id).clean(self.cx),
|
||||||
|
name: None,
|
||||||
|
attrs: Default::default(),
|
||||||
|
visibility: None,
|
||||||
|
def_id: self.next_def_id(impl_def_id.krate),
|
||||||
|
stability: None,
|
||||||
|
deprecation: None,
|
||||||
|
inner: ImplItem(Impl {
|
||||||
|
unsafety: hir::Unsafety::Normal,
|
||||||
|
generics: (t_generics, &predicates).clean(self.cx),
|
||||||
|
provided_trait_methods,
|
||||||
|
trait_: Some(trait_.clean(self.cx)),
|
||||||
|
for_: ty.clean(self.cx),
|
||||||
|
items: infcx.tcx.associated_items(impl_def_id)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.clean(self.cx),
|
||||||
|
polarity: None,
|
||||||
|
synthetic: false,
|
||||||
|
blanket_impl: Some(infcx.tcx.type_of(impl_def_id)
|
||||||
|
.clean(self.cx)),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
debug!("{:?} => {}", trait_ref, may_apply);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impls
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx: 'a, 'rcx: 'a> Finder<'a, 'tcx, 'rcx> for BlanketImplFinder<'a, 'tcx, 'rcx> {
|
||||||
|
fn get_cx(&self) -> &DocContext<'a, 'tcx, 'rcx> {
|
||||||
|
&self.cx
|
||||||
|
}
|
||||||
|
}
|
65
src/librustdoc/clean/def_ctor.rs
Normal file
65
src/librustdoc/clean/def_ctor.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
use core::DocContext;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub fn get_def_ctor_from_def_id<F>(cx: &DocContext,
|
||||||
|
def_id: DefId,
|
||||||
|
callback: &F,
|
||||||
|
) -> Vec<Item>
|
||||||
|
where F: Fn(&Fn(DefId) -> Def) -> Vec<Item> {
|
||||||
|
let ty = cx.tcx.type_of(def_id);
|
||||||
|
|
||||||
|
match ty.sty {
|
||||||
|
ty::TyAdt(adt, _) => callback(&match adt.adt_kind() {
|
||||||
|
AdtKind::Struct => Def::Struct,
|
||||||
|
AdtKind::Enum => Def::Enum,
|
||||||
|
AdtKind::Union => Def::Union,
|
||||||
|
}),
|
||||||
|
ty::TyInt(_) |
|
||||||
|
ty::TyUint(_) |
|
||||||
|
ty::TyFloat(_) |
|
||||||
|
ty::TyStr |
|
||||||
|
ty::TyBool |
|
||||||
|
ty::TyChar => callback(&move |_: DefId| {
|
||||||
|
match ty.sty {
|
||||||
|
ty::TyInt(x) => Def::PrimTy(hir::TyInt(x)),
|
||||||
|
ty::TyUint(x) => Def::PrimTy(hir::TyUint(x)),
|
||||||
|
ty::TyFloat(x) => Def::PrimTy(hir::TyFloat(x)),
|
||||||
|
ty::TyStr => Def::PrimTy(hir::TyStr),
|
||||||
|
ty::TyBool => Def::PrimTy(hir::TyBool),
|
||||||
|
ty::TyChar => Def::PrimTy(hir::TyChar),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
_ => {
|
||||||
|
debug!("Unexpected type {:?}", def_id);
|
||||||
|
Vec::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_def_ctor_from_node_id<F>(cx: &DocContext,
|
||||||
|
id: ast::NodeId,
|
||||||
|
name: String,
|
||||||
|
callback: &F,
|
||||||
|
) -> Vec<Item>
|
||||||
|
where F: Fn(&Fn(DefId) -> Def, String) -> Vec<Item> {
|
||||||
|
let item = &cx.tcx.hir.expect_item(id).node;
|
||||||
|
|
||||||
|
callback(&match *item {
|
||||||
|
hir::ItemKind::Struct(_, _) => Def::Struct,
|
||||||
|
hir::ItemKind::Union(_, _) => Def::Union,
|
||||||
|
hir::ItemKind::Enum(_, _) => Def::Enum,
|
||||||
|
_ => panic!("Unexpected type {:?} {:?}", item, id),
|
||||||
|
}, name)
|
||||||
|
}
|
154
src/librustdoc/clean/finder_trait.rs
Normal file
154
src/librustdoc/clean/finder_trait.rs
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
use rustc::hir;
|
||||||
|
use syntax_pos::DUMMY_SP;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub trait Finder<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||||
|
fn get_cx(&self) -> &DocContext<'a, 'tcx, 'rcx>;
|
||||||
|
|
||||||
|
// This is an ugly hack, but it's the simplest way to handle synthetic impls without greatly
|
||||||
|
// refactoring either librustdoc or librustc. In particular, allowing new DefIds to be
|
||||||
|
// registered after the AST is constructed would require storing the defid mapping in a
|
||||||
|
// RefCell, decreasing the performance for normal compilation for very little gain.
|
||||||
|
//
|
||||||
|
// Instead, we construct 'fake' def ids, which start immediately after the last DefId in
|
||||||
|
// DefIndexAddressSpace::Low. In the Debug impl for clean::Item, we explicitly check for fake
|
||||||
|
// def ids, as we'll end up with a panic if we use the DefId Debug impl for fake DefIds
|
||||||
|
fn next_def_id(&self, crate_num: CrateNum) -> DefId {
|
||||||
|
let start_def_id = {
|
||||||
|
let next_id = if crate_num == LOCAL_CRATE {
|
||||||
|
self.get_cx()
|
||||||
|
.tcx
|
||||||
|
.hir
|
||||||
|
.definitions()
|
||||||
|
.def_path_table()
|
||||||
|
.next_id(DefIndexAddressSpace::Low)
|
||||||
|
} else {
|
||||||
|
self.get_cx()
|
||||||
|
.cstore
|
||||||
|
.def_path_table(crate_num)
|
||||||
|
.next_id(DefIndexAddressSpace::Low)
|
||||||
|
};
|
||||||
|
|
||||||
|
DefId {
|
||||||
|
krate: crate_num,
|
||||||
|
index: next_id,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut fake_ids = self.get_cx().fake_def_ids.borrow_mut();
|
||||||
|
|
||||||
|
let def_id = fake_ids.entry(crate_num).or_insert(start_def_id).clone();
|
||||||
|
fake_ids.insert(
|
||||||
|
crate_num,
|
||||||
|
DefId {
|
||||||
|
krate: crate_num,
|
||||||
|
index: DefIndex::from_array_index(
|
||||||
|
def_id.index.as_array_index() + 1,
|
||||||
|
def_id.index.address_space(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
MAX_DEF_ID.with(|m| {
|
||||||
|
m.borrow_mut()
|
||||||
|
.entry(def_id.krate.clone())
|
||||||
|
.or_insert(start_def_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.get_cx().all_fake_def_ids.borrow_mut().insert(def_id);
|
||||||
|
|
||||||
|
def_id.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_real_ty<F>(&self,
|
||||||
|
def_id: DefId,
|
||||||
|
def_ctor: &F,
|
||||||
|
real_name: &Option<Ident>,
|
||||||
|
generics: &ty::Generics,
|
||||||
|
) -> hir::Ty
|
||||||
|
where F: Fn(DefId) -> Def {
|
||||||
|
let path = get_path_for_type(self.get_cx().tcx, def_id, def_ctor);
|
||||||
|
let mut segments = path.segments.into_vec();
|
||||||
|
let last = segments.pop().expect("segments were empty");
|
||||||
|
|
||||||
|
segments.push(hir::PathSegment::new(
|
||||||
|
real_name.unwrap_or(last.ident),
|
||||||
|
self.generics_to_path_params(generics.clone()),
|
||||||
|
false,
|
||||||
|
));
|
||||||
|
|
||||||
|
let new_path = hir::Path {
|
||||||
|
span: path.span,
|
||||||
|
def: path.def,
|
||||||
|
segments: HirVec::from_vec(segments),
|
||||||
|
};
|
||||||
|
|
||||||
|
hir::Ty {
|
||||||
|
id: ast::DUMMY_NODE_ID,
|
||||||
|
node: hir::TyKind::Path(hir::QPath::Resolved(None, P(new_path))),
|
||||||
|
span: DUMMY_SP,
|
||||||
|
hir_id: hir::DUMMY_HIR_ID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generics_to_path_params(&self, generics: ty::Generics) -> hir::GenericArgs {
|
||||||
|
let mut args = vec![];
|
||||||
|
|
||||||
|
for param in generics.params.iter() {
|
||||||
|
match param.kind {
|
||||||
|
ty::GenericParamDefKind::Lifetime => {
|
||||||
|
let name = if param.name == "" {
|
||||||
|
hir::ParamName::Plain(keywords::StaticLifetime.ident())
|
||||||
|
} else {
|
||||||
|
hir::ParamName::Plain(ast::Ident::from_interned_str(param.name))
|
||||||
|
};
|
||||||
|
|
||||||
|
args.push(hir::GenericArg::Lifetime(hir::Lifetime {
|
||||||
|
id: ast::DUMMY_NODE_ID,
|
||||||
|
span: DUMMY_SP,
|
||||||
|
name: hir::LifetimeName::Param(name),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
ty::GenericParamDefKind::Type {..} => {
|
||||||
|
args.push(hir::GenericArg::Type(self.ty_param_to_ty(param.clone())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hir::GenericArgs {
|
||||||
|
args: HirVec::from_vec(args),
|
||||||
|
bindings: HirVec::new(),
|
||||||
|
parenthesized: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ty_param_to_ty(&self, param: ty::GenericParamDef) -> hir::Ty {
|
||||||
|
debug!("ty_param_to_ty({:?}) {:?}", param, param.def_id);
|
||||||
|
hir::Ty {
|
||||||
|
id: ast::DUMMY_NODE_ID,
|
||||||
|
node: hir::TyKind::Path(hir::QPath::Resolved(
|
||||||
|
None,
|
||||||
|
P(hir::Path {
|
||||||
|
span: DUMMY_SP,
|
||||||
|
def: Def::TyParam(param.def_id),
|
||||||
|
segments: HirVec::from_vec(vec![
|
||||||
|
hir::PathSegment::from_ident(Ident::from_interned_str(param.name))
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
)),
|
||||||
|
span: DUMMY_SP,
|
||||||
|
hir_id: hir::DUMMY_HIR_ID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,13 @@ use rustc::util::nodemap::FxHashSet;
|
||||||
|
|
||||||
use core::{DocContext, DocAccessLevels};
|
use core::{DocContext, DocAccessLevels};
|
||||||
use doctree;
|
use doctree;
|
||||||
use clean::{self, GetDefId, ToSource, get_auto_traits_with_def_id};
|
use clean::{
|
||||||
|
self,
|
||||||
|
GetDefId,
|
||||||
|
ToSource,
|
||||||
|
get_auto_traits_with_def_id,
|
||||||
|
get_blanket_impls_with_def_id,
|
||||||
|
};
|
||||||
|
|
||||||
use super::Clean;
|
use super::Clean;
|
||||||
|
|
||||||
|
@ -168,7 +174,7 @@ pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let fqn = if let clean::TypeKind::Macro = kind {
|
let fqn = if let clean::TypeKind::Macro = kind {
|
||||||
vec![crate_name, relative.last().unwrap()]
|
vec![crate_name, relative.last().expect("relative was empty")]
|
||||||
} else {
|
} else {
|
||||||
once(crate_name).chain(relative).collect()
|
once(crate_name).chain(relative).collect()
|
||||||
};
|
};
|
||||||
|
@ -274,12 +280,15 @@ pub fn build_impls(cx: &DocContext, did: DefId, auto_traits: bool) -> Vec<clean:
|
||||||
|
|
||||||
if auto_traits {
|
if auto_traits {
|
||||||
let auto_impls = get_auto_traits_with_def_id(cx, did);
|
let auto_impls = get_auto_traits_with_def_id(cx, did);
|
||||||
|
{
|
||||||
let mut renderinfo = cx.renderinfo.borrow_mut();
|
let mut renderinfo = cx.renderinfo.borrow_mut();
|
||||||
let new_impls: Vec<clean::Item> = auto_impls.into_iter()
|
let new_impls: Vec<clean::Item> = auto_impls.into_iter()
|
||||||
.filter(|i| renderinfo.inlined.insert(i.def_id)).collect();
|
.filter(|i| renderinfo.inlined.insert(i.def_id)).collect();
|
||||||
|
|
||||||
impls.extend(new_impls);
|
impls.extend(new_impls);
|
||||||
}
|
}
|
||||||
|
impls.extend(get_blanket_impls_with_def_id(cx, did));
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the first time we've inlined something from another crate, then
|
// If this is the first time we've inlined something from another crate, then
|
||||||
// we inline *all* impls from all the crates into this crate. Note that there's
|
// we inline *all* impls from all the crates into this crate. Note that there's
|
||||||
|
@ -336,10 +345,13 @@ pub fn build_impls(cx: &DocContext, did: DefId, auto_traits: bool) -> Vec<clean:
|
||||||
build_impl(cx, def_id, &mut impls);
|
build_impl(cx, def_id, &mut impls);
|
||||||
|
|
||||||
let auto_impls = get_auto_traits_with_def_id(cx, def_id);
|
let auto_impls = get_auto_traits_with_def_id(cx, def_id);
|
||||||
|
let blanket_impls = get_blanket_impls_with_def_id(cx, def_id);
|
||||||
let mut renderinfo = cx.renderinfo.borrow_mut();
|
let mut renderinfo = cx.renderinfo.borrow_mut();
|
||||||
|
|
||||||
let new_impls: Vec<clean::Item> = auto_impls.into_iter()
|
let new_impls: Vec<clean::Item> = auto_impls.into_iter()
|
||||||
.filter(|i| renderinfo.inlined.insert(i.def_id)).collect();
|
.chain(blanket_impls.into_iter())
|
||||||
|
.filter(|i| renderinfo.inlined.insert(i.def_id))
|
||||||
|
.collect();
|
||||||
|
|
||||||
impls.extend(new_impls);
|
impls.extend(new_impls);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,13 @@ pub mod inline;
|
||||||
pub mod cfg;
|
pub mod cfg;
|
||||||
mod simplify;
|
mod simplify;
|
||||||
mod auto_trait;
|
mod auto_trait;
|
||||||
|
mod blanket_impl;
|
||||||
|
pub mod def_ctor;
|
||||||
|
mod finder_trait;
|
||||||
|
|
||||||
use self::cfg::Cfg;
|
use self::cfg::Cfg;
|
||||||
use self::auto_trait::AutoTraitFinder;
|
use self::auto_trait::AutoTraitFinder;
|
||||||
|
use self::blanket_impl::BlanketImplFinder;
|
||||||
|
|
||||||
thread_local!(static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = RefCell::new(FxHashMap()));
|
thread_local!(static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = RefCell::new(FxHashMap()));
|
||||||
|
|
||||||
|
@ -569,7 +573,7 @@ pub struct Module {
|
||||||
impl Clean<Item> for doctree::Module {
|
impl Clean<Item> for doctree::Module {
|
||||||
fn clean(&self, cx: &DocContext) -> Item {
|
fn clean(&self, cx: &DocContext) -> Item {
|
||||||
let name = if self.name.is_some() {
|
let name = if self.name.is_some() {
|
||||||
self.name.unwrap().clean(cx)
|
self.name.expect("No name provided").clean(cx)
|
||||||
} else {
|
} else {
|
||||||
"".to_string()
|
"".to_string()
|
||||||
};
|
};
|
||||||
|
@ -1064,7 +1068,7 @@ fn span_of_attrs(attrs: &Attributes) -> syntax_pos::Span {
|
||||||
return DUMMY_SP;
|
return DUMMY_SP;
|
||||||
}
|
}
|
||||||
let start = attrs.doc_strings[0].span();
|
let start = attrs.doc_strings[0].span();
|
||||||
let end = attrs.doc_strings.last().unwrap().span();
|
let end = attrs.doc_strings.last().expect("No doc strings provided").span();
|
||||||
start.to(end)
|
start.to(end)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1728,7 +1732,7 @@ impl Clean<Lifetime> for hir::GenericParam {
|
||||||
hir::GenericBound::Outlives(lt) => lt,
|
hir::GenericBound::Outlives(lt) => lt,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
});
|
});
|
||||||
let name = bounds.next().unwrap().name.ident();
|
let name = bounds.next().expect("no more bounds").name.ident();
|
||||||
let mut s = format!("{}: {}", self.name.ident(), name);
|
let mut s = format!("{}: {}", self.name.ident(), name);
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
s.push_str(&format!(" + {}", bound.name.ident()));
|
s.push_str(&format!(" + {}", bound.name.ident()));
|
||||||
|
@ -1841,8 +1845,8 @@ impl<'tcx> Clean<WherePredicate> for ty::OutlivesPredicate<ty::Region<'tcx>, ty:
|
||||||
fn clean(&self, cx: &DocContext) -> WherePredicate {
|
fn clean(&self, cx: &DocContext) -> WherePredicate {
|
||||||
let ty::OutlivesPredicate(ref a, ref b) = *self;
|
let ty::OutlivesPredicate(ref a, ref b) = *self;
|
||||||
WherePredicate::RegionPredicate {
|
WherePredicate::RegionPredicate {
|
||||||
lifetime: a.clean(cx).unwrap(),
|
lifetime: a.clean(cx).expect("failed to clean lifetime"),
|
||||||
bounds: vec![GenericBound::Outlives(b.clean(cx).unwrap())]
|
bounds: vec![GenericBound::Outlives(b.clean(cx).expect("failed to clean bounds"))]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1853,7 +1857,7 @@ impl<'tcx> Clean<WherePredicate> for ty::OutlivesPredicate<Ty<'tcx>, ty::Region<
|
||||||
|
|
||||||
WherePredicate::BoundPredicate {
|
WherePredicate::BoundPredicate {
|
||||||
ty: ty.clean(cx),
|
ty: ty.clean(cx),
|
||||||
bounds: vec![GenericBound::Outlives(lt.clean(cx).unwrap())]
|
bounds: vec![GenericBound::Outlives(lt.clean(cx).expect("failed to clean lifetimes"))]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1947,7 +1951,7 @@ impl Clean<GenericParamDef> for hir::GenericParam {
|
||||||
hir::GenericBound::Outlives(lt) => lt,
|
hir::GenericBound::Outlives(lt) => lt,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
});
|
});
|
||||||
let name = bounds.next().unwrap().name.ident();
|
let name = bounds.next().expect("no more bounds").name.ident();
|
||||||
let mut s = format!("{}: {}", self.name.ident(), name);
|
let mut s = format!("{}: {}", self.name.ident(), name);
|
||||||
for bound in bounds {
|
for bound in bounds {
|
||||||
s.push_str(&format!(" + {}", bound.name.ident()));
|
s.push_str(&format!(" + {}", bound.name.ident()));
|
||||||
|
@ -2933,7 +2937,7 @@ impl Clean<Type> for hir::Ty {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(&hir::ItemKind::Ty(ref ty, ref generics)) = alias {
|
if let Some(&hir::ItemKind::Ty(ref ty, ref generics)) = alias {
|
||||||
let provided_params = &path.segments.last().unwrap();
|
let provided_params = &path.segments.last().expect("segments were empty");
|
||||||
let mut ty_substs = FxHashMap();
|
let mut ty_substs = FxHashMap();
|
||||||
let mut lt_substs = FxHashMap();
|
let mut lt_substs = FxHashMap();
|
||||||
provided_params.with_generic_args(|generic_args| {
|
provided_params.with_generic_args(|generic_args| {
|
||||||
|
@ -3006,7 +3010,7 @@ impl Clean<Type> for hir::Ty {
|
||||||
segments: segments.into(),
|
segments: segments.into(),
|
||||||
};
|
};
|
||||||
Type::QPath {
|
Type::QPath {
|
||||||
name: p.segments.last().unwrap().ident.name.clean(cx),
|
name: p.segments.last().expect("segments were empty").ident.name.clean(cx),
|
||||||
self_type: box qself.clean(cx),
|
self_type: box qself.clean(cx),
|
||||||
trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
|
trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
|
||||||
}
|
}
|
||||||
|
@ -3062,7 +3066,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||||
ty::TyStr => Primitive(PrimitiveType::Str),
|
ty::TyStr => Primitive(PrimitiveType::Str),
|
||||||
ty::TySlice(ty) => Slice(box ty.clean(cx)),
|
ty::TySlice(ty) => Slice(box ty.clean(cx)),
|
||||||
ty::TyArray(ty, n) => {
|
ty::TyArray(ty, n) => {
|
||||||
let mut n = cx.tcx.lift(&n).unwrap();
|
let mut n = cx.tcx.lift(&n).expect("array lift failed");
|
||||||
if let ConstValue::Unevaluated(def_id, substs) = n.val {
|
if let ConstValue::Unevaluated(def_id, substs) = n.val {
|
||||||
let param_env = cx.tcx.param_env(def_id);
|
let param_env = cx.tcx.param_env(def_id);
|
||||||
let cid = GlobalId {
|
let cid = GlobalId {
|
||||||
|
@ -3084,7 +3088,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||||
},
|
},
|
||||||
ty::TyFnDef(..) |
|
ty::TyFnDef(..) |
|
||||||
ty::TyFnPtr(_) => {
|
ty::TyFnPtr(_) => {
|
||||||
let ty = cx.tcx.lift(self).unwrap();
|
let ty = cx.tcx.lift(self).expect("TyFnPtr lift failed");
|
||||||
let sig = ty.fn_sig(cx.tcx);
|
let sig = ty.fn_sig(cx.tcx);
|
||||||
BareFunction(box BareFunctionDecl {
|
BareFunction(box BareFunctionDecl {
|
||||||
unsafety: sig.unsafety(),
|
unsafety: sig.unsafety(),
|
||||||
|
@ -3175,7 +3179,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||||
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
|
||||||
// by looking up the projections associated with the def_id.
|
// by looking up the projections associated with the def_id.
|
||||||
let predicates_of = cx.tcx.predicates_of(def_id);
|
let predicates_of = cx.tcx.predicates_of(def_id);
|
||||||
let substs = cx.tcx.lift(&substs).unwrap();
|
let substs = cx.tcx.lift(&substs).expect("TyAnon lift failed");
|
||||||
let bounds = predicates_of.instantiate(cx.tcx, substs);
|
let bounds = predicates_of.instantiate(cx.tcx, substs);
|
||||||
let mut regions = vec![];
|
let mut regions = vec![];
|
||||||
let mut has_sized = false;
|
let mut has_sized = false;
|
||||||
|
@ -3314,6 +3318,7 @@ impl Clean<Vec<Item>> for doctree::Struct {
|
||||||
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
||||||
let name = self.name.clean(cx);
|
let name = self.name.clean(cx);
|
||||||
let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone());
|
let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone());
|
||||||
|
ret.extend(get_blanket_impls_with_node_id(cx, self.id, name.clone()));
|
||||||
|
|
||||||
*cx.current_item_name.borrow_mut() = Some(self.name);
|
*cx.current_item_name.borrow_mut() = Some(self.name);
|
||||||
ret.push(Item {
|
ret.push(Item {
|
||||||
|
@ -3340,6 +3345,7 @@ impl Clean<Vec<Item>> for doctree::Union {
|
||||||
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
||||||
let name = self.name.clean(cx);
|
let name = self.name.clean(cx);
|
||||||
let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone());
|
let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone());
|
||||||
|
ret.extend(get_blanket_impls_with_node_id(cx, self.id, name.clone()));
|
||||||
|
|
||||||
*cx.current_item_name.borrow_mut() = Some(self.name);
|
*cx.current_item_name.borrow_mut() = Some(self.name);
|
||||||
ret.push(Item {
|
ret.push(Item {
|
||||||
|
@ -3393,6 +3399,7 @@ impl Clean<Vec<Item>> for doctree::Enum {
|
||||||
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
||||||
let name = self.name.clean(cx);
|
let name = self.name.clean(cx);
|
||||||
let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone());
|
let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone());
|
||||||
|
ret.extend(get_blanket_impls_with_node_id(cx, self.id, name.clone()));
|
||||||
|
|
||||||
*cx.current_item_name.borrow_mut() = Some(self.name);
|
*cx.current_item_name.borrow_mut() = Some(self.name);
|
||||||
ret.push(Item {
|
ret.push(Item {
|
||||||
|
@ -3545,7 +3552,7 @@ pub struct Path {
|
||||||
|
|
||||||
impl Path {
|
impl Path {
|
||||||
pub fn last_name(&self) -> &str {
|
pub fn last_name(&self) -> &str {
|
||||||
self.segments.last().unwrap().name.as_str()
|
self.segments.last().expect("segments were empty").name.as_str()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3875,6 +3882,17 @@ pub fn get_auto_traits_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
|
||||||
finder.get_with_def_id(id)
|
finder.get_with_def_id(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_blanket_impls_with_node_id(cx: &DocContext, id: ast::NodeId, name: String) -> Vec<Item> {
|
||||||
|
let finder = BlanketImplFinder::new(cx);
|
||||||
|
finder.get_with_node_id(id, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_blanket_impls_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
|
||||||
|
let finder = BlanketImplFinder::new(cx);
|
||||||
|
|
||||||
|
finder.get_with_def_id(id)
|
||||||
|
}
|
||||||
|
|
||||||
fn get_name_if_possible(cx: &DocContext, node: NodeId) -> Option<Name> {
|
fn get_name_if_possible(cx: &DocContext, node: NodeId) -> Option<Name> {
|
||||||
match cx.tcx.hir.get(node) {
|
match cx.tcx.hir.get(node) {
|
||||||
Node::NodeItem(_) |
|
Node::NodeItem(_) |
|
||||||
|
@ -4196,7 +4214,7 @@ fn print_const(cx: &DocContext, n: &ty::Const) -> String {
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
::rustc::mir::fmt_const_val(&mut s, n).unwrap();
|
::rustc::mir::fmt_const_val(&mut s, n).expect("fmt_const_val failed");
|
||||||
// array lengths are obviously usize
|
// array lengths are obviously usize
|
||||||
if s.ends_with("usize") {
|
if s.ends_with("usize") {
|
||||||
let n = s.len() - "usize".len();
|
let n = s.len() - "usize".len();
|
||||||
|
@ -4257,7 +4275,8 @@ fn register_def(cx: &DocContext, def: Def) -> DefId {
|
||||||
Def::TyForeign(i) => (i, TypeKind::Foreign),
|
Def::TyForeign(i) => (i, TypeKind::Foreign),
|
||||||
Def::Const(i) => (i, TypeKind::Const),
|
Def::Const(i) => (i, TypeKind::Const),
|
||||||
Def::Static(i, _) => (i, TypeKind::Static),
|
Def::Static(i, _) => (i, TypeKind::Static),
|
||||||
Def::Variant(i) => (cx.tcx.parent_def_id(i).unwrap(), TypeKind::Enum),
|
Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent def id"),
|
||||||
|
TypeKind::Enum),
|
||||||
Def::Macro(i, _) => (i, TypeKind::Macro),
|
Def::Macro(i, _) => (i, TypeKind::Macro),
|
||||||
Def::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait),
|
Def::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait),
|
||||||
Def::SelfTy(_, Some(impl_def_id)) => {
|
Def::SelfTy(_, Some(impl_def_id)) => {
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub fn where_clauses(cx: &DocContext, clauses: Vec<WP>) -> Vec<WP> {
|
||||||
if !trait_is_same_or_supertrait(cx, did, trait_did) {
|
if !trait_is_same_or_supertrait(cx, did, trait_did) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
let last = path.segments.last_mut().unwrap();
|
let last = path.segments.last_mut().expect("segments were empty");
|
||||||
match last.args {
|
match last.args {
|
||||||
PP::AngleBracketed { ref mut bindings, .. } => {
|
PP::AngleBracketed { ref mut bindings, .. } => {
|
||||||
bindings.push(clean::TypeBinding {
|
bindings.push(clean::TypeBinding {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue