diff --git a/.travis.yml b/.travis.yml index c76e17a27d188..db34f1404481b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -169,6 +169,8 @@ matrix: if: branch = auto - env: IMAGE=x86_64-gnu-aux if: branch = auto + - env: IMAGE=x86_64-gnu-cargotest + if: branch = auto - env: IMAGE=x86_64-gnu-debug if: branch = auto - env: IMAGE=x86_64-gnu-nopt diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 6bec933018686..d42476bc4130d 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,7 +6,7 @@ A version of this document [can be found online](https://www.rust-lang.org/condu **Contact**: [rust-mods@rust-lang.org](mailto:rust-mods@rust-lang.org) -* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic. +* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic. * On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all. * Please be kind and courteous. There's no need to be mean or rude. * Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. diff --git a/appveyor.yml b/appveyor.yml index 599d1b40ceb1e..b86fa25337b00 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,6 +25,11 @@ environment: RUST_CHECK_TARGET: check-aux RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc + # MSVC cargotest + - MSYS_BITS: 64 + SCRIPT: python x.py test src/tools/cargotest + RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc + # 32/64-bit MinGW builds. # # We are using MinGW with posix threads since LLVM does not compile with diff --git a/config.toml.example b/config.toml.example index 261fe2053879f..df0142b8d46df 100644 --- a/config.toml.example +++ b/config.toml.example @@ -203,6 +203,16 @@ # Where to install man pages in `prefix` above #mandir = "share/man" +# Where to install data in `prefix` above (currently unused) +#datadir = "share" + +# Where to install additional info in `prefix` above (currently unused) +#infodir = "share/info" + +# Where to install local state (currently unused) +# If this is a relative path, it will get installed in `prefix` above +#localstatedir = "/var/lib" + # ============================================================================= # Options for compiling Rust code itself # ============================================================================= diff --git a/src/Cargo.lock b/src/Cargo.lock index 0989c430df0e4..69c3789f337c6 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1,7 +1,3 @@ -[root] -name = "workspace_symbol" -version = "0.1.0" - [[package]] name = "advapi32-sys" version = "0.2.0" @@ -24,7 +20,7 @@ name = "aho-corasick" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -63,7 +59,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ar" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -72,11 +68,12 @@ version = "0.0.0" [[package]] name = "atty" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -85,42 +82,33 @@ name = "backtrace" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bin_lib" version = "0.1.0" -[[package]] -name = "bin_lib_no_cfg_test" -version = "0.1.0" - [[package]] name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bitflags" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "0.9.1" @@ -138,14 +126,14 @@ dependencies = [ "build_helper 0.1.0", "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -171,25 +159,25 @@ dependencies = [ name = "build_helper" version = "0.1.0" dependencies = [ - "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cargo" -version = "0.23.0" +version = "0.24.0" dependencies = [ - "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "cargotest 0.1.0", "core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crates-io 0.12.0", + "crates-io 0.13.0", "crossbeam 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crypto-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -199,14 +187,13 @@ dependencies = [ "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "home 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jobserver 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -214,7 +201,7 @@ dependencies = [ "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -224,18 +211,28 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cargo_metadata" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cargotest" version = "0.1.0" dependencies = [ - "cargo 0.23.0", - "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo 0.24.0", + "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -260,7 +257,7 @@ version = "2.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -270,6 +267,44 @@ dependencies = [ "yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clippy" +version = "0.0.166" +dependencies = [ + "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy-mini-macro-test 0.1.0", + "clippy_lints 0.0.166", + "compiletest_rs 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "clippy-mini-macro-test" +version = "0.1.0" + +[[package]] +name = "clippy_lints" +version = "0.0.166" +dependencies = [ + "if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cmake" version = "0.1.26" @@ -279,11 +314,19 @@ dependencies = [ ] [[package]] -name = "collections" -version = "0.0.0" +name = "commoncrypto" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "alloc 0.0.0", - "core 0.0.0", + "commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "commoncrypto-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -300,25 +343,26 @@ version = "0.0.0" dependencies = [ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "completion" -version = "0.1.0" - -[[package]] -name = "conv" -version = "0.3.3" +name = "compiletest_rs" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "completion" +version = "0.1.0" + [[package]] name = "core" version = "0.0.0" @@ -332,7 +376,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -340,18 +384,18 @@ name = "core-foundation-sys" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crates-io" -version = "0.12.0" +version = "0.13.0" dependencies = [ "curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -365,6 +409,18 @@ name = "crossbeam" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crypto-hash" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cssparser" version = "0.13.7" @@ -373,7 +429,7 @@ dependencies = [ "cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", - "procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "procedural-masquerade 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -384,7 +440,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", - "procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "procedural-masquerade 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -395,10 +451,10 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -408,19 +464,14 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "custom_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "dbghelp-sys" version = "0.2.0" @@ -457,7 +508,7 @@ name = "docopt" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -469,6 +520,22 @@ name = "dtoa" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "duct" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "os_pipe 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "shared_child 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "either" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "enum_primitive" version = "0.1.1" @@ -495,6 +562,14 @@ dependencies = [ "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "error-chain" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.11.0" @@ -510,19 +585,20 @@ dependencies = [ "rustdoc 0.0.0", ] +[[package]] +name = "features" +version = "0.1.0" + [[package]] name = "filetime" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "find_all_refs" -version = "0.1.0" - [[package]] name = "find_all_refs_no_cfg_test" version = "0.1.0" @@ -536,7 +612,7 @@ name = "flate2" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -560,10 +636,26 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fuchsia-zircon" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "futf" version = "0.1.3" @@ -589,10 +681,10 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -620,14 +712,10 @@ dependencies = [ "aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "goto_def" -version = "0.1.0" - [[package]] name = "graphviz" version = "0.0.0" @@ -646,13 +734,13 @@ name = "handlebars" version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -660,10 +748,6 @@ name = "hex" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "highlight" -version = "0.1.0" - [[package]] name = "home" version = "0.3.0" @@ -676,10 +760,6 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hover" -version = "0.1.0" - [[package]] name = "html-diff" version = "0.0.4" @@ -710,6 +790,11 @@ dependencies = [ "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "if_chain" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ignore" version = "0.2.2" @@ -717,9 +802,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -745,13 +830,21 @@ dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "xz2 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "itertools" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "either 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "itoa" version = "0.3.4" @@ -759,11 +852,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jobserver" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -775,7 +868,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -806,14 +899,19 @@ dependencies = [ "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lazy_static" -version = "0.2.8" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazycell" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -825,21 +923,21 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.31" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.6.15" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "curl-sys 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -849,19 +947,19 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libz-sys" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -881,8 +979,8 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -891,23 +989,6 @@ name = "mac" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "magenta" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "magenta-sys" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "markup5ever" version = "0.3.2" @@ -935,14 +1016,14 @@ dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "handlebars 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -952,15 +1033,15 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -969,7 +1050,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -994,11 +1075,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nix" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "num" version = "0.1.40" @@ -1019,7 +1111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1067,16 +1159,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num_cpus" -version = "1.6.2" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "omit_init_build" -version = "0.1.0" - [[package]] name = "open" version = "1.2.1" @@ -1084,14 +1172,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.9.19" +version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1101,15 +1189,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.19" +version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "os_pipe" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "owning_ref" version = "0.3.3" @@ -1169,7 +1267,7 @@ version = "0.7.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1187,7 +1285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "precomputed-hash" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1201,7 +1299,7 @@ dependencies = [ [[package]] name = "procedural-masquerade" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1223,10 +1321,11 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.0.14" +version = "0.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1243,6 +1342,11 @@ name = "quick-error" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "quine-mc_cluskey" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "0.2.3" @@ -1276,11 +1380,11 @@ dependencies = [ [[package]] name = "rand" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1288,6 +1392,14 @@ name = "redox_syscall" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "reformat" version = "0.1.0" @@ -1314,7 +1426,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1338,48 +1450,44 @@ version = "0.1.0" name = "remote-test-server" version = "0.1.0" -[[package]] -name = "rename" -version = "0.1.0" - [[package]] name = "rls" version = "0.122.0" dependencies = [ - "cargo 0.23.0", + "cargo 0.24.0", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "languageserver-types 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "racer 2.0.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-analysis 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-analysis 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-rustc 0.1.1 (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.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 0.2.7", + "rustfmt-nightly 0.2.13", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rls-analysis" -version = "0.6.8" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive-new 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rls-data" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1429,7 +1537,7 @@ dependencies = [ "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "fmt_macros 0.0.0", "graphviz 0.0.0", - "jobserver 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_back 0.0.0", @@ -1554,7 +1662,7 @@ dependencies = [ name = "rustc_driver" version = "0.0.0" dependencies = [ - "ar 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "arena 0.0.0", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "graphviz 0.0.0", @@ -1589,6 +1697,7 @@ dependencies = [ name = "rustc_errors" version = "0.0.0" dependencies = [ + "rustc_data_structures 0.0.0", "serialize 0.0.0", "syntax_pos 0.0.0", ] @@ -1740,7 +1849,7 @@ name = "rustc_save_analysis" version = "0.0.0" dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1757,9 +1866,9 @@ dependencies = [ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", - "jobserver 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1781,7 +1890,7 @@ dependencies = [ name = "rustc_trans_utils" version = "0.0.0" dependencies = [ - "ar 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1829,7 +1938,7 @@ dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "html-diff 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1841,18 +1950,18 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "0.2.7" +version = "0.2.13" dependencies = [ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "strings 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1890,10 +1999,18 @@ dependencies = [ "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", "phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", - "precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "semver" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "semver" version = "0.8.0" @@ -1942,7 +2059,7 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1955,6 +2072,16 @@ dependencies = [ name = "serialize" version = "0.0.0" +[[package]] +name = "shared_child" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "shell-escape" version = "0.1.3" @@ -1972,12 +2099,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "socket2" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1995,7 +2122,6 @@ dependencies = [ "alloc_jemalloc 0.0.0", "alloc_system 0.0.0", "build_helper 0.1.0", - "collections 0.0.0", "compiler_builtins 0.0.0", "core 0.0.0", "libc 0.0.0", @@ -2024,9 +2150,9 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", - "precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_codegen 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2125,7 +2251,7 @@ name = "syntex_errors" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2147,7 +2273,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_errors 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2161,8 +2287,8 @@ name = "tar" version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "xattr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2171,7 +2297,7 @@ name = "tempdir" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2203,7 +2329,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2215,6 +2341,16 @@ dependencies = [ "wincolor 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "test" version = "0.0.0" @@ -2238,7 +2374,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2254,7 +2390,7 @@ name = "thread_local" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2316,10 +2452,6 @@ name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unicødë" -version = "0.1.0" - [[package]] name = "unreachable" version = "0.1.1" @@ -2441,6 +2573,10 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "workspace_symbol" +version = "0.1.0" + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -2455,7 +2591,7 @@ name = "xattr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2476,44 +2612,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" -"checksum ar 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b24e4eef8e3fa7e2ca75b157e6039cdf8d9d3a68213ddc19d0fd9d576b9717c9" -"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159" +"checksum ar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35c7a5669cb64f085739387e1308b74e6d44022464b7f1b63bbd4ceb6379ec31" +"checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860" "checksum backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983" -"checksum backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c63ea141ef8fdb10409d0f5daf30ac51f84ef43bff66f16627773d2a292cd189" +"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32" +"checksum cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "be1057b8462184f634c3a208ee35b0f935cfd94b694b26deadccd98732088d7b" "checksum cc 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c674f0870e3dbd4105184ea035acb1c32c8ae69939c9e228d2b11bbfe29efad" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3451e409013178663435d6f15fdb212f14ee4424a3d74f979d081d0a66b6f1f2" "checksum cmake 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "357c07e7a1fc95732793c1edb5901e1a1f305cfcf63a90eb12dbd22bdb6b789d" -"checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" +"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" +"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" +"checksum compiletest_rs 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2741d378feb7a434dba54228c89a70b4e427fee521de67cdda3750b8a0265f5a" "checksum core-foundation 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5909502e547762013619f4c4e01cc7393c20fe2d52d7fa471c1210adb2320dc7" "checksum core-foundation-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bc9fb3d6cb663e6fd7cf1c63f9b144ee2b1e4a78595a0451dd34bff85b9a3387" "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" "checksum crossbeam 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8837ab96533202c5b610ed44bc7f4183e7957c1c8f56e8cc78bb098593c8ba0a" +"checksum crypto-hash 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34903878eec1694faf53cae8473a088df333181de421d4d3d48061d6559fe602" "checksum cssparser 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef6124306e5ebc5ab11891d063aeafdd0cdc308079b708c8b566125f3680292b" "checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df" "checksum curl 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7034c534a1d7d22f7971d6088aa9d281d219ef724026c3428092500f41ae9c2c" "checksum curl-sys 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "4bee31aa3a079d5f3ff9579ea4dcfb1b1a17a40886f5f467436d383e78134b55" -"checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" "checksum debug_unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a032eac705ca39214d169f83e3d3da290af06d8d1d344d1baad2fd002dca4b3" "checksum derive-new 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41be6ca3b99e0c0483fb2389685448f650459c3ecbe4e18d7705d8010ec4ab8e" "checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472" "checksum docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b5b93718f8b3e5544fcc914c43de828ca6c6ace23e0332c6080a2977b49787a" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" +"checksum duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e45aa15fe0a8a8f511e6d834626afd55e49b62e5c8802e18328a87e8a8f6065c" +"checksum either 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e311a7479512fbdf858fb54d91ec59f3b9f85bc0113659f46bba12b199d273ce" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" -"checksum filetime 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "6ab199bf38537c6f38792669e081e0bb278b9b7405bba2642e4e5d15bf732c0e" +"checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" +"checksum filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "aa75ec8f7927063335a9583e7fa87b0110bb888cf766dc01b54c0ff70d760c8e" "checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" "checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" "checksum foreign-types 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e4056b9bd47f8ac5ba12be771f77a0dae796d1bbaaf5fd0b9c2d38b69b8a29d" "checksum fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ab76cfd2aaa59b7bf6688ad9ba15bbae64bff97f04ea02144cfd3443e5c2866" +"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" +"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" "checksum futf 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "51f93f3de6ba1794dcd5810b3546d004600a59a98266487c8407bc4b24e398f3" "checksum futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "05a23db7bd162d4e8265968602930c476f688f0c180b44bdaf55e0cb2c687558" "checksum getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "65922871abd2f101a2eb0eaebadc66668e54a87ad9c3dd82520b5f86ede5eff9" @@ -2528,31 +2671,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum html-diff 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5298d63081a642508fce965740ddb03a386c5d81bf1fef0579a815cf49cb8c68" "checksum html5ever 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a49d5001dd1bddf042ea41ed4e0a671d50b1bf187e66b349d7ec613bdce4ad90" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" +"checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" "checksum ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b3fcaf2365eb14b28ec7603c98c06cc531f19de9eb283d89a3dff8417c8c99f5" +"checksum itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3f2be4da1690a039e9ae5fd575f706a63ad5a2120f161b1d653c9da3930dd21" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" -"checksum jobserver 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "094f87ed101b6832def8632f43db43dc204d27897eb95aca69b26ce2e4011e84" +"checksum jobserver 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "931b04e5e57d88cc909528f0d701db36a870b72a052648ded8baf80f9f445e0f" "checksum jsonrpc-core 7.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1acd0f9934da94466d2370f36832b9b19271b4abdfdb5e69f0bcd991ebcd515" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kuchiki 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ef2ea4f2f7883cd7c6772b06c14abca01a2cc1f75c426cebffcf6b3b925ef9fc" "checksum languageserver-types 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d52e477b23bf52cd3ca0f9fc6c5d14be954eec97e3b9cdfbd962d911bd533caf" -"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" -"checksum libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d1419b2939a0bc44b77feb34661583c7546b532b192feab36249ab584b86856c" -"checksum libgit2-sys 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)" = "205fc37e829c5b36de63d14c8dc8b62c5a6a2519b16318ed0977079ca97256a9" +"checksum lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9e5e58fa1a4c3b915a561a78a22ee0cac6ab97dca2504428bc1cb074375f8d5" +"checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" +"checksum libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)" = "56cce3130fd040c28df6f495c8492e5ec5808fb4c9093c310df02b0c8f030148" +"checksum libgit2-sys 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "6f74b4959cef96898f5123148724fc7dee043b9a6b99f219d948851bfbe53cb2" "checksum libssh2-sys 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0db4ec23611747ef772db1c4d650f8bd762f07b461727ec998f953c614024b75" -"checksum libz-sys 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "44ebbc760fd2d2f4d93de09a0e13d97e057612052e871da9985cedcb451e6bd5" +"checksum libz-sys 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "87f737ad6cc6fd6eefe3d9dc5412f1573865bded441300904d2f42269e140f16" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" "checksum lzma-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c1b93b78f89e8737dac81837fc8f5521ac162abcba902e1a3db949d55346d1da" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" -"checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527" -"checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699" "checksum markup5ever 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ff834ac7123c6a37826747e5ca09db41fd7a83126792021c2e636ad174bb77d3" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum mdbook 0.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "8a1ac668292d1e5c7b1c6fd64f70d3a85105b8069a89558a0d67bdb2ff298ca1" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" +"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a" "checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "3a80f842784ef6c9a958b68b7516bc7e35883c614004dd94959a4dca1b716c09" +"checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487" "checksum num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "a311b77ebdc5dd4cf6449d81e4135d9f0e3b153839ac90e648a8ef538f923525" "checksum num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "8fd0f8dbb4c0960998958a796281d88c16fbe68d87b1baa6f31e2979e81fd0bd" "checksum num-complex 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "503e668405c5492d67cf662a81e05be40efe2e6bcf10f7794a07bd9865e704e6" @@ -2560,11 +2705,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01" "checksum num-rational 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "288629c76fac4b33556f4b7ab57ba21ae202da65ba8b77466e6d598e31990790" "checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0" -"checksum num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aec53c34f2d0247c5ca5d32cca1478762f301740468ee9ee6dcb7a0dd7a0c584" +"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d" "checksum open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113" -"checksum openssl 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "816914b22eb15671d62c73442a51978f311e911d6a6f6cbdafa6abce1b5038fc" +"checksum openssl 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf434ff6117485dc16478d77a4f5c84eccc9c3645c4da8323b287ad6a15a638" "checksum openssl-probe 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98df0270d404ccd3c050a41d579c52d1db15375168bb3471e04ec0f5f378daf" -"checksum openssl-sys 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4c63a7d559c1e5afa6d6a9e6fa34bbc5f800ffc9ae08b72c605420b0c4f5e8" +"checksum openssl-sys 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)" = "0ad395f1cee51b64a8d07cc8063498dc7554db62d5f3ca87a67f4eed2791d0c8" +"checksum os_pipe 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "998bfbb3042e715190fe2a41abfa047d7e8cb81374d2977d7f100eacd8619cb1" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356" "checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" @@ -2573,23 +2719,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03" "checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" -"checksum precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf1fc3616b3ef726a847f2cd2388c646ef6a1f1ba4835c2629004da48184150" -"checksum procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c93cdc1fb30af9ddf3debc4afbdb0f35126cbd99daa229dd76cdd5349b41d989" +"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +"checksum procedural-masquerade 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9ae21842e88415394f6b6fccf1f4af4c98a5bfb3eab92188f2e83409cda0c995" "checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" -"checksum pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab1e588ef8efd702c7ed9d2bd774db5e6f4d878bb5a1a9f371828fbdff6973" +"checksum pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "378e941dbd392c101f2cb88097fa4d7167bc421d4b88de3ff7dbee503bc3233b" "checksum pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a656fdb8b6848f896df5e478a0eb9083681663e37dcb77dd16981ff65329fe8b" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" +"checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" "checksum quote 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c5cf478fe1006dbcc72567121d23dbdae5f1632386068c5c86ff4f645628504" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum racer 2.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "f120c7510ef7aff254aeb06067fb6fac573ec96a1660e194787cf9dced412bf0" -"checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf" +"checksum rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "61efcbcd9fa8d8fbb07c84e34a8af18a1ff177b449689ad38a6e9457ecc7b2ae" "checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" -"checksum rls-analysis 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fa390bdc70b0a90d07d9cd5c6989ba5fca2d59728903919ebda1a1b2037b18d7" -"checksum rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11d339f1888e33e74d8032de0f83c40b2bdaaaf04a8cfc03b32186c3481fb534" +"checksum rls-analysis 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd4e96e3a7d4cf3f31d789080ddd88fbe3251df2feb168049a24eda8b6046ed8" +"checksum rls-data 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aea328fa69702c1b0fc395f2c71eae954bf984ac1e418c72f69221b6e3d15ff" "checksum rls-rustc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b21ea952e9bf1569929abf1bb920262cde04b7b1b26d8e0260286302807299d2" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff" @@ -2599,17 +2747,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" "checksum scopeguard 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "59a076157c1e2dc561d8de585151ee6965d910dd4dcb5dabb7ae3e83981a6c57" "checksum selectors 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c89b1c6a3c029c82263f7dd2d44d0005ee7374eb09e254ab59dede4353a8c0" +"checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" "checksum semver 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bee2bc909ab2d8d60dab26e8cad85b25d795b14603a0dcb627b78b9d30b6454b" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "6a7046c9d4c6c522d10b2d098f9bebe2bef227e0e74044d8c1bfcf6b476af799" "checksum serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "1afcaae083fd1c46952a315062326bc9957f182358eb7da03b57ef1c688f7aa9" "checksum serde_derive_internals 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd381f6d01a6616cdba8530492d453b7761b456ba974e98768a18cad2cd76f58" "checksum serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "190e9765dcedb56be63b6e0993a006c7e3b071a016a304736e4a315dc01fb142" -"checksum serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d243424e06f9f9c39e3cd36147470fd340db785825e367625f79298a6ac6b7ac" +"checksum serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ee28c1d94a7745259b767ca9e5b95d55bafbd3205ca3acb978cad84a6ed6bc62" +"checksum shared_child 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "099b38928dbe4a0a01fcd8c233183072f14a7d126a34bed05880869be66e14cc" "checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f8266519bc1d17d0b5b16f6c21295625d562841c708f6376f49028a43e9c11e" -"checksum socket2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9e76b159741052c7deaa9fd0b5ca6b5f79cecf525ed665abfe5002086c6b2791" +"checksum socket2 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b4896961171cd3317c7e9603d88f379f8c6e45342212235d356496680c68fd" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum string_cache 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "413fc7852aeeb5472f1986ef755f561ddf0c789d3d796e65f0b6fe293ecd4ef8" "checksum string_cache_codegen 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "479cde50c3539481f33906a387f2bd17c8e87cb848c35b6021d41fb81ff9b4d7" @@ -2628,6 +2778,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1" "checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" "checksum termcolor 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9065bced9c3e43453aa3d56f1e98590b8455b341d2fa191a1090c0dd0b242c75" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8e08afc40ae3459e4838f303e465aa50d823df8d7f83ca88108f6d3afe7edd" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" diff --git a/src/Cargo.toml b/src/Cargo.toml index f4b4189e01f06..39904927ca650 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -5,6 +5,7 @@ members = [ "libstd", "libtest", "tools/cargotest", + "tools/clippy", "tools/compiletest", "tools/error_index_generator", "tools/linkchecker", @@ -21,15 +22,10 @@ members = [ "tools/rustfmt", # FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude "tools/rls/test_data/borrow_error", - "tools/rls/test_data/completion", - "tools/rls/test_data/find_all_refs", + "tools/rls/test_data/common", + "tools/rls/test_data/features", "tools/rls/test_data/find_all_refs_no_cfg_test", - "tools/rls/test_data/goto_def", - "tools/rls/test_data/highlight", - "tools/rls/test_data/hover", - "tools/rls/test_data/rename", "tools/rls/test_data/reformat", - "tools/rls/test_data/bin_lib_no_cfg_test", "tools/rls/test_data/multiple_bins", "tools/rls/test_data/bin_lib", "tools/rls/test_data/reformat_with_range", @@ -37,8 +33,6 @@ members = [ "tools/rls/test_data/infer_bin", "tools/rls/test_data/infer_custom_bin", "tools/rls/test_data/infer_lib", - "tools/rls/test_data/omit_init_build", - "tools/rls/test_data/unicødë", "tools/rls/test_data/workspace_symbol", ] diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index aeeda85e924ef..16a23eb364a38 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -175,6 +175,9 @@ fn main() { if let Ok(s) = env::var("RUSTC_CODEGEN_UNITS") { cmd.arg("-C").arg(format!("codegen-units={}", s)); } + if stage != "0" && env::var("RUSTC_THINLTO").is_ok() { + cmd.arg("-Ccodegen-units=16").arg("-Zthinlto"); + } // Emit save-analysis info. if env::var("RUSTC_SAVE_ANALYSIS") == Ok("api".to_string()) { diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index dee4999879ca3..0dca395fa1fdb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -471,8 +471,6 @@ impl<'a> Builder<'a> { .env("RUSTC", self.out.join("bootstrap/debug/rustc")) .env("RUSTC_REAL", self.rustc(compiler)) .env("RUSTC_STAGE", stage.to_string()) - .env("RUSTC_CODEGEN_UNITS", - self.config.rust_codegen_units.to_string()) .env("RUSTC_DEBUG_ASSERTIONS", self.config.rust_debug_assertions.to_string()) .env("RUSTC_SYSROOT", self.sysroot(compiler)) @@ -486,6 +484,10 @@ impl<'a> Builder<'a> { }) .env("TEST_MIRI", self.config.test_miri.to_string()); + if let Some(n) = self.config.rust_codegen_units { + cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); + } + if let Some(host_linker) = self.build.linker(compiler.host) { cargo.env("RUSTC_HOST_LINKER", host_linker); } @@ -618,6 +620,14 @@ impl<'a> Builder<'a> { // FIXME: cargo bench does not accept `--release` if self.config.rust_optimize && cmd != "bench" { cargo.arg("--release"); + + if mode != Mode::Libstd && + self.config.rust_codegen_units.is_none() && + self.build.is_rust_llvm(compiler.host) + + { + cargo.env("RUSTC_THINLTO", "1"); + } } if self.config.locked_deps { cargo.arg("--locked"); diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs index 6e3e3c920291d..e531fdaf2923b 100644 --- a/src/bootstrap/cc_detect.rs +++ b/src/bootstrap/cc_detect.rs @@ -84,7 +84,7 @@ pub fn find(build: &mut Build) { if let Some(cc) = config.and_then(|c| c.cc.as_ref()) { cfg.compiler(cc); } else { - set_compiler(&mut cfg, "gcc", target, config, build); + set_compiler(&mut cfg, Language::C, target, config, build); } let compiler = cfg.get_compiler(); @@ -112,7 +112,7 @@ pub fn find(build: &mut Build) { if let Some(cxx) = config.and_then(|c| c.cxx.as_ref()) { cfg.compiler(cxx); } else { - set_compiler(&mut cfg, "g++", host, config, build); + set_compiler(&mut cfg, Language::CPlusPlus, host, config, build); } let compiler = cfg.get_compiler(); build.verbose(&format!("CXX_{} = {:?}", host, compiler.path())); @@ -121,7 +121,7 @@ pub fn find(build: &mut Build) { } fn set_compiler(cfg: &mut cc::Build, - gnu_compiler: &str, + compiler: Language, target: Interned, config: Option<&Target>, build: &Build) { @@ -132,7 +132,7 @@ fn set_compiler(cfg: &mut cc::Build, t if t.contains("android") => { if let Some(ndk) = config.and_then(|c| c.ndk.as_ref()) { let target = target.replace("armv7", "arm"); - let compiler = format!("{}-{}", target, gnu_compiler); + let compiler = format!("{}-{}", target, compiler.clang()); cfg.compiler(ndk.join("bin").join(compiler)); } } @@ -141,6 +141,7 @@ fn set_compiler(cfg: &mut cc::Build, // which is a gcc version from ports, if this is the case. t if t.contains("openbsd") => { let c = cfg.get_compiler(); + let gnu_compiler = compiler.gcc(); if !c.path().ends_with(gnu_compiler) { return } @@ -183,3 +184,29 @@ fn set_compiler(cfg: &mut cc::Build, _ => {} } } + +/// The target programming language for a native compiler. +enum Language { + /// The compiler is targeting C. + C, + /// The compiler is targeting C++. + CPlusPlus, +} + +impl Language { + /// Obtains the name of a compiler in the GCC collection. + fn gcc(self) -> &'static str { + match self { + Language::C => "gcc", + Language::CPlusPlus => "g++", + } + } + + /// Obtains the name of a compiler in the clang suite. + fn clang(self) -> &'static str { + match self { + Language::C => "clang", + Language::CPlusPlus => "clang++", + } + } +} diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 6ed504dfe74a3..189b652d19bbe 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -24,7 +24,7 @@ use Build; use config::Config; // The version number -pub const CFG_RELEASE_NUM: &str = "1.22.0"; +pub const CFG_RELEASE_NUM: &str = "1.23.0"; // An optional number to put after the label, e.g. '.2' -> '-beta.2' // Be sure to make this starts with a dot to conform to semver pre-release diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index f837371bebecb..4540f62087228 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -29,7 +29,7 @@ use build_helper::{output, mtime, up_to_date}; use filetime::FileTime; use serde_json; -use util::{exe, libdir, is_dylib, copy, read_stamp_file}; +use util::{exe, libdir, is_dylib, copy, read_stamp_file, CiEnv}; use {Build, Compiler, Mode}; use native; use tool; @@ -792,7 +792,7 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) { cargo.arg("--message-format").arg("json") .stdout(Stdio::piped()); - if stderr_isatty() { + if stderr_isatty() && build.ci_env == CiEnv::None { // since we pass message-format=json to cargo, we need to tell the rustc // wrapper to give us colored output if necessary. This is because we // only want Cargo's JSON output, not rustcs. @@ -860,10 +860,18 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) { // have a hash in the name, but there's a version of this file in // the `deps` folder which *does* have a hash in the name. That's // the one we'll want to we'll probe for it later. - toplevel.push((filename.file_stem().unwrap() - .to_str().unwrap().to_string(), - filename.extension().unwrap().to_owned() - .to_str().unwrap().to_string())); + // + // We do not use `Path::file_stem` or `Path::extension` here, + // because some generated files may have multiple extensions e.g. + // `std-.dll.lib` on Windows. The aforementioned methods only + // split the file name by the last extension (`.lib`) while we need + // to split by all extensions (`.dll.lib`). + let filename = filename.file_name().unwrap().to_str().unwrap(); + let mut parts = filename.splitn(2, '.'); + let file_stem = parts.next().unwrap().to_owned(); + let extension = parts.next().unwrap().to_owned(); + + toplevel.push((file_stem, extension)); } } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index d6c83e3acfc8a..33c7141e7044a 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -81,7 +81,7 @@ pub struct Config { // rust codegen options pub rust_optimize: bool, - pub rust_codegen_units: u32, + pub rust_codegen_units: Option, pub rust_debug_assertions: bool, pub rust_debuginfo: bool, pub rust_debuginfo_lines: bool, @@ -207,6 +207,11 @@ struct Install { bindir: Option, libdir: Option, mandir: Option, + + // standard paths, currently unused + datadir: Option, + infodir: Option, + localstatedir: Option, } /// TOML representation of how the LLVM build is configured. @@ -307,7 +312,6 @@ impl Config { config.submodules = true; config.docs = true; config.rust_rpath = true; - config.rust_codegen_units = 1; config.channel = "dev".to_string(); config.codegen_tests = true; config.ignore_git = false; @@ -470,8 +474,8 @@ impl Config { config.musl_root = rust.musl_root.clone().map(PathBuf::from); match rust.codegen_units { - Some(0) => config.rust_codegen_units = num_cpus::get() as u32, - Some(n) => config.rust_codegen_units = n, + Some(0) => config.rust_codegen_units = Some(num_cpus::get() as u32), + Some(n) => config.rust_codegen_units = Some(n), None => {} } } diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 42425a164a20e..579422c97993c 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -225,7 +225,12 @@ def err(msg): unknown_args.append(arg) p("") -if 'option-checking' not in known_args or known_args['option-checking'][1]: +# Note: here and a few other places, we use [-1] to apply the *last* value +# passed. But if option-checking is enabled, then the known_args loop will +# also assert that options are only passed once. +option_checking = ('option-checking' not in known_args + or known_args['option-checking'][-1][1]) +if option_checking: if len(unknown_args) > 0: err("Option '" + unknown_args[0] + "' is not recognized") if len(need_value_args) > 0: @@ -238,7 +243,7 @@ def err(msg): def build(): if 'build' in known_args: - return known_args['build'][0][1] + return known_args['build'][-1][1] return bootstrap.default_build_triple() @@ -276,9 +281,9 @@ def set(key, value): # Ensure each option is only passed once arr = known_args[key] - if len(arr) > 1: + if option_checking and len(arr) > 1: err("Option '{}' provided more than once".format(key)) - option, value = arr[0] + option, value = arr[-1] # If we have a clear avenue to set our value in rustbuild, do so if option.rustbuild is not None: diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index e41f01ac83440..e79f6e086ae04 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -738,7 +738,6 @@ impl Step for Src { "src/liballoc_jemalloc", "src/liballoc_system", "src/libbacktrace", - "src/libcollections", "src/libcompiler_builtins", "src/libcore", "src/liblibc", diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index b9a52a66793df..16e8ee182bd8e 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -66,7 +66,7 @@ macro_rules! book { } book!( - Nomicon, "src/doc/book", "nomicon"; + Nomicon, "src/doc/nomicon", "nomicon"; Reference, "src/doc/reference", "reference"; Rustdoc, "src/doc/rustdoc", "rustdoc"; ); @@ -490,7 +490,7 @@ impl Step for Std { // for which docs must be built. if !build.config.compiler_docs { cargo.arg("--no-deps"); - for krate in &["alloc", "collections", "core", "std", "std_unicode"] { + for krate in &["alloc", "core", "std", "std_unicode"] { cargo.arg("-p").arg(krate); // Create all crate output directories first to make sure rustdoc uses // relative links. @@ -623,11 +623,9 @@ impl Step for Rustc { compile::rustc_cargo(build, &compiler, target, &mut cargo); if build.config.compiler_docs { - // src/rustc/Cargo.toml contains bin crates called rustc and rustdoc - // which would otherwise overwrite the docs for the real rustc and - // rustdoc lib crates. - cargo.arg("-p").arg("rustc_driver") - .arg("-p").arg("rustdoc"); + // src/rustc/Cargo.toml contains a bin crate called rustc which + // would otherwise overwrite the docs for the real rustc lib crate. + cargo.arg("-p").arg("rustc_driver"); } else { // Like with libstd above if compiler docs aren't enabled then we're not // documenting internal dependencies, so we have a whitelist. diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index df378188b4ad0..b5d51598fab88 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -136,9 +136,12 @@ To learn more about a subcommand, run `./x.py -h`"); let subcommand = match subcommand { Some(s) => s, None => { - // No subcommand -- show the general usage and subcommand help + // No or an invalid subcommand -- show the general usage and subcommand help + // An exit code will be 0 when no subcommand is given, and 1 in case of an invalid + // subcommand. println!("{}\n", subcommand_help); - process::exit(1); + let exit_code = if args.is_empty() { 0 } else { 1 }; + process::exit(exit_code); } }; diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 004f0c31024cd..eb92c8f143bef 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -52,7 +52,6 @@ check: $(Q)$(BOOTSTRAP) test $(BOOTSTRAP_ARGS) check-aux: $(Q)$(BOOTSTRAP) test \ - src/tools/cargotest \ src/tools/cargo \ src/tools/rls \ src/tools/rustfmt \ diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index c37b1dad4c687..fb15f767f9e34 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -446,6 +446,7 @@ impl Step for Openssl { "powerpc64-unknown-linux-gnu" => "linux-ppc64", "powerpc64le-unknown-linux-gnu" => "linux-ppc64le", "s390x-unknown-linux-gnu" => "linux64-s390x", + "sparc64-unknown-linux-gnu" => "linux64-sparcv9", "sparc64-unknown-netbsd" => "BSD-sparc64", "x86_64-apple-darwin" => "darwin64-x86_64-cc", "x86_64-linux-android" => "linux-x86_64", diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 912ffa519758c..688ee6ba295fa 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -193,12 +193,12 @@ macro_rules! tool { } pub fn tool_default_stage(&self, tool: Tool) -> u32 { - // Compile the error-index in the top stage as it depends on - // rustdoc, so we want to avoid recompiling rustdoc twice if we - // can. Otherwise compile everything else in stage0 as there's - // no need to rebootstrap everything + // Compile the error-index in the same stage as rustdoc to avoid + // recompiling rustdoc twice if we can. Otherwise compile + // everything else in stage0 as there's no need to rebootstrap + // everything. match tool { - Tool::ErrorIndex => self.top_stage, + Tool::ErrorIndex if self.top_stage >= 2 => self.top_stage, _ => 0, } } diff --git a/src/ci/docker/arm-android/Dockerfile b/src/ci/docker/arm-android/Dockerfile index 49d07d28d3c8e..f2773a720cfbc 100644 --- a/src/ci/docker/arm-android/Dockerfile +++ b/src/ci/docker/arm-android/Dockerfile @@ -5,21 +5,27 @@ RUN sh /scripts/android-base-apt-get.sh COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_and_make_toolchain android-ndk-r13b-linux-x86_64.zip arm 9 + download_and_make_toolchain android-ndk-r15c-linux-x86_64.zip arm 14 +# Note: +# Do not upgrade to `openjdk-9-jre-headless`, as it will cause certificate error +# when installing the Android SDK (see PR #45193). This is unfortunate, but +# every search result suggested either disabling HTTPS or replacing JDK 9 by +# JDK 8 as the solution (e.g. https://stackoverflow.com/q/41421340). :| RUN dpkg --add-architecture i386 && \ apt-get update && \ apt-get install -y --no-install-recommends \ libgl1-mesa-glx \ libpulse0 \ libstdc++6:i386 \ - openjdk-9-jre-headless \ + openjdk-8-jre-headless \ tzdata COPY scripts/android-sdk.sh /scripts/ RUN . /scripts/android-sdk.sh && \ - download_and_create_avd tools_r25.2.5-linux.zip armeabi-v7a 18 + download_and_create_avd 4333796 armeabi-v7a 18 +ENV PATH=$PATH:/android/sdk/emulator ENV PATH=$PATH:/android/sdk/tools ENV PATH=$PATH:/android/sdk/platform-tools @@ -27,7 +33,7 @@ ENV TARGETS=arm-linux-androideabi ENV RUST_CONFIGURE_ARGS \ --target=$TARGETS \ - --arm-linux-androideabi-ndk=/android/ndk/arm-9 + --arm-linux-androideabi-ndk=/android/ndk/arm-14 ENV SCRIPT python2.7 ../x.py test --target $TARGETS diff --git a/src/ci/docker/asmjs/Dockerfile b/src/ci/docker/asmjs/Dockerfile index c0bf689e39db9..07849a20d0045 100644 --- a/src/ci/docker/asmjs/Dockerfile +++ b/src/ci/docker/asmjs/Dockerfile @@ -31,4 +31,4 @@ ENV TARGETS=asmjs-unknown-emscripten ENV RUST_CONFIGURE_ARGS --target=$TARGETS -ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/run-pass +ENV SCRIPT python2.7 ../x.py test --target $TARGETS diff --git a/src/ci/docker/cross/build-arm-musl.sh b/src/ci/docker/cross/build-arm-musl.sh index 780099e2ec176..567e5d9ac9863 100755 --- a/src/ci/docker/cross/build-arm-musl.sh +++ b/src/ci/docker/cross/build-arm-musl.sh @@ -11,7 +11,7 @@ set -ex -MUSL=1.1.16 +MUSL=1.1.17 hide_output() { set +x diff --git a/src/ci/docker/disabled/dist-aarch64-android/Dockerfile b/src/ci/docker/disabled/dist-aarch64-android/Dockerfile index 20d823a3d7338..ce5e8cfaf0958 100644 --- a/src/ci/docker/disabled/dist-aarch64-android/Dockerfile +++ b/src/ci/docker/disabled/dist-aarch64-android/Dockerfile @@ -5,7 +5,7 @@ RUN sh /scripts/android-base-apt-get.sh COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_and_make_toolchain android-ndk-r13b-linux-x86_64.zip arm64 21 + download_and_make_toolchain android-ndk-r15c-linux-x86_64.zip arm64 21 ENV PATH=$PATH:/android/ndk/arm64-21/bin diff --git a/src/ci/docker/disabled/dist-armv7-android/Dockerfile b/src/ci/docker/disabled/dist-armv7-android/Dockerfile index 3435d641a13c5..3177fa2147fa1 100644 --- a/src/ci/docker/disabled/dist-armv7-android/Dockerfile +++ b/src/ci/docker/disabled/dist-armv7-android/Dockerfile @@ -5,17 +5,17 @@ RUN sh /scripts/android-base-apt-get.sh COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_ndk android-ndk-r13b-linux-x86_64.zip && \ - make_standalone_toolchain arm 9 && \ + download_ndk android-ndk-r15c-linux-x86_64.zip && \ + make_standalone_toolchain arm 14 && \ make_standalone_toolchain arm 21 && \ remove_ndk RUN chmod 777 /android/ndk && \ ln -s /android/ndk/arm-21 /android/ndk/arm -ENV PATH=$PATH:/android/ndk/arm-9/bin +ENV PATH=$PATH:/android/ndk/arm-14/bin -ENV DEP_Z_ROOT=/android/ndk/arm-9/sysroot/usr/ +ENV DEP_Z_ROOT=/android/ndk/arm-14/sysroot/usr/ ENV HOSTS=armv7-linux-androideabi @@ -27,18 +27,18 @@ ENV RUST_CONFIGURE_ARGS \ --enable-extended \ --enable-cargo-openssl-static -# We support api level 9, but api level 21 is required to build llvm. To +# We support api level 14, but api level 21 is required to build llvm. To # overcome this problem we use a ndk with api level 21 to build llvm and then -# switch to a ndk with api level 9 to complete the build. When the linker is +# switch to a ndk with api level 14 to complete the build. When the linker is # invoked there are missing symbols (like sigsetempty, not available with api -# level 9), the default linker behavior is to generate an error, to allow the +# level 14), the default linker behavior is to generate an error, to allow the # build to finish we use --warn-unresolved-symbols. Note that the missing # symbols does not affect std, only the compiler (llvm) and cargo (openssl). ENV SCRIPT \ python2.7 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \ (export RUSTFLAGS="\"-C link-arg=-Wl,--warn-unresolved-symbols\""; \ rm /android/ndk/arm && \ - ln -s /android/ndk/arm-9 /android/ndk/arm && \ + ln -s /android/ndk/arm-14 /android/ndk/arm && \ python2.7 ../x.py dist --host $HOSTS --target $HOSTS) COPY scripts/sccache.sh /scripts/ diff --git a/src/ci/docker/disabled/dist-i686-android/Dockerfile b/src/ci/docker/disabled/dist-i686-android/Dockerfile index 4bb7053760f9c..ace9c4feb4f3b 100644 --- a/src/ci/docker/disabled/dist-i686-android/Dockerfile +++ b/src/ci/docker/disabled/dist-i686-android/Dockerfile @@ -5,17 +5,17 @@ RUN sh /scripts/android-base-apt-get.sh COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_ndk android-ndk-r13b-linux-x86_64.zip && \ - make_standalone_toolchain x86 9 && \ + download_ndk android-ndk-r15c-linux-x86_64.zip && \ + make_standalone_toolchain x86 14 && \ make_standalone_toolchain x86 21 && \ remove_ndk RUN chmod 777 /android/ndk && \ ln -s /android/ndk/x86-21 /android/ndk/x86 -ENV PATH=$PATH:/android/ndk/x86-9/bin +ENV PATH=$PATH:/android/ndk/x86-14/bin -ENV DEP_Z_ROOT=/android/ndk/x86-9/sysroot/usr/ +ENV DEP_Z_ROOT=/android/ndk/x86-14/sysroot/usr/ ENV HOSTS=i686-linux-android @@ -27,18 +27,18 @@ ENV RUST_CONFIGURE_ARGS \ --enable-extended \ --enable-cargo-openssl-static -# We support api level 9, but api level 21 is required to build llvm. To +# We support api level 14, but api level 21 is required to build llvm. To # overcome this problem we use a ndk with api level 21 to build llvm and then -# switch to a ndk with api level 9 to complete the build. When the linker is +# switch to a ndk with api level 14 to complete the build. When the linker is # invoked there are missing symbols (like sigsetempty, not available with api -# level 9), the default linker behavior is to generate an error, to allow the +# level 14), the default linker behavior is to generate an error, to allow the # build to finish we use --warn-unresolved-symbols. Note that the missing # symbols does not affect std, only the compiler (llvm) and cargo (openssl). ENV SCRIPT \ python2.7 ../x.py build src/llvm --host $HOSTS --target $HOSTS && \ (export RUSTFLAGS="\"-C link-arg=-Wl,--warn-unresolved-symbols\""; \ rm /android/ndk/x86 && \ - ln -s /android/ndk/x86-9 /android/ndk/x86 && \ + ln -s /android/ndk/x86-14 /android/ndk/x86 && \ python2.7 ../x.py dist --host $HOSTS --target $HOSTS) COPY scripts/sccache.sh /scripts/ diff --git a/src/ci/docker/disabled/dist-x86_64-android/Dockerfile b/src/ci/docker/disabled/dist-x86_64-android/Dockerfile index 525b218417b67..322d26f0adc4c 100644 --- a/src/ci/docker/disabled/dist-x86_64-android/Dockerfile +++ b/src/ci/docker/disabled/dist-x86_64-android/Dockerfile @@ -5,7 +5,7 @@ RUN sh /scripts/android-base-apt-get.sh COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_and_make_toolchain android-ndk-r13b-linux-x86_64.zip x86_64 21 + download_and_make_toolchain android-ndk-r15c-linux-x86_64.zip x86_64 21 ENV PATH=$PATH:/android/ndk/x86_64-21/bin diff --git a/src/ci/docker/dist-android/Dockerfile b/src/ci/docker/dist-android/Dockerfile index a36f7fc1ac528..5d7545a3c2a95 100644 --- a/src/ci/docker/dist-android/Dockerfile +++ b/src/ci/docker/dist-android/Dockerfile @@ -6,9 +6,9 @@ RUN sh /scripts/android-base-apt-get.sh # ndk COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_ndk android-ndk-r13b-linux-x86_64.zip && \ - make_standalone_toolchain arm 9 && \ - make_standalone_toolchain x86 9 && \ + download_ndk android-ndk-r15c-linux-x86_64.zip && \ + make_standalone_toolchain arm 14 && \ + make_standalone_toolchain x86 14 && \ make_standalone_toolchain arm64 21 && \ make_standalone_toolchain x86_64 21 && \ remove_ndk @@ -23,9 +23,9 @@ ENV TARGETS=$TARGETS,x86_64-linux-android ENV RUST_CONFIGURE_ARGS \ --target=$TARGETS \ --enable-extended \ - --arm-linux-androideabi-ndk=/android/ndk/arm-9 \ - --armv7-linux-androideabi-ndk=/android/ndk/arm-9 \ - --i686-linux-android-ndk=/android/ndk/x86-9 \ + --arm-linux-androideabi-ndk=/android/ndk/arm-14 \ + --armv7-linux-androideabi-ndk=/android/ndk/arm-14 \ + --i686-linux-android-ndk=/android/ndk/x86-14 \ --aarch64-linux-android-ndk=/android/ndk/arm64-21 \ --x86_64-linux-android-ndk=/android/ndk/x86_64-21 diff --git a/src/ci/docker/dist-i586-gnu-i686-musl/build-musl.sh b/src/ci/docker/dist-i586-gnu-i686-musl/build-musl.sh index ad285a57a84a3..883859d1fa64e 100644 --- a/src/ci/docker/dist-i586-gnu-i686-musl/build-musl.sh +++ b/src/ci/docker/dist-i586-gnu-i686-musl/build-musl.sh @@ -15,7 +15,7 @@ set -ex export CFLAGS="-fPIC -Wa,-mrelax-relocations=no" export CXXFLAGS="-Wa,-mrelax-relocations=no" -MUSL=musl-1.1.16 +MUSL=musl-1.1.17 curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf - cd $MUSL CC=gcc \ diff --git a/src/ci/docker/dist-x86_64-musl/build-musl.sh b/src/ci/docker/dist-x86_64-musl/build-musl.sh index 776da0093974c..9be8d001149e9 100644 --- a/src/ci/docker/dist-x86_64-musl/build-musl.sh +++ b/src/ci/docker/dist-x86_64-musl/build-musl.sh @@ -15,7 +15,7 @@ set -ex export CFLAGS="-fPIC -Wa,-mrelax-relocations=no" export CXXFLAGS="-Wa,-mrelax-relocations=no" -MUSL=musl-1.1.16 +MUSL=musl-1.1.17 curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf - cd $MUSL ./configure --prefix=/musl-x86_64 --disable-shared diff --git a/src/ci/docker/scripts/android-sdk.sh b/src/ci/docker/scripts/android-sdk.sh index 3aa2b9d58d57a..99c5776c2e849 100644 --- a/src/ci/docker/scripts/android-sdk.sh +++ b/src/ci/docker/scripts/android-sdk.sh @@ -10,40 +10,40 @@ set -ex -URL=https://dl.google.com/android/repository +export ANDROID_HOME=/android/sdk +PATH=$PATH:"${ANDROID_HOME}/tools/bin" download_sdk() { - mkdir -p /android/sdk - cd /android/sdk - curl -fO $URL/$1 - unzip -q $1 - rm -rf $1 + mkdir -p /android + curl -fo sdk.zip "https://dl.google.com/android/repository/sdk-tools-linux-$1.zip" + unzip -q sdk.zip -d "$ANDROID_HOME" + rm -f sdk.zip } download_sysimage() { - # See https://developer.android.com/studio/tools/help/android.html abi=$1 api=$2 - filter="platform-tools,android-$api" - filter="$filter,sys-img-$abi-android-$api" - - # Keep printing yes to accept the licenses - while true; do echo yes; sleep 10; done | \ - /android/sdk/tools/android update sdk -a --no-ui \ - --filter "$filter" --no-https + # See https://developer.android.com/studio/command-line/sdkmanager.html for + # usage of `sdkmanager`. + # + # The output from sdkmanager is so noisy that it will occupy all of the 4 MB + # log extremely quickly. Thus we must silence all output. + yes | sdkmanager --licenses > /dev/null + sdkmanager platform-tools emulator \ + "platforms;android-$api" \ + "system-images;android-$api;default;$abi" > /dev/null } create_avd() { - # See https://developer.android.com/studio/tools/help/android.html abi=$1 api=$2 - echo no | \ - /android/sdk/tools/android create avd \ - --name $abi-$api \ - --target android-$api \ - --abi $abi + # See https://developer.android.com/studio/command-line/avdmanager.html for + # usage of `avdmanager`. + echo no | avdmanager create avd \ + -n "$abi-$api" \ + -k "system-images;android-$api;default;$abi" } download_and_create_avd() { @@ -51,3 +51,15 @@ download_and_create_avd() { download_sysimage $2 $3 create_avd $2 $3 } + +# Usage: +# +# setup_android_sdk 4333796 armeabi-v7a 18 +# +# 4333796 => +# SDK tool version. +# Copy from https://developer.android.com/studio/index.html#command-tools +# armeabi-v7a => +# System image ABI +# 18 => +# Android API Level (18 = Android 4.3 = Jelly Bean MR2) diff --git a/src/ci/docker/x86_64-gnu-cargotest/Dockerfile b/src/ci/docker/x86_64-gnu-cargotest/Dockerfile new file mode 100644 index 0000000000000..a5326625bf49c --- /dev/null +++ b/src/ci/docker/x86_64-gnu-cargotest/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:16.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + libssl-dev \ + sudo \ + xz-utils \ + pkg-config \ + libgl1-mesa-dev \ + llvm-dev \ + libfreetype6-dev \ + libexpat1-dev + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + +ENV RUST_CONFIGURE_ARGS --build=x86_64-unknown-linux-gnu +ENV SCRIPT python2.7 ../x.py test src/tools/cargotest diff --git a/src/doc/book b/src/doc/book index 08e79609ce885..7db393dae740d 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 08e79609ce88583fa7286157dfe497486a09fabe +Subproject commit 7db393dae740d84775b73f403123c866e94e3a5b diff --git a/src/doc/nomicon b/src/doc/nomicon index 0ee3f7265e9d0..1625e0b8c8708 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 0ee3f7265e9d09746d901cef6f1f300baff1d923 +Subproject commit 1625e0b8c870891b84b0969777a974bf87be579b diff --git a/src/doc/unstable-book/src/language-features/attr-literals.md b/src/doc/unstable-book/src/language-features/attr-literals.md index 60741a74400d2..6606f3c4e5c54 100644 --- a/src/doc/unstable-book/src/language-features/attr-literals.md +++ b/src/doc/unstable-book/src/language-features/attr-literals.md @@ -15,16 +15,16 @@ The `attr_literals` unstable feature allows other types of literals to be used in attributes. Here are some examples of attributes that can now be used with this feature enabled: -+```rust,ignore -+#[attr] -+#[attr(true)] -+#[attr(ident)] -+#[attr(ident, 100, true, "true", ident = 100, ident = "hello", ident(100))] -+#[attr(100)] -+#[attr(enabled = true)] -+#[enabled(true)] -+#[attr("hello")] -+#[repr(C, align = 4)] -+#[repr(C, align(4))] -+``` +```rust,ignore +#[attr] +#[attr(true)] +#[attr(ident)] +#[attr(ident, 100, true, "true", ident = 100, ident = "hello", ident(100))] +#[attr(100)] +#[attr(enabled = true)] +#[enabled(true)] +#[attr("hello")] +#[repr(C, align = 4)] +#[repr(C, align(4))] +``` diff --git a/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md b/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md new file mode 100644 index 0000000000000..11b3ee8edf0b1 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/crate-visibility-modifier.md @@ -0,0 +1,20 @@ +# `crate_visibility_modifier` + +The tracking issue for this feature is: [#45388] + +[#45388]: https://github.com/rust-lang/rust/issues/45388 + +----- + +The `crate_visibility_modifier` feature allows the `crate` keyword to be used +as a visibility modifier synonymous to `pub(crate)`, indicating that a type +(function, _&c._) is to be visible to the entire enclosing crate, but not to +other crates. + +```rust +#![feature(crate_visibility_modifier)] + +crate struct Foo { + bar: usize, +} +``` diff --git a/src/doc/unstable-book/src/language-features/on-unimplemented.md b/src/doc/unstable-book/src/language-features/on-unimplemented.md index 9eea3fccbbc17..70c7c110b786a 100644 --- a/src/doc/unstable-book/src/language-features/on-unimplemented.md +++ b/src/doc/unstable-book/src/language-features/on-unimplemented.md @@ -15,8 +15,8 @@ For example: ```rust,compile_fail #![feature(on_unimplemented)] -#[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an \ - iterator over elements of type `{A}`"] +#[rustc_on_unimplemented="an iterator over elements of type `{A}` \ + cannot be built from a collection of type `{Self}`"] trait MyIterator { fn next(&mut self) -> A; } @@ -37,9 +37,9 @@ error[E0277]: the trait bound `&[{integer}]: MyIterator` is not satisfied --> :14:5 | 14 | iterate_chars(&[1, 2, 3][..]); - | ^^^^^^^^^^^^^ the trait `MyIterator` is not implemented for `&[{integer}]` + | ^^^^^^^^^^^^^ an iterator over elements of type `char` cannot be built from a collection of type `&[{integer}]` | - = note: a collection of type `&[{integer}]` cannot be built from an iterator over elements of type `char` + = help: the trait `MyIterator` is not implemented for `&[{integer}]` = note: required by `iterate_chars` error: aborting due to previous error diff --git a/src/doc/unstable-book/src/library-features/collections.md b/src/doc/unstable-book/src/library-features/collections.md deleted file mode 100644 index 5c937833c9e26..0000000000000 --- a/src/doc/unstable-book/src/library-features/collections.md +++ /dev/null @@ -1,5 +0,0 @@ -# `collections` - -This feature is internal to the Rust compiler and is not intended for general use. - ------------------------- diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index 6642da858e551..15c9fc2e504a1 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -74,7 +74,7 @@ ENUM_TUPLE, ENUM_STRUCT, STRUCT_FIELDS, STRUCT_TUPLE = range(4) -def create_test_case(type, trait, super_traits, number_of_errors): +def create_test_case(type, trait, super_traits, error_count): string = [ENUM_STRING, ENUM_STRUCT_VARIANT_STRING, STRUCT_STRING, STRUCT_TUPLE_STRING][type] all_traits = ','.join([trait] + super_traits) super_traits = ','.join(super_traits) @@ -113,7 +113,7 @@ def write_file(name, string): for (trait, supers, errs) in [('Clone', [], 1), ('PartialEq', [], 2), - ('PartialOrd', ['PartialEq'], 9), + ('PartialOrd', ['PartialEq'], 3), ('Eq', ['PartialEq'], 1), ('Ord', ['Eq', 'PartialOrd', 'PartialEq'], 1), ('Debug', [], 1), diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 5a9cd82b9d119..3a2022ad429f7 100644 --- a/src/liballoc/allocator.rs +++ b/src/liballoc/allocator.rs @@ -70,7 +70,7 @@ impl Layout { /// /// * `align` must be a power of two, /// - /// * `align` must not exceed 2^31 (i.e. `1 << 31`), + /// * `align` must not exceed 231 (i.e. `1 << 31`), /// /// * `size`, when rounded up to the nearest multiple of `align`, /// must not overflow (i.e. the rounded value must be less than @@ -113,7 +113,7 @@ impl Layout { /// # Safety /// /// This function is unsafe as it does not verify that `align` is - /// a power-of-two that is also less than or equal to 2^31, nor + /// a power-of-two that is also less than or equal to 231, nor /// that `size` aligned to `align` fits within the address space /// (i.e. the `Layout::from_size_align` preconditions). #[inline] @@ -227,7 +227,7 @@ impl Layout { }; // We can assume that `self.align` is a power-of-two that does - // not exceed 2^31. Furthermore, `alloc_size` has already been + // not exceed 231. Furthermore, `alloc_size` has already been // rounded up to a multiple of `self.align`; therefore, the // call to `Layout::from_size_align` below should never panic. Some((Layout::from_size_align(alloc_size, self.align).unwrap(), padded_size)) diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 578d90c5ba9bb..58299d5d8361e 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -475,7 +475,6 @@ //! them with the same character. For example, the `{` character is escaped with //! `{{` and the `}` character is escaped with `}}`. //! -//! [`format!`]: ../../macro.format.html //! [`usize`]: ../../std/primitive.usize.html //! [`isize`]: ../../std/primitive.isize.html //! [`i8`]: ../../std/primitive.i8.html diff --git a/src/libbacktrace/configure b/src/libbacktrace/configure index ed47ba3c2fa08..df6497fc64667 100755 --- a/src/libbacktrace/configure +++ b/src/libbacktrace/configure @@ -12338,7 +12338,7 @@ else _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : - ALLOC_FILE=mmap.lo + ALLOC_FILE=alloc.lo else ALLOC_FILE=alloc.lo fi diff --git a/src/libcollections/Cargo.toml b/src/libcollections/Cargo.toml deleted file mode 100644 index 800e36161d245..0000000000000 --- a/src/libcollections/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -authors = ["The Rust Project Developers"] -name = "collections" -version = "0.0.0" - -[lib] -name = "collections" -path = "lib.rs" - -[dependencies] -alloc = { path = "../liballoc" } -core = { path = "../libcore" } diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs deleted file mode 100644 index 55316db3d5a43..0000000000000 --- a/src/libcollections/lib.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2017 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_attributes)] -#![unstable(feature = "collections", - reason = "this library is unlikely to be stabilized in its current \ - form or name", - issue = "27783")] -#![rustc_deprecated(since = "1.20.0", - reason = "collections moved to `alloc`")] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", - issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", - test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] -#![no_std] -#![deny(warnings)] - -#![feature(alloc)] -#![feature(collections_range)] -#![feature(macro_reexport)] -#![feature(staged_api)] - -//! Collection types -//! -//! See [`std::collections`](../std/collections/index.html) for a detailed -//! discussion of collections in Rust. - -#[macro_reexport(vec, format)] -extern crate alloc; - -pub use alloc::Bound; - -pub use alloc::binary_heap; -pub use alloc::borrow; -pub use alloc::fmt; -pub use alloc::linked_list; -pub use alloc::range; -pub use alloc::slice; -pub use alloc::str; -pub use alloc::string; -pub use alloc::vec; -pub use alloc::vec_deque; - -pub use alloc::btree_map; -pub use alloc::btree_set; - -#[doc(no_inline)] -pub use alloc::binary_heap::BinaryHeap; -#[doc(no_inline)] -pub use alloc::btree_map::BTreeMap; -#[doc(no_inline)] -pub use alloc::btree_set::BTreeSet; -#[doc(no_inline)] -pub use alloc::linked_list::LinkedList; -#[doc(no_inline)] -pub use alloc::vec_deque::VecDeque; -#[doc(no_inline)] -pub use alloc::string::String; -#[doc(no_inline)] -pub use alloc::vec::Vec; diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index b9c5ff10f87b9..d222bf6173226 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -329,7 +329,7 @@ impl Cell { /// let c = Cell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_cell_new"))] + #[rustc_const_unstable(feature = "const_cell_new")] #[inline] pub const fn new(value: T) -> Cell { Cell { @@ -544,7 +544,7 @@ impl RefCell { /// let c = RefCell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_refcell_new"))] + #[rustc_const_unstable(feature = "const_refcell_new")] #[inline] pub const fn new(value: T) -> RefCell { RefCell { @@ -1190,7 +1190,7 @@ impl UnsafeCell { /// let uc = UnsafeCell::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_unsafe_cell_new"))] + #[rustc_const_unstable(feature = "const_unsafe_cell_new")] #[inline] pub const fn new(value: T) -> UnsafeCell { UnsafeCell { value: value } diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index bc1b911cd78cc..b3c11ed1b5ac4 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -665,16 +665,36 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl Hash for *const T { + impl Hash for *const T { fn hash(&self, state: &mut H) { - state.write_usize(*self as usize) + if mem::size_of::() == mem::size_of::() { + // Thin pointer + state.write_usize(*self as *const () as usize); + } else { + // Fat pointer + let (a, b) = unsafe { + *(self as *const Self as *const (usize, usize)) + }; + state.write_usize(a); + state.write_usize(b); + } } } #[stable(feature = "rust1", since = "1.0.0")] - impl Hash for *mut T { + impl Hash for *mut T { fn hash(&self, state: &mut H) { - state.write_usize(*self as usize) + if mem::size_of::() == mem::size_of::() { + // Thin pointer + state.write_usize(*self as *const () as usize); + } else { + // Fat pointer + let (a, b) = unsafe { + *(self as *const Self as *const (usize, usize)) + }; + state.write_usize(a); + state.write_usize(b); + } } } } diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index d82de082da6d0..4e4d9b3f1e2f0 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -22,7 +22,7 @@ use mem; /// This is currently the default hashing function used by standard library /// (eg. `collections::HashMap` uses it by default). /// -/// See: https://131002.net/siphash/ +/// See: #[unstable(feature = "sip_hash_13", issue = "34767")] #[rustc_deprecated(since = "1.13.0", reason = "use `std::collections::hash_map::DefaultHasher` instead")] @@ -33,7 +33,7 @@ pub struct SipHasher13 { /// An implementation of SipHash 2-4. /// -/// See: https://131002.net/siphash/ +/// See: #[unstable(feature = "sip_hash_13", issue = "34767")] #[rustc_deprecated(since = "1.13.0", reason = "use `std::collections::hash_map::DefaultHasher` instead")] @@ -44,7 +44,7 @@ pub struct SipHasher24 { /// An implementation of SipHash 2-4. /// -/// See: https://131002.net/siphash/ +/// See: /// /// SipHash is a general-purpose hashing function: it runs at a good /// speed (competitive with Spooky and City) and permits strong _keyed_ diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index bc82f0230e5b4..0136273ebc941 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -627,6 +627,9 @@ extern "rust-intrinsic" { pub fn rustc_peek(_: T) -> T; /// Aborts the execution of the process. + /// + /// The stabilized version of this intrinsic is + /// [`std::process::abort`](../../std/process/fn.abort.html) pub fn abort() -> !; /// Tells LLVM that this point in the code is not reachable, enabling @@ -676,6 +679,10 @@ extern "rust-intrinsic" { pub fn min_align_of() -> usize; pub fn pref_align_of() -> usize; + /// The size of the referenced value in bytes. + /// + /// The stabilized version of this intrinsic is + /// [`std::mem::size_of_val`](../../std/mem/fn.size_of_val.html). pub fn size_of_val(_: &T) -> usize; pub fn min_align_of_val(_: &T) -> usize; @@ -921,6 +928,9 @@ extern "rust-intrinsic" { /// /// If the actual type neither requires drop glue nor implements /// `Copy`, then may return `true` or `false`. + /// + /// The stabilized version of this intrinsic is + /// [`std::mem::needs_drop`](../../std/mem/fn.needs_drop.html). pub fn needs_drop() -> bool; /// Calculates the offset from a pointer. @@ -1376,17 +1386,5 @@ extern "rust-intrinsic" { /// } /// # } } /// ``` - #[cfg(not(stage0))] pub fn align_offset(ptr: *const (), align: usize) -> usize; } - -#[cfg(stage0)] -/// remove me after the next release -pub unsafe fn align_offset(ptr: *const (), align: usize) -> usize { - let offset = ptr as usize % align; - if offset == 0 { - 0 - } else { - align - offset - } -} diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 69612bd2a32a4..5659d5b8d66b2 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -85,29 +85,28 @@ #![feature(prelude_import)] #![feature(repr_simd, platform_intrinsics)] #![feature(rustc_attrs)] -#![cfg_attr(not(stage0), feature(rustc_const_unstable))] +#![feature(rustc_const_unstable)] #![feature(specialization)] #![feature(staged_api)] #![feature(unboxed_closures)] #![feature(untagged_unions)] #![feature(unwind_attributes)] - -#![cfg_attr(not(stage0), feature(const_min_value))] -#![cfg_attr(not(stage0), feature(const_max_value))] -#![cfg_attr(not(stage0), feature(const_atomic_bool_new))] -#![cfg_attr(not(stage0), feature(const_atomic_isize_new))] -#![cfg_attr(not(stage0), feature(const_atomic_usize_new))] -#![cfg_attr(not(stage0), feature(const_atomic_i8_new))] -#![cfg_attr(not(stage0), feature(const_atomic_u8_new))] -#![cfg_attr(not(stage0), feature(const_atomic_i16_new))] -#![cfg_attr(not(stage0), feature(const_atomic_u16_new))] -#![cfg_attr(not(stage0), feature(const_atomic_i32_new))] -#![cfg_attr(not(stage0), feature(const_atomic_u32_new))] -#![cfg_attr(not(stage0), feature(const_atomic_i64_new))] -#![cfg_attr(not(stage0), feature(const_atomic_u64_new))] -#![cfg_attr(not(stage0), feature(const_unsafe_cell_new))] -#![cfg_attr(not(stage0), feature(const_cell_new))] -#![cfg_attr(not(stage0), feature(const_nonzero_new))] +#![feature(const_min_value)] +#![feature(const_max_value)] +#![feature(const_atomic_bool_new)] +#![feature(const_atomic_isize_new)] +#![feature(const_atomic_usize_new)] +#![feature(const_atomic_i8_new)] +#![feature(const_atomic_u8_new)] +#![feature(const_atomic_i16_new)] +#![feature(const_atomic_u16_new)] +#![feature(const_atomic_i32_new)] +#![feature(const_atomic_u32_new)] +#![feature(const_atomic_i64_new)] +#![feature(const_atomic_u64_new)] +#![feature(const_unsafe_cell_new)] +#![feature(const_cell_new)] +#![feature(const_nonzero_new)] #[prelude_import] #[allow(unused)] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index d64c984ea7d28..12667036444e6 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -682,7 +682,7 @@ mod builtin { #[cfg(dox)] macro_rules! file { () => ({ /* compiler built-in */ }) } - /// A macro which stringifies its argument. + /// A macro which stringifies its arguments. /// /// For more information, see the documentation for [`std::stringify!`]. /// @@ -690,7 +690,7 @@ mod builtin { #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] #[cfg(dox)] - macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) } + macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) } /// Includes a utf8-encoded file as a string. /// diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 16d5fadc53620..d57fbdf55f80e 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -311,7 +311,7 @@ pub fn forget(t: T) { /// [alignment]: ./fn.align_of.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_size_of"))] +#[rustc_const_unstable(feature = "const_size_of")] pub const fn size_of() -> usize { unsafe { intrinsics::size_of::() } } @@ -403,7 +403,7 @@ pub fn min_align_of_val(val: &T) -> usize { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_align_of"))] +#[rustc_const_unstable(feature = "const_align_of")] pub const fn align_of() -> usize { unsafe { intrinsics::min_align_of::() } } diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index f075d825f5d53..edc0104f46b5c 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -71,7 +71,7 @@ impl NonZero { #[unstable(feature = "nonzero", reason = "needs an RFC to flesh out the design", issue = "27730")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_nonzero_new"))] + #[rustc_const_unstable(feature = "const_nonzero_new")] #[inline] pub const unsafe fn new_unchecked(inner: T) -> Self { NonZero(inner) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 85be8a08728e5..5799d37c19cc6 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -109,7 +109,7 @@ macro_rules! int_impl { /// assert_eq!(i8::min_value(), -128); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))] + #[rustc_const_unstable(feature = "const_min_value")] #[inline] pub const fn min_value() -> Self { !0 ^ ((!0 as $UnsignedT) >> 1) as Self @@ -123,7 +123,7 @@ macro_rules! int_impl { /// assert_eq!(i8::max_value(), 127); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))] + #[rustc_const_unstable(feature = "const_max_value")] #[inline] pub const fn max_value() -> Self { !Self::min_value() @@ -1282,7 +1282,7 @@ macro_rules! uint_impl { /// assert_eq!(u8::min_value(), 0); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_min_value"))] + #[rustc_const_unstable(feature = "const_min_value")] #[inline] pub const fn min_value() -> Self { 0 } @@ -1294,7 +1294,7 @@ macro_rules! uint_impl { /// assert_eq!(u8::max_value(), 255); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_max_value"))] + #[rustc_const_unstable(feature = "const_max_value")] #[inline] pub const fn max_value() -> Self { !0 } diff --git a/src/libcore/ops/generator.rs b/src/libcore/ops/generator.rs index 798c182bc6e38..dc7669d195c13 100644 --- a/src/libcore/ops/generator.rs +++ b/src/libcore/ops/generator.rs @@ -14,7 +14,7 @@ /// possible return values of a generator. Currently this corresponds to either /// a suspension point (`Yielded`) or a termination point (`Complete`). #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] -#[cfg_attr(not(stage0), lang = "generator_state")] +#[lang = "generator_state"] #[unstable(feature = "generator_trait", issue = "43122")] pub enum GeneratorState { /// The generator suspended with a value. @@ -70,7 +70,7 @@ pub enum GeneratorState { /// More documentation of generators can be found in the unstable book. /// /// [RFC 2033]: https://github.com/rust-lang/rfcs/pull/2033 -#[cfg_attr(not(stage0), lang = "generator")] +#[lang = "generator"] #[unstable(feature = "generator_trait", issue = "43122")] #[fundamental] pub trait Generator { diff --git a/src/libcore/ops/try.rs b/src/libcore/ops/try.rs index e788b66a1ec82..81e5cb5c35045 100644 --- a/src/libcore/ops/try.rs +++ b/src/libcore/ops/try.rs @@ -15,24 +15,19 @@ /// extracting those success or failure values from an existing instance and /// creating a new instance from a success or failure value. #[unstable(feature = "try_trait", issue = "42327")] -#[cfg_attr(stage0, - rustc_on_unimplemented = "the `?` operator can only be used in a \ - function that returns `Result` \ - (or another type that implements `{Try}`)")] -#[cfg_attr(not(stage0), - rustc_on_unimplemented( - on(all( - any(from_method="from_error", from_method="from_ok"), - from_desugaring="?"), - message="the `?` operator can only be used in a \ - function that returns `Result` \ - (or another type that implements `{Try}`)", - label="cannot use the `?` operator in a function that returns `{Self}`"), - on(all(from_method="into_result", from_desugaring="?"), - message="the `?` operator can only be applied to values \ - that implement `{Try}`", - label="the `?` operator cannot be applied to type `{Self}`") -))] +#[rustc_on_unimplemented( + on(all( + any(from_method="from_error", from_method="from_ok"), + from_desugaring="?"), + message="the `?` operator can only be used in a \ + function that returns `Result` \ + (or another type that implements `{Try}`)", + label="cannot use the `?` operator in a function that returns `{Self}`"), + on(all(from_method="into_result", from_desugaring="?"), + message="the `?` operator can only be applied to values \ + that implement `{Try}`", + label="the `?` operator cannot be applied to type `{Self}`") +)] pub trait Try { /// The type of this value when viewed as successful. #[unstable(feature = "try_trait", issue = "42327")] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 3d6abbb7e49c9..5cd672b03ffc9 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -74,7 +74,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_ptr_null"))] +#[rustc_const_unstable(feature = "const_ptr_null")] pub const fn null() -> *const T { 0 as *const T } /// Creates a null mutable raw pointer. @@ -89,7 +89,7 @@ pub const fn null() -> *const T { 0 as *const T } /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_ptr_null_mut"))] +#[rustc_const_unstable(feature = "const_ptr_null_mut")] pub const fn null_mut() -> *mut T { 0 as *mut T } /// Swaps the values at two mutable locations of the same type, without @@ -228,7 +228,7 @@ pub unsafe fn replace(dest: *mut T, mut src: T) -> T { /// moves the value out of `src` without preventing further usage of `src`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `src` is not used before the data is overwritten again (e.g. with `write`, -/// `zero_memory`, or `copy_memory`). Note that `*src = foo` counts as a use +/// `write_bytes`, or `copy`). Note that `*src = foo` counts as a use /// because it will attempt to drop the value previously at `*src`. /// /// The pointer must be aligned; use `read_unaligned` if that is not the case. @@ -264,7 +264,7 @@ pub unsafe fn read(src: *const T) -> T { /// moves the value out of `src` without preventing further usage of `src`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `src` is not used before the data is overwritten again (e.g. with `write`, -/// `zero_memory`, or `copy_memory`). Note that `*src = foo` counts as a use +/// `write_bytes`, or `copy`). Note that `*src = foo` counts as a use /// because it will attempt to drop the value previously at `*src`. /// /// # Examples @@ -397,7 +397,7 @@ pub unsafe fn write_unaligned(dst: *mut T, src: T) { /// moves the value out of `src` without preventing further usage of `src`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `src` is not used before the data is overwritten again (e.g. with `write`, -/// `zero_memory`, or `copy_memory`). Note that `*src = foo` counts as a use +/// `write_bytes`, or `copy`). Note that `*src = foo` counts as a use /// because it will attempt to drop the value previously at `*src`. /// /// # Examples @@ -551,7 +551,7 @@ impl *const T { /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request - /// for 2^63 bytes due to page-table limitations or splitting the address space. + /// for 263 bytes due to page-table limitations or splitting the address space. /// However, some 32-bit and 16-bit platforms may successfully serve a request for /// more than `isize::MAX` bytes with things like Physical Address /// Extension. As such, memory acquired directly from allocators or memory @@ -684,7 +684,7 @@ impl *const T { /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request - /// for 2^63 bytes due to page-table limitations or splitting the address space. + /// for 263 bytes due to page-table limitations or splitting the address space. /// However, some 32-bit and 16-bit platforms may successfully serve a request for /// more than `isize::MAX` bytes with things like Physical Address /// Extension. As such, memory acquired directly from allocators or memory @@ -743,7 +743,7 @@ impl *const T { /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request - /// for 2^63 bytes due to page-table limitations or splitting the address space. + /// for 263 bytes due to page-table limitations or splitting the address space. /// However, some 32-bit and 16-bit platforms may successfully serve a request for /// more than `isize::MAX` bytes with things like Physical Address /// Extension. As such, memory acquired directly from allocators or memory @@ -871,7 +871,7 @@ impl *const T { /// moves the value out of `self` without preventing further usage of `self`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `zero_memory`, or `copy_memory`). Note that `*self = foo` counts as a use + /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use /// because it will attempt to drop the value previously at `*self`. /// /// The pointer must be aligned; use `read_unaligned` if that is not the case. @@ -925,7 +925,7 @@ impl *const T { /// moves the value out of `self` without preventing further usage of `self`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `zero_memory`, or `copy_memory`). Note that `*self = foo` counts as a use + /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use /// because it will attempt to drop the value previously at `*self`. /// /// # Examples @@ -961,7 +961,7 @@ impl *const T { /// moves the value out of `self` without preventing further usage of `self`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `zero_memory`, or `copy_memory`). Note that `*self = foo` counts as a use + /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use /// because it will attempt to drop the value previously at `*self`. /// /// # Examples @@ -1182,7 +1182,7 @@ impl *mut T { /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request - /// for 2^63 bytes due to page-table limitations or splitting the address space. + /// for 263 bytes due to page-table limitations or splitting the address space. /// However, some 32-bit and 16-bit platforms may successfully serve a request for /// more than `isize::MAX` bytes with things like Physical Address /// Extension. As such, memory acquired directly from allocators or memory @@ -1382,7 +1382,7 @@ impl *mut T { /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request - /// for 2^63 bytes due to page-table limitations or splitting the address space. + /// for 263 bytes due to page-table limitations or splitting the address space. /// However, some 32-bit and 16-bit platforms may successfully serve a request for /// more than `isize::MAX` bytes with things like Physical Address /// Extension. As such, memory acquired directly from allocators or memory @@ -1441,7 +1441,7 @@ impl *mut T { /// /// Most platforms fundamentally can't even construct such an allocation. /// For instance, no known 64-bit platform can ever serve a request - /// for 2^63 bytes due to page-table limitations or splitting the address space. + /// for 263 bytes due to page-table limitations or splitting the address space. /// However, some 32-bit and 16-bit platforms may successfully serve a request for /// more than `isize::MAX` bytes with things like Physical Address /// Extension. As such, memory acquired directly from allocators or memory @@ -1569,7 +1569,7 @@ impl *mut T { /// moves the value out of `self` without preventing further usage of `self`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `zero_memory`, or `copy_memory`). Note that `*self = foo` counts as a use + /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use /// because it will attempt to drop the value previously at `*self`. /// /// The pointer must be aligned; use `read_unaligned` if that is not the case. @@ -1623,7 +1623,7 @@ impl *mut T { /// moves the value out of `self` without preventing further usage of `self`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `src` is not used before the data is overwritten again (e.g. with `write`, - /// `zero_memory`, or `copy_memory`). Note that `*self = foo` counts as a use + /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use /// because it will attempt to drop the value previously at `*self`. /// /// # Examples @@ -1659,7 +1659,7 @@ impl *mut T { /// moves the value out of `self` without preventing further usage of `self`. /// If `T` is not `Copy`, then care must be taken to ensure that the value at /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `zero_memory`, or `copy_memory`). Note that `*self = foo` counts as a use + /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use /// because it will attempt to drop the value previously at `*self`. /// /// # Examples @@ -2333,7 +2333,7 @@ impl Unique { /// /// `ptr` must be non-null. #[unstable(feature = "unique", issue = "27730")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_unique_new"))] + #[rustc_const_unstable(feature = "const_unique_new")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData } } @@ -2468,7 +2468,7 @@ impl Shared { /// /// `ptr` must be non-null. #[unstable(feature = "shared", issue = "27730")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_shared_new"))] + #[rustc_const_unstable(feature = "const_shared_new")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { Shared { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData } } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 524f4508c9b1a..53b056d2b8b6f 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -243,7 +243,7 @@ impl AtomicBool { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_atomic_bool_new"))] + #[rustc_const_unstable(feature = "const_atomic_bool_new")] pub const fn new(v: bool) -> AtomicBool { AtomicBool { v: UnsafeCell::new(v as u8) } } @@ -657,7 +657,7 @@ impl AtomicPtr { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_atomic_ptr_new"))] + #[rustc_const_unstable(feature = "const_atomic_ptr_new")] pub const fn new(p: *mut T) -> AtomicPtr { AtomicPtr { p: UnsafeCell::new(p) } } @@ -992,7 +992,7 @@ macro_rules! atomic_int { /// ``` #[inline] #[$stable] - #[cfg_attr(not(stage0), $const_unstable)] + #[$const_unstable] pub const fn new(v: $int_type) -> Self { $atomic_type {v: UnsafeCell::new(v)} } diff --git a/src/libcore/tests/hash/mod.rs b/src/libcore/tests/hash/mod.rs index 43ba941f13bfc..8716421b424de 100644 --- a/src/libcore/tests/hash/mod.rs +++ b/src/libcore/tests/hash/mod.rs @@ -79,6 +79,14 @@ fn test_writer_hasher() { let ptr = 5_usize as *mut i32; assert_eq!(hash(&ptr), 5); + + let cs: &mut [u8] = &mut [1, 2, 3]; + let ptr = cs.as_ptr(); + let slice_ptr = cs as *const [u8]; + assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64); + + let slice_ptr = cs as *mut [u8]; + assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64); } struct Custom { hash: u64 } diff --git a/src/libcore/tests/hash/sip.rs b/src/libcore/tests/hash/sip.rs index 4a9657e03404a..c6dd41798f2a7 100644 --- a/src/libcore/tests/hash/sip.rs +++ b/src/libcore/tests/hash/sip.rs @@ -243,24 +243,22 @@ fn test_siphash_2_4() { t += 1; } } -#[test] #[cfg(target_arch = "arm")] + +#[test] +#[cfg(target_pointer_width = "32")] fn test_hash_usize() { let val = 0xdeadbeef_deadbeef_u64; assert!(hash(&(val as u64)) != hash(&(val as usize))); assert_eq!(hash(&(val as u32)), hash(&(val as usize))); } -#[test] #[cfg(target_arch = "x86_64")] + +#[test] +#[cfg(target_pointer_width = "64")] fn test_hash_usize() { let val = 0xdeadbeef_deadbeef_u64; assert_eq!(hash(&(val as u64)), hash(&(val as usize))); assert!(hash(&(val as u32)) != hash(&(val as usize))); } -#[test] #[cfg(target_arch = "x86")] -fn test_hash_usize() { - let val = 0xdeadbeef_deadbeef_u64; - assert!(hash(&(val as u64)) != hash(&(val as usize))); - assert_eq!(hash(&(val as u32)), hash(&(val as usize))); -} #[test] fn test_hash_idempotent() { diff --git a/src/liblibc b/src/liblibc index 44e4018e1a377..7e33065ce4975 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit 44e4018e1a37716286ec98cb5b7dd7d33ecaf940 +Subproject commit 7e33065ce49759958c0d1c04fcadef961032a943 diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 6993ef3768a79..4a763d4144edc 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -90,6 +90,11 @@ macro_rules! is_input_attr { ($attr:ident) => (false); } +macro_rules! is_eval_always_attr { + (eval_always) => (true); + ($attr:ident) => (false); +} + macro_rules! contains_anon_attr { ($($attr:ident),*) => ({$(is_anon_attr!($attr) | )* false}); } @@ -98,6 +103,10 @@ macro_rules! contains_input_attr { ($($attr:ident),*) => ({$(is_input_attr!($attr) | )* false}); } +macro_rules! contains_eval_always_attr { + ($($attr:ident),*) => ({$(is_eval_always_attr!($attr) | )* false}); +} + macro_rules! define_dep_nodes { (<$tcx:tt> $( @@ -160,6 +169,15 @@ macro_rules! define_dep_nodes { } } + #[inline] + pub fn is_eval_always(&self) -> bool { + match *self { + $( + DepKind :: $variant => { contains_eval_always_attr!($($attr), *) } + )* + } + } + #[allow(unreachable_code)] #[inline] pub fn has_params(&self) -> bool { @@ -447,10 +465,10 @@ define_dep_nodes!( <'tcx> // Represents different phases in the compiler. [] RegionScopeTree(DefId), - [] Coherence, - [] CoherenceInherentImplOverlapCheck, + [eval_always] Coherence, + [eval_always] CoherenceInherentImplOverlapCheck, [] CoherenceCheckTrait(DefId), - [] PrivacyAccessLevels(CrateNum), + [eval_always] PrivacyAccessLevels(CrateNum), // Represents the MIR for a fn; also used as the task node for // things read/modify that MIR. @@ -467,7 +485,7 @@ define_dep_nodes!( <'tcx> [] Reachability, [] MirKeys, - [] CrateVariances, + [eval_always] CrateVariances, // Nodes representing bits of computed IR in the tcx. Each shared // table in the tcx (or elsewhere) maps to one of these @@ -497,9 +515,10 @@ define_dep_nodes!( <'tcx> [] DtorckConstraint(DefId), [] AdtDestructor(DefId), [] AssociatedItemDefIds(DefId), - [] InherentImpls(DefId), + [eval_always] InherentImpls(DefId), [] TypeckBodiesKrate, [] TypeckTables(DefId), + [] UsedTraitImports(DefId), [] HasTypeckTables(DefId), [] ConstEval { param_env: ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)> }, [] SymbolName(DefId), @@ -566,7 +585,7 @@ define_dep_nodes!( <'tcx> [] IsCompilerBuiltins(CrateNum), [] HasGlobalAllocator(CrateNum), [] ExternCrate(DefId), - [] LintLevels, + [eval_always] LintLevels, [] Specializes { impl1: DefId, impl2: DefId }, [input] InScopeTraits(DefIndex), [] ModuleExports(DefId), @@ -625,14 +644,14 @@ define_dep_nodes!( <'tcx> [] StabilityIndex, [] AllCrateNums, [] ExportedSymbols(CrateNum), - [] CollectAndPartitionTranslationItems, + [eval_always] CollectAndPartitionTranslationItems, [] ExportName(DefId), [] ContainsExternIndicator(DefId), [] IsTranslatedFunction(DefId), [] CodegenUnit(InternedString), [] CompileCodegenUnit(InternedString), [] OutputFilenames, - + [anon] NormalizeTy, // We use this for most things when incr. comp. is turned off. [] Null, ); diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 8aff042955c17..ec709b301eb73 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -12,7 +12,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHashingContextProvider}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use session::config::OutputType; use std::cell::{Ref, RefCell}; use std::env; use std::hash::Hash; @@ -200,11 +199,27 @@ impl DepGraph { -> (R, DepNodeIndex) where C: DepGraphSafe + StableHashingContextProvider, R: HashStable, + { + self.with_task_impl(key, cx, arg, task, + |data, key| data.borrow_mut().push_task(key), + |data, key| data.borrow_mut().pop_task(key)) + } + + fn with_task_impl(&self, + key: DepNode, + cx: C, + arg: A, + task: fn(C, A) -> R, + push: fn(&RefCell, DepNode), + pop: fn(&RefCell, DepNode) -> DepNodeIndex) + -> (R, DepNodeIndex) + where C: DepGraphSafe + StableHashingContextProvider, + R: HashStable, { if let Some(ref data) = self.data { debug_assert!(!data.colors.borrow().contains_key(&key)); - data.current.borrow_mut().push_task(key); + push(&data.current, key); if cfg!(debug_assertions) { profq_msg(ProfileQueriesMsg::TaskBegin(key.clone())) }; @@ -221,7 +236,7 @@ impl DepGraph { profq_msg(ProfileQueriesMsg::TaskEnd) }; - let dep_node_index = data.current.borrow_mut().pop_task(key); + let dep_node_index = pop(&data.current, key); let mut stable_hasher = StableHasher::new(); result.hash_stable(&mut hcx, &mut stable_hasher); @@ -291,6 +306,22 @@ impl DepGraph { } } + /// Execute something within an "eval-always" task which is a task + // that runs whenever anything changes. + pub fn with_eval_always_task(&self, + key: DepNode, + cx: C, + arg: A, + task: fn(C, A) -> R) + -> (R, DepNodeIndex) + where C: DepGraphSafe + StableHashingContextProvider, + R: HashStable, + { + self.with_task_impl(key, cx, arg, task, + |data, key| data.borrow_mut().push_eval_always_task(key), + |data, key| data.borrow_mut().pop_eval_always_task(key)) + } + #[inline] pub fn read(&self, v: DepNode) { if let Some(ref data) = self.data { @@ -647,7 +678,14 @@ impl DepGraph { pub struct WorkProduct { pub cgu_name: String, /// Saved files associated with this CGU - pub saved_files: Vec<(OutputType, String)>, + pub saved_files: Vec<(WorkProductFileKind, String)>, +} + +#[derive(Clone, Copy, Debug, RustcEncodable, RustcDecodable)] +pub enum WorkProductFileKind { + Object, + Bytecode, + BytecodeCompressed, } pub(super) struct CurrentDepGraph { @@ -782,6 +820,24 @@ impl CurrentDepGraph { } } + fn push_eval_always_task(&mut self, key: DepNode) { + self.task_stack.push(OpenTask::EvalAlways { node: key }); + } + + fn pop_eval_always_task(&mut self, key: DepNode) -> DepNodeIndex { + let popped_node = self.task_stack.pop().unwrap(); + + if let OpenTask::EvalAlways { + node, + } = popped_node { + debug_assert_eq!(node, key); + let krate_idx = self.node_to_node_index[&DepNode::new_no_params(DepKind::Krate)]; + self.alloc_node(node, vec![krate_idx]) + } else { + bug!("pop_eval_always_task() - Expected eval always task to be popped"); + } + } + fn read_index(&mut self, source: DepNodeIndex) { match self.task_stack.last_mut() { Some(&mut OpenTask::Regular { @@ -812,7 +868,8 @@ impl CurrentDepGraph { reads.push(source); } } - Some(&mut OpenTask::Ignore) | None => { + Some(&mut OpenTask::Ignore) | + Some(&mut OpenTask::EvalAlways { .. }) | None => { // ignore } } @@ -845,4 +902,7 @@ enum OpenTask { read_set: FxHashSet, }, Ignore, + EvalAlways { + node: DepNode, + }, } diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs index 690db8a552248..fe0212423f6ef 100644 --- a/src/librustc/dep_graph/mod.rs +++ b/src/librustc/dep_graph/mod.rs @@ -21,6 +21,7 @@ mod serialized; pub use self::dep_tracking_map::{DepTrackingMap, DepTrackingMapConfig}; pub use self::dep_node::{DepNode, DepKind, DepConstructor, WorkProductId, label_strs}; pub use self::graph::{DepGraph, WorkProduct, DepNodeIndex, DepNodeColor}; +pub use self::graph::WorkProductFileKind; pub use self::prev::PreviousDepGraph; pub use self::query::DepGraphQuery; pub use self::safe::AssertDepGraphSafe; diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 26f56ffacae7f..2b6e1d855680d 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -401,16 +401,6 @@ fn bar(x: &str, y: &str) -> &str { } fn baz<'a>(x: &'a str, y: &str) -> &str { } ``` -Here's an example that is currently an error, but may work in a future version -of Rust: - -```compile_fail,E0106 -struct Foo<'a>(&'a str); - -trait Quux { } -impl Quux for Foo { } -``` - Lifetime elision in implementation headers was part of the lifetime elision RFC. It is, however, [currently unimplemented][iss15872]. @@ -1875,7 +1865,7 @@ fn main() { "##, E0601: r##" -No `main` function was found in a binary crate. To fix this error, just add a +No `main` function was found in a binary crate. To fix this error, add a `main` function. For example: ``` diff --git a/src/librustc/hir/README.md b/src/librustc/hir/README.md index c832a897dee8b..e283fc40c50a3 100644 --- a/src/librustc/hir/README.md +++ b/src/librustc/hir/README.md @@ -57,7 +57,7 @@ carry around references into the HIR, but rather to carry around *identifier numbers* (or just "ids"). Right now, you will find four sorts of identifiers in active use: -- `DefId`, which primarily name "definitions" or top-level items. +- `DefId`, which primarily names "definitions" or top-level items. - You can think of a `DefId` as being shorthand for a very explicit and complete path, like `std::collections::HashMap`. However, these paths are able to name things that are not nameable in @@ -114,6 +114,6 @@ A **body** represents some kind of executable code, such as the body of a function/closure or the definition of a constant. Bodies are associated with an **owner**, which is typically some kind of item (e.g., a `fn()` or `const`), but could also be a closure expression -(e.g., `|x, y| x + y`). You can use the HIR map to find find the body +(e.g., `|x, y| x + y`). You can use the HIR map to find the body associated with a given def-id (`maybe_body_owned_by()`) or to find the owner of a body (`body_owner_def_id()`). diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index 4e0c6479abf14..64bcdc7920a01 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -35,6 +35,7 @@ pub enum Def { Variant(DefId), Trait(DefId), TyAlias(DefId), + TyForeign(DefId), AssociatedTy(DefId), PrimTy(hir::PrimTy), TyParam(DefId), @@ -152,7 +153,7 @@ impl Def { Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) | Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) | Def::Macro(id, ..) | - Def::GlobalAsm(id) => { + Def::GlobalAsm(id) | Def::TyForeign(id) => { id } @@ -186,6 +187,7 @@ impl Def { Def::StructCtor(.., CtorKind::Fictive) => bug!("impossible struct constructor"), Def::Union(..) => "union", Def::Trait(..) => "trait", + Def::TyForeign(..) => "foreign type", Def::Method(..) => "method", Def::Const(..) => "constant", Def::AssociatedConst(..) => "associated constant", diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 1755b3bca0572..ae25924ab420c 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -704,6 +704,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v } } ForeignItemStatic(ref typ, _) => visitor.visit_ty(typ), + ForeignItemType => (), } walk_list!(visitor, visit_attribute, &foreign_item.attrs); @@ -780,9 +781,7 @@ pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<' FnKind::ItemFn(_, generics, ..) => { visitor.visit_generics(generics); } - FnKind::Method(_, sig, ..) => { - visitor.visit_generics(&sig.generics); - } + FnKind::Method(..) | FnKind::Closure(_) => {} } } @@ -802,6 +801,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem) { visitor.visit_name(trait_item.span, trait_item.name); walk_list!(visitor, visit_attribute, &trait_item.attrs); + visitor.visit_generics(&trait_item.generics); match trait_item.node { TraitItemKind::Const(ref ty, default) => { visitor.visit_id(trait_item.id); @@ -810,7 +810,6 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai } TraitItemKind::Method(ref sig, TraitMethod::Required(ref names)) => { visitor.visit_id(trait_item.id); - visitor.visit_generics(&sig.generics); visitor.visit_fn_decl(&sig.decl); for name in names { visitor.visit_name(name.span, name.node); @@ -852,6 +851,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt ref vis, ref defaultness, ref attrs, + ref generics, ref node, span } = *impl_item; @@ -860,6 +860,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt visitor.visit_vis(vis); visitor.visit_defaultness(defaultness); walk_list!(visitor, visit_attribute, attrs); + visitor.visit_generics(generics); match *node { ImplItemKind::Const(ref ty, body) => { visitor.visit_id(impl_item.id); diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 848da9637a299..3834852cac5a9 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1539,6 +1539,7 @@ impl<'a> LoweringContext<'a> { hir_id, name: this.lower_ident(i.ident), attrs: this.lower_attrs(&i.attrs), + generics: this.lower_generics(&i.generics), node: match i.node { TraitItemKind::Const(ref ty, ref default) => { hir::TraitItemKind::Const(this.lower_ty(ty), @@ -1603,6 +1604,7 @@ impl<'a> LoweringContext<'a> { hir_id, name: this.lower_ident(i.ident), attrs: this.lower_attrs(&i.attrs), + generics: this.lower_generics(&i.generics), vis: this.lower_visibility(&i.vis, None), defaultness: this.lower_defaultness(i.defaultness, true /* [1] */), node: match i.node { @@ -1720,6 +1722,9 @@ impl<'a> LoweringContext<'a> { ForeignItemKind::Static(ref t, m) => { hir::ForeignItemStatic(this.lower_ty(t), m) } + ForeignItemKind::Ty => { + hir::ForeignItemType + } }, vis: this.lower_visibility(&i.vis, None), span: i.span, @@ -1729,7 +1734,6 @@ impl<'a> LoweringContext<'a> { fn lower_method_sig(&mut self, sig: &MethodSig) -> hir::MethodSig { hir::MethodSig { - generics: self.lower_generics(&sig.generics), abi: sig.abi, unsafety: self.lower_unsafety(sig.unsafety), constness: self.lower_constness(sig.constness), @@ -2666,7 +2670,7 @@ impl<'a> LoweringContext<'a> { -> hir::Visibility { match *v { Visibility::Public => hir::Public, - Visibility::Crate(_) => hir::Visibility::Crate, + Visibility::Crate(..) => hir::Visibility::Crate, Visibility::Restricted { ref path, id } => { hir::Visibility::Restricted { path: P(self.lower_path(id, path, ParamMode::Explicit, true)), diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 80fadcda2775d..816793cc1aaa0 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -12,6 +12,7 @@ use super::*; use dep_graph::{DepGraph, DepKind, DepNodeIndex}; use hir::intravisit::{Visitor, NestedVisitorMap}; +use session::CrateDisambiguator; use std::iter::repeat; use syntax::ast::{NodeId, CRATE_NODE_ID}; use syntax_pos::Span; @@ -118,7 +119,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { } pub(super) fn finalize_and_compute_crate_hash(self, - crate_disambiguator: &str) + crate_disambiguator: CrateDisambiguator) -> Vec> { let mut node_hashes: Vec<_> = self .hir_body_nodes @@ -133,7 +134,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { self.dep_graph.with_task(DepNode::new_no_params(DepKind::Krate), &self.hcx, - (node_hashes, crate_disambiguator), + (node_hashes, crate_disambiguator.to_fingerprint()), identity_fn); self.map } diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 673e6d3bbfbae..9d49776749bcb 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -10,12 +10,14 @@ use hir::map::definitions::*; use hir::def_id::{CRATE_DEF_INDEX, DefIndex, DefIndexAddressSpace}; +use session::CrateDisambiguator; use syntax::ast::*; use syntax::ext::hygiene::Mark; use syntax::visit; use syntax::symbol::keywords; use syntax::symbol::Symbol; +use syntax::parse::token::{self, Token}; use hir::map::{ITEM_LIKE_SPACE, REGULAR_SPACE}; @@ -43,7 +45,9 @@ impl<'a> DefCollector<'a> { } } - pub fn collect_root(&mut self, crate_name: &str, crate_disambiguator: &str) { + pub fn collect_root(&mut self, + crate_name: &str, + crate_disambiguator: CrateDisambiguator) { let root = self.definitions.create_root_def(crate_name, crate_disambiguator); assert_eq!(root, CRATE_DEF_INDEX); @@ -283,4 +287,17 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { _ => visit::walk_stmt(self, stmt), } } + + fn visit_token(&mut self, t: Token) { + if let Token::Interpolated(nt) = t { + match nt.0 { + token::NtExpr(ref expr) => { + if let ExprKind::Mac(..) = expr.node { + self.visit_macro_invoc(expr.id, false); + } + } + _ => {} + } + } + } } diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 8bc7cf2faba04..6418df479526c 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -22,6 +22,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::stable_hasher::StableHasher; use serialize::{Encodable, Decodable, Encoder, Decoder}; +use session::CrateDisambiguator; use std::fmt::Write; use std::hash::Hash; use syntax::ast; @@ -231,7 +232,9 @@ impl DefKey { DefPathHash(hasher.finish()) } - fn root_parent_stable_hash(crate_name: &str, crate_disambiguator: &str) -> DefPathHash { + fn root_parent_stable_hash(crate_name: &str, + crate_disambiguator: CrateDisambiguator) + -> DefPathHash { let mut hasher = StableHasher::new(); // Disambiguate this from a regular DefPath hash, // see compute_stable_hash() above. @@ -467,7 +470,7 @@ impl Definitions { /// Add a definition with a parent definition. pub fn create_root_def(&mut self, crate_name: &str, - crate_disambiguator: &str) + crate_disambiguator: CrateDisambiguator) -> DefIndex { let key = DefKey { parent: None, diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 8ce2feab06cef..a23658664dc6a 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -1014,8 +1014,8 @@ pub fn map_crate<'hir>(sess: &::session::Session, hcx); intravisit::walk_crate(&mut collector, &forest.krate); - let crate_disambiguator = sess.local_crate_disambiguator().as_str(); - collector.finalize_and_compute_crate_hash(&crate_disambiguator) + let crate_disambiguator = sess.local_crate_disambiguator(); + collector.finalize_and_compute_crate_hash(crate_disambiguator) }; if log_enabled!(::log::LogLevel::Debug) { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 5ad0ff04c1b9c..58f1b1f9a41e7 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1295,7 +1295,6 @@ pub struct MethodSig { pub constness: Constness, pub abi: Abi, pub decl: P, - pub generics: Generics, } // The bodies for items are stored "out of line", in a separate @@ -1316,6 +1315,7 @@ pub struct TraitItem { pub name: Name, pub hir_id: HirId, pub attrs: HirVec, + pub generics: Generics, pub node: TraitItemKind, pub span: Span, } @@ -1360,6 +1360,7 @@ pub struct ImplItem { pub vis: Visibility, pub defaultness: Defaultness, pub attrs: HirVec, + pub generics: Generics, pub node: ImplItemKind, pub span: Span, } @@ -1853,6 +1854,19 @@ impl Item_ { _ => None, } } + + pub fn generics(&self) -> Option<&Generics> { + Some(match *self { + ItemFn(_, _, _, _, ref generics, _) | + ItemTy(_, ref generics) | + ItemEnum(_, ref generics) | + ItemStruct(_, ref generics) | + ItemUnion(_, ref generics) | + ItemTrait(_, ref generics, _, _) | + ItemImpl(_, _, _, ref generics, _, _, _)=> generics, + _ => return None + }) + } } /// A reference from an trait to one of its associated items. This @@ -1911,6 +1925,8 @@ pub enum ForeignItem_ { /// A foreign static item (`static ext: u8`), with optional mutability /// (the boolean is true when mutable) ForeignItemStatic(P, bool), + /// A foreign type + ForeignItemType, } impl ForeignItem_ { @@ -1918,6 +1934,7 @@ impl ForeignItem_ { match *self { ForeignItemFn(..) => "foreign function", ForeignItemStatic(..) => "foreign static item", + ForeignItemType => "foreign type", } } } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 7287e599b290d..24a0b5fcea9b8 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -478,6 +478,13 @@ impl<'a> State<'a> { self.end()?; // end the head-ibox self.end() // end the outer cbox } + hir::ForeignItemType => { + self.head(&visibility_qualified(&item.vis, "type"))?; + self.print_name(item.name)?; + self.s.word(";")?; + self.end()?; // end the head-ibox + self.end() // end the outer cbox + } } } @@ -880,6 +887,7 @@ impl<'a> State<'a> { pub fn print_method_sig(&mut self, name: ast::Name, m: &hir::MethodSig, + generics: &hir::Generics, vis: &hir::Visibility, arg_names: &[Spanned], body_id: Option) @@ -889,7 +897,7 @@ impl<'a> State<'a> { m.constness, m.abi, Some(name), - &m.generics, + generics, vis, arg_names, body_id) @@ -905,12 +913,14 @@ impl<'a> State<'a> { self.print_associated_const(ti.name, &ty, default, &hir::Inherited)?; } hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => { - self.print_method_sig(ti.name, sig, &hir::Inherited, arg_names, None)?; + self.print_method_sig(ti.name, sig, &ti.generics, &hir::Inherited, arg_names, + None)?; self.s.word(";")?; } hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { self.head("")?; - self.print_method_sig(ti.name, sig, &hir::Inherited, &[], Some(body))?; + self.print_method_sig(ti.name, sig, &ti.generics, &hir::Inherited, &[], + Some(body))?; self.nbsp()?; self.end()?; // need to close a box self.end()?; // need to close a box @@ -938,7 +948,7 @@ impl<'a> State<'a> { } hir::ImplItemKind::Method(ref sig, body) => { self.head("")?; - self.print_method_sig(ii.name, sig, &ii.vis, &[], Some(body))?; + self.print_method_sig(ii.name, sig, &ii.generics, &ii.vis, &[], Some(body))?; self.nbsp()?; self.end()?; // need to close a box self.end()?; // need to close a box diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index c0fae8bf8bd20..181b97aa7b54a 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -232,8 +232,7 @@ impl_stable_hash_for!(struct hir::MethodSig { unsafety, constness, abi, - decl, - generics + decl }); impl_stable_hash_for!(struct hir::TypeBinding { @@ -709,6 +708,7 @@ impl<'gcx> HashStable> for hir::TraitItem { hir_id: _, name, ref attrs, + ref generics, ref node, span } = *self; @@ -716,6 +716,7 @@ impl<'gcx> HashStable> for hir::TraitItem { hcx.hash_hir_item_like(attrs, |hcx| { name.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); + generics.hash_stable(hcx, hasher); node.hash_stable(hcx, hasher); span.hash_stable(hcx, hasher); }); @@ -744,6 +745,7 @@ impl<'gcx> HashStable> for hir::ImplItem { ref vis, defaultness, ref attrs, + ref generics, ref node, span } = *self; @@ -753,6 +755,7 @@ impl<'gcx> HashStable> for hir::ImplItem { vis.hash_stable(hcx, hasher); defaultness.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); + generics.hash_stable(hcx, hasher); node.hash_stable(hcx, hasher); span.hash_stable(hcx, hasher); }); @@ -974,7 +977,8 @@ impl_stable_hash_for!(struct hir::ForeignItem { impl_stable_hash_for!(enum hir::ForeignItem_ { ForeignItemFn(fn_decl, arg_names, generics), - ForeignItemStatic(ty, is_mutbl) + ForeignItemStatic(ty, is_mutbl), + ForeignItemType }); impl_stable_hash_for!(enum hir::Stmt_ { @@ -1083,6 +1087,7 @@ impl_stable_hash_for!(enum hir::def::Def { PrimTy(prim_ty), TyParam(def_id), SelfTy(trait_def_id, impl_def_id), + TyForeign(def_id), Fn(def_id), Const(def_id), Static(def_id, is_mutbl), diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 50f7e4ba176e5..48d3017f59763 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -610,8 +610,7 @@ for ty::TypeVariants<'gcx> def_id.hash_stable(hcx, hasher); closure_substs.hash_stable(hcx, hasher); } - TyGenerator(def_id, closure_substs, interior) - => { + TyGenerator(def_id, closure_substs, interior) => { def_id.hash_stable(hcx, hasher); closure_substs.hash_stable(hcx, hasher); interior.hash_stable(hcx, hasher); @@ -630,6 +629,9 @@ for ty::TypeVariants<'gcx> TyParam(param_ty) => { param_ty.hash_stable(hcx, hasher); } + TyForeign(def_id) => { + def_id.hash_stable(hcx, hasher); + } TyInfer(..) => { bug!("ty::TypeVariants::hash_stable() - Unexpected variant {:?}.", *self) } @@ -755,13 +757,11 @@ impl<'gcx> HashStable> for ty::CrateVariancesMap { hcx: &mut StableHashingContext<'gcx>, hasher: &mut StableHasher) { let ty::CrateVariancesMap { - ref dependencies, ref variances, // This is just an irrelevant helper value. empty_variance: _, } = *self; - dependencies.hash_stable(hcx, hasher); variances.hash_stable(hcx, hasher); } } diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index c274f8bda9fb0..41e7dffe54dc1 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -312,6 +312,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { ty::TyNever | ty::TyTuple(..) | ty::TyProjection(..) | + ty::TyForeign(..) | ty::TyParam(..) | ty::TyAnon(..) => { t.super_fold_with(self) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 39bcd7035742e..79eeebfb25031 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -480,16 +480,16 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { { assert!(!value.needs_subst()); let value = self.erase_late_bound_regions(value); - self.normalize_associated_type(&value) + self.fully_normalize_associated_types_in(&value) } /// Fully normalizes any associated types in `value`, using an /// empty environment and `Reveal::All` mode (therefore, suitable /// only for monomorphized code during trans, basically). - pub fn normalize_associated_type(self, value: &T) -> T + pub fn fully_normalize_associated_types_in(self, value: &T) -> T where T: TransNormalize<'tcx> { - debug!("normalize_associated_type(t={:?})", value); + debug!("fully_normalize_associated_types_in(t={:?})", value); let param_env = ty::ParamEnv::empty(Reveal::All); let value = self.erase_regions(value); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 64fe4626d6ee6..0cec26d339c69 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -47,6 +47,7 @@ #![feature(core_intrinsics)] #![feature(i128_type)] #![cfg_attr(windows, feature(libc))] +#![feature(macro_vis_matcher)] #![feature(never_type)] #![feature(nonzero)] #![feature(quote)] @@ -56,9 +57,7 @@ #![feature(unboxed_closures)] #![feature(trace_macros)] #![feature(test)] - -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(const_atomic_bool_new))] +#![feature(const_atomic_bool_new)] #![recursion_limit="512"] diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index d28963fc726ab..855cc069d117a 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -106,12 +106,6 @@ declare_lint! { "unknown crate type found in #[crate_type] directive" } -declare_lint! { - pub FAT_PTR_TRANSMUTES, - Allow, - "detects transmutes of fat pointers" -} - declare_lint! { pub TRIVIAL_CASTS, Allow, @@ -250,7 +244,6 @@ impl LintPass for HardwiredLints { UNUSED_FEATURES, STABLE_FEATURES, UNKNOWN_CRATE_TYPES, - FAT_PTR_TRANSMUTES, TRIVIAL_CASTS, TRIVIAL_NUMERIC_CASTS, PRIVATE_IN_PUBLIC, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 4d1374b69b85c..601e0316d4af9 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -352,6 +352,9 @@ pub struct LateContext<'a, 'tcx: 'a> { lint_sess: LintSession<'tcx, LateLintPassObject>, last_ast_node_with_lint_attrs: ast::NodeId, + + /// Generic type parameters in scope for the item we are in. + pub generics: Option<&'tcx hir::Generics>, } /// Context for lint checking of the AST, after expansion, before lowering to @@ -646,13 +649,16 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> { } fn visit_item(&mut self, it: &'tcx hir::Item) { + let generics = self.generics.take(); + self.generics = it.node.generics(); self.with_lint_attrs(it.id, &it.attrs, |cx| { cx.with_param_env(it.id, |cx| { run_lints!(cx, check_item, late_passes, it); hir_visit::walk_item(cx, it); run_lints!(cx, check_item_post, late_passes, it); }); - }) + }); + self.generics = generics; } fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) { @@ -774,6 +780,8 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) { + let generics = self.generics.take(); + self.generics = Some(&trait_item.generics); self.with_lint_attrs(trait_item.id, &trait_item.attrs, |cx| { cx.with_param_env(trait_item.id, |cx| { run_lints!(cx, check_trait_item, late_passes, trait_item); @@ -781,9 +789,12 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> { run_lints!(cx, check_trait_item_post, late_passes, trait_item); }); }); + self.generics = generics; } fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { + let generics = self.generics.take(); + self.generics = Some(&impl_item.generics); self.with_lint_attrs(impl_item.id, &impl_item.attrs, |cx| { cx.with_param_env(impl_item.id, |cx| { run_lints!(cx, check_impl_item, late_passes, impl_item); @@ -791,6 +802,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> { run_lints!(cx, check_impl_item_post, late_passes, impl_item); }); }); + self.generics = generics; } fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) { @@ -991,6 +1003,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { access_levels, lint_sess: LintSession::new(&tcx.sess.lint_store), last_ast_node_with_lint_attrs: ast::CRATE_NODE_ID, + generics: None, }; // Visit the whole crate. diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 42b5e2dd83de5..52dcbfdedef5d 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -84,29 +84,16 @@ impl Lint { } } -/// Build a `Lint` initializer. -#[macro_export] -macro_rules! lint_initializer { - ($name:ident, $level:ident, $desc:expr) => ( - ::rustc::lint::Lint { - name: stringify!($name), - default_level: ::rustc::lint::$level, - desc: $desc, - } - ) -} - /// Declare a static item of type `&'static Lint`. #[macro_export] macro_rules! declare_lint { - (pub $name:ident, $level:ident, $desc:expr) => ( - pub static $name: &'static ::rustc::lint::Lint - = &lint_initializer!($name, $level, $desc); - ); - ($name:ident, $level:ident, $desc:expr) => ( - static $name: &'static ::rustc::lint::Lint - = &lint_initializer!($name, $level, $desc); - ); + ($vis: vis $NAME: ident, $Level: ident, $desc: expr) => ( + $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { + name: stringify!($NAME), + default_level: $crate::lint::$Level, + desc: $desc + }; + ) } /// Declare a static `LintArray` and return it as an expression. diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index a97bfa0536987..f4ba7890b170d 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -30,7 +30,7 @@ use hir::map::definitions::{Definitions, DefKey, DefPathTable}; use hir::svh::Svh; use ich; use ty::{self, TyCtxt}; -use session::Session; +use session::{Session, CrateDisambiguator}; use session::search_paths::PathKind; use util::nodemap::NodeSet; @@ -267,7 +267,7 @@ pub trait CrateStore { fn export_macros_untracked(&self, cnum: CrateNum); fn dep_kind_untracked(&self, cnum: CrateNum) -> DepKind; fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol; - fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> Symbol; + fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator; fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh; fn struct_field_names_untracked(&self, def: DefId) -> Vec; fn item_children_untracked(&self, did: DefId, sess: &Session) -> Vec; @@ -338,7 +338,7 @@ impl CrateStore for DummyCrateStore { fn dep_kind_untracked(&self, cnum: CrateNum) -> DepKind { bug!("is_explicitly_linked") } fn export_macros_untracked(&self, cnum: CrateNum) { bug!("export_macros") } fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol { bug!("crate_name") } - fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> Symbol { + fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator { bug!("crate_disambiguator") } fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index bb6213cb5faaf..2037bc01a5bc9 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -58,11 +58,10 @@ fn item_might_be_inlined(item: &hir::Item) -> bool { } fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - sig: &hir::MethodSig, impl_item: &hir::ImplItem, impl_src: DefId) -> bool { if attr::requests_inline(&impl_item.attrs) || - generics_require_inlining(&sig.generics) { + generics_require_inlining(&impl_item.generics) { return true } if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) { @@ -176,8 +175,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { Some(hir_map::NodeImplItem(impl_item)) => { match impl_item.node { hir::ImplItemKind::Const(..) => true, - hir::ImplItemKind::Method(ref sig, _) => { - if generics_require_inlining(&sig.generics) || + hir::ImplItemKind::Method(..) => { + if generics_require_inlining(&impl_item.generics) || attr::requests_inline(&impl_item.attrs) { true } else { @@ -293,9 +292,9 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { hir::ImplItemKind::Const(_, body) => { self.visit_nested_body(body); } - hir::ImplItemKind::Method(ref sig, body) => { + hir::ImplItemKind::Method(_, body) => { let did = self.tcx.hir.get_parent_did(search_item); - if method_might_be_inlined(self.tcx, sig, impl_item, did) { + if method_might_be_inlined(self.tcx, impl_item, did) { self.visit_nested_body(body) } } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index d0c5460fa9714..ee0e580920e1f 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -365,6 +365,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { hir::ForeignItemStatic(..) => { intravisit::walk_foreign_item(self, item); } + hir::ForeignItemType => { + intravisit::walk_foreign_item(self, item); + } } } @@ -412,7 +415,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { if let hir::TraitItemKind::Method(ref sig, _) = trait_item.node { self.visit_early_late( Some(self.hir_map.get_parent(trait_item.id)), - &sig.decl, &sig.generics, + &sig.decl, &trait_item.generics, |this| intravisit::walk_trait_item(this, trait_item)) } else { intravisit::walk_trait_item(self, trait_item); @@ -423,7 +426,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node { self.visit_early_late( Some(self.hir_map.get_parent(impl_item.id)), - &sig.decl, &sig.generics, + &sig.decl, &impl_item.generics, |this| intravisit::walk_impl_item(this, impl_item)) } else { intravisit::walk_impl_item(self, impl_item); diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 4e4fc8b3118ff..b30d5e384884e 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -18,8 +18,9 @@ use hir::def::Def; use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; use ty::{self, TyCtxt}; use middle::privacy::AccessLevels; +use session::DiagnosticMessageId; use syntax::symbol::Symbol; -use syntax_pos::{Span, DUMMY_SP}; +use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use syntax::ast; use syntax::ast::{NodeId, Attribute}; use syntax::feature_gate::{GateIssue, emit_feature_err, find_lang_feature_accepted_version}; @@ -597,8 +598,29 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { feature.as_str(), &r), None => format!("use of unstable library feature '{}'", &feature) }; - emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span, - GateIssue::Library(Some(issue)), &msg); + + + let msp: MultiSpan = span.into(); + let cm = &self.sess.parse_sess.codemap(); + let span_key = msp.primary_span().and_then(|sp: Span| + if sp != DUMMY_SP { + let file = cm.lookup_char_pos(sp.lo()).file; + if file.name.starts_with("<") && file.name.ends_with(" macros>") { + None + } else { + Some(span) + } + } else { + None + } + ); + + let error_id = (DiagnosticMessageId::StabilityId(issue), span_key, msg.clone()); + let fresh = self.sess.one_time_diagnostics.borrow_mut().insert(error_id); + if fresh { + emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span, + GateIssue::Library(Some(issue)), &msg); + } } Some(_) => { // Stable APIs are always ok to call and deprecated APIs are diff --git a/src/librustc/mir/README.md b/src/librustc/mir/README.md index e8ed8bf104cc8..fb0c7ce1df23d 100644 --- a/src/librustc/mir/README.md +++ b/src/librustc/mir/README.md @@ -6,7 +6,7 @@ register and define new MIR transformations and analyses. Most of the code that operates on MIR can be found in the `librustc_mir` crate or other crates. The code found here in -`librustc` is just the datatype definitions, alonging the functions +`librustc` is just the datatype definitions, along with the functions which operate on MIR to be placed everywhere else. ## MIR Data Types and visitor @@ -27,7 +27,7 @@ As a MIR *consumer*, you are expected to use one of the queries that returns a "final MIR". As of the time of this writing, there is only one: `optimized_mir(def_id)`, but more are expected to come in the future. For foreign def-ids, we simply read the MIR from the other -crate's metadata. But for local query, this query will construct the +crate's metadata. But for local def-ids, the query will construct the MIR and then iteratively optimize it by putting it through various pipeline stages. This section describes those pipeline stages and how you can extend them. @@ -51,7 +51,7 @@ a `&'tcx Steal>`, allocated using **stolen** by the next suite of optimizations -- this is an optimization to avoid cloning the MIR. Attempting to use a stolen result will cause a panic in the compiler. Therefore, it is important -that you not read directly from these intermediate queries except as +that you do not read directly from these intermediate queries except as part of the MIR processing pipeline. Because of this stealing mechanism, some care must also be taken to diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 0159a198bc647..f5a3c1989cf83 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -650,7 +650,9 @@ pub enum TerminatorKind<'tcx> { Call { /// The function that’s being called func: Operand<'tcx>, - /// Arguments the function is called with + /// Arguments the function is called with. These are owned by the callee, which is free to + /// modify them. This is important as "by-value" arguments might be passed by-reference at + /// the ABI level. args: Vec>, /// Destination for the return value. If some, the call is converging. destination: Option<(Lvalue<'tcx>, BasicBlock)>, diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index f9a4b5bb9a537..89896898684f7 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -156,6 +156,7 @@ impl OutputType { pub enum ErrorOutputType { HumanReadable(ColorConfig), Json, + Short(ColorConfig), } impl Default for ErrorOutputType { @@ -935,6 +936,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, build_debugging_options, "Z", "debugging", DB_OPTIONS, db_type_desc, dbsetters, + trans: Option = (None, parse_opt_string, [TRACKED], + "the backend to use"), verbose: bool = (false, parse_bool, [UNTRACKED], "in general, enable more debug printouts"), span_free_formats: bool = (false, parse_bool, [UNTRACKED], @@ -1362,7 +1365,7 @@ pub fn rustc_optgroups() -> Vec { opt::multi("Z", "", "Set internal debugging options", "FLAG"), opt::opt_s("", "error-format", "How errors and other messages are produced", - "human|json"), + "human|json|short"), opt::opt_s("", "color", "Configure coloring of output: auto = colorize, if output goes to a tty (default); always = always colorize output; @@ -1429,15 +1432,16 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) // opt_present because the latter will panic. let error_format = if matches.opts_present(&["error-format".to_owned()]) { match matches.opt_str("error-format").as_ref().map(|s| &s[..]) { - Some("human") => ErrorOutputType::HumanReadable(color), - Some("json") => ErrorOutputType::Json, + Some("human") => ErrorOutputType::HumanReadable(color), + Some("json") => ErrorOutputType::Json, + Some("short") => ErrorOutputType::Short(color), None => ErrorOutputType::HumanReadable(color), Some(arg) => { early_error(ErrorOutputType::HumanReadable(color), - &format!("argument for --error-format must be human or json (instead \ - was `{}`)", + &format!("argument for --error-format must be `human`, `json` or \ + `short` (instead was `{}`)", arg)) } } diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 2634ab1000703..be35cc8e4a1c0 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -12,6 +12,7 @@ pub use self::code_stats::{CodeStats, DataTypeKind, FieldInfo}; pub use self::code_stats::{SizeKind, TypeSizeInfo, VariantInfo}; use hir::def_id::{CrateNum, DefIndex}; +use ich::Fingerprint; use lint; use middle::allocator::AllocatorKind; @@ -29,7 +30,6 @@ use syntax::json::JsonEmitter; use syntax::feature_gate; use syntax::parse; use syntax::parse::ParseSess; -use syntax::symbol::Symbol; use syntax::{ast, codemap}; use syntax::feature_gate::AttributeType; use syntax_pos::{Span, MultiSpan}; @@ -75,20 +75,20 @@ pub struct Session { pub working_dir: (String, bool), pub lint_store: RefCell, pub buffered_lints: RefCell>, - /// Set of (LintId, Option, message) tuples tracking lint + /// Set of (DiagnosticId, Option, message) tuples tracking /// (sub)diagnostics that have been set once, but should not be set again, - /// in order to avoid redundantly verbose output (Issue #24690). - pub one_time_diagnostics: RefCell, String)>>, + /// in order to avoid redundantly verbose output (Issue #24690, #44953). + pub one_time_diagnostics: RefCell, String)>>, pub plugin_llvm_passes: RefCell>, pub plugin_attributes: RefCell>, pub crate_types: RefCell>, pub dependency_formats: RefCell, - /// The crate_disambiguator is constructed out of all the `-C metadata` + /// The crate_disambiguator is constructed out of all the `-C metadata` /// arguments passed to the compiler. Its value together with the crate-name /// forms a unique global identifier for the crate. It is used to allow /// multiple crates with the same name to coexist. See the /// trans::back::symbol_names module for more information. - pub crate_disambiguator: RefCell>, + pub crate_disambiguator: RefCell>, pub features: RefCell, /// The maximum recursion limit for potentially infinitely recursive @@ -164,10 +164,17 @@ enum DiagnosticBuilderMethod { // add more variants as needed to support one-time diagnostics } +/// Diagnostic message id - used in order to avoid emitting the same message more than once +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum DiagnosticMessageId { + LintId(lint::LintId), + StabilityId(u32) +} + impl Session { - pub fn local_crate_disambiguator(&self) -> Symbol { + pub fn local_crate_disambiguator(&self) -> CrateDisambiguator { match *self.crate_disambiguator.borrow() { - Some(sym) => sym, + Some(value) => value, None => bug!("accessing disambiguator before initialization"), } } @@ -360,7 +367,7 @@ impl Session { do_method() }, _ => { - let lint_id = lint::LintId::of(lint); + let lint_id = DiagnosticMessageId::LintId(lint::LintId::of(lint)); let id_span_message = (lint_id, span, message.to_owned()); let fresh = self.one_time_diagnostics.borrow_mut().insert(id_span_message); if fresh { @@ -471,14 +478,18 @@ impl Session { /// Returns the symbol name for the registrar function, /// given the crate Svh and the function DefIndex. - pub fn generate_plugin_registrar_symbol(&self, disambiguator: Symbol, index: DefIndex) + pub fn generate_plugin_registrar_symbol(&self, disambiguator: CrateDisambiguator, + index: DefIndex) -> String { - format!("__rustc_plugin_registrar__{}_{}", disambiguator, index.as_usize()) + format!("__rustc_plugin_registrar__{}_{}", disambiguator.to_fingerprint().to_hex(), + index.as_usize()) } - pub fn generate_derive_registrar_symbol(&self, disambiguator: Symbol, index: DefIndex) + pub fn generate_derive_registrar_symbol(&self, disambiguator: CrateDisambiguator, + index: DefIndex) -> String { - format!("__rustc_derive_registrar__{}_{}", disambiguator, index.as_usize()) + format!("__rustc_derive_registrar__{}_{}", disambiguator.to_fingerprint().to_hex(), + index.as_usize()) } pub fn sysroot<'a>(&'a self) -> &'a Path { @@ -711,12 +722,10 @@ pub fn build_session_with_codemap(sopts: config::Options, let emitter: Box = match (sopts.error_format, emitter_dest) { (config::ErrorOutputType::HumanReadable(color_config), None) => { - Box::new(EmitterWriter::stderr(color_config, - Some(codemap.clone()))) + Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), false)) } (config::ErrorOutputType::HumanReadable(_), Some(dst)) => { - Box::new(EmitterWriter::new(dst, - Some(codemap.clone()))) + Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false)) } (config::ErrorOutputType::Json, None) => { Box::new(JsonEmitter::stderr(Some(registry), codemap.clone())) @@ -724,6 +733,12 @@ pub fn build_session_with_codemap(sopts: config::Options, (config::ErrorOutputType::Json, Some(dst)) => { Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone())) } + (config::ErrorOutputType::Short(color_config), None) => { + Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true)) + } + (config::ErrorOutputType::Short(_), Some(dst)) => { + Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true)) + } }; let diagnostic_handler = @@ -768,7 +783,12 @@ pub fn build_session_(sopts: config::Options, let print_fuel_crate = sopts.debugging_opts.print_fuel.clone(); let print_fuel = Cell::new(0); - let working_dir = env::current_dir().unwrap().to_string_lossy().into_owned(); + let working_dir = match env::current_dir() { + Ok(dir) => dir.to_string_lossy().into_owned(), + Err(e) => { + panic!(p_s.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e))) + } + }; let working_dir = file_path_mapping.map_prefix(working_dir); let sess = Session { @@ -838,6 +858,26 @@ pub fn build_session_(sopts: config::Options, sess } +/// Hash value constructed out of all the `-C metadata` arguments passed to the +/// compiler. Together with the crate-name forms a unique global identifier for +/// the crate. +#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)] +pub struct CrateDisambiguator(Fingerprint); + +impl CrateDisambiguator { + pub fn to_fingerprint(self) -> Fingerprint { + self.0 + } +} + +impl From for CrateDisambiguator { + fn from(fingerprint: Fingerprint) -> CrateDisambiguator { + CrateDisambiguator(fingerprint) + } +} + +impl_stable_hash_for!(tuple_struct CrateDisambiguator { fingerprint }); + /// Holds data on the current incremental compilation session, if there is one. #[derive(Debug)] pub enum IncrCompSession { @@ -867,10 +907,12 @@ pub enum IncrCompSession { pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(color_config) => { - Box::new(EmitterWriter::stderr(color_config, - None)) + Box::new(EmitterWriter::stderr(color_config, None, false)) } config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()), + config::ErrorOutputType::Short(color_config) => { + Box::new(EmitterWriter::stderr(color_config, None, true)) + } }; let handler = errors::Handler::with_emitter(true, false, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal); @@ -880,10 +922,12 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { pub fn early_warn(output: config::ErrorOutputType, msg: &str) { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(color_config) => { - Box::new(EmitterWriter::stderr(color_config, - None)) + Box::new(EmitterWriter::stderr(color_config, None, false)) } config::ErrorOutputType::Json => Box::new(JsonEmitter::basic()), + config::ErrorOutputType::Short(color_config) => { + Box::new(EmitterWriter::stderr(color_config, None, true)) + } }; let handler = errors::Handler::with_emitter(true, false, emitter); handler.emit(&MultiSpan::new(), msg, errors::Level::Warning); diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index dc5ce7353246a..10a32c26e741d 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -304,6 +304,10 @@ fn ty_is_local_constructor(ty: Ty, infer_is_local: InferIsLocal)-> bool { def.did.is_local() } + ty::TyForeign(did) => { + did.is_local() + } + ty::TyDynamic(ref tt, ..) => { tt.principal().map_or(false, |p| p.def_id().is_local()) } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 030b7e4f646f9..e2b23c12cf1f3 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -255,6 +255,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { AdtKind::Enum => Some(17), }, ty::TyGenerator(..) => Some(18), + ty::TyForeign(..) => Some(19), ty::TyInfer(..) | ty::TyError => None } } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index cec79faff315d..6c573acf07d63 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1705,6 +1705,12 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { // say nothing; a candidate may be added by // `assemble_candidates_from_object_ty`. } + ty::TyForeign(..) => { + // Since the contents of foreign types is unknown, + // we don't add any `..` impl. Default traits could + // still be provided by a manual implementation for + // this trait and type. + } ty::TyParam(..) | ty::TyProjection(..) => { // In these cases, we don't know what the actual @@ -2022,7 +2028,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { Where(ty::Binder(Vec::new())) } - ty::TyStr | ty::TySlice(_) | ty::TyDynamic(..) => Never, + ty::TyStr | ty::TySlice(_) | ty::TyDynamic(..) | ty::TyForeign(..) => Never, ty::TyTuple(tys, _) => { Where(ty::Binder(tys.last().into_iter().cloned().collect())) @@ -2066,7 +2072,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { Where(ty::Binder(Vec::new())) } - ty::TyDynamic(..) | ty::TyStr | ty::TySlice(..) | ty::TyGenerator(..) | + ty::TyDynamic(..) | ty::TyStr | ty::TySlice(..) | + ty::TyGenerator(..) | ty::TyForeign(..) | ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutMutable }) => { Never } @@ -2148,6 +2155,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ty::TyDynamic(..) | ty::TyParam(..) | + ty::TyForeign(..) | ty::TyProjection(..) | ty::TyInfer(ty::TyVar(_)) | ty::TyInfer(ty::FreshTy(_)) | diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 20da4c084f01e..d8d0715ff3957 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -20,7 +20,7 @@ use super::{SelectionContext, FulfillmentContext}; use super::util::impl_trait_ref_and_oblig; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use hir::def_id::DefId; use infer::{InferCtxt, InferOk}; use ty::subst::{Subst, Substs}; @@ -335,7 +335,12 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx |ty| format!(" for `{}`", ty)))); } Err(cname) => { - err.note(&format!("conflicting implementation in crate `{}`", cname)); + let msg = match to_pretty_impl_header(tcx, overlap.with_impl) { + Some(s) => format!( + "conflicting implementation in crate `{}`:\n- {}", cname, s), + None => format!("conflicting implementation in crate `{}`", cname), + }; + err.note(&msg); } } @@ -353,3 +358,56 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx Rc::new(sg) } + +/// Recovers the "impl X for Y" signature from `impl_def_id` and returns it as a +/// string. +fn to_pretty_impl_header(tcx: TyCtxt, impl_def_id: DefId) -> Option { + use std::fmt::Write; + + let trait_ref = if let Some(tr) = tcx.impl_trait_ref(impl_def_id) { + tr + } else { + return None; + }; + + let mut w = "impl".to_owned(); + + let substs = Substs::identity_for_item(tcx, impl_def_id); + + // FIXME: Currently only handles ?Sized. + // Needs to support ?Move and ?DynSized when they are implemented. + let mut types_without_default_bounds = FxHashSet::default(); + let sized_trait = tcx.lang_items().sized_trait(); + + if !substs.is_noop() { + types_without_default_bounds.extend(substs.types()); + w.push('<'); + w.push_str(&substs.iter().map(|k| k.to_string()).collect::>().join(", ")); + w.push('>'); + } + + write!(w, " {} for {}", trait_ref, tcx.type_of(impl_def_id)).unwrap(); + + // The predicates will contain default bounds like `T: Sized`. We need to + // remove these bounds, and add `T: ?Sized` to any untouched type parameters. + let predicates = tcx.predicates_of(impl_def_id).predicates; + let mut pretty_predicates = Vec::with_capacity(predicates.len()); + for p in predicates { + if let Some(poly_trait_ref) = p.to_opt_poly_trait_ref() { + if Some(poly_trait_ref.def_id()) == sized_trait { + types_without_default_bounds.remove(poly_trait_ref.self_ty()); + continue; + } + } + pretty_predicates.push(p.to_string()); + } + for ty in types_without_default_bounds { + pretty_predicates.push(format!("{}: ?Sized", ty)); + } + if !pretty_predicates.is_empty() { + write!(w, "\n where {}", pretty_predicates.join(", ")).unwrap(); + } + + w.push(';'); + Some(w) +} diff --git a/src/librustc/traits/trans/mod.rs b/src/librustc/traits/trans/mod.rs index aa3179dd01f56..761e7259204bf 100644 --- a/src/librustc/traits/trans/mod.rs +++ b/src/librustc/traits/trans/mod.rs @@ -13,16 +13,14 @@ // seems likely that they should eventually be merged into more // general routines. -use dep_graph::{DepGraph, DepKind, DepTrackingMap, DepTrackingMapConfig}; +use dep_graph::{DepKind, DepTrackingMapConfig}; use infer::TransNormalize; -use std::cell::RefCell; use std::marker::PhantomData; use syntax_pos::DUMMY_SP; use traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext, Vtable}; use ty::{self, Ty, TyCtxt}; use ty::subst::{Subst, Substs}; use ty::fold::{TypeFoldable, TypeFolder}; -use util::common::MemoizationMap; /// Attempts to resolve an obligation to a vtable.. The result is /// a shallow vtable resolution -- meaning that we do not @@ -130,24 +128,8 @@ impl<'a, 'gcx> TypeFolder<'gcx, 'gcx> for AssociatedTypeNormalizer<'a, 'gcx> { if !ty.has_projections() { ty } else { - self.tcx.trans_trait_caches.project_cache.memoize(ty, || { - debug!("AssociatedTypeNormalizer: ty={:?}", ty); - self.tcx.normalize_associated_type(&ty) - }) - } - } -} - -/// Specializes caches used in trans -- in particular, they assume all -/// types are fully monomorphized and that free regions can be erased. -pub struct TransTraitCaches<'tcx> { - project_cache: RefCell>>, -} - -impl<'tcx> TransTraitCaches<'tcx> { - pub fn new(graph: DepGraph) -> Self { - TransTraitCaches { - project_cache: RefCell::new(DepTrackingMap::new(graph)), + debug!("AssociatedTypeNormalizer: ty={:?}", ty); + self.tcx.fully_normalize_monormophic_ty(ty) } } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 3d5e8ea583ccc..6ab81a41d6809 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -386,8 +386,10 @@ pub struct TypeckTables<'tcx> { cast_kinds: ItemLocalMap, /// Set of trait imports actually used in the method resolution. - /// This is used for warning unused imports. - pub used_trait_imports: DefIdSet, + /// This is used for warning unused imports. During type + /// checking, this `Rc` should not be cloned: it must have a ref-count + /// of 1 so that we can insert things into the set mutably. + pub used_trait_imports: Rc, /// If any errors occurred while type-checking this body, /// this field will be set to `true`. @@ -417,7 +419,7 @@ impl<'tcx> TypeckTables<'tcx> { liberated_fn_sigs: ItemLocalMap(), fru_field_types: ItemLocalMap(), cast_kinds: ItemLocalMap(), - used_trait_imports: DefIdSet(), + used_trait_imports: Rc::new(DefIdSet()), tainted_by_errors: false, free_region_map: FreeRegionMap::new(), } @@ -851,9 +853,6 @@ pub struct GlobalCtxt<'tcx> { pub sess: &'tcx Session, - - pub trans_trait_caches: traits::trans::TransTraitCaches<'tcx>, - pub dep_graph: DepGraph, /// Common types, pre-interned for your convenience. @@ -1137,7 +1136,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { tls::enter_global(GlobalCtxt { sess: s, cstore, - trans_trait_caches: traits::trans::TransTraitCaches::new(dep_graph.clone()), global_arenas: arenas, global_interners: interners, dep_graph: dep_graph.clone(), @@ -1251,7 +1249,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { crate_name, // Don't print the whole crate disambiguator. That's just // annoying in debug output. - &(crate_disambiguator.as_str())[..4], + &(crate_disambiguator.to_fingerprint().to_hex())[..4], self.def_path(def_id).to_string_no_crate()) } @@ -1612,7 +1610,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { pub fn print_debug_stats(self) { sty_debug_print!( self, - TyAdt, TyArray, TySlice, TyRawPtr, TyRef, TyFnDef, TyFnPtr, TyGenerator, + TyAdt, TyArray, TySlice, TyRawPtr, TyRef, TyFnDef, TyFnPtr, TyGenerator, TyForeign, TyDynamic, TyClosure, TyTuple, TyParam, TyInfer, TyProjection, TyAnon); println!("Substs interner: #{}", self.interners.substs.borrow().len()); @@ -1863,6 +1861,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.mk_ty(TyAdt(def, substs)) } + pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> { + self.mk_ty(TyForeign(def_id)) + } + pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> { let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem); let adt_def = self.adt_def(def_id); @@ -2322,4 +2324,7 @@ pub fn provide(providers: &mut ty::maps::Providers) { assert_eq!(cnum, LOCAL_CRATE); tcx.sess.features.borrow().clone_closures }; + providers.fully_normalize_monormophic_ty = |tcx, ty| { + tcx.fully_normalize_associated_types_in(&ty) + }; } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index 52a8389bd8f5f..5cfa72c07126f 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -182,6 +182,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { ty::TyTuple(ref tys, _) if tys.is_empty() => self.to_string(), ty::TyAdt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)), + ty::TyForeign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)), ty::TyArray(_, n) => { if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { format!("array of {} elements", n) diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index 490bfe78a9a1f..138f6af77c658 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -49,6 +49,7 @@ pub enum SimplifiedTypeGen AnonSimplifiedType(D), FunctionSimplifiedType(usize), ParameterSimplifiedType, + ForeignSimplifiedType(DefId), } /// Tries to simplify a type by dropping type parameters, deref'ing away any reference types, etc. @@ -113,6 +114,9 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, ty::TyAnon(def_id, _) => { Some(AnonSimplifiedType(def_id)) } + ty::TyForeign(def_id) => { + Some(ForeignSimplifiedType(def_id)) + } ty::TyInfer(_) | ty::TyError => None, } } @@ -140,6 +144,7 @@ impl SimplifiedTypeGen { AnonSimplifiedType(d) => AnonSimplifiedType(map(d)), FunctionSimplifiedType(n) => FunctionSimplifiedType(n), ParameterSimplifiedType => ParameterSimplifiedType, + ForeignSimplifiedType(d) => ForeignSimplifiedType(d), } } } @@ -172,6 +177,7 @@ impl<'gcx, D> HashStable> for SimplifiedTypeGen GeneratorSimplifiedType(d) => d.hash_stable(hcx, hasher), AnonSimplifiedType(d) => d.hash_stable(hcx, hasher), FunctionSimplifiedType(n) => n.hash_stable(hcx, hasher), + ForeignSimplifiedType(d) => d.hash_stable(hcx, hasher), } } } diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 9ece719c76470..63c646dbd2310 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -63,7 +63,8 @@ impl FlagComputation { &ty::TyFloat(_) | &ty::TyUint(_) | &ty::TyNever | - &ty::TyStr => { + &ty::TyStr | + &ty::TyForeign(..) => { } // You might think that we could just return TyError for diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 600b2572f92b8..442c79393fdc7 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -100,7 +100,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> { impl<'a, 'b, 'tcx> Instance<'tcx> { pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> Instance<'tcx> { - assert!(substs.is_normalized_for_trans() && !substs.has_escaping_regions(), + assert!(!substs.has_escaping_regions(), "substs of instance {:?} not normalized for trans: {:?}", def_id, substs); Instance { def: InstanceDef::Item(def_id), substs: substs } @@ -139,7 +139,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> { substs: &'tcx Substs<'tcx>) -> Option> { debug!("resolve(def_id={:?}, substs={:?})", def_id, substs); let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) { - debug!(" => associated item, attempting to find impl"); + debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env); let item = tcx.associated_item(def_id); resolve_associated_item(tcx, &item, param_env, trait_def_id, substs) } else { diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index a8ccb3e269ffc..98c55331f8a10 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -281,6 +281,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } + ty::TyForeign(did) => self.push_item_path(buffer, did), + ty::TyBool | ty::TyChar | ty::TyInt(_) | @@ -344,8 +346,9 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option { .next(), ty::TyFnDef(def_id, _) | - ty::TyClosure(def_id, _) => Some(def_id), - ty::TyGenerator(def_id, _, _) => Some(def_id), + ty::TyClosure(def_id, _) | + ty::TyGenerator(def_id, _, _) | + ty::TyForeign(def_id) => Some(def_id), ty::TyBool | ty::TyChar | diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 1709f9ed2df1c..491fa2a240cce 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1141,14 +1141,15 @@ impl<'a, 'tcx> Layout { Ok(Scalar { value: Pointer, non_zero: non_zero }) } else { let unsized_part = tcx.struct_tail(pointee); - let meta = match unsized_part.sty { - ty::TySlice(_) | ty::TyStr => { - Int(dl.ptr_sized_integer()) - } - ty::TyDynamic(..) => Pointer, - _ => return Err(LayoutError::Unknown(unsized_part)) - }; - Ok(FatPointer { metadata: meta, non_zero: non_zero }) + match unsized_part.sty { + ty::TySlice(_) | ty::TyStr => Ok(FatPointer { + metadata: Int(dl.ptr_sized_integer()), + non_zero: non_zero + }), + ty::TyDynamic(..) => Ok(FatPointer { metadata: Pointer, non_zero: non_zero }), + ty::TyForeign(..) => Ok(Scalar { value: Pointer, non_zero: non_zero }), + _ => Err(LayoutError::Unknown(unsized_part)), + } } }; @@ -1239,7 +1240,7 @@ impl<'a, 'tcx> Layout { non_zero: false } } - ty::TyDynamic(..) => { + ty::TyDynamic(..) | ty::TyForeign(..) => { let mut unit = Struct::new(dl, &vec![], &ReprOptions::default(), StructKind::AlwaysSizedUnivariant, ty)?; unit.sized = false; @@ -2252,7 +2253,8 @@ impl<'a, 'tcx> TyLayout<'tcx> { ty::TyFnPtr(_) | ty::TyNever | ty::TyFnDef(..) | - ty::TyDynamic(..) => { + ty::TyDynamic(..) | + ty::TyForeign(..) => { bug!("TyLayout::field_type({:?}): not applicable", self) } diff --git a/src/librustc/ty/maps/README.md b/src/librustc/ty/maps/README.md index 8abc68d431a53..8207c18e67791 100644 --- a/src/librustc/ty/maps/README.md +++ b/src/librustc/ty/maps/README.md @@ -169,7 +169,7 @@ That is, they take an `&mut Providers` and mutate it in place. Usually we use the formulation above just because it looks nice, but you could as well do `providers.type_of = type_of`, which would be equivalent. (Here, `type_of` would be a top-level function, defined as we saw -before.) So, if we wanted to have add a provider for some other query, +before.) So, if we want to add a provider for some other query, let's call it `fubar`, into the crate above, we might modify the `provide()` function like so: @@ -185,7 +185,7 @@ pub fn provide(providers: &mut Providers) { fn fubar<'cx, 'tcx>(tcx: TyCtxt<'cx, 'tcx>, key: DefId) -> Fubar<'tcx> { .. } ``` -NB. Most of the `rustc_*` crate only provide **local +NB. Most of the `rustc_*` crates only provide **local providers**. Almost all **extern providers** wind up going through the `rustc_metadata` crate, which loads the information from the crate metadata. But in some cases there are crates that provide queries for @@ -201,7 +201,7 @@ Well, defining a query takes place in two steps: 1. first, you have to specify the query name and arguments; and then, 2. you have to supply query providers where needed. -The specify the query name and arguments, you simply add an entry +To specify the query name and arguments, you simply add an entry to the big macro invocation in `mod.rs`. This will probably have changed by the time you read this README, but at present it looks something like: diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 8f8cda0e0f1d1..deaafd1efed45 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -532,3 +532,9 @@ impl<'tcx> QueryDescription for queries::has_copy_closures<'tcx> { format!("seeing if the crate has enabled `Copy` closures") } } + +impl<'tcx> QueryDescription for queries::fully_normalize_monormophic_ty<'tcx> { + fn describe(_tcx: TyCtxt, _: Ty) -> String { + format!("normalizing types") + } +} diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 839042bf229aa..79fee8bf930d4 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -29,7 +29,7 @@ use middle::lang_items::{LanguageItems, LangItem}; use middle::exported_symbols::SymbolExportLevel; use middle::trans::{CodegenUnit, Stats}; use mir; -use session::CompileResult; +use session::{CompileResult, CrateDisambiguator}; use session::config::OutputFilenames; use traits::Vtable; use traits::specialization_graph; @@ -183,6 +183,8 @@ define_maps! { <'tcx> [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>, + [] fn used_trait_imports: UsedTraitImports(DefId) -> Rc, + [] fn has_typeck_tables: HasTypeckTables(DefId) -> bool, [] fn coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (), @@ -283,7 +285,7 @@ define_maps! { <'tcx> [] fn native_libraries: NativeLibraries(CrateNum) -> Rc>, [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option, [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option, - [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> Symbol, + [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator, [] fn crate_hash: CrateHash(CrateNum) -> Svh, [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol, @@ -349,6 +351,7 @@ define_maps! { <'tcx> // Normally you would just use `tcx.erase_regions(&value)`, // however, which uses this query as a kind of cache. [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>, + [] fn fully_normalize_monormophic_ty: normalize_ty_node(Ty<'tcx>) -> Ty<'tcx>, } ////////////////////////////////////////////////////////////////////// @@ -490,3 +493,6 @@ fn output_filenames_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructor<'tcx> { DepConstructor::VtableMethods{ trait_ref } } +fn normalize_ty_node<'tcx>(_: Ty<'tcx>) -> DepConstructor<'tcx> { + DepConstructor::NormalizeTy +} diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 5f93c3de336cc..bb042be525425 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -433,10 +433,17 @@ macro_rules! define_maps { profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin); let res = tcx.cycle_check(span, Query::$name(key), || { tcx.sess.diagnostic().track_diagnostics(|| { - tcx.dep_graph.with_task(dep_node, - tcx, - key, - Self::compute_result) + if dep_node.kind.is_eval_always() { + tcx.dep_graph.with_eval_always_task(dep_node, + tcx, + key, + Self::compute_result) + } else { + tcx.dep_graph.with_task(dep_node, + tcx, + key, + Self::compute_result) + } }) })?; profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd); @@ -697,6 +704,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::FulfillObligation | DepKind::VtableMethods | DepKind::EraseRegionsTy | + DepKind::NormalizeTy | // These are just odd DepKind::Null | @@ -753,6 +761,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::InherentImpls => { force!(inherent_impls, def_id!()); } DepKind::TypeckBodiesKrate => { force!(typeck_item_bodies, LOCAL_CRATE); } DepKind::TypeckTables => { force!(typeck_tables_of, def_id!()); } + DepKind::UsedTraitImports => { force!(used_trait_imports, def_id!()); } DepKind::HasTypeckTables => { force!(has_typeck_tables, def_id!()); } DepKind::SymbolName => { force!(def_symbol_name, def_id!()); } DepKind::SpecializationGraph => { force!(specialization_graph_of, def_id!()); } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 129c81c5cd61f..b3f2886cdf9de 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -26,6 +26,7 @@ use middle::privacy::AccessLevels; use middle::resolve_lifetime::ObjectLifetimeDefault; use mir::Mir; use mir::GeneratorLayout; +use session::CrateDisambiguator; use traits; use ty; use ty::subst::{Subst, Substs}; @@ -55,7 +56,6 @@ use rustc_const_math::ConstInt; use rustc_data_structures::accumulate_vec::IntoIter as AccIntoIter; use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult, HashStable}; -use rustc_data_structures::transitive_relation::TransitiveRelation; use hir; @@ -313,11 +313,6 @@ pub enum Variance { /// `tcx.variances_of()` to get the variance for a *particular* /// item. pub struct CrateVariancesMap { - /// This relation tracks the dependencies between the variance of - /// various items. In particular, if `a < b`, then the variance of - /// `a` depends on the sources of `b`. - pub dependencies: TransitiveRelation, - /// For each item with generics, maps to a vector of the variance /// of its generics. If an item has no generics, it will have no /// entry. @@ -1789,7 +1784,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { vec![] } - TyStr | TyDynamic(..) | TySlice(_) | TyError => { + TyStr | TyDynamic(..) | TySlice(_) | TyForeign(..) | TyError => { // these are never sized - return the target type vec![ty] } @@ -2562,7 +2557,7 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } fn crate_disambiguator<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - crate_num: CrateNum) -> Symbol { + crate_num: CrateNum) -> CrateDisambiguator { assert_eq!(crate_num, LOCAL_CRATE); tcx.sess.local_crate_disambiguator() } diff --git a/src/librustc/ty/outlives.rs b/src/librustc/ty/outlives.rs index 5e1dc485d420f..707137649d771 100644 --- a/src/librustc/ty/outlives.rs +++ b/src/librustc/ty/outlives.rs @@ -142,6 +142,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ty::TyNever | // ... ty::TyAdt(..) | // OutlivesNominalType ty::TyAnon(..) | // OutlivesNominalType (ish) + ty::TyForeign(..) | // OutlivesNominalType ty::TyStr | // OutlivesScalar (ish) ty::TyArray(..) | // ... ty::TySlice(..) | // ... diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 309880ba06333..376cdc462e82f 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -381,6 +381,12 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, Ok(tcx.mk_adt(a_def, substs)) } + (&ty::TyForeign(a_id), &ty::TyForeign(b_id)) + if a_id == b_id => + { + Ok(tcx.mk_foreign(a_id)) + } + (&ty::TyDynamic(ref a_obj, ref a_region), &ty::TyDynamic(ref b_obj, ref b_region)) => { let region_bound = relation.with_cause(Cause::ExistentialRegionBound, |relation| { diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 54d55748c8e3a..5f1448cd1f18e 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -676,7 +676,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)), ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) | - ty::TyParam(..) | ty::TyNever => return self + ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => return self }; if self.sty == sty { @@ -710,7 +710,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { ty::TyAnon(_, ref substs) => substs.visit_with(visitor), ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) | - ty::TyParam(..) | ty::TyNever => false, + ty::TyParam(..) | ty::TyNever | ty::TyForeign(..) => false, } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 064627c21bfe6..d0ac7d0183a58 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -104,6 +104,8 @@ pub enum TypeVariants<'tcx> { /// definition and not a concrete use of it. TyAdt(&'tcx AdtDef, &'tcx Substs<'tcx>), + TyForeign(DefId), + /// The pointee of a string slice. Written as `str`. TyStr, @@ -1117,13 +1119,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } - pub fn is_structural(&self) -> bool { - match self.sty { - TyAdt(..) | TyTuple(..) | TyArray(..) | TyClosure(..) => true, - _ => self.is_slice() | self.is_trait(), - } - } - #[inline] pub fn is_simd(&self) -> bool { match self.sty { @@ -1347,6 +1342,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { match self.sty { TyDynamic(ref tt, ..) => tt.principal().map(|p| p.def_id()), TyAdt(def, _) => Some(def.did), + TyForeign(did) => Some(did), TyClosure(id, _) => Some(id), _ => None, } @@ -1396,6 +1392,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { TyRawPtr(_) | TyNever | TyTuple(..) | + TyForeign(..) | TyParam(_) | TyInfer(_) | TyError => { diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index e2881ac9b798e..83222e79a1298 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -107,6 +107,19 @@ impl<'tcx> fmt::Debug for Kind<'tcx> { } } +impl<'tcx> fmt::Display for Kind<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some(ty) = self.as_type() { + write!(f, "{}", ty) + } else if let Some(r) = self.as_region() { + write!(f, "{}", r) + } else { + // FIXME(RFC 2000): extend this if/else chain when we support const generic. + unimplemented!(); + } + } +} + impl<'tcx> TypeFoldable<'tcx> for Kind<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { if let Some(ty) = self.as_type() { diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index c8037ce081a71..39842a543b54b 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -553,7 +553,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let result = match ty.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | - ty::TyFloat(_) | ty::TyStr | ty::TyNever | + ty::TyFloat(_) | ty::TyStr | ty::TyNever | ty::TyForeign(..) | ty::TyRawPtr(..) | ty::TyRef(..) | ty::TyFnDef(..) | ty::TyFnPtr(_) => { // these types never have a destructor Ok(ty::DtorckConstraint::empty()) @@ -714,6 +714,7 @@ impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W> TyAnon(def_id, _) | TyFnDef(def_id, _) => self.def_id(def_id), TyAdt(d, _) => self.def_id(d.did), + TyForeign(def_id) => self.def_id(def_id), TyFnPtr(f) => { self.hash(f.unsafety()); self.hash(f.abi()); @@ -1109,6 +1110,9 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyChar | ty::TyRawPtr(_) | ty::TyRef(..) | ty::TyStr => false, + // Foreign types can never have destructors + ty::TyForeign(..) => false, + // Issue #22536: We first query type_moves_by_default. It sees a // normalized version of the type, and therefore will definitely // know whether the type implements Copy (and thus needs no diff --git a/src/librustc/ty/walk.rs b/src/librustc/ty/walk.rs index df07844ccebaf..448ad4cf675c7 100644 --- a/src/librustc/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -82,7 +82,8 @@ pub fn walk_shallow<'tcx>(ty: Ty<'tcx>) -> AccIntoIter> { fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { match parent_ty.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | - ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyNever | ty::TyError => { + ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyNever | ty::TyError | + ty::TyForeign(..) => { } ty::TyArray(ty, len) => { push_const(stack, len); diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 41e27fca3f320..c631e2c4db51b 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -284,7 +284,8 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { ty::TyError | ty::TyStr | ty::TyNever | - ty::TyParam(_) => { + ty::TyParam(_) | + ty::TyForeign(..) => { // WfScalar, WfParameter, etc } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 0eb2c19fe44dd..acb929981fbf2 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -17,7 +17,7 @@ use ty::{BrAnon, BrEnv, BrFresh, BrNamed}; use ty::{TyBool, TyChar, TyAdt}; use ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr}; use ty::{TyParam, TyRawPtr, TyRef, TyNever, TyTuple}; -use ty::{TyClosure, TyGenerator, TyProjection, TyAnon}; +use ty::{TyClosure, TyGenerator, TyForeign, TyProjection, TyAnon}; use ty::{TyDynamic, TyInt, TyUint, TyInfer}; use ty::{self, Ty, TyCtxt, TypeFoldable}; use util::nodemap::FxHashSet; @@ -1012,6 +1012,7 @@ define_print! { Ok(()) } } + TyForeign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]), TyProjection(ref data) => data.print(f, cx), TyAnon(def_id, substs) => { ty::tls::with(|tcx| { diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index 9e3e622e25260..9e348f6222329 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -45,14 +45,12 @@ #![deny(warnings)] #![forbid(unsafe_code)] +#![feature(const_max_value)] +#![feature(const_min_value)] #![feature(i128_type)] #![feature(slice_patterns)] #![feature(try_from)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(const_min_value))] -#![cfg_attr(not(stage0), feature(const_max_value))] - // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] extern crate rustc_cratesio_shim; diff --git a/src/librustc_back/target/sparcv9_sun_solaris.rs b/src/librustc_back/target/sparcv9_sun_solaris.rs index bfe1afebdb3a3..1d9027275db82 100644 --- a/src/librustc_back/target/sparcv9_sun_solaris.rs +++ b/src/librustc_back/target/sparcv9_sun_solaris.rs @@ -17,6 +17,7 @@ pub fn target() -> TargetResult { // llvm calls this "v9" base.cpu = "v9".to_string(); base.max_atomic_width = Some(64); + base.exe_allocation_crate = None; Ok(Target { llvm_target: "sparcv9-sun-solaris".to_string(), diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 6fd9ff4012efa..c1d0d849dfb46 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -395,10 +395,21 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { assert!(self.bccx.region_scope_tree.scopes_intersect(old_loan.kill_scope, new_loan.kill_scope)); - self.report_error_if_loan_conflicts_with_restriction( - old_loan, new_loan, old_loan, new_loan) && - self.report_error_if_loan_conflicts_with_restriction( - new_loan, old_loan, old_loan, new_loan) + let err_old_new = self.report_error_if_loan_conflicts_with_restriction( + old_loan, new_loan, old_loan, new_loan).err(); + let err_new_old = self.report_error_if_loan_conflicts_with_restriction( + new_loan, old_loan, old_loan, new_loan).err(); + + match (err_old_new, err_new_old) { + (Some(mut err), None) | (None, Some(mut err)) => err.emit(), + (Some(mut err_old), Some(mut err_new)) => { + err_old.emit(); + err_new.cancel(); + } + (None, None) => return true, + } + + false } pub fn report_error_if_loan_conflicts_with_restriction(&self, @@ -406,7 +417,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { loan2: &Loan<'tcx>, old_loan: &Loan<'tcx>, new_loan: &Loan<'tcx>) - -> bool { + -> Result<(), DiagnosticBuilder<'a>> { //! Checks whether the restrictions introduced by `loan1` would //! prohibit `loan2`. Returns false if an error is reported. @@ -416,7 +427,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { loan2); if compatible_borrow_kinds(loan1.kind, loan2.kind) { - return true; + return Ok(()); } let loan2_base_path = owned_ptr_base_path_rc(&loan2.loan_path); @@ -520,11 +531,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { _ => { } } - err.emit(); - return false; + return Err(err); } - true + Ok(()) } fn consume_common(&self, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index d29250ac57cfb..add128cc2cf6a 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -744,7 +744,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { let mut err = self.cannot_reassign_immutable(span, &self.loan_path_to_string(lp), Origin::Ast); - err.span_label(span, "re-assignment of immutable variable"); + err.span_label(span, "cannot assign twice to immutable variable"); if span != assign.span { err.span_label(assign.span, format!("first assignment to `{}`", self.loan_path_to_string(lp))); diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 7520c6ac652ba..657156902b5c1 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -13,9 +13,7 @@ use rustc::middle::const_val::ConstAggregate::*; use rustc::middle::const_val::ErrKind::*; use rustc::middle::const_val::{ByteArray, ConstVal, ConstEvalErr, EvalResult, ErrKind}; -use rustc::hir::map as hir_map; use rustc::hir::map::blocks::FnLikeNode; -use rustc::traits; use rustc::hir::def::{Def, CtorKind}; use rustc::hir::def_id::DefId; use rustc::ty::{self, Ty, TyCtxt}; @@ -54,33 +52,12 @@ macro_rules! math { pub fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, key: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>) -> Option<(DefId, &'tcx Substs<'tcx>)> { - let (def_id, _) = key.value; - if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { - match tcx.hir.find(node_id) { - Some(hir_map::NodeTraitItem(_)) => { - // If we have a trait item and the substitutions for it, - // `resolve_trait_associated_const` will select an impl - // or the default. - resolve_trait_associated_const(tcx, key) - } - _ => Some(key.value) - } - } else { - match tcx.describe_def(def_id) { - Some(Def::AssociatedConst(_)) => { - // As mentioned in the comments above for in-crate - // constants, we only try to find the expression for a - // trait-associated const if the caller gives us the - // substitutions for the reference to it. - if tcx.trait_of_item(def_id).is_some() { - resolve_trait_associated_const(tcx, key) - } else { - Some(key.value) - } - } - _ => Some(key.value) - } - } + ty::Instance::resolve( + tcx, + key.param_env, + key.value.0, + key.value.1, + ).map(|instance| (instance.def_id(), instance.substs)) } pub struct ConstContext<'a, 'tcx: 'a> { @@ -119,6 +96,7 @@ type CastResult<'tcx> = Result, ErrKind<'tcx>>; fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, e: &'tcx Expr) -> EvalResult<'tcx> { + trace!("eval_const_expr_partial: {:?}", e); let tcx = cx.tcx; let ty = cx.tables.expr_ty(e).subst(tcx, cx.substs); let mk_const = |val| tcx.mk_const(ty::Const { val, ty }); @@ -289,6 +267,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, match cx.tables.qpath_def(qpath, e.hir_id) { Def::Const(def_id) | Def::AssociatedConst(def_id) => { + let substs = tcx.normalize_associated_type_in_env(&substs, cx.param_env); match tcx.at(e.span).const_eval(cx.param_env.and((def_id, substs))) { Ok(val) => val, Err(ConstEvalErr { kind: TypeckError, .. }) => { @@ -486,67 +465,6 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, Ok(result) } -fn resolve_trait_associated_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - key: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>) - -> Option<(DefId, &'tcx Substs<'tcx>)> { - let param_env = key.param_env; - let (def_id, substs) = key.value; - let trait_item = tcx.associated_item(def_id); - let trait_id = trait_item.container.id(); - let trait_ref = ty::Binder(ty::TraitRef::new(trait_id, substs)); - debug!("resolve_trait_associated_const: trait_ref={:?}", - trait_ref); - - tcx.infer_ctxt().enter(|infcx| { - let mut selcx = traits::SelectionContext::new(&infcx); - let obligation = traits::Obligation::new(traits::ObligationCause::dummy(), - param_env, - trait_ref.to_poly_trait_predicate()); - let selection = match selcx.select(&obligation) { - Ok(Some(vtable)) => vtable, - // Still ambiguous, so give up and let the caller decide whether this - // expression is really needed yet. Some associated constant values - // can't be evaluated until monomorphization is done in trans. - Ok(None) => { - return None - } - Err(_) => { - return None - } - }; - - // NOTE: this code does not currently account for specialization, but when - // it does so, it should hook into the param_env.reveal to determine when the - // constant should resolve. - match selection { - traits::VtableImpl(ref impl_data) => { - let name = trait_item.name; - let ac = tcx.associated_items(impl_data.impl_def_id) - .find(|item| item.kind == ty::AssociatedKind::Const && item.name == name); - match ac { - // FIXME(eddyb) Use proper Instance resolution to - // get the correct Substs returned from here. - Some(ic) => { - let substs = Substs::identity_for_item(tcx, ic.def_id); - Some((ic.def_id, substs)) - } - None => { - if trait_item.defaultness.has_value() { - Some(key.value) - } else { - None - } - } - } - } - traits::VtableParam(_) => None, - _ => { - bug!("resolve_trait_associated_const: unexpected vtable type {:?}", selection) - } - } - }) -} - fn cast_const_int<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, val: ConstInt, ty: Ty<'tcx>) diff --git a/src/librustc_const_eval/lib.rs b/src/librustc_const_eval/lib.rs index 0c3606cab10e1..7b1c33cb2710c 100644 --- a/src/librustc_const_eval/lib.rs +++ b/src/librustc_const_eval/lib.rs @@ -25,8 +25,7 @@ #![feature(box_syntax)] #![feature(i128_type)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(const_min_value))] +#![feature(const_min_value)] extern crate arena; #[macro_use] extern crate syntax; diff --git a/src/librustc_const_math/lib.rs b/src/librustc_const_math/lib.rs index 0533f10104a5a..c6893acb31f2e 100644 --- a/src/librustc_const_math/lib.rs +++ b/src/librustc_const_math/lib.rs @@ -22,9 +22,8 @@ #![feature(i128)] #![feature(i128_type)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(const_min_value))] -#![cfg_attr(not(stage0), feature(const_max_value))] +#![feature(const_min_value)] +#![feature(const_max_value)] extern crate rustc_apfloat; diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 831e113016fd9..d82b712b5b14b 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -13,24 +13,13 @@ use std::marker::PhantomData; use std::mem; use sip128::SipHasher128; -/// When hashing something that ends up affecting properties like symbol names. We -/// want these symbol names to be calculated independent of other factors like -/// what architecture you're compiling *from*. +/// When hashing something that ends up affecting properties like symbol names, +/// we want these symbol names to be calculated independently of other factors +/// like what architecture you're compiling *from*. /// -/// The hashing just uses the standard `Hash` trait, but the implementations of -/// `Hash` for the `usize` and `isize` types are *not* architecture independent -/// (e.g. they has 4 or 8 bytes). As a result we want to avoid `usize` and -/// `isize` completely when hashing. -/// -/// To do that, we encode all integers to be hashed with some -/// arch-independent encoding. -/// -/// At the moment, we pass i8/u8 straight through and encode -/// all other integers using leb128. -/// -/// This hasher currently always uses the stable Blake2b algorithm -/// and allows for variable output lengths through its type -/// parameter. +/// To that end we always convert integers to little-endian format before +/// hashing and the architecture dependent `isize` and `usize` types are +/// extended to 64 bits if needed. pub struct StableHasher { state: SipHasher128, bytes_hashed: u64, @@ -86,9 +75,6 @@ impl StableHasher { } } -// For the non-u8 integer cases we leb128 encode them first. Because small -// integers dominate, this significantly and cheaply reduces the number of -// bytes hashed, which is good because blake2b is expensive. impl Hasher for StableHasher { fn finish(&self) -> u64 { panic!("use StableHasher::finalize instead"); @@ -132,8 +118,11 @@ impl Hasher for StableHasher { #[inline] fn write_usize(&mut self, i: usize) { - self.state.write_usize(i.to_le()); - self.bytes_hashed += ::std::mem::size_of::() as u64; + // Always treat usize as u64 so we get the same results on 32 and 64 bit + // platforms. This is important for symbol hashes when cross compiling, + // for example. + self.state.write_u64((i as u64).to_le()); + self.bytes_hashed += 8; } #[inline] @@ -168,8 +157,11 @@ impl Hasher for StableHasher { #[inline] fn write_isize(&mut self, i: isize) { - self.state.write_isize(i.to_le()); - self.bytes_hashed += ::std::mem::size_of::() as u64; + // Always treat isize as i64 so we get the same results on 32 and 64 bit + // platforms. This is important for symbol hashes when cross compiling, + // for example. + self.state.write_i64((i as i64).to_le()); + self.bytes_hashed += 8; } } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7dbf93da38598..10232127f6e05 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -14,7 +14,7 @@ use rustc::hir::lowering::lower_crate; use rustc::ich::Fingerprint; use rustc_data_structures::stable_hasher::StableHasher; use rustc_mir as mir; -use rustc::session::{Session, CompileResult}; +use rustc::session::{Session, CompileResult, CrateDisambiguator}; use rustc::session::CompileIncomplete; use rustc::session::config::{self, Input, OutputFilenames, OutputType}; use rustc::session::search_paths::PathKind; @@ -58,7 +58,6 @@ use syntax::{ast, diagnostics, visit}; use syntax::attr; use syntax::ext::base::ExtCtxt; use syntax::parse::{self, PResult}; -use syntax::symbol::Symbol; use syntax::util::node_count::NodeCounter; use syntax; use syntax_ext; @@ -68,7 +67,7 @@ use derive_registrar; use profile; -pub fn compile_input(sess: &Session, +pub fn compile_input(sess: &Session, cstore: &CStore, input: &Input, outdir: &Option, @@ -208,7 +207,7 @@ pub fn compile_input(sess: &Session, None }; - phase_3_run_analysis_passes(sess, + phase_3_run_analysis_passes(sess, cstore, hir_map, analysis, @@ -245,7 +244,7 @@ pub fn compile_input(sess: &Session, tcx.print_debug_stats(); } - let trans = phase_4_translate_to_llvm::(tcx, rx); + let trans = phase_4_translate_to_llvm::(tcx, rx); if log_enabled!(::log::LogLevel::Info) { println!("Post-trans"); @@ -268,7 +267,7 @@ pub fn compile_input(sess: &Session, } let (phase5_result, trans) = - phase_5_run_llvm_passes::(sess, &dep_graph, trans); + phase_5_run_llvm_passes::(sess, &dep_graph, trans); controller_entry_point!(after_llvm, sess, @@ -279,7 +278,7 @@ pub fn compile_input(sess: &Session, // Run the linker on any artifacts that resulted from the LLVM run. // This should produce either a finished executable or library. time(sess.time_passes(), "linking", || { - DefaultTransCrate::link_binary(sess, &trans, &outputs) + Trans::link_binary(sess, &trans, &outputs) }); // Now that we won't touch anything in the incremental compilation directory @@ -633,12 +632,12 @@ pub fn phase_2_configure_and_expand(sess: &Session, *sess.crate_types.borrow_mut() = collect_crate_types(sess, &krate.attrs); - let disambiguator = Symbol::intern(&compute_crate_disambiguator(sess)); + let disambiguator = compute_crate_disambiguator(sess); *sess.crate_disambiguator.borrow_mut() = Some(disambiguator); rustc_incremental::prepare_session_directory( sess, &crate_name, - &disambiguator.as_str(), + disambiguator, ); let dep_graph = if sess.opts.build_dep_graph() { @@ -911,7 +910,7 @@ pub fn phase_2_configure_and_expand(sess: &Session, /// Run the resolution, typechecking, region checking and other /// miscellaneous analysis passes on the crate. Return various /// structures carrying the results of the analysis. -pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, +pub fn phase_3_run_analysis_passes<'tcx, Trans: TransCrate, F, R>(sess: &'tcx Session, cstore: &'tcx CrateStore, hir_map: hir_map::Map<'tcx>, mut analysis: ty::CrateAnalysis, @@ -967,7 +966,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, mir::provide(&mut local_providers); reachable::provide(&mut local_providers); rustc_privacy::provide(&mut local_providers); - DefaultTransCrate::provide_local(&mut local_providers); + Trans::provide_local(&mut local_providers); typeck::provide(&mut local_providers); ty::provide(&mut local_providers); traits::provide(&mut local_providers); @@ -980,7 +979,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session, let mut extern_providers = ty::maps::Providers::default(); cstore::provide(&mut extern_providers); - DefaultTransCrate::provide_extern(&mut extern_providers); + Trans::provide_extern(&mut extern_providers); ty::provide_extern(&mut extern_providers); traits::provide_extern(&mut extern_providers); // FIXME(eddyb) get rid of this once we replace const_eval with miri. @@ -1312,16 +1311,13 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec String { +pub fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator { use std::hash::Hasher; // The crate_disambiguator is a 128 bit hash. The disambiguator is fed // into various other hashes quite a bit (symbol hashes, incr. comp. hashes, // debuginfo type IDs, etc), so we don't want it to be too wide. 128 bits // should still be safe enough to avoid collisions in practice. - // FIXME(mw): It seems that the crate_disambiguator is used everywhere as - // a hex-string instead of raw bytes. We should really use the - // smaller representation. let mut hasher = StableHasher::::new(); let mut metadata = session.opts.cg.metadata.clone(); @@ -1340,11 +1336,13 @@ pub fn compute_crate_disambiguator(session: &Session) -> String { hasher.write(s.as_bytes()); } - // If this is an executable, add a special suffix, so that we don't get - // symbol conflicts when linking against a library of the same name. + // Also incorporate crate type, so that we don't get symbol conflicts when + // linking against a library of the same name, if this is an executable. let is_exe = session.crate_types.borrow().contains(&config::CrateTypeExecutable); + hasher.write(if is_exe { b"exe" } else { b"lib" }); + + CrateDisambiguator::from(hasher.finish()) - format!("{}{}", hasher.finish().to_hex(), if is_exe { "-exe" } else {""}) } pub fn build_output_filenames(input: &Input, diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 3514302c6c8f3..5205b4760da54 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -138,7 +138,9 @@ pub fn run(run_compiler: F) -> isize } None => { let emitter = - errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None); + errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, + None, + true); let handler = errors::Handler::with_emitter(true, false, Box::new(emitter)); handler.emit(&MultiSpan::new(), "aborting due to previous error(s)", @@ -224,8 +226,6 @@ pub fn run_compiler<'a>(args: &[String], }, }; - let cstore = Rc::new(CStore::new(DefaultTransCrate::metadata_loader())); - let loader = file_loader.unwrap_or(box RealFileLoader); let codemap = Rc::new(CodeMap::with_file_loader(loader, sopts.file_path_mapping())); let mut sess = session::build_session_with_codemap( @@ -238,23 +238,32 @@ pub fn run_compiler<'a>(args: &[String], target_features::add_configuration(&mut cfg, &sess); sess.parse_sess.config = cfg; - do_or_return!(callbacks.late_callback(&matches, - &sess, - &*cstore, - &input, - &odir, - &ofile), Some(sess)); - let plugins = sess.opts.debugging_opts.extra_plugins.clone(); let control = callbacks.build_controller(&sess, &matches); - (driver::compile_input(&sess, - &cstore, - &input, - &odir, - &ofile, - Some(plugins), - &control), - Some(sess)) + + let trans_name = sess.opts.debugging_opts.trans.unwrap_or_else(||"llvm".to_string()); + match *trans_name { + "llvm" => { + let cstore = Rc::new(CStore::new(DefaultTransCrate::metadata_loader())); + + do_or_return!(callbacks.late_callback(&matches, + &sess, + &*cstore, + &input, + &odir, + &ofile), Some(sess)); + + (driver::compile_input::(&sess, + &cstore, + &input, + &odir, + &ofile, + Some(plugins), + &control), + Some(sess)) + } + _ => sess.fatal(&format!("Invalid trans {}", trans_name)), + } } // Extract output directory and file from matches. @@ -1208,7 +1217,9 @@ pub fn monitor(f: F) { // Thread panicked without emitting a fatal diagnostic if !value.is::() { let emitter = - Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None)); + Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, + None, + false)); let handler = errors::Handler::with_emitter(true, false, emitter); // a .span_bug or .bug call has already printed what diff --git a/src/librustc_errors/Cargo.toml b/src/librustc_errors/Cargo.toml index 78ff52b4b2371..c72e9dd0ea322 100644 --- a/src/librustc_errors/Cargo.toml +++ b/src/librustc_errors/Cargo.toml @@ -11,3 +11,4 @@ crate-type = ["dylib"] [dependencies] serialize = { path = "../libserialize" } syntax_pos = { path = "../libsyntax_pos" } +rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 02c0307e98cc8..5e0e624082e6f 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -17,7 +17,7 @@ use syntax_pos::{MultiSpan, Span}; use snippet::Style; #[must_use] -#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub struct Diagnostic { pub level: Level, pub message: Vec<(String, Style)>, @@ -28,7 +28,7 @@ pub struct Diagnostic { } /// For example a note attached to an error. -#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub struct SubDiagnostic { pub level: Level, pub message: Vec<(String, Style)>, @@ -229,6 +229,7 @@ impl Diagnostic { /// "try adding parentheses: `(tup.0).1`" /// /// The message + /// /// * should not end in any punctuation (a `:` is added automatically) /// * should not be a question /// * should not contain any parts like "the following", "as shown" @@ -248,6 +249,7 @@ impl Diagnostic { self } + /// Prints out a message with multiple suggested edits of the code. pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec) -> &mut Self { self.suggestions.push(CodeSuggestion { substitution_parts: vec![Substitution { diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 2f994de396c6f..5db5a9a1133d8 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -107,6 +107,7 @@ impl ColorConfig { pub struct EmitterWriter { dst: Destination, cm: Option>, + short_message: bool, } struct FileWithAnnotatedLines { @@ -116,25 +117,34 @@ struct FileWithAnnotatedLines { } impl EmitterWriter { - pub fn stderr(color_config: ColorConfig, code_map: Option>) -> EmitterWriter { + pub fn stderr(color_config: ColorConfig, + code_map: Option>, + short_message: bool) + -> EmitterWriter { if color_config.use_color() { let dst = Destination::from_stderr(); EmitterWriter { dst, cm: code_map, + short_message: short_message, } } else { EmitterWriter { dst: Raw(Box::new(io::stderr())), cm: code_map, + short_message: short_message, } } } - pub fn new(dst: Box, code_map: Option>) -> EmitterWriter { + pub fn new(dst: Box, + code_map: Option>, + short_message: bool) + -> EmitterWriter { EmitterWriter { dst: Raw(dst), cm: code_map, + short_message: short_message, } } @@ -671,7 +681,7 @@ impl EmitterWriter { Style::LabelSecondary }; Some((p, style)) - }, + } _ => None } @@ -689,11 +699,13 @@ impl EmitterWriter { } } } - for span_label in msp.span_labels() { - if span_label.span != DUMMY_SP { - let hi = cm.lookup_char_pos(span_label.span.hi()); - if hi.line > max { - max = hi.line; + if !self.short_message { + for span_label in msp.span_labels() { + if span_label.span != DUMMY_SP { + let hi = cm.lookup_char_pos(span_label.span.hi()); + if hi.line > max { + max = hi.line; + } } } } @@ -881,7 +893,8 @@ impl EmitterWriter { -> io::Result<()> { let mut buffer = StyledBuffer::new(); - if msp.primary_spans().is_empty() && msp.span_labels().is_empty() && is_secondary { + if msp.primary_spans().is_empty() && msp.span_labels().is_empty() && is_secondary + && !self.short_message { // This is a secondary message with no span info for _ in 0..max_line_num_len { buffer.prepend(0, " ", Style::NoStyle); @@ -916,12 +929,12 @@ impl EmitterWriter { if primary_span != &&DUMMY_SP { (cm.lookup_char_pos(primary_span.lo()), cm) } else { - emit_to_destination(&buffer.render(), level, &mut self.dst)?; + emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; return Ok(()); } } else { // If we don't have span information, emit and exit - emit_to_destination(&buffer.render(), level, &mut self.dst)?; + emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; return Ok(()); }; if let Ok(pos) = @@ -940,18 +953,24 @@ impl EmitterWriter { // to do this, we need to know if this span will be primary let is_primary = primary_lo.file.name == annotated_file.file.name; if is_primary { - // remember where we are in the output buffer for easy reference - let buffer_msg_line_offset = buffer.num_lines(); - - buffer.prepend(buffer_msg_line_offset, "--> ", Style::LineNumber); let loc = primary_lo.clone(); - buffer.append(buffer_msg_line_offset, - &format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0 + 1), - Style::LineAndColumn); - for _ in 0..max_line_num_len { - buffer.prepend(buffer_msg_line_offset, " ", Style::NoStyle); + if !self.short_message { + // remember where we are in the output buffer for easy reference + let buffer_msg_line_offset = buffer.num_lines(); + + buffer.prepend(buffer_msg_line_offset, "--> ", Style::LineNumber); + buffer.append(buffer_msg_line_offset, + &format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0 + 1), + Style::LineAndColumn); + for _ in 0..max_line_num_len { + buffer.prepend(buffer_msg_line_offset, " ", Style::NoStyle); + } + } else { + buffer.prepend(0, + &format!("{}:{}:{} - ", loc.file.name, loc.line, loc.col.0 + 1), + Style::LineAndColumn); } - } else { + } else if !self.short_message { // remember where we are in the output buffer for easy reference let buffer_msg_line_offset = buffer.num_lines(); @@ -968,104 +987,111 @@ impl EmitterWriter { } } - // Put in the spacer between the location and annotated source - let buffer_msg_line_offset = buffer.num_lines(); - draw_col_separator_no_space(&mut buffer, buffer_msg_line_offset, max_line_num_len + 1); + if !self.short_message { + // Put in the spacer between the location and annotated source + let buffer_msg_line_offset = buffer.num_lines(); + draw_col_separator_no_space(&mut buffer, + buffer_msg_line_offset, + max_line_num_len + 1); - // Contains the vertical lines' positions for active multiline annotations - let mut multilines = HashMap::new(); + // Contains the vertical lines' positions for active multiline annotations + let mut multilines = HashMap::new(); - // Next, output the annotate source for this file - for line_idx in 0..annotated_file.lines.len() { - let previous_buffer_line = buffer.num_lines(); + // Next, output the annotate source for this file + for line_idx in 0..annotated_file.lines.len() { + let previous_buffer_line = buffer.num_lines(); - let width_offset = 3 + max_line_num_len; - let code_offset = if annotated_file.multiline_depth == 0 { - width_offset - } else { - width_offset + annotated_file.multiline_depth + 1 - }; + let width_offset = 3 + max_line_num_len; + let code_offset = if annotated_file.multiline_depth == 0 { + width_offset + } else { + width_offset + annotated_file.multiline_depth + 1 + }; - let depths = self.render_source_line(&mut buffer, - annotated_file.file.clone(), - &annotated_file.lines[line_idx], - width_offset, - code_offset); + let depths = self.render_source_line(&mut buffer, + annotated_file.file.clone(), + &annotated_file.lines[line_idx], + width_offset, + code_offset); - let mut to_add = HashMap::new(); + let mut to_add = HashMap::new(); - for (depth, style) in depths { - if multilines.get(&depth).is_some() { - multilines.remove(&depth); - } else { - to_add.insert(depth, style); + for (depth, style) in depths { + if multilines.get(&depth).is_some() { + multilines.remove(&depth); + } else { + to_add.insert(depth, style); + } } - } - // Set the multiline annotation vertical lines to the left of - // the code in this line. - for (depth, style) in &multilines { - for line in previous_buffer_line..buffer.num_lines() { - draw_multiline_line(&mut buffer, - line, - width_offset, - *depth, - *style); - } - } - // check to see if we need to print out or elide lines that come between - // this annotated line and the next one. - if line_idx < (annotated_file.lines.len() - 1) { - let line_idx_delta = annotated_file.lines[line_idx + 1].line_index - - annotated_file.lines[line_idx].line_index; - if line_idx_delta > 2 { - let last_buffer_line_num = buffer.num_lines(); - buffer.puts(last_buffer_line_num, 0, "...", Style::LineNumber); - - // Set the multiline annotation vertical lines on `...` bridging line. - for (depth, style) in &multilines { + // Set the multiline annotation vertical lines to the left of + // the code in this line. + for (depth, style) in &multilines { + for line in previous_buffer_line..buffer.num_lines() { draw_multiline_line(&mut buffer, - last_buffer_line_num, + line, width_offset, *depth, *style); } - } else if line_idx_delta == 2 { - let unannotated_line = annotated_file.file - .get_line(annotated_file.lines[line_idx].line_index) - .unwrap_or_else(|| Cow::from("")); - - let last_buffer_line_num = buffer.num_lines(); - - buffer.puts(last_buffer_line_num, - 0, - &(annotated_file.lines[line_idx + 1].line_index - 1) - .to_string(), - Style::LineNumber); - draw_col_separator(&mut buffer, last_buffer_line_num, 1 + max_line_num_len); - buffer.puts(last_buffer_line_num, - code_offset, - &unannotated_line, - Style::Quotation); - - for (depth, style) in &multilines { - draw_multiline_line(&mut buffer, - last_buffer_line_num, - width_offset, - *depth, - *style); + } + // check to see if we need to print out or elide lines that come between + // this annotated line and the next one. + if line_idx < (annotated_file.lines.len() - 1) { + let line_idx_delta = annotated_file.lines[line_idx + 1].line_index - + annotated_file.lines[line_idx].line_index; + if line_idx_delta > 2 { + let last_buffer_line_num = buffer.num_lines(); + buffer.puts(last_buffer_line_num, 0, "...", Style::LineNumber); + + // Set the multiline annotation vertical lines on `...` bridging line. + for (depth, style) in &multilines { + draw_multiline_line(&mut buffer, + last_buffer_line_num, + width_offset, + *depth, + *style); + } + } else if line_idx_delta == 2 { + let unannotated_line = annotated_file.file + .get_line(annotated_file.lines[line_idx].line_index) + .unwrap_or_else(|| Cow::from("")); + + let last_buffer_line_num = buffer.num_lines(); + + buffer.puts(last_buffer_line_num, + 0, + &(annotated_file.lines[line_idx + 1].line_index - 1) + .to_string(), + Style::LineNumber); + draw_col_separator(&mut buffer, + last_buffer_line_num, + 1 + max_line_num_len); + buffer.puts(last_buffer_line_num, + code_offset, + &unannotated_line, + Style::Quotation); + + for (depth, style) in &multilines { + draw_multiline_line(&mut buffer, + last_buffer_line_num, + width_offset, + *depth, + *style); + } } } - } - multilines.extend(&to_add); + multilines.extend(&to_add); + } } } // final step: take our styled buffer, render it, then output it - emit_to_destination(&buffer.render(), level, &mut self.dst)?; + emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; Ok(()) + } fn emit_suggestion_default(&mut self, suggestion: &CodeSuggestion, @@ -1141,7 +1167,7 @@ impl EmitterWriter { let msg = format!("and {} other candidates", suggestions.len() - MAX_SUGGESTIONS); buffer.puts(row_num, 0, &msg, Style::NoStyle); } - emit_to_destination(&buffer.render(), level, &mut self.dst)?; + emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?; } Ok(()) } @@ -1158,42 +1184,47 @@ impl EmitterWriter { Ok(()) => { if !children.is_empty() { let mut buffer = StyledBuffer::new(); - draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1); - match emit_to_destination(&buffer.render(), level, &mut self.dst) { + if !self.short_message { + draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1); + } + match emit_to_destination(&buffer.render(), level, &mut self.dst, + self.short_message) { Ok(()) => (), Err(e) => panic!("failed to emit error: {}", e) } } - for child in children { - match child.render_span { - Some(FullSpan(ref msp)) => { - match self.emit_message_default(msp, - &child.styled_message(), - &None, - &child.level, - max_line_num_len, - true) { - Err(e) => panic!("failed to emit error: {}", e), - _ => () + if !self.short_message { + for child in children { + match child.render_span { + Some(FullSpan(ref msp)) => { + match self.emit_message_default(msp, + &child.styled_message(), + &None, + &child.level, + max_line_num_len, + true) { + Err(e) => panic!("failed to emit error: {}", e), + _ => () + } } - }, - Some(Suggestion(ref cs)) => { - match self.emit_suggestion_default(cs, - &child.level, - max_line_num_len) { - Err(e) => panic!("failed to emit error: {}", e), - _ => () + Some(Suggestion(ref cs)) => { + match self.emit_suggestion_default(cs, + &child.level, + max_line_num_len) { + Err(e) => panic!("failed to emit error: {}", e), + _ => () + } } - }, - None => { - match self.emit_message_default(&child.span, - &child.styled_message(), - &None, - &child.level, - max_line_num_len, - true) { - Err(e) => panic!("failed to emit error: {}", e), - _ => (), + None => { + match self.emit_message_default(&child.span, + &child.styled_message(), + &None, + &child.level, + max_line_num_len, + true) { + Err(e) => panic!("failed to emit error: {}", e), + _ => (), + } } } } @@ -1263,7 +1294,8 @@ fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool { fn emit_to_destination(rendered_buffer: &Vec>, lvl: &Level, - dst: &mut Destination) + dst: &mut Destination, + short_message: bool) -> io::Result<()> { use lock; @@ -1286,7 +1318,9 @@ fn emit_to_destination(rendered_buffer: &Vec>, write!(dst, "{}", part.text)?; dst.reset_attrs()?; } - write!(dst, "\n")?; + if !short_message { + write!(dst, "\n")?; + } } dst.flush()?; Ok(()) diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index d9b0f4ac8a6c0..ba7268a4bc393 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -18,10 +18,12 @@ #![feature(range_contains)] #![cfg_attr(unix, feature(libc))] #![feature(conservative_impl_trait)] +#![feature(i128_type)] extern crate term; #[cfg(unix)] extern crate libc; +extern crate rustc_data_structures; extern crate serialize as rustc_serialize; extern crate syntax_pos; @@ -31,6 +33,9 @@ use self::Level::*; use emitter::{Emitter, EmitterWriter}; +use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::stable_hasher::StableHasher; + use std::borrow::Cow; use std::cell::{RefCell, Cell}; use std::mem; @@ -47,7 +52,7 @@ mod lock; use syntax_pos::{BytePos, Loc, FileLinesResult, FileMap, FileName, MultiSpan, Span, NO_EXPANSION}; -#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub enum RenderSpan { /// A FullSpan renders with both with an initial line for the /// message, prefixed by file:linenum, followed by a summary of @@ -61,7 +66,7 @@ pub enum RenderSpan { Suggestion(CodeSuggestion), } -#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub struct CodeSuggestion { /// Each substitute can have multiple variants due to multiple /// applicable suggestions @@ -86,7 +91,7 @@ pub struct CodeSuggestion { pub show_code_when_inline: bool, } -#[derive(Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] /// See the docs on `CodeSuggestion::substitutions` pub struct Substitution { pub span: Span, @@ -271,6 +276,11 @@ pub struct Handler { continue_after_error: Cell, delayed_span_bug: RefCell>, tracked_diagnostics: RefCell>>, + + // This set contains a hash of every diagnostic that has been emitted by + // this handler. These hashes is used to avoid emitting the same error + // twice. + emitted_diagnostics: RefCell>, } impl Handler { @@ -279,7 +289,7 @@ impl Handler { treat_err_as_bug: bool, cm: Option>) -> Handler { - let emitter = Box::new(EmitterWriter::stderr(color_config, cm)); + let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false)); Handler::with_emitter(can_emit_warnings, treat_err_as_bug, emitter) } @@ -295,6 +305,7 @@ impl Handler { continue_after_error: Cell::new(true), delayed_span_bug: RefCell::new(None), tracked_diagnostics: RefCell::new(None), + emitted_diagnostics: RefCell::new(FxHashSet()), } } @@ -559,15 +570,29 @@ impl Handler { } fn emit_db(&self, db: &DiagnosticBuilder) { + let diagnostic = &**db; + if let Some(ref mut list) = *self.tracked_diagnostics.borrow_mut() { - list.push((**db).clone()); + list.push(diagnostic.clone()); + } + + let diagnostic_hash = { + use std::hash::Hash; + let mut hasher = StableHasher::new(); + diagnostic.hash(&mut hasher); + hasher.finish() + }; + + // Only emit the diagnostic if we haven't already emitted an equivalent + // one: + if self.emitted_diagnostics.borrow_mut().insert(diagnostic_hash) { + self.emitter.borrow_mut().emit(db); } - self.emitter.borrow_mut().emit(db); } } -#[derive(Copy, PartialEq, Clone, Debug, RustcEncodable, RustcDecodable)] +#[derive(Copy, PartialEq, Clone, Hash, Debug, RustcEncodable, RustcDecodable)] pub enum Level { Bug, Fatal, diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 52e3fcc1b474c..2e8deeee5a599 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -203,7 +203,7 @@ pub struct StyledString { pub style: Style, } -#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub enum Style { HeaderMsg, LineAndColumn, diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index d53ee5c804f60..89310b9d6f589 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -115,7 +115,7 @@ //! implemented. use rustc::hir::svh::Svh; -use rustc::session::Session; +use rustc::session::{Session, CrateDisambiguator}; use rustc::util::fs as fs_util; use rustc_data_structures::{flock, base_n}; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; @@ -188,7 +188,7 @@ pub fn in_incr_comp_dir(incr_comp_session_dir: &Path, file_name: &str) -> PathBu /// The garbage collection will take care of it. pub fn prepare_session_directory(sess: &Session, crate_name: &str, - crate_disambiguator: &str) { + crate_disambiguator: CrateDisambiguator) { if sess.opts.incremental.is_none() { return } @@ -614,21 +614,17 @@ fn string_to_timestamp(s: &str) -> Result { fn crate_path(sess: &Session, crate_name: &str, - crate_disambiguator: &str) + crate_disambiguator: CrateDisambiguator) -> PathBuf { - use std::hash::{Hasher, Hash}; - use std::collections::hash_map::DefaultHasher; let incr_dir = sess.opts.incremental.as_ref().unwrap().clone(); - // The full crate disambiguator is really long. A hash of it should be + // The full crate disambiguator is really long. 64 bits of it should be // sufficient. - let mut hasher = DefaultHasher::new(); - crate_disambiguator.hash(&mut hasher); + let crate_disambiguator = crate_disambiguator.to_fingerprint().to_smaller_hash(); + let crate_disambiguator = base_n::encode(crate_disambiguator, INT_ENCODE_BASE); - let crate_name = format!("{}-{}", - crate_name, - base_n::encode(hasher.finish(), INT_ENCODE_BASE)); + let crate_name = format!("{}-{}", crate_name, crate_disambiguator); incr_dir.join(crate_name) } diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs index 9865e8fb1734a..f23b8dc85b8bb 100644 --- a/src/librustc_incremental/persist/work_product.rs +++ b/src/librustc_incremental/persist/work_product.rs @@ -11,9 +11,8 @@ //! This module contains files for saving intermediate work-products. use persist::fs::*; -use rustc::dep_graph::{WorkProduct, WorkProductId, DepGraph}; +use rustc::dep_graph::{WorkProduct, WorkProductId, DepGraph, WorkProductFileKind}; use rustc::session::Session; -use rustc::session::config::OutputType; use rustc::util::fs::link_or_copy; use std::path::PathBuf; use std::fs as std_fs; @@ -21,19 +20,24 @@ use std::fs as std_fs; pub fn save_trans_partition(sess: &Session, dep_graph: &DepGraph, cgu_name: &str, - files: &[(OutputType, PathBuf)]) { + files: &[(WorkProductFileKind, PathBuf)]) { debug!("save_trans_partition({:?},{:?})", cgu_name, files); if sess.opts.incremental.is_none() { - return; + return } let work_product_id = WorkProductId::from_cgu_name(cgu_name); let saved_files: Option> = files.iter() .map(|&(kind, ref path)| { - let file_name = format!("cgu-{}.{}", cgu_name, kind.extension()); + let extension = match kind { + WorkProductFileKind::Object => "o", + WorkProductFileKind::Bytecode => "bc", + WorkProductFileKind::BytecodeCompressed => "bc-compressed", + }; + let file_name = format!("cgu-{}.{}", cgu_name, extension); let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name); match link_or_copy(path, &path_in_incr_dir) { Ok(_) => Some((kind, file_name)), diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index bc2a1f08441d1..70cac419648d5 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -621,12 +621,6 @@ impl EarlyLintPass for AnonymousParameters { } } -declare_lint! { - DEPRECATED_ATTR, - Warn, - "detects use of deprecated attributes" -} - /// Checks for use of attributes which have been deprecated. #[derive(Clone)] pub struct DeprecatedAttr { @@ -645,7 +639,7 @@ impl DeprecatedAttr { impl LintPass for DeprecatedAttr { fn get_lints(&self) -> LintArray { - lint_array!(DEPRECATED_ATTR) + lint_array!() } } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 4ba7f7aa951f7..42fcf377d6539 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -28,6 +28,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(i128_type)] +#![feature(macro_vis_matcher)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(slice_patterns)] @@ -163,7 +164,12 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { UNUSED_UNSAFE, PATH_STATEMENTS, UNUSED_ATTRIBUTES, - UNUSED_MACROS); + UNUSED_MACROS, + UNUSED_ALLOCATION, + UNUSED_DOC_COMMENT, + UNUSED_EXTERN_CRATES, + UNUSED_FEATURES, + UNUSED_PARENS); // Guidelines for creating a future incompatibility lint: // @@ -239,15 +245,15 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { // Register renamed and removed lints store.register_renamed("unknown_features", "unused_features"); - store.register_removed("unsigned_negation", - "replaced by negate_unsigned feature gate"); + store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); store.register_removed("negate_unsigned", "cast a signed value instead"); store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok"); // This was renamed to raw_pointer_derive, which was then removed, // so it is also considered removed - store.register_removed("raw_pointer_deriving", - "using derive with raw pointers is ok"); + store.register_removed("raw_pointer_deriving", "using derive with raw pointers is ok"); store.register_removed("drop_with_repr_extern", "drop flags have been removed"); + store.register_removed("fat_ptr_transmutes", "was accidentally removed back in 2014"); + store.register_removed("deprecated_attr", "use `deprecated` instead"); store.register_removed("transmute_from_fn_item_types", "always cast functions before transmuting them"); store.register_removed("hr_lifetime_in_assoc_type", diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index d3a5d52b295af..8f08987505b94 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -431,7 +431,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // fields are actually safe. let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.normalize_associated_type(&field.ty(cx, substs)); + let field_ty = cx.fully_normalize_associated_types_in( + &field.ty(cx, substs) + ); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -463,7 +465,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.normalize_associated_type(&field.ty(cx, substs)); + let field_ty = cx.fully_normalize_associated_types_in( + &field.ty(cx, substs) + ); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -516,7 +520,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Check the contained variants. for variant in &def.variants { for field in &variant.fields { - let arg = cx.normalize_associated_type(&field.ty(cx, substs)); + let arg = cx.fully_normalize_associated_types_in( + &field.ty(cx, substs) + ); let r = self.check_type_for_ffi(cache, arg); match r { FfiSafe => {} @@ -615,6 +621,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { FfiSafe } + ty::TyForeign(..) => FfiSafe, + ty::TyParam(..) | ty::TyInfer(..) | ty::TyError | @@ -629,7 +637,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { fn check_type_for_ffi_and_report_errors(&mut self, sp: Span, ty: Ty<'tcx>) { // it is only OK to use this function because extern fns cannot have // any generic types right now: - let ty = self.cx.tcx.normalize_associated_type(&ty); + let ty = self.cx.tcx.fully_normalize_associated_types_in(&ty); match self.check_type_for_ffi(&mut FxHashSet(), ty) { FfiResult::FfiSafe => {} @@ -717,6 +725,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { hir::ForeignItemStatic(ref ty, _) => { vis.check_foreign_static(ni.id, ty.span); } + hir::ForeignItemType => () } } } diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index a058f84e58806..32f724f7541c7 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -225,7 +225,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes { } declare_lint! { - UNUSED_PARENS, + pub(super) UNUSED_PARENS, Warn, "`if`, `match`, `while` and `return` do not need parentheses" } @@ -350,7 +350,7 @@ impl EarlyLintPass for UnusedImportBraces { } declare_lint! { - UNUSED_ALLOCATION, + pub(super) UNUSED_ALLOCATION, Warn, "detects unnecessary allocations that can be eliminated" } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 39bdf88925e44..cfc8d271327fb 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -19,7 +19,7 @@ use rustc::hir::def_id::{CrateNum, DefIndex, CRATE_DEF_INDEX}; use rustc::hir::svh::Svh; use rustc::middle::allocator::AllocatorKind; use rustc::middle::cstore::DepKind; -use rustc::session::Session; +use rustc::session::{Session, CrateDisambiguator}; use rustc::session::config::{Sanitizer, self}; use rustc_back::PanicStrategy; use rustc::session::search_paths::PathKind; @@ -626,7 +626,7 @@ impl<'a> CrateLoader<'a> { pub fn find_plugin_registrar(&mut self, span: Span, name: &str) - -> Option<(PathBuf, Symbol, DefIndex)> { + -> Option<(PathBuf, CrateDisambiguator, DefIndex)> { let ekrate = self.read_extension_crate(span, &ExternCrateInfo { name: Symbol::intern(name), ident: Symbol::intern(name), diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 9e47e96aee4ef..c688b4c408a35 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -17,6 +17,7 @@ use rustc::hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefIndex}; use rustc::hir::map::definitions::DefPathTable; use rustc::hir::svh::Svh; use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader}; +use rustc::session::CrateDisambiguator; use rustc_back::PanicStrategy; use rustc_data_structures::indexed_vec::IndexVec; use rustc::util::nodemap::{FxHashMap, FxHashSet, NodeMap}; @@ -171,7 +172,7 @@ impl CrateMetadata { pub fn hash(&self) -> Svh { self.root.hash } - pub fn disambiguator(&self) -> Symbol { + pub fn disambiguator(&self) -> CrateDisambiguator { self.root.disambiguator } diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 8eacc21ab003b..fbe63e0ab4a8a 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -21,7 +21,7 @@ use rustc::middle::cstore::{CrateStore, DepKind, EncodedMetadataHashes, NativeLibraryKind}; use rustc::middle::stability::DeprecationEntry; use rustc::hir::def; -use rustc::session::Session; +use rustc::session::{CrateDisambiguator, Session}; use rustc::ty::{self, TyCtxt}; use rustc::ty::maps::Providers; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, CRATE_DEF_INDEX}; @@ -384,7 +384,7 @@ impl CrateStore for cstore::CStore { self.get_crate_data(cnum).name } - fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> Symbol + fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator { self.get_crate_data(cnum).disambiguator() } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 65cf15e5a0ec7..909e01376b92c 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -449,6 +449,7 @@ impl<'tcx> EntryKind<'tcx> { EntryKind::Enum(..) => Def::Enum(did), EntryKind::MacroDef(_) => Def::Macro(did, MacroKind::Bang), EntryKind::GlobalAsm => Def::GlobalAsm(did), + EntryKind::ForeignType => Def::TyForeign(did), EntryKind::ForeignMod | EntryKind::Impl(_) | diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 6b49be3e12192..abe2b6d0c1b19 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1419,6 +1419,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { } hir::ForeignItemStatic(_, true) => EntryKind::ForeignMutStatic, hir::ForeignItemStatic(_, false) => EntryKind::ForeignImmStatic, + hir::ForeignItemType => EntryKind::ForeignType, }; Entry { diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index dad0d26d2715d..3c3162bcb5138 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -18,6 +18,7 @@ use rustc::ich::StableHashingContext; use rustc::middle::cstore::{DepKind, LinkagePreference, NativeLibrary}; use rustc::middle::lang_items; use rustc::mir; +use rustc::session::CrateDisambiguator; use rustc::ty::{self, Ty, ReprOptions}; use rustc_back::PanicStrategy; @@ -191,7 +192,7 @@ pub struct CrateRoot { pub name: Symbol, pub triple: String, pub hash: hir::svh::Svh, - pub disambiguator: Symbol, + pub disambiguator: CrateDisambiguator, pub panic_strategy: PanicStrategy, pub has_global_allocator: bool, pub has_default_lib_allocator: bool, @@ -291,6 +292,7 @@ pub enum EntryKind<'tcx> { ForeignImmStatic, ForeignMutStatic, ForeignMod, + ForeignType, GlobalAsm, Type, Enum(ReprOptions), @@ -324,6 +326,7 @@ impl<'gcx> HashStable> for EntryKind<'gcx> { EntryKind::ForeignMutStatic | EntryKind::ForeignMod | EntryKind::GlobalAsm | + EntryKind::ForeignType | EntryKind::Field | EntryKind::Type => { // Nothing else to hash here. diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index ff923ce259fb4..ee2ef00be57b6 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -1161,7 +1161,7 @@ impl<'c, 'b, 'a: 'b+'c, 'gcx, 'tcx: 'a> MirBorrowckCtxt<'c, 'b, 'a, 'gcx, 'tcx> self.tcx.cannot_reassign_immutable(span, &self.describe_lvalue(lvalue), Origin::Mir) - .span_label(span, "re-assignment of immutable variable") + .span_label(span, "cannot assign twice to immutable variable") .span_label(assigned_span, format!("first assignment to `{}`", self.describe_lvalue(lvalue))) .emit(); diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index cdbcb43370fe0..280e1c8196636 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -247,7 +247,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } else { let args: Vec<_> = args.into_iter() - .map(|arg| unpack!(block = this.as_local_operand(block, arg))) + .map(|arg| { + let scope = this.local_scope(); + // Function arguments are owned by the callee, so we need as_temp() + // instead of as_operand() to enforce copies + let operand = unpack!(block = this.as_temp(block, scope, arg)); + Operand::Consume(Lvalue::Local(operand)) + }) .collect(); let success = this.cfg.start_new_block(); diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index b8bb2a404620e..b2f0ff57b62d6 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -21,6 +21,7 @@ use rustc::mir::visit::{MutVisitor, Lookup}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::subst::Substs; use rustc::util::nodemap::NodeMap; +use rustc_const_eval::pattern::{BindingMode, PatternKind}; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use shim; use std::mem; @@ -571,13 +572,24 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // Bind the argument patterns for (index, &(ty, pattern)) in arguments.iter().enumerate() { // Function arguments always get the first Local indices after the return pointer - let lvalue = Lvalue::Local(Local::new(index + 1)); + let local = Local::new(index + 1); + let lvalue = Lvalue::Local(local); if let Some(pattern) = pattern { let pattern = self.hir.pattern_from_hir(pattern); - scope = self.declare_bindings(scope, ast_body.span, - LintLevel::Inherited, &pattern); - unpack!(block = self.lvalue_into_pattern(block, pattern, &lvalue)); + + match *pattern.kind { + // Don't introduce extra copies for simple bindings + PatternKind::Binding { mutability, var, mode: BindingMode::ByValue, .. } => { + self.local_decls[local].mutability = mutability; + self.var_indices.insert(var, local); + } + _ => { + scope = self.declare_bindings(scope, ast_body.span, + LintLevel::Inherited, &pattern); + unpack!(block = self.lvalue_into_pattern(block, pattern, &lvalue)); + } + } } // Make sure we drop (parts of) the argument even when not matched on. diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 216f6e4457096..5451da2148e7d 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -232,7 +232,7 @@ pub trait BorrowckErrors { -> DiagnosticBuilder { struct_span_err!(self, span, E0384, - "re-assignment of immutable variable `{}`{OGN}", + "cannot assign twice to immutable variable `{}`{OGN}", desc, OGN=o) } diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 14e33378969aa..e44f3f3982491 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -288,7 +288,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { err.emit(); }); } - ForeignItemKind::Static(..) => {} + ForeignItemKind::Static(..) | ForeignItemKind::Ty => {} } visit::walk_foreign_item(self, fi) diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index d3202ba4ab535..a6eaff4481c76 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -140,8 +140,7 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> { self.tcx.lint_node(CONST_ERR, expr.id, expr.span, - &format!("constant evaluation error: {}. This will \ - become a HARD ERROR in the future", + &format!("constant evaluation error: {}", err.description().into_oneline())); } } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index e7a1dd6b043b1..3beba03ee1401 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -85,6 +85,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { fn item_ty_level(&self, item_def_id: DefId) -> Option { let ty_def_id = match self.tcx.type_of(item_def_id).sty { ty::TyAdt(adt, _) => adt.did, + ty::TyForeign(did) => did, ty::TyDynamic(ref obj, ..) if obj.principal().is_some() => obj.principal().unwrap().def_id(), ty::TyProjection(ref proj) => proj.trait_ref(self.tcx).def_id, @@ -444,6 +445,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { let ty_def_id = match ty.sty { ty::TyAdt(adt, _) => Some(adt.did), + ty::TyForeign(did) => Some(did), ty::TyDynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), ty::TyProjection(ref proj) => Some(proj.item_def_id), ty::TyFnDef(def_id, ..) | @@ -800,7 +802,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { impl<'a, 'tcx> TypeVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { match ty.sty { - ty::TyAdt(&ty::AdtDef { did: def_id, .. }, ..) | ty::TyFnDef(def_id, ..) => { + ty::TyAdt(&ty::AdtDef { did: def_id, .. }, ..) | + ty::TyFnDef(def_id, ..) | + ty::TyForeign(def_id) => { if !self.item_is_accessible(def_id) { let msg = format!("type `{}` is private", ty); self.tcx.sess.span_err(self.span, &msg); @@ -1329,6 +1333,7 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<' fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { let ty_def_id = match ty.sty { ty::TyAdt(adt, _) => Some(adt.did), + ty::TyForeign(did) => Some(did), ty::TyDynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), ty::TyProjection(ref proj) => { if self.required_visibility == ty::Visibility::Invisible { @@ -1349,8 +1354,13 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<' if let Some(def_id) = ty_def_id { // Non-local means public (private items can't leave their crate, modulo bugs) if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { - let item = self.tcx.hir.expect_item(node_id); - let vis = ty::Visibility::from_hir(&item.vis, node_id, self.tcx); + let vis = match self.tcx.hir.find(node_id) { + Some(hir::map::NodeItem(item)) => &item.vis, + Some(hir::map::NodeForeignItem(item)) => &item.vis, + _ => bug!("expected item of foreign item"), + }; + + let vis = ty::Visibility::from_hir(vis, node_id, self.tcx); if !vis.is_at_least(self.min_visibility, self.tcx) { self.min_visibility = vis; @@ -1563,9 +1573,7 @@ pub fn provide(providers: &mut Providers) { } pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc { - tcx.dep_graph.with_ignore(|| { // FIXME - tcx.privacy_access_levels(LOCAL_CRATE) - }) + tcx.privacy_access_levels(LOCAL_CRATE) } fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index a4d1ae1621571..880b370c7f66b 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -40,7 +40,7 @@ use syntax::ext::base::SyntaxExtension; use syntax::ext::base::Determinacy::Undetermined; use syntax::ext::hygiene::Mark; use syntax::ext::tt::macro_rules; -use syntax::parse::token; +use syntax::parse::token::{self, Token}; use syntax::symbol::keywords; use syntax::symbol::Symbol; use syntax::visit::{self, Visitor}; @@ -419,17 +419,20 @@ impl<'a> Resolver<'a> { /// Constructs the reduced graph for one foreign item. fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem, expansion: Mark) { - let def = match item.node { + let (def, ns) = match item.node { ForeignItemKind::Fn(..) => { - Def::Fn(self.definitions.local_def_id(item.id)) + (Def::Fn(self.definitions.local_def_id(item.id)), ValueNS) } ForeignItemKind::Static(_, m) => { - Def::Static(self.definitions.local_def_id(item.id), m) + (Def::Static(self.definitions.local_def_id(item.id), m), ValueNS) + } + ForeignItemKind::Ty => { + (Def::TyForeign(self.definitions.local_def_id(item.id)), TypeNS) } }; let parent = self.current_module; let vis = self.resolve_visibility(&item.vis); - self.define(parent, item.ident, ValueNS, (def, vis, item.span, expansion)); + self.define(parent, item.ident, ns, (def, vis, item.span, expansion)); } fn build_reduced_graph_for_block(&mut self, block: &Block, expansion: Mark) { @@ -462,7 +465,7 @@ impl<'a> Resolver<'a> { span); self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion)); } - Def::Variant(..) | Def::TyAlias(..) => { + Def::Variant(..) | Def::TyAlias(..) | Def::TyForeign(..) => { self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion)); } Def::Fn(..) | Def::Static(..) | Def::Const(..) | Def::VariantCtor(..) => { @@ -830,4 +833,17 @@ impl<'a, 'b> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b> { visit::walk_trait_item(self, item); self.resolver.current_module = parent; } + + fn visit_token(&mut self, t: Token) { + if let Token::Interpolated(nt) = t { + match nt.0 { + token::NtExpr(ref expr) => { + if let ast::ExprKind::Mac(..) = expr.node { + self.visit_invoc(expr.id); + } + } + _ => {} + } + } + } } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 4aab43cbec701..83eeaf551c56c 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -468,7 +468,8 @@ impl<'a> PathSource<'a> { PathSource::Type => match def { Def::Struct(..) | Def::Union(..) | Def::Enum(..) | Def::Trait(..) | Def::TyAlias(..) | Def::AssociatedTy(..) | - Def::PrimTy(..) | Def::TyParam(..) | Def::SelfTy(..) => true, + Def::PrimTy(..) | Def::TyParam(..) | Def::SelfTy(..) | + Def::TyForeign(..) => true, _ => false, }, PathSource::Trait => match def { @@ -707,6 +708,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { HasTypeParameters(generics, ItemRibKind) } ForeignItemKind::Static(..) => NoTypeParameters, + ForeignItemKind::Ty => NoTypeParameters, }; self.with_type_parameter_rib(type_parameters, |this| { visit::walk_foreign_item(this, foreign_item); @@ -718,12 +720,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { _: Span, node_id: NodeId) { let rib_kind = match function_kind { - FnKind::ItemFn(_, generics, ..) => { - self.visit_generics(generics); + FnKind::ItemFn(..) => { ItemRibKind } FnKind::Method(_, sig, _, _) => { - self.visit_generics(&sig.generics); MethodRibKind(!sig.decl.has_self()) } FnKind::Closure(_) => ClosureRibKind(node_id), @@ -1417,7 +1417,7 @@ impl<'a> Resolver<'a> { let mut definitions = Definitions::new(); DefCollector::new(&mut definitions, Mark::root()) - .collect_root(crate_name, &session.local_crate_disambiguator().as_str()); + .collect_root(crate_name, session.local_crate_disambiguator()); let mut invocations = FxHashMap(); invocations.insert(Mark::root(), @@ -1880,7 +1880,7 @@ impl<'a> Resolver<'a> { } TraitItemKind::Method(ref sig, _) => { let type_parameters = - HasTypeParameters(&sig.generics, + HasTypeParameters(&trait_item.generics, MethodRibKind(!sig.decl.has_self())); this.with_type_parameter_rib(type_parameters, |this| { visit::walk_trait_item(this, trait_item) @@ -2084,7 +2084,9 @@ impl<'a> Resolver<'a> { ValueNS, impl_item.span, |n, s| ResolutionError::ConstNotMemberOfTrait(n, s)); - visit::walk_impl_item(this, impl_item); + this.with_constant_rib(|this| + visit::walk_impl_item(this, impl_item) + ); } ImplItemKind::Method(ref sig, _) => { // If this is a trait impl, ensure the method @@ -2097,7 +2099,7 @@ impl<'a> Resolver<'a> { // We also need a new scope for the method- // specific type parameters. let type_parameters = - HasTypeParameters(&sig.generics, + HasTypeParameters(&impl_item.generics, MethodRibKind(!sig.decl.has_self())); this.with_type_parameter_rib(type_parameters, |this| { visit::walk_impl_item(this, impl_item); diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index aa249af363f41..12897050164c9 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -15,7 +15,7 @@ rustc_data_structures = { path = "../librustc_data_structures" } rustc_typeck = { path = "../librustc_typeck" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rls-data = "0.10" +rls-data = "0.11" rls-span = "0.4" # FIXME(#40527) should move rustc serialize out of tree rustc-serialize = "0.3" diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 3e730cf836523..4eac4398c1827 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -263,6 +263,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { HirDef::Union(..) | HirDef::Enum(..) | HirDef::TyAlias(..) | + HirDef::TyForeign(..) | HirDef::Trait(_) => { let span = self.span_from_span(sub_span.expect("No span found for type ref")); self.dumper.dump_ref(Ref { @@ -354,23 +355,24 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { body: Option<&'l ast::Block>, id: ast::NodeId, name: ast::Ident, + generics: &'l ast::Generics, vis: ast::Visibility, span: Span) { debug!("process_method: {}:{}", id, name); if let Some(mut method_data) = self.save_ctxt.get_method_data(id, name.name, span) { - let sig_str = ::make_signature(&sig.decl, &sig.generics); + let sig_str = ::make_signature(&sig.decl, &generics); if body.is_some() { self.nest_tables(id, |v| { v.process_formals(&sig.decl.inputs, &method_data.qualname) }); } - self.process_generic_params(&sig.generics, span, &method_data.qualname, id); + self.process_generic_params(&generics, span, &method_data.qualname, id); method_data.value = sig_str; - method_data.sig = sig::method_signature(id, name, sig, &self.save_ctxt); + method_data.sig = sig::method_signature(id, name, generics, sig, &self.save_ctxt); self.dumper.dump_def(vis == ast::Visibility::Public, method_data); } @@ -610,7 +612,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let parent = Some(::id_from_node_id(item.id, &self.save_ctxt)); self.dumper.dump_def(item.vis == ast::Visibility::Public, Def { - kind: DefKind::Struct, + kind: DefKind::StructVariant, id, span, name, @@ -644,7 +646,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let parent = Some(::id_from_node_id(item.id, &self.save_ctxt)); self.dumper.dump_def(item.vis == ast::Visibility::Public, Def { - kind: DefKind::Tuple, + kind: DefKind::TupleVariant, id, span, name, @@ -1007,6 +1009,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { body.as_ref().map(|x| &**x), trait_item.id, trait_item.ident, + &trait_item.generics, ast::Visibility::Public, trait_item.span); } @@ -1066,6 +1069,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { Some(body), impl_item.id, impl_item.ident, + &impl_item.generics, impl_item.vis.clone(), impl_item.span); } @@ -1536,6 +1540,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc self.visit_ty(ty); } + ast::ForeignItemKind::Ty => { + if let Some(var_data) = self.save_ctxt.get_extern_item_data(item) { + down_cast_data!(var_data, DefData, item.span); + self.dumper.dump_def(item.vis == ast::Visibility::Public, var_data); + } + } } } } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 1c6007966afa3..cf2cad1b38c42 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -173,6 +173,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { attributes: lower_attributes(item.attrs.clone(), self), })) } + // FIXME(plietar): needs a new DefKind in rls-data + ast::ForeignItemKind::Ty => None, } } @@ -642,6 +644,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { HirDef::Union(def_id) | HirDef::Enum(def_id) | HirDef::TyAlias(def_id) | + HirDef::TyForeign(def_id) | HirDef::AssociatedTy(def_id) | HirDef::Trait(def_id) | HirDef::TyParam(def_id) => { diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 47e5ad6c01088..b0844d1b82404 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -77,13 +77,14 @@ pub fn variant_signature(variant: &ast::Variant, scx: &SaveContext) -> Option Option { if !scx.config.signatures { return None; } - make_method_signature(id, ident, m, scx).ok() + make_method_signature(id, ident, generics, m, scx).ok() } pub fn assoc_const_signature(id: NodeId, @@ -807,6 +808,23 @@ impl Sig for ast::ForeignItem { Ok(extend_sig(ty_sig, text, defs, vec![])) } + ast::ForeignItemKind::Ty => { + let mut text = "type ".to_owned(); + let name = self.ident.to_string(); + let defs = vec![SigElement { + id: id_from_node_id(self.id, scx), + start: offset + text.len(), + end: offset + text.len() + name.len(), + }]; + text.push_str(&name); + text.push(';'); + + Ok(Signature { + text: text, + defs: defs, + refs: vec![], + }) + } } } } @@ -895,6 +913,7 @@ fn make_assoc_const_signature(id: NodeId, fn make_method_signature(id: NodeId, ident: ast::Ident, + generics: &ast::Generics, m: &ast::MethodSig, scx: &SaveContext) -> Result { @@ -915,7 +934,7 @@ fn make_method_signature(id: NodeId, let mut sig = name_and_generics(text, 0, - &m.generics, + generics, id, ident, scx)?; diff --git a/src/librustc_trans/adt.rs b/src/librustc_trans/adt.rs index 23a45a7962abf..b06f8e4e67116 100644 --- a/src/librustc_trans/adt.rs +++ b/src/librustc_trans/adt.rs @@ -80,7 +80,7 @@ pub fn compute_fields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, ty::TyGenerator(def_id, substs, _) => { if variant_index > 0 { bug!("{} is a generator, which only has one variant", t);} substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().normalize_associated_type(&t) + cx.tcx().fully_normalize_associated_types_in(&t) }).collect() }, _ => bug!("{} is not a type that can have fields.", t) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 570a6bbac1e4e..b203bd640cf14 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -9,7 +9,7 @@ // except according to those terms. use super::archive::{ArchiveBuilder, ArchiveConfig}; -use super::bytecode::{self, RLIB_BYTECODE_EXTENSION}; +use super::bytecode::RLIB_BYTECODE_EXTENSION; use super::linker::Linker; use super::command::Command; use super::rpath::RPathConfig; @@ -37,7 +37,7 @@ use std::env; use std::ffi::OsString; use std::fmt; use std::fs::{self, File}; -use std::io::{self, Read, Write, BufWriter}; +use std::io::{self, Write, BufWriter}; use std::path::{Path, PathBuf}; use std::process::{Output, Stdio}; use std::str; @@ -126,14 +126,6 @@ fn command_path(sess: &Session) -> OsString { env::join_paths(new_path).unwrap() } -fn metadata_obj(outputs: &OutputFilenames) -> PathBuf { - outputs.temp_path(OutputType::Object, Some(METADATA_MODULE_NAME)) -} - -fn allocator_obj(outputs: &OutputFilenames) -> PathBuf { - outputs.temp_path(OutputType::Object, Some(ALLOCATOR_MODULE_NAME)) -} - pub fn remove(sess: &Session, path: &Path) { match fs::remove_file(path) { Ok(..) => {} @@ -175,13 +167,23 @@ pub fn link_binary(sess: &Session, // Remove the temporary object file and metadata if we aren't saving temps if !sess.opts.cg.save_temps { if sess.opts.output_types.should_trans() { - for obj in trans.modules.iter() { - remove(sess, &obj.object); + for obj in trans.modules.iter().filter_map(|m| m.object.as_ref()) { + remove(sess, obj); } } - remove(sess, &metadata_obj(outputs)); - if trans.allocator_module.is_some() { - remove(sess, &allocator_obj(outputs)); + for obj in trans.modules.iter().filter_map(|m| m.bytecode_compressed.as_ref()) { + remove(sess, obj); + } + if let Some(ref obj) = trans.metadata_module.object { + remove(sess, obj); + } + if let Some(ref allocator) = trans.allocator_module { + if let Some(ref obj) = allocator.object { + remove(sess, obj); + } + if let Some(ref bc) = allocator.bytecode_compressed { + remove(sess, bc); + } } } @@ -256,8 +258,8 @@ fn link_binary_output(sess: &Session, crate_type: config::CrateType, outputs: &OutputFilenames, crate_name: &str) -> Vec { - for module in trans.modules.iter() { - check_file_is_writeable(&module.object, sess); + for obj in trans.modules.iter().filter_map(|m| m.object.as_ref()) { + check_file_is_writeable(obj, sess); } let tmpdir = match TempDir::new("rustc") { @@ -280,20 +282,14 @@ fn link_binary_output(sess: &Session, link_rlib(sess, trans, RlibFlavor::Normal, - outputs, &out_filename, tmpdir.path()).build(); } config::CrateTypeStaticlib => { - link_staticlib(sess, - trans, - outputs, - &out_filename, - tmpdir.path()); + link_staticlib(sess, trans, &out_filename, tmpdir.path()); } _ => { - link_natively(sess, crate_type, &out_filename, - trans, outputs, tmpdir.path()); + link_natively(sess, crate_type, &out_filename, trans, tmpdir.path()); } } out_filenames.push(out_filename); @@ -349,14 +345,13 @@ enum RlibFlavor { fn link_rlib<'a>(sess: &'a Session, trans: &CrateTranslation, flavor: RlibFlavor, - outputs: &OutputFilenames, out_filename: &Path, tmpdir: &Path) -> ArchiveBuilder<'a> { info!("preparing rlib to {:?}", out_filename); let mut ab = ArchiveBuilder::new(archive_config(sess, out_filename, None)); - for module in trans.modules.iter() { - ab.add_file(&module.object); + for obj in trans.modules.iter().filter_map(|m| m.object.as_ref()) { + ab.add_file(obj); } // Note that in this loop we are ignoring the value of `lib.cfg`. That is, @@ -421,56 +416,9 @@ fn link_rlib<'a>(sess: &'a Session, ab.add_file(&metadata); // For LTO purposes, the bytecode of this library is also inserted - // into the archive. If codegen_units > 1, we insert each of the - // bitcode files. - for module in trans.modules.iter() { - // Note that we make sure that the bytecode filename in the - // archive is never exactly 16 bytes long by adding a 16 byte - // extension to it. This is to work around a bug in LLDB that - // would cause it to crash if the name of a file in an archive - // was exactly 16 bytes. - let bc_filename = module.object.with_extension("bc"); - let bc_encoded_filename = tmpdir.join({ - module.object.with_extension(RLIB_BYTECODE_EXTENSION).file_name().unwrap() - }); - - let mut bc_data = Vec::new(); - match fs::File::open(&bc_filename).and_then(|mut f| { - f.read_to_end(&mut bc_data) - }) { - Ok(..) => {} - Err(e) => sess.fatal(&format!("failed to read bytecode: {}", - e)) - } - - let encoded = bytecode::encode(&module.llmod_id, &bc_data); - - let mut bc_file_deflated = match fs::File::create(&bc_encoded_filename) { - Ok(file) => file, - Err(e) => { - sess.fatal(&format!("failed to create compressed \ - bytecode file: {}", e)) - } - }; - - match bc_file_deflated.write_all(&encoded) { - Ok(()) => {} - Err(e) => { - sess.fatal(&format!("failed to write compressed \ - bytecode: {}", e)); - } - }; - - ab.add_file(&bc_encoded_filename); - - // See the bottom of back::write::run_passes for an explanation - // of when we do and don't keep .#module-name#.bc files around. - let user_wants_numbered_bitcode = - sess.opts.output_types.contains_key(&OutputType::Bitcode) && - sess.codegen_units() > 1; - if !sess.opts.cg.save_temps && !user_wants_numbered_bitcode { - remove(sess, &bc_filename); - } + // into the archive. + for bytecode in trans.modules.iter().filter_map(|m| m.bytecode_compressed.as_ref()) { + ab.add_file(bytecode); } // After adding all files to the archive, we need to update the @@ -482,8 +430,11 @@ fn link_rlib<'a>(sess: &'a Session, } RlibFlavor::StaticlibBase => { - if trans.allocator_module.is_some() { - ab.add_file(&allocator_obj(outputs)); + let obj = trans.allocator_module + .as_ref() + .and_then(|m| m.object.as_ref()); + if let Some(obj) = obj { + ab.add_file(obj); } } } @@ -505,13 +456,11 @@ fn link_rlib<'a>(sess: &'a Session, // metadata file). fn link_staticlib(sess: &Session, trans: &CrateTranslation, - outputs: &OutputFilenames, out_filename: &Path, tempdir: &Path) { let mut ab = link_rlib(sess, trans, RlibFlavor::StaticlibBase, - outputs, out_filename, tempdir); let mut all_native_libs = vec![]; @@ -616,7 +565,6 @@ fn link_natively(sess: &Session, crate_type: config::CrateType, out_filename: &Path, trans: &CrateTranslation, - outputs: &OutputFilenames, tmpdir: &Path) { info!("preparing {:?} to {:?}", crate_type, out_filename); let flavor = sess.linker_flavor(); @@ -656,7 +604,7 @@ fn link_natively(sess: &Session, { let mut linker = trans.linker_info.to_linker(cmd, &sess); link_args(&mut *linker, sess, crate_type, tmpdir, - out_filename, outputs, trans); + out_filename, trans); cmd = linker.finalize(); } if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) { @@ -878,7 +826,6 @@ fn link_args(cmd: &mut Linker, crate_type: config::CrateType, tmpdir: &Path, out_filename: &Path, - outputs: &OutputFilenames, trans: &CrateTranslation) { // The default library location, we need this to find the runtime. @@ -889,8 +836,8 @@ fn link_args(cmd: &mut Linker, let t = &sess.target.target; cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path)); - for module in trans.modules.iter() { - cmd.add_object(&module.object); + for obj in trans.modules.iter().filter_map(|m| m.object.as_ref()) { + cmd.add_object(obj); } cmd.output_filename(out_filename); @@ -913,11 +860,16 @@ fn link_args(cmd: &mut Linker, // object file, so we link that in here. if crate_type == config::CrateTypeDylib || crate_type == config::CrateTypeProcMacro { - cmd.add_object(&metadata_obj(outputs)); + if let Some(obj) = trans.metadata_module.object.as_ref() { + cmd.add_object(obj); + } } - if trans.allocator_module.is_some() { - cmd.add_object(&allocator_obj(outputs)); + let obj = trans.allocator_module + .as_ref() + .and_then(|m| m.object.as_ref()); + if let Some(obj) = obj { + cmd.add_object(obj); } // Try to strip as much out of the generated object by removing unused @@ -1185,9 +1137,9 @@ fn add_upstream_rust_crates(cmd: &mut Linker, for f in archive.src_files() { if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { - archive.remove_file(&f); - continue - } + archive.remove_file(&f); + continue + } } archive.build(); diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs index 01d3d656dfe19..48c3fd638c36b 100644 --- a/src/librustc_trans/back/lto.rs +++ b/src/librustc_trans/back/lto.rs @@ -343,8 +343,7 @@ fn thin_lto(diag_handler: &Handler, info!("local module: {} - {}", i, module.llmod_id); let llvm = module.llvm().expect("can't lto pretranslated module"); let name = CString::new(module.llmod_id.clone()).unwrap(); - let buffer = llvm::LLVMRustThinLTOBufferCreate(llvm.llmod); - let buffer = ThinBuffer(buffer); + let buffer = ThinBuffer::new(llvm.llmod); thin_modules.push(llvm::ThinLTOModule { identifier: name.as_ptr(), data: buffer.data().as_ptr(), @@ -499,13 +498,13 @@ unsafe impl Send for ModuleBuffer {} unsafe impl Sync for ModuleBuffer {} impl ModuleBuffer { - fn new(m: ModuleRef) -> ModuleBuffer { + pub fn new(m: ModuleRef) -> ModuleBuffer { ModuleBuffer(unsafe { llvm::LLVMRustModuleBufferCreate(m) }) } - fn data(&self) -> &[u8] { + pub fn data(&self) -> &[u8] { unsafe { let ptr = llvm::LLVMRustModuleBufferPtr(self.0); let len = llvm::LLVMRustModuleBufferLen(self.0); @@ -545,13 +544,20 @@ impl Drop for ThinData { } } -struct ThinBuffer(*mut llvm::ThinLTOBuffer); +pub struct ThinBuffer(*mut llvm::ThinLTOBuffer); unsafe impl Send for ThinBuffer {} unsafe impl Sync for ThinBuffer {} impl ThinBuffer { - fn data(&self) -> &[u8] { + pub fn new(m: ModuleRef) -> ThinBuffer { + unsafe { + let buffer = llvm::LLVMRustThinLTOBufferCreate(m); + ThinBuffer(buffer) + } + } + + pub fn data(&self) -> &[u8] { unsafe { let ptr = llvm::LLVMRustThinLTOBufferPtr(self.0) as *const _; let len = llvm::LLVMRustThinLTOBufferLen(self.0); diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs index 4996972a64586..eb1c5cb788153 100644 --- a/src/librustc_trans/back/symbol_export.rs +++ b/src/librustc_trans/back/symbol_export.rs @@ -34,7 +34,7 @@ pub fn threshold(tcx: TyCtxt) -> SymbolExportLevel { pub fn metadata_symbol_name(tcx: TyCtxt) -> String { format!("rust_metadata_{}_{}", tcx.crate_name(LOCAL_CRATE), - tcx.crate_disambiguator(LOCAL_CRATE)) + tcx.crate_disambiguator(LOCAL_CRATE).to_fingerprint().to_hex()) } fn crate_export_threshold(crate_type: config::CrateType) -> SymbolExportLevel { diff --git a/src/librustc_trans/back/symbol_names.rs b/src/librustc_trans/back/symbol_names.rs index 0ebfe4daad18f..695950e672785 100644 --- a/src/librustc_trans/back/symbol_names.rs +++ b/src/librustc_trans/back/symbol_names.rs @@ -220,7 +220,7 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if avoid_cross_crate_conflicts { hasher.hash(tcx.crate_name.as_str()); - hasher.hash(tcx.sess.local_crate_disambiguator().as_str()); + hasher.hash(tcx.sess.local_crate_disambiguator()); } }); diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index f8dbe68dba9be..5550ab9fa55e6 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -8,14 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use back::lto; +use back::bytecode::{self, RLIB_BYTECODE_EXTENSION}; +use back::lto::{self, ModuleBuffer, ThinBuffer}; use back::link::{self, get_linker, remove}; use back::linker::LinkerInfo; use back::symbol_export::ExportedSymbols; use base; use consts; use rustc_incremental::{save_trans_partition, in_incr_comp_dir}; -use rustc::dep_graph::DepGraph; +use rustc::dep_graph::{DepGraph, WorkProductFileKind}; use rustc::middle::cstore::{LinkMeta, EncodedMetadata}; use rustc::session::config::{self, OutputFilenames, OutputType, OutputTypes, Passes, SomePasses, AllPasses, Sanitizer}; @@ -44,7 +45,7 @@ use rustc_demangle; use std::any::Any; use std::ffi::{CString, CStr}; -use std::fs; +use std::fs::{self, File}; use std::io; use std::io::Write; use std::mem; @@ -228,6 +229,7 @@ pub struct ModuleConfig { // Flags indicating which outputs to produce. emit_no_opt_bc: bool, emit_bc: bool, + emit_bc_compressed: bool, emit_lto_bc: bool, emit_ir: bool, emit_asm: bool, @@ -257,6 +259,7 @@ impl ModuleConfig { emit_no_opt_bc: false, emit_bc: false, + emit_bc_compressed: false, emit_lto_bc: false, emit_ir: false, emit_asm: false, @@ -627,20 +630,34 @@ unsafe fn codegen(cgcx: &CodegenContext, let bc_out = cgcx.output_filenames.temp_path(OutputType::Bitcode, module_name); let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, module_name); - if write_bc { - let bc_out_c = path2cstr(&bc_out); - if llvm::LLVMRustThinLTOAvailable() { - with_codegen(tm, llmod, config.no_builtins, |cpm| { - llvm::LLVMRustWriteThinBitcodeToFile( - cpm, - llmod, - bc_out_c.as_ptr(), - ) - }); + + if write_bc || config.emit_bc_compressed { + let thin; + let old; + let data = if llvm::LLVMRustThinLTOAvailable() { + thin = ThinBuffer::new(llmod); + thin.data() } else { - llvm::LLVMWriteBitcodeToFile(llmod, bc_out_c.as_ptr()); + old = ModuleBuffer::new(llmod); + old.data() + }; + timeline.record("make-bc"); + + if write_bc { + if let Err(e) = File::create(&bc_out).and_then(|mut f| f.write_all(data)) { + diag_handler.err(&format!("failed to write bytecode: {}", e)); + } + timeline.record("write-bc"); + } + + if config.emit_bc_compressed { + let dst = bc_out.with_extension(RLIB_BYTECODE_EXTENSION); + let data = bytecode::encode(&mtrans.llmod_id, data); + if let Err(e) = File::create(&dst).and_then(|mut f| f.write_all(&data)) { + diag_handler.err(&format!("failed to write bytecode: {}", e)); + } + timeline.record("compress-bc"); } - timeline.record("bc"); } time(config.time_passes, &format!("codegen passes [{}]", module_name.unwrap()), @@ -736,6 +753,7 @@ unsafe fn codegen(cgcx: &CodegenContext, drop(handlers); Ok(mtrans.into_compiled_module(config.emit_obj, config.emit_bc, + config.emit_bc_compressed, &cgcx.output_filenames)) } @@ -822,11 +840,12 @@ pub fn start_async_translation(tcx: TyCtxt, allocator_config.emit_bc = true; } - // Emit bitcode files for the crate if we're emitting an rlib. - // Whenever an rlib is created, the bitcode is inserted into the - // archive in order to allow LTO against it. + // Emit compressed bitcode files for the crate if we're emitting an rlib. + // Whenever an rlib is created, the bitcode is inserted into the archive in + // order to allow LTO against it. if need_crate_bitcode_for_rlib(sess) { - modules_config.emit_bc = true; + modules_config.emit_bc_compressed = true; + allocator_config.emit_bc_compressed = true; } for output_type in output_types_override.keys() { @@ -906,8 +925,7 @@ pub fn start_async_translation(tcx: TyCtxt, fn copy_module_artifacts_into_incr_comp_cache(sess: &Session, dep_graph: &DepGraph, - compiled_modules: &CompiledModules, - crate_output: &OutputFilenames) { + compiled_modules: &CompiledModules) { if sess.opts.incremental.is_none() { return; } @@ -915,20 +933,17 @@ fn copy_module_artifacts_into_incr_comp_cache(sess: &Session, for module in compiled_modules.modules.iter() { let mut files = vec![]; - if module.emit_obj { - let path = crate_output.temp_path(OutputType::Object, Some(&module.name)); - files.push((OutputType::Object, path)); + if let Some(ref path) = module.object { + files.push((WorkProductFileKind::Object, path.clone())); } - - if module.emit_bc { - let path = crate_output.temp_path(OutputType::Bitcode, Some(&module.name)); - files.push((OutputType::Bitcode, path)); + if let Some(ref path) = module.bytecode { + files.push((WorkProductFileKind::Bytecode, path.clone())); + } + if let Some(ref path) = module.bytecode_compressed { + files.push((WorkProductFileKind::BytecodeCompressed, path.clone())); } - save_trans_partition(sess, - dep_graph, - &module.name, - &files); + save_trans_partition(sess, dep_graph, &module.name, &files); } } @@ -1032,8 +1047,6 @@ fn produce_final_output_artifacts(sess: &Session, // well. // Specific rules for keeping .#module-name#.bc: - // - If we're building an rlib (`needs_crate_bitcode`), then keep - // it. // - If the user requested bitcode (`user_wants_bitcode`), and // codegen_units > 1, then keep it. // - If the user requested bitcode but codegen_units == 1, then we @@ -1043,41 +1056,37 @@ fn produce_final_output_artifacts(sess: &Session, // If you change how this works, also update back::link::link_rlib, // where .#module-name#.bc files are (maybe) deleted after making an // rlib. - let needs_crate_bitcode = need_crate_bitcode_for_rlib(sess); let needs_crate_object = crate_output.outputs.contains_key(&OutputType::Exe); - let keep_numbered_bitcode = needs_crate_bitcode || - (user_wants_bitcode && sess.codegen_units() > 1); + let keep_numbered_bitcode = user_wants_bitcode && sess.codegen_units() > 1; let keep_numbered_objects = needs_crate_object || (user_wants_objects && sess.codegen_units() > 1); for module in compiled_modules.modules.iter() { - let module_name = Some(&module.name[..]); - - if module.emit_obj && !keep_numbered_objects { - let path = crate_output.temp_path(OutputType::Object, module_name); - remove(sess, &path); + if let Some(ref path) = module.object { + if !keep_numbered_objects { + remove(sess, path); + } } - if module.emit_bc && !keep_numbered_bitcode { - let path = crate_output.temp_path(OutputType::Bitcode, module_name); - remove(sess, &path); + if let Some(ref path) = module.bytecode { + if !keep_numbered_bitcode { + remove(sess, path); + } } } - if compiled_modules.metadata_module.emit_bc && !user_wants_bitcode { - let path = crate_output.temp_path(OutputType::Bitcode, - Some(&compiled_modules.metadata_module.name)); - remove(sess, &path); - } - - if let Some(ref allocator_module) = compiled_modules.allocator_module { - if allocator_module.emit_bc && !user_wants_bitcode { - let path = crate_output.temp_path(OutputType::Bitcode, - Some(&allocator_module.name)); + if !user_wants_bitcode { + if let Some(ref path) = compiled_modules.metadata_module.bytecode { remove(sess, &path); } + + if let Some(ref allocator_module) = compiled_modules.allocator_module { + if let Some(ref path) = allocator_module.bytecode { + remove(sess, path); + } + } } } @@ -1149,8 +1158,28 @@ fn execute_work_item(cgcx: &CodegenContext, .as_ref() .unwrap(); let name = &mtrans.name; + let mut object = None; + let mut bytecode = None; + let mut bytecode_compressed = None; for (kind, saved_file) in wp.saved_files { - let obj_out = cgcx.output_filenames.temp_path(kind, Some(name)); + let obj_out = match kind { + WorkProductFileKind::Object => { + let path = cgcx.output_filenames.temp_path(OutputType::Object, Some(name)); + object = Some(path.clone()); + path + } + WorkProductFileKind::Bytecode => { + let path = cgcx.output_filenames.temp_path(OutputType::Bitcode, Some(name)); + bytecode = Some(path.clone()); + path + } + WorkProductFileKind::BytecodeCompressed => { + let path = cgcx.output_filenames.temp_path(OutputType::Bitcode, Some(name)) + .with_extension(RLIB_BYTECODE_EXTENSION); + bytecode_compressed = Some(path.clone()); + path + } + }; let source_file = in_incr_comp_dir(&incr_comp_session_dir, &saved_file); debug!("copying pre-existing module `{}` from {:?} to {}", @@ -1167,16 +1196,18 @@ fn execute_work_item(cgcx: &CodegenContext, } } } - let object = cgcx.output_filenames.temp_path(OutputType::Object, Some(name)); + assert_eq!(object.is_some(), config.emit_obj); + assert_eq!(bytecode.is_some(), config.emit_bc); + assert_eq!(bytecode_compressed.is_some(), config.emit_bc_compressed); Ok(WorkItemResult::Compiled(CompiledModule { - object, llmod_id: mtrans.llmod_id.clone(), name: module_name, kind: ModuleKind::Regular, pre_existing: true, - emit_bc: config.emit_bc, - emit_obj: config.emit_obj, + object, + bytecode, + bytecode_compressed, })) } else { debug!("llvm-optimizing {:?}", module_name); @@ -2053,8 +2084,7 @@ impl OngoingCrateTranslation { copy_module_artifacts_into_incr_comp_cache(sess, dep_graph, - &compiled_modules, - &self.output_filenames); + &compiled_modules); produce_final_output_artifacts(sess, &compiled_modules, &self.output_filenames); @@ -2075,6 +2105,7 @@ impl OngoingCrateTranslation { modules: compiled_modules.modules, allocator_module: compiled_modules.allocator_module, + metadata_module: compiled_modules.metadata_module, }; if self.no_integrated_as { diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 547b1f7b2bf96..5ad3a7d26558a 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1312,7 +1312,8 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // 1. http://llvm.org/bugs/show_bug.cgi?id=11479 let llmod_id = format!("{}-{}.rs", cgu.name(), - tcx.crate_disambiguator(LOCAL_CRATE)); + tcx.crate_disambiguator(LOCAL_CRATE) + .to_fingerprint().to_hex()); // Instantiate translation items without filling out definitions yet... let scx = SharedCrateContext::new(tcx); diff --git a/src/librustc_trans/builder.rs b/src/librustc_trans/builder.rs index 41a238ea8e3fa..b366d5579c3d1 100644 --- a/src/librustc_trans/builder.rs +++ b/src/librustc_trans/builder.rs @@ -112,6 +112,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } + pub fn set_value_name(&self, value: ValueRef, name: &str) { + let cname = CString::new(name.as_bytes()).unwrap(); + unsafe { + llvm::LLVMSetValueName(value, cname.as_ptr()); + } + } + pub fn position_before(&self, insn: ValueRef) { unsafe { llvm::LLVMPositionBuilderBefore(self.llbuilder, insn); diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 1722d008a54c2..9df057c77a95d 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -32,6 +32,7 @@ use rustc::session::Session; use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::FxHashMap; +use rustc_trans_utils; use std::ffi::{CStr, CString}; use std::cell::{Cell, RefCell}; @@ -301,6 +302,10 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { common::type_is_freeze(self.tcx, ty) } + pub fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool { + rustc_trans_utils::common::type_has_metadata(self.tcx, ty) + } + pub fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx } @@ -642,7 +647,7 @@ impl<'a, 'tcx> LayoutTyper<'tcx> for &'a SharedCrateContext<'a, 'tcx> { } fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx> { - self.tcx().normalize_associated_type(&ty) + self.tcx().fully_normalize_associated_types_in(&ty) } } diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 201d786776455..4f07af9071da3 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -543,6 +543,11 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, trait_pointer_metadata(cx, t, None, unique_type_id), false) } + ty::TyForeign(..) => { + MetadataCreationResult::new( + foreign_type_metadata(cx, t, unique_type_id), + false) + } ty::TyRawPtr(ty::TypeAndMut{ty, ..}) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) => { match ptr_metadata(ty) { @@ -582,7 +587,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } ty::TyGenerator(def_id, substs, _) => { let upvar_tys : Vec<_> = substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().normalize_associated_type(&t) + cx.tcx().fully_normalize_associated_types_in(&t) }).collect(); prepare_tuple_metadata(cx, t, @@ -752,6 +757,17 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, return ty_metadata; } +fn foreign_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, + t: Ty<'tcx>, + unique_type_id: UniqueTypeId) -> DIType { + debug!("foreign_type_metadata: {:?}", t); + + let llvm_type = type_of::type_of(cx, t); + + let name = compute_debuginfo_type_name(cx, t, false); + create_struct_stub(cx, llvm_type, &name, unique_type_id, NO_SCOPE_METADATA) +} + fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, pointer_type: Ty<'tcx>, pointee_type_metadata: DIType) diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 7e2ac95cd845c..1a28429201618 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -376,7 +376,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, name_to_append_suffix_to.push_str(","); } - let actual_type = cx.tcx().normalize_associated_type(&actual_type); + let actual_type = cx.tcx().fully_normalize_associated_types_in(&actual_type); // Add actual type name to <...> clause of function name let actual_type_name = compute_debuginfo_type_name(cx, actual_type, @@ -389,7 +389,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo { let names = get_type_parameter_names(cx, generics); substs.types().zip(names).map(|(ty, name)| { - let actual_type = cx.tcx().normalize_associated_type(&ty); + let actual_type = cx.tcx().fully_normalize_associated_types_in(&ty); let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); let name = CString::new(name.as_str().as_bytes()).unwrap(); unsafe { diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index 7bf9d39ea2f25..85467f5bfbd22 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -48,6 +48,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::TyInt(int_ty) => output.push_str(int_ty.ty_to_string()), ty::TyUint(uint_ty) => output.push_str(uint_ty.ty_to_string()), ty::TyFloat(float_ty) => output.push_str(float_ty.ty_to_string()), + ty::TyForeign(def_id) => push_item_name(cx, def_id, qualified, output), ty::TyAdt(def, substs) => { push_item_name(cx, def.did, qualified, output); push_type_params(cx, substs, output); diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index f78d80a197ca9..e80239175681e 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -139,13 +139,15 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, } "size_of_val" => { let tp_ty = substs.type_at(0); - if !bcx.ccx.shared().type_is_sized(tp_ty) { + if bcx.ccx.shared().type_is_sized(tp_ty) { + let lltp_ty = type_of::type_of(ccx, tp_ty); + C_usize(ccx, machine::llsize_of_alloc(ccx, lltp_ty)) + } else if bcx.ccx.shared().type_has_metadata(tp_ty) { let (llsize, _) = glue::size_and_align_of_dst(bcx, tp_ty, llargs[1]); llsize } else { - let lltp_ty = type_of::type_of(ccx, tp_ty); - C_usize(ccx, machine::llsize_of_alloc(ccx, lltp_ty)) + C_usize(ccx, 0u64) } } "min_align_of" => { @@ -154,12 +156,14 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, } "min_align_of_val" => { let tp_ty = substs.type_at(0); - if !bcx.ccx.shared().type_is_sized(tp_ty) { + if bcx.ccx.shared().type_is_sized(tp_ty) { + C_usize(ccx, ccx.align_of(tp_ty) as u64) + } else if bcx.ccx.shared().type_has_metadata(tp_ty) { let (_, llalign) = glue::size_and_align_of_dst(bcx, tp_ty, llargs[1]); llalign } else { - C_usize(ccx, ccx.align_of(tp_ty) as u64) + C_usize(ccx, 1u64) } } "pref_align_of" => { diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 88ec3a65d3577..c0460fb4852e9 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -30,9 +30,8 @@ #![feature(slice_patterns)] #![feature(conservative_impl_trait)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(const_atomic_bool_new))] -#![cfg_attr(not(stage0), feature(const_once_new))] +#![feature(const_atomic_bool_new)] +#![feature(const_once_new)] use rustc::dep_graph::WorkProduct; use syntax_pos::symbol::Symbol; @@ -64,6 +63,7 @@ extern crate serialize; extern crate cc; // Used to locate MSVC pub use base::trans_crate; +use back::bytecode::RLIB_BYTECODE_EXTENSION; pub use metadata::LlvmMetadataLoader; pub use llvm_util::{init, target_features, print_version, print_passes, print, enable_llvm_debug}; @@ -90,7 +90,7 @@ mod diagnostics; pub mod back { mod archive; - mod bytecode; + pub mod bytecode; mod command; pub(crate) mod linker; pub mod link; @@ -227,21 +227,37 @@ impl ModuleTranslation { pub fn into_compiled_module(self, emit_obj: bool, emit_bc: bool, + emit_bc_compressed: bool, outputs: &OutputFilenames) -> CompiledModule { let pre_existing = match self.source { ModuleSource::Preexisting(_) => true, ModuleSource::Translated(_) => false, }; - let object = outputs.temp_path(OutputType::Object, Some(&self.name)); + let object = if emit_obj { + Some(outputs.temp_path(OutputType::Object, Some(&self.name))) + } else { + None + }; + let bytecode = if emit_bc { + Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name))) + } else { + None + }; + let bytecode_compressed = if emit_bc_compressed { + Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)) + .with_extension(RLIB_BYTECODE_EXTENSION)) + } else { + None + }; CompiledModule { llmod_id: self.llmod_id, name: self.name.clone(), kind: self.kind, pre_existing, - emit_obj, - emit_bc, object, + bytecode, + bytecode_compressed, } } } @@ -250,11 +266,11 @@ impl ModuleTranslation { pub struct CompiledModule { pub name: String, pub llmod_id: String, - pub object: PathBuf, pub kind: ModuleKind, pub pre_existing: bool, - pub emit_obj: bool, - pub emit_bc: bool, + pub object: Option, + pub bytecode: Option, + pub bytecode_compressed: Option, } pub enum ModuleSource { @@ -289,6 +305,7 @@ pub struct CrateTranslation { pub crate_name: Symbol, pub modules: Vec, allocator_module: Option, + metadata_module: CompiledModule, pub link: rustc::middle::cstore::LinkMeta, pub metadata: rustc::middle::cstore::EncodedMetadata, windows_subsystem: Option, diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index 1017ec6b3c3f8..00815be278ee0 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -64,11 +64,18 @@ struct LocalAnalyzer<'mir, 'a: 'mir, 'tcx: 'a> { impl<'mir, 'a, 'tcx> LocalAnalyzer<'mir, 'a, 'tcx> { fn new(mircx: &'mir MirContext<'a, 'tcx>) -> LocalAnalyzer<'mir, 'a, 'tcx> { - LocalAnalyzer { + let mut analyzer = LocalAnalyzer { cx: mircx, lvalue_locals: BitVector::new(mircx.mir.local_decls.len()), seen_assigned: BitVector::new(mircx.mir.local_decls.len()) + }; + + // Arguments get assigned to by means of the function being called + for idx in 0..mircx.mir.arg_count { + analyzer.seen_assigned.insert(idx + 1); } + + analyzer } fn mark_as_lvalue(&mut self, local: mir::Local) { diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index 1b8e68f691ae6..cea7b9585d8e3 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -428,11 +428,11 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { .projection_ty(tcx, &projection.elem); let base = tr_base.to_const(span); let projected_ty = self.monomorphize(&projected_ty).to_ty(tcx); - let is_sized = self.ccx.shared().type_is_sized(projected_ty); + let has_metadata = self.ccx.shared().type_has_metadata(projected_ty); let (projected, llextra) = match projection.elem { mir::ProjectionElem::Deref => { - let (base, extra) = if is_sized { + let (base, extra) = if !has_metadata { (base.llval, ptr::null_mut()) } else { base.get_fat_ptr() @@ -463,7 +463,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { mir::ProjectionElem::Field(ref field, _) => { let llprojected = adt::const_get_field(self.ccx, tr_base.ty, base.llval, field.index()); - let llextra = if is_sized { + let llextra = if !has_metadata { ptr::null_mut() } else { tr_base.llextra diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs index 6799e52904d34..d939acaccd99c 100644 --- a/src/librustc_trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -147,15 +147,16 @@ impl<'a, 'tcx> LvalueRef<'tcx> { // * Packed struct - There is no alignment padding // * Field is sized - pointer is properly aligned already if st.offsets[ix] == layout::Size::from_bytes(0) || st.packed || - bcx.ccx.shared().type_is_sized(fty) { - return (bcx.struct_gep( - ptr_val, adt::struct_llfields_index(st, ix)), alignment); - } + bcx.ccx.shared().type_is_sized(fty) + { + return (bcx.struct_gep( + ptr_val, adt::struct_llfields_index(st, ix)), alignment); + } - // If the type of the last field is [T] or str, then we don't need to do + // If the type of the last field is [T], str or a foreign type, then we don't need to do // any adjusments match fty.sty { - ty::TySlice(..) | ty::TyStr => { + ty::TySlice(..) | ty::TyStr | ty::TyForeign(..) => { return (bcx.struct_gep( ptr_val, adt::struct_llfields_index(st, ix)), alignment); } @@ -328,7 +329,9 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { let ((llprojected, align), llextra) = match projection.elem { mir::ProjectionElem::Deref => bug!(), mir::ProjectionElem::Field(ref field, _) => { - let llextra = if self.ccx.shared().type_is_sized(projected_ty.to_ty(tcx)) { + let has_metadata = self.ccx.shared() + .type_has_metadata(projected_ty.to_ty(tcx)); + let llextra = if !has_metadata { ptr::null_mut() } else { tr_base.llextra @@ -415,3 +418,4 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { self.monomorphize(&lvalue_ty.to_ty(tcx)) } } + diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index d5d44bfa7ba43..59da80035fd36 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -386,6 +386,12 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, let arg_decl = &mir.local_decls[local]; let arg_ty = mircx.monomorphize(&arg_decl.ty); + let name = if let Some(name) = arg_decl.name { + name.as_str().to_string() + } else { + format!("arg{}", arg_index) + }; + if Some(local) == mir.spread_arg { // This argument (e.g. the last argument in the "rust-call" ABI) // is a tuple that was spread at the ABI level and now we have @@ -397,7 +403,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, _ => bug!("spread argument isn't a tuple?!") }; - let lvalue = LvalueRef::alloca(bcx, arg_ty, &format!("arg{}", arg_index)); + let lvalue = LvalueRef::alloca(bcx, arg_ty, &name); for (i, &tupled_arg_ty) in tupled_arg_tys.iter().enumerate() { let (dst, _) = lvalue.trans_field_ptr(bcx, i); let arg = &mircx.fn_ty.args[idx]; @@ -444,6 +450,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, llarg_idx += 1; } let llarg = llvm::get_param(bcx.llfn(), llarg_idx as c_uint); + bcx.set_value_name(llarg, &name); llarg_idx += 1; llarg } else if !lvalue_locals.contains(local.index()) && @@ -481,10 +488,13 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, let meta_llty = type_of::unsized_info_ty(bcx.ccx, pointee); let llarg = bcx.pointercast(llarg, data_llty.ptr_to()); + bcx.set_value_name(llarg, &(name.clone() + ".ptr")); let llmeta = bcx.pointercast(llmeta, meta_llty); + bcx.set_value_name(llmeta, &(name + ".meta")); OperandValue::Pair(llarg, llmeta) } else { + bcx.set_value_name(llarg, &name); OperandValue::Immediate(llarg) }; let operand = OperandRef { @@ -493,7 +503,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, }; return LocalRef::Operand(Some(operand.unpack_if_pair(bcx))); } else { - let lltemp = LvalueRef::alloca(bcx, arg_ty, &format!("arg{}", arg_index)); + let lltemp = LvalueRef::alloca(bcx, arg_ty, &name); if common::type_is_fat_ptr(bcx.ccx, arg_ty) { // we pass fat pointers as two words, but we want to // represent them internally as a pointer to two words, diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index 822431eba42f1..777b86387e8bf 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -364,7 +364,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { // Note: lvalues are indirect, so storing the `llval` into the // destination effectively creates a reference. - let operand = if bcx.ccx.shared().type_is_sized(ty) { + let operand = if !bcx.ccx.shared().type_has_metadata(ty) { OperandRef { val: OperandValue::Immediate(tr_lvalue.llval), ty: ref_ty, diff --git a/src/librustc_trans/trans_item.rs b/src/librustc_trans/trans_item.rs index db1af8cdefbe9..fb68be293a79e 100644 --- a/src/librustc_trans/trans_item.rs +++ b/src/librustc_trans/trans_item.rs @@ -230,4 +230,3 @@ fn predefine_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ccx.instances().borrow_mut().insert(instance, lldecl); } - diff --git a/src/librustc_trans/type_of.rs b/src/librustc_trans/type_of.rs index 992c74b9020c3..cac09a81361f0 100644 --- a/src/librustc_trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -22,7 +22,7 @@ use syntax::ast; pub fn fat_ptr_base_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type { match ty.sty { ty::TyRef(_, ty::TypeAndMut { ty: t, .. }) | - ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) if !ccx.shared().type_is_sized(t) => { + ty::TyRawPtr(ty::TypeAndMut { ty: t, .. }) if ccx.shared().type_has_metadata(t) => { in_memory_type_of(ccx, t).ptr_to() } ty::TyAdt(def, _) if def.is_box() => { @@ -62,7 +62,7 @@ pub fn immediate_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> /// is too large for it to be placed in SSA value (by our rules). /// For the raw type without far pointer indirection, see `in_memory_type_of`. pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type { - let ty = if !cx.shared().type_is_sized(ty) { + let ty = if cx.shared().type_has_metadata(ty) { cx.tcx().mk_imm_ptr(ty) } else { ty @@ -106,7 +106,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> } let ptr_ty = |ty: Ty<'tcx>| { - if !cx.shared().type_is_sized(ty) { + if cx.shared().type_has_metadata(ty) { if let ty::TyStr = ty.sty { // This means we get a nicer name in the output (str is always // unsized). @@ -158,7 +158,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> // fat pointers is of the right type (e.g. for array accesses), even // when taking the address of an unsized field in a struct. ty::TySlice(ty) => in_memory_type_of(cx, ty), - ty::TyStr | ty::TyDynamic(..) => Type::i8(cx), + ty::TyStr | ty::TyDynamic(..) | ty::TyForeign(..) => Type::i8(cx), ty::TyFnDef(..) => Type::nil(cx), ty::TyFnPtr(sig) => { diff --git a/src/librustc_trans_utils/collector.rs b/src/librustc_trans_utils/collector.rs index c87d86262efdd..cf9b80e5ed404 100644 --- a/src/librustc_trans_utils/collector.rs +++ b/src/librustc_trans_utils/collector.rs @@ -203,7 +203,7 @@ use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::mir::{self, Location}; use rustc::mir::visit::Visitor as MirVisitor; -use common::{def_ty, instance_ty, type_is_sized}; +use common::{def_ty, instance_ty, type_has_metadata}; use monomorphize::{self, Instance}; use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap}; @@ -782,7 +782,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, target_ty: Ty<'tcx>) -> (Ty<'tcx>, Ty<'tcx>) { let ptr_vtable = |inner_source: Ty<'tcx>, inner_target: Ty<'tcx>| { - if !type_is_sized(tcx, inner_source) { + if type_has_metadata(tcx, inner_source) { (inner_source, inner_target) } else { tcx.struct_lockstep_tails(inner_source, inner_target) diff --git a/src/librustc_trans_utils/common.rs b/src/librustc_trans_utils/common.rs index 634e37220e2f1..ec9c5b1119b74 100644 --- a/src/librustc_trans_utils/common.rs +++ b/src/librustc_trans_utils/common.rs @@ -25,6 +25,19 @@ pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> boo ty.is_sized(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP) } +pub fn type_has_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { + if type_is_sized(tcx, ty) { + return false; + } + + let tail = tcx.struct_tail(ty); + match tail.sty { + ty::TyForeign(..) => false, + ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true, + _ => bug!("unexpected unsized tail: {:?}", tail.sty), + } +} + pub fn requests_inline<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &ty::Instance<'tcx> diff --git a/src/librustc_trans_utils/lib.rs b/src/librustc_trans_utils/lib.rs index bc8f8d5a6da2d..6a341a1e7d378 100644 --- a/src/librustc_trans_utils/lib.rs +++ b/src/librustc_trans_utils/lib.rs @@ -27,8 +27,6 @@ #![feature(slice_patterns)] #![feature(conservative_impl_trait)] -#![cfg_attr(stage0, feature(const_fn))] - extern crate ar; extern crate flate2; extern crate owning_ref; @@ -50,7 +48,7 @@ use rustc::util::nodemap::NodeSet; use syntax::attr; -mod common; +pub mod common; pub mod link; pub mod collector; pub mod trans_item; diff --git a/src/librustc_trans_utils/monomorphize.rs b/src/librustc_trans_utils/monomorphize.rs index 471be439a8f3b..ab61dacf010ae 100644 --- a/src/librustc_trans_utils/monomorphize.rs +++ b/src/librustc_trans_utils/monomorphize.rs @@ -131,6 +131,6 @@ pub fn field_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &'tcx ty::FieldDef) -> Ty<'tcx> { - tcx.normalize_associated_type(&f.ty(tcx, param_substs)) + tcx.fully_normalize_associated_types_in(&f.ty(tcx, param_substs)) } diff --git a/src/librustc_trans_utils/trans_item.rs b/src/librustc_trans_utils/trans_item.rs index 0ada39d7d2711..817ceefeb7fe9 100644 --- a/src/librustc_trans_utils/trans_item.rs +++ b/src/librustc_trans_utils/trans_item.rs @@ -335,6 +335,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { output); } }, + ty::TyForeign(did) => self.push_def_path(did, output), ty::TyFnDef(..) | ty::TyFnPtr(_) => { let sig = t.fn_sig(self.tcx); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 7c9497badfbea..c7f7e62fd61ef 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -928,7 +928,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let span = path.span; match path.def { - Def::Enum(did) | Def::TyAlias(did) | Def::Struct(did) | Def::Union(did) => { + Def::Enum(did) | Def::TyAlias(did) | Def::Struct(did) | + Def::Union(did) | Def::TyForeign(did) => { assert_eq!(opt_self_ty, None); self.prohibit_type_params(path.segments.split_last().unwrap().1); self.ast_path_to_ty(span, did, path.segments.last().unwrap()) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 9c6cacb9d25f9..7b35b46683099 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -13,7 +13,7 @@ //! A cast `e as U` is valid if one of the following holds: //! * `e` has type `T` and `T` coerces to `U`; *coercion-cast* //! * `e` has type `*T`, `U` is `*U_0`, and either `U_0: Sized` or -//! unsize_kind(`T`) = unsize_kind(`U_0`); *ptr-ptr-cast* +//! pointer_kind(`T`) = pointer_kind(`U_0`); *ptr-ptr-cast* //! * `e` has type `*T` and `U` is a numeric type, while `T: Sized`; *ptr-addr-cast* //! * `e` is an integer and `U` is `*U_0`, while `U_0: Sized`; *addr-ptr-cast* //! * `e` has type `T` and `T` and `U` are any numeric types; *numeric-cast* @@ -26,7 +26,7 @@ //! * `e` is a function pointer type and `U` is an integer; *fptr-addr-cast* //! //! where `&.T` and `*T` are references of either mutability, -//! and where unsize_kind(`T`) is the kind of the unsize info +//! and where pointer_kind(`T`) is the kind of the unsize info //! in `T` - the vtable for a trait definition (e.g. `fmt::Display` or //! `Iterator`, not `Iterator`) or a length (or `()` if `T: Sized`). //! @@ -64,11 +64,16 @@ pub struct CastCheck<'tcx> { span: Span, } -/// The kind of the unsize info (length or vtable) - we only allow casts between -/// fat pointers if their unsize-infos have the same kind. +/// The kind of pointer and associated metadata (thin, length or vtable) - we +/// only allow casts between fat pointers if their metadata have the same +/// kind. #[derive(Copy, Clone, PartialEq, Eq)] -enum UnsizeKind<'tcx> { +enum PointerKind<'tcx> { + /// No metadata attached, ie pointer to sized type or foreign type + Thin, + /// A trait object Vtable(Option), + /// Slice Length, /// The unsize info of this projection OfProjection(&'tcx ty::ProjectionTy<'tcx>), @@ -79,22 +84,28 @@ enum UnsizeKind<'tcx> { impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// Returns the kind of unsize information of t, or None /// if t is sized or it is unknown. - fn unsize_kind(&self, t: Ty<'tcx>) -> Option> { + fn pointer_kind(&self, t: Ty<'tcx>, span: Span) -> PointerKind<'tcx> { + if self.type_is_known_to_be_sized(t, span) { + return PointerKind::Thin; + } + match t.sty { - ty::TySlice(_) | ty::TyStr => Some(UnsizeKind::Length), + ty::TySlice(_) | ty::TyStr => PointerKind::Length, ty::TyDynamic(ref tty, ..) => - Some(UnsizeKind::Vtable(tty.principal().map(|p| p.def_id()))), + PointerKind::Vtable(tty.principal().map(|p| p.def_id())), ty::TyAdt(def, substs) if def.is_struct() => { // FIXME(arielb1): do some kind of normalization match def.struct_variant().fields.last() { - None => None, - Some(f) => self.unsize_kind(f.ty(self.tcx, substs)), + None => PointerKind::Thin, + Some(f) => self.pointer_kind(f.ty(self.tcx, substs), span), } } + // Pointers to foreign types are thin, despite being unsized + ty::TyForeign(..) => PointerKind::Thin, // We should really try to normalize here. - ty::TyProjection(ref pi) => Some(UnsizeKind::OfProjection(pi)), - ty::TyParam(ref p) => Some(UnsizeKind::OfParam(p)), - _ => None, + ty::TyProjection(ref pi) => PointerKind::OfProjection(pi), + ty::TyParam(ref p) => PointerKind::OfParam(p), + _ => panic!(), } } } @@ -446,20 +457,23 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", m_expr, m_cast); // ptr-ptr cast. vtables must match. - // Cast to sized is OK - if fcx.type_is_known_to_be_sized(m_cast.ty, self.span) { + // Cast to thin pointer is OK + let cast_kind = fcx.pointer_kind(m_cast.ty, self.span); + if cast_kind == PointerKind::Thin { return Ok(CastKind::PtrPtrCast); } - // sized -> unsized? report invalid cast (don't complain about vtable kinds) - if fcx.type_is_known_to_be_sized(m_expr.ty, self.span) { + // thin -> fat? report invalid cast (don't complain about vtable kinds) + let expr_kind = fcx.pointer_kind(m_expr.ty, self.span); + if expr_kind == PointerKind::Thin { return Err(CastError::SizedUnsizedCast); } // vtable kinds must match - match (fcx.unsize_kind(m_cast.ty), fcx.unsize_kind(m_expr.ty)) { - (Some(a), Some(b)) if a == b => Ok(CastKind::PtrPtrCast), - _ => Err(CastError::DifferingKinds), + if cast_kind == expr_kind { + Ok(CastKind::PtrPtrCast) + } else { + Err(CastError::DifferingKinds) } } @@ -467,9 +481,9 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { fcx: &FnCtxt<'a, 'gcx, 'tcx>, m_cast: &'tcx ty::TypeAndMut<'tcx>) -> Result { - // fptr-ptr cast. must be to sized ptr + // fptr-ptr cast. must be to thin ptr - if fcx.type_is_known_to_be_sized(m_cast.ty, self.span) { + if fcx.pointer_kind(m_cast.ty, self.span) == PointerKind::Thin { Ok(CastKind::FnPtrPtrCast) } else { Err(CastError::IllegalCast) @@ -480,9 +494,9 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { fcx: &FnCtxt<'a, 'gcx, 'tcx>, m_expr: &'tcx ty::TypeAndMut<'tcx>) -> Result { - // ptr-addr cast. must be from sized ptr + // ptr-addr cast. must be from thin ptr - if fcx.type_is_known_to_be_sized(m_expr.ty, self.span) { + if fcx.pointer_kind(m_expr.ty, self.span) == PointerKind::Thin { Ok(CastKind::PtrAddrCast) } else { Err(CastError::NeedViaThinPtr) @@ -519,7 +533,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { m_cast: &'tcx ty::TypeAndMut<'tcx>) -> Result { // ptr-addr cast. pointer must be thin. - if fcx.type_is_known_to_be_sized(m_cast.ty, self.span) { + if fcx.pointer_kind(m_cast.ty, self.span) == PointerKind::Thin { Ok(CastKind::AddrPtrCast) } else { Err(CastError::IllegalCast) diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index b21d48886120c..554a858bcc173 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -568,15 +568,11 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let num_trait_m_type_params = trait_m_generics.types.len(); if num_impl_m_type_params != num_trait_m_type_params { let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); - let span = match tcx.hir.expect_impl_item(impl_m_node_id).node { - ImplItemKind::Method(ref impl_m_sig, _) => { - if impl_m_sig.generics.is_parameterized() { - impl_m_sig.generics.span - } else { - impl_m_span - } - } - _ => bug!("{:?} is not a method", impl_m), + let impl_m_item = tcx.hir.expect_impl_item(impl_m_node_id); + let span = if impl_m_item.generics.is_parameterized() { + impl_m_item.generics.span + } else { + impl_m_span }; let mut err = struct_span_err!(tcx.sess, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index d4eda13c6cd40..58d72e37d51cf 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -25,6 +25,8 @@ use syntax_pos::Span; use rustc::hir; +use std::rc::Rc; + pub use self::MethodError::*; pub use self::CandidateSource::*; @@ -163,7 +165,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(import_id) = pick.import_id { let import_def_id = self.tcx.hir.local_def_id(import_id); debug!("used_trait_import: {:?}", import_def_id); - self.tables.borrow_mut().used_trait_imports.insert(import_def_id); + Rc::get_mut(&mut self.tables.borrow_mut().used_trait_imports) + .unwrap().insert(import_def_id); } self.tcx.check_stability(pick.item.def_id, call_expr.id, span); @@ -361,7 +364,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(import_id) = pick.import_id { let import_def_id = self.tcx.hir.local_def_id(import_id); debug!("used_trait_import: {:?}", import_def_id); - self.tables.borrow_mut().used_trait_imports.insert(import_def_id); + Rc::get_mut(&mut self.tables.borrow_mut().used_trait_imports) + .unwrap().insert(import_def_id); } let def = pick.item.def(); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 78941cb3a5686..a24f420af80dc 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -414,6 +414,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { ty::TyAdt(def, _) => { self.assemble_inherent_impl_candidates_for_type(def.did); } + ty::TyForeign(did) => { + self.assemble_inherent_impl_candidates_for_type(did); + } ty::TyParam(p) => { self.assemble_inherent_candidates_from_param(self_ty, p); } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 23148406a111e..8613ec86b4a73 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -451,6 +451,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn is_local(ty: Ty) -> bool { match ty.sty { ty::TyAdt(def, _) => def.did.is_local(), + ty::TyForeign(did) => did.is_local(), ty::TyDynamic(ref tr, ..) => tr.principal() .map_or(false, |p| p.def_id().is_local()), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d4616a7c304ae..c82cafd3a62ed 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -106,9 +106,10 @@ use session::{CompileIncomplete, Session}; use TypeAndSubsts; use lint; use util::common::{ErrorReported, indenter}; -use util::nodemap::{DefIdMap, FxHashMap, NodeMap}; +use util::nodemap::{DefIdMap, DefIdSet, FxHashMap, NodeMap}; use std::cell::{Cell, RefCell, Ref, RefMut}; +use std::rc::Rc; use std::collections::hash_map::Entry; use std::cmp; use std::fmt::Display; @@ -742,6 +743,7 @@ pub fn provide(providers: &mut Providers) { closure_kind, generator_sig, adt_destructor, + used_trait_imports, ..*providers }; } @@ -845,6 +847,12 @@ fn has_typeck_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, primary_body_of(tcx, id).is_some() } +fn used_trait_imports<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId) + -> Rc { + tcx.typeck_tables_of(def_id).used_trait_imports.clone() +} + fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::TypeckTables<'tcx> { diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index b3648d357e515..ce2ac73a27e0c 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -23,6 +23,7 @@ use rustc::util::nodemap::DefIdSet; use syntax::ast; use syntax_pos::Span; use std::mem; +use std::rc::Rc; /////////////////////////////////////////////////////////////////////////// // Entry point @@ -49,7 +50,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { wbcx.visit_generator_interiors(); let used_trait_imports = mem::replace(&mut self.tables.borrow_mut().used_trait_imports, - DefIdSet()); + Rc::new(DefIdSet())); debug!("used_trait_imports({:?}) = {:?}", item_def_id, used_trait_imports); wbcx.tables.used_trait_imports = used_trait_imports; diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 0c35b5e6834de..b867a655b4a6a 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -66,10 +66,9 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut used_trait_imports = DefIdSet(); for &body_id in tcx.hir.krate().bodies.keys() { let item_def_id = tcx.hir.body_owner_def_id(body_id); - let tables = tcx.typeck_tables_of(item_def_id); - let imports = &tables.used_trait_imports; + let imports = tcx.used_trait_imports(item_def_id); debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports); - used_trait_imports.extend(imports); + used_trait_imports.extend(imports.iter()); } let mut visitor = CheckVisitor { tcx, used_trait_imports }; diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index 15e15abfb3606..c56a3b91ca37f 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -117,6 +117,9 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { ty::TyAdt(def, _) => { self.check_def_id(item, def.did); } + ty::TyForeign(did) => { + self.check_def_id(item, did); + } ty::TyDynamic(ref data, ..) if data.principal().is_some() => { self.check_def_id(item, data.principal().unwrap().def_id()); } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 097720adad447..a5edc95b79b08 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -68,10 +68,10 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { } // In addition to the above rules, we restrict impls of defaulted traits - // so that they can only be implemented on structs/enums. To see why this - // restriction exists, consider the following example (#22978). Imagine - // that crate A defines a defaulted trait `Foo` and a fn that operates - // on pairs of types: + // so that they can only be implemented on nominal types, such as structs, + // enums or foreign types. To see why this restriction exists, consider the + // following example (#22978). Imagine that crate A defines a defaulted trait + // `Foo` and a fn that operates on pairs of types: // // ``` // // Crate A @@ -109,11 +109,12 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { let self_ty = trait_ref.self_ty(); let opt_self_def_id = match self_ty.sty { ty::TyAdt(self_def, _) => Some(self_def.did), + ty::TyForeign(did) => Some(did), _ => None, }; let msg = match opt_self_def_id { - // We only want to permit structs/enums, but not *all* structs/enums. + // We only want to permit nominal types, but not *all* nominal types. // They must be local to the current crate, so that people // can't do `unsafe impl Send for Rc` or // `impl !Send for Box`. diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index a5b3f8cb806be..75e864d07a6c2 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -261,19 +261,9 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let item_node_id = tcx.hir.as_local_node_id(item_def_id).unwrap(); let ast_generics = match tcx.hir.get(item_node_id) { - NodeTraitItem(item) => { - match item.node { - TraitItemKind::Method(ref sig, _) => &sig.generics, - _ => return result - } - } + NodeTraitItem(item) => &item.generics, - NodeImplItem(item) => { - match item.node { - ImplItemKind::Method(ref sig, _) => &sig.generics, - _ => return result - } - } + NodeImplItem(item) => &item.generics, NodeItem(item) => { match item.node { @@ -818,12 +808,12 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match node { hir_map::NodeTraitItem(item) => match item.node { hir::TraitItemKind::Method(ref sig, _) => - has_late_bound_regions(tcx, &sig.generics, &sig.decl), + has_late_bound_regions(tcx, &item.generics, &sig.decl), _ => None, }, hir_map::NodeImplItem(item) => match item.node { hir::ImplItemKind::Method(ref sig, _) => - has_late_bound_regions(tcx, &sig.generics, &sig.decl), + has_late_bound_regions(tcx, &item.generics, &sig.decl), _ => None, }, hir_map::NodeForeignItem(item) => match item.node { @@ -881,19 +871,9 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let no_generics = hir::Generics::empty(); let ast_generics = match node { - NodeTraitItem(item) => { - match item.node { - TraitItemKind::Method(ref sig, _) => &sig.generics, - _ => &no_generics - } - } + NodeTraitItem(item) => &item.generics, - NodeImplItem(item) => { - match item.node { - ImplItemKind::Method(ref sig, _) => &sig.generics, - _ => &no_generics - } - } + NodeImplItem(item) => &item.generics, NodeItem(item) => { match item.node { @@ -936,7 +916,8 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(item) => { match item.node { ForeignItemStatic(..) => &no_generics, - ForeignItemFn(_, _, ref generics) => generics + ForeignItemFn(_, _, ref generics) => generics, + ForeignItemType => &no_generics, } } @@ -1114,7 +1095,8 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let substs = Substs::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } - ForeignItemStatic(ref t, _) => icx.to_ty(t) + ForeignItemStatic(ref t, _) => icx.to_ty(t), + ForeignItemType => tcx.mk_foreign(def_id), } } @@ -1353,19 +1335,9 @@ fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let icx = ItemCtxt::new(tcx, def_id); let no_generics = hir::Generics::empty(); let ast_generics = match node { - NodeTraitItem(item) => { - match item.node { - TraitItemKind::Method(ref sig, _) => &sig.generics, - _ => &no_generics - } - } + NodeTraitItem(item) => &item.generics, - NodeImplItem(item) => { - match item.node { - ImplItemKind::Method(ref sig, _) => &sig.generics, - _ => &no_generics - } - } + NodeImplItem(item) => &item.generics, NodeItem(item) => { match item.node { @@ -1393,7 +1365,8 @@ fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(item) => { match item.node { ForeignItemStatic(..) => &no_generics, - ForeignItemFn(_, _, ref generics) => generics + ForeignItemFn(_, _, ref generics) => generics, + ForeignItemType => &no_generics, } } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 8f91d07b53fb2..594cd0878cbfb 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -3986,6 +3986,10 @@ details. "##, E0599: r##" +This error occurs when a method is used on a type which doesn't implement it: + +Erroneous code example: + ```compile_fail,E0599 struct Mouth; diff --git a/src/librustc_typeck/variance/README.md b/src/librustc_typeck/variance/README.md index 592916178897c..64d3389b34af7 100644 --- a/src/librustc_typeck/variance/README.md +++ b/src/librustc_typeck/variance/README.md @@ -104,22 +104,16 @@ into two queries: - `crate_variances` computes the variance for all items in the current crate. - `variances_of` accesses the variance for an individual reading; it works by requesting `crate_variances` and extracting the relevant data. - + If you limit yourself to reading `variances_of`, your code will only depend then on the inference inferred for that particular item. -Eventually, the goal is to rely on the red-green dependency management -algorithm. At the moment, however, we rely instead on a hack, where -`variances_of` ignores the dependencies of accessing -`crate_variances` and instead computes the *correct* dependencies -itself. To this end, when we build up the constraints in the system, -we also built up a transitive `dependencies` relation as part of the -crate map. A `(X, Y)` pair is added to the map each time we have a -constraint that the variance of some inferred for the item `X` depends -on the variance of some element of `Y`. This is to some extent a -mirroring of the inference graph in the dependency graph. This means -we can just completely ignore the fixed-point iteration, since it is -just shuffling values along this graph. +Ultimately, this setup relies on the red-green algorithm. +In particular, every variance query ultimately depends on -- effectively -- +all type definitions in the entire crate (through `crate_variances`), +but since most changes will not result in a change +to the actual results from variance inference, +the `variances_of` query will wind up being considered green after it is re-evaluated. ### Addendum: Variance on traits diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index c1653cfb43bc8..ef6552c8e33f4 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -22,7 +22,6 @@ use syntax::ast; use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; -use rustc_data_structures::transitive_relation::TransitiveRelation; use rustc_data_structures::stable_hasher::StableHashingContextProvider; use super::terms::*; @@ -38,11 +37,6 @@ pub struct ConstraintContext<'a, 'tcx: 'a> { bivariant: VarianceTermPtr<'a>, pub constraints: Vec>, - - /// This relation tracks the dependencies between the variance of - /// various items. In particular, if `a < b`, then the variance of - /// `a` depends on the sources of `b`. - pub dependencies: TransitiveRelation, } /// Declares that the variable `decl_id` appears in a location with @@ -63,7 +57,6 @@ pub struct Constraint<'a> { /// then while we are visiting `Bar`, the `CurrentItem` would have /// the def-id and the start of `Foo`'s inferreds. pub struct CurrentItem { - def_id: DefId, inferred_start: InferredIndex, } @@ -81,7 +74,6 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>) invariant, bivariant, constraints: Vec::new(), - dependencies: TransitiveRelation::new(), }; tcx.hir.krate().visit_all_item_likes(&mut constraint_cx); @@ -201,7 +193,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { let id = tcx.hir.as_local_node_id(def_id).unwrap(); let inferred_start = self.terms_cx.inferred_starts[&id]; - let current_item = &CurrentItem { def_id, inferred_start }; + let current_item = &CurrentItem { inferred_start }; match tcx.type_of(def_id).sty { ty::TyAdt(def, _) => { // Not entirely obvious: constraints on structs/enums do not @@ -313,7 +305,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { match ty.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | - ty::TyStr | ty::TyNever => { + ty::TyStr | ty::TyNever | ty::TyForeign(..) => { // leaf type -- noop } @@ -410,12 +402,6 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { return; } - // Add a corresponding relation into the dependencies to - // indicate that the variance for `current` relies on `def_id`. - if self.tcx().dep_graph.is_fully_enabled() { - self.dependencies.add(current.def_id, def_id); - } - let (local, remote) = if let Some(id) = self.tcx().hir.as_local_node_id(def_id) { (Some(self.terms_cx.inferred_starts[&id]), None) } else { diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 7a9f35545e2f3..418d2b9467096 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -94,20 +94,9 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) // Everything else must be inferred. - // Lacking red/green, we read the variances for all items here - // but ignore the dependencies, then re-synthesize the ones we need. - let crate_map = tcx.dep_graph.with_ignore(|| tcx.crate_variances(LOCAL_CRATE)); + let crate_map = tcx.crate_variances(LOCAL_CRATE); let dep_node = item_def_id.to_dep_node(tcx, DepKind::ItemVarianceConstraints); tcx.dep_graph.read(dep_node); - for &dep_def_id in crate_map.dependencies.less_than(&item_def_id) { - if dep_def_id.is_local() { - let dep_node = dep_def_id.to_dep_node(tcx, DepKind::ItemVarianceConstraints); - tcx.dep_graph.read(dep_node); - } else { - let dep_node = dep_def_id.to_dep_node(tcx, DepKind::ItemVariances); - tcx.dep_graph.read(dep_node); - } - } crate_map.variances.get(&item_def_id) .unwrap_or(&crate_map.empty_variance) diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index 495eb95419a90..434e8ce148f3b 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -34,7 +34,7 @@ struct SolveContext<'a, 'tcx: 'a> { } pub fn solve_constraints(constraints_cx: ConstraintContext) -> ty::CrateVariancesMap { - let ConstraintContext { terms_cx, dependencies, constraints, .. } = constraints_cx; + let ConstraintContext { terms_cx, constraints, .. } = constraints_cx; let mut solutions = vec![ty::Bivariant; terms_cx.inferred_terms.len()]; for &(id, ref variances) in &terms_cx.lang_items { @@ -53,7 +53,7 @@ pub fn solve_constraints(constraints_cx: ConstraintContext) -> ty::CrateVariance let variances = solutions_cx.create_map(); let empty_variance = Rc::new(Vec::new()); - ty::CrateVariancesMap { dependencies, variances, empty_variance } + ty::CrateVariancesMap { variances, empty_variance } } impl<'a, 'tcx> SolveContext<'a, 'tcx> { diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index e168222058f9a..988cc08433588 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] env_logger = { version = "0.4", default-features = false } log = "0.3" -pulldown-cmark = { version = "0.0.14", default-features = false } +pulldown-cmark = { version = "0.1.0", default-features = false } html-diff = "0.0.4" [build-dependencies] diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ad171c4babbce..f8fea643d5e14 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -419,6 +419,8 @@ pub enum ItemEnum { ForeignFunctionItem(Function), /// `static`s from an extern block ForeignStaticItem(Static), + /// `type`s from an extern block + ForeignTypeItem, MacroItem(Macro), PrimitiveItem(PrimitiveType), AssociatedConstItem(Type, Option), @@ -1141,13 +1143,13 @@ pub struct Method { pub abi: Abi, } -impl<'a> Clean for (&'a hir::MethodSig, hir::BodyId) { +impl<'a> Clean for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId) { fn clean(&self, cx: &DocContext) -> Method { Method { - generics: self.0.generics.clean(cx), + generics: self.1.clean(cx), unsafety: self.0.unsafety, constness: self.0.constness, - decl: (&*self.0.decl, self.1).clean(cx), + decl: (&*self.0.decl, self.2).clean(cx), abi: self.0.abi } } @@ -1380,13 +1382,13 @@ impl Clean for hir::TraitItem { default.map(|e| print_const_expr(cx, e))) } hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { - MethodItem((sig, body).clean(cx)) + MethodItem((sig, &self.generics, body).clean(cx)) } hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref names)) => { TyMethodItem(TyMethod { unsafety: sig.unsafety.clone(), decl: (&*sig.decl, &names[..]).clean(cx), - generics: sig.generics.clean(cx), + generics: self.generics.clean(cx), abi: sig.abi }) } @@ -1415,7 +1417,7 @@ impl Clean for hir::ImplItem { Some(print_const_expr(cx, expr))) } hir::ImplItemKind::Method(ref sig, body) => { - MethodItem((sig, body).clean(cx)) + MethodItem((sig, &self.generics, body).clean(cx)) } hir::ImplItemKind::Type(ref ty) => TypedefItem(Typedef { type_: ty.clean(cx), @@ -1646,6 +1648,7 @@ pub enum TypeKind { Trait, Variant, Typedef, + Foreign, } pub trait GetDefId { @@ -2027,6 +2030,17 @@ impl<'tcx> Clean for Ty<'tcx> { is_generic: false, } } + ty::TyForeign(did) => { + inline::record_extern_fqn(cx, did, TypeKind::Foreign); + let path = external_path(cx, &cx.tcx.item_name(did), + None, false, vec![], Substs::empty()); + ResolvedPath { + path: path, + typarams: None, + did: did, + is_generic: false, + } + } ty::TyDynamic(ref obj, ref reg) => { if let Some(principal) = obj.principal() { let did = principal.def_id(); @@ -2840,6 +2854,9 @@ impl Clean for hir::ForeignItem { expr: "".to_string(), }) } + hir::ForeignItemType => { + ForeignTypeItem + } }; Item { name: Some(self.name.clean(cx)), diff --git a/src/librustdoc/html/item_type.rs b/src/librustdoc/html/item_type.rs index f584c4e2f4d9c..c9c5f01f0aea1 100644 --- a/src/librustdoc/html/item_type.rs +++ b/src/librustdoc/html/item_type.rs @@ -41,6 +41,7 @@ pub enum ItemType { Constant = 17, AssociatedConst = 18, Union = 19, + ForeignType = 20, } @@ -82,6 +83,7 @@ impl<'a> From<&'a clean::Item> for ItemType { clean::AssociatedConstItem(..) => ItemType::AssociatedConst, clean::AssociatedTypeItem(..) => ItemType::AssociatedType, clean::DefaultImplItem(..) => ItemType::Impl, + clean::ForeignTypeItem => ItemType::ForeignType, clean::StrippedItem(..) => unreachable!(), } } @@ -100,6 +102,7 @@ impl From for ItemType { clean::TypeKind::Const => ItemType::Constant, clean::TypeKind::Variant => ItemType::Variant, clean::TypeKind::Typedef => ItemType::Typedef, + clean::TypeKind::Foreign => ItemType::ForeignType, } } } @@ -127,6 +130,7 @@ impl ItemType { ItemType::AssociatedType => "associatedtype", ItemType::Constant => "constant", ItemType::AssociatedConst => "associatedconstant", + ItemType::ForeignType => "foreigntype", } } @@ -139,7 +143,8 @@ impl ItemType { ItemType::Typedef | ItemType::Trait | ItemType::Primitive | - ItemType::AssociatedType => NameSpace::Type, + ItemType::AssociatedType | + ItemType::ForeignType => NameSpace::Type, ItemType::ExternCrate | ItemType::Import | diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 80d1f0b01cc26..001e773098eb3 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -371,7 +371,7 @@ impl<'a, I: Iterator>> Iterator for Footnotes<'a, I> { match self.inner.next() { Some(Event::FootnoteReference(ref reference)) => { let entry = self.get_entry(&reference); - let reference = format!("{0}\ + let reference = format!("{0}\ ", (*entry).1); return Some(Event::Html(reference.into())); @@ -394,7 +394,7 @@ impl<'a, I: Iterator>> Iterator for Footnotes<'a, I> { v.sort_by(|a, b| a.1.cmp(&b.1)); let mut ret = String::from("

    "); for (mut content, id) in v { - write!(ret, "
  1. ", id).unwrap(); + write!(ret, "
  2. ", id).unwrap(); let mut is_paragraph = false; if let Some(&Event::End(Tag::Paragraph)) = content.last() { content.pop(); @@ -402,7 +402,7 @@ impl<'a, I: Iterator>> Iterator for Footnotes<'a, I> { } html::push_html(&mut ret, content.into_iter()); write!(ret, - " ", + " ", id).unwrap(); if is_paragraph { ret.push_str("

    "); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index d538428a7e9a9..ac2cb1665a77a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2044,6 +2044,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, ItemType::Primitive => ("primitives", "Primitive Types"), ItemType::AssociatedType => ("associated-types", "Associated Types"), ItemType::AssociatedConst => ("associated-consts", "Associated Constants"), + ItemType::ForeignType => ("foreign-types", "Foreign Types"), }; write!(w, "

    \ {name}

    \n", @@ -3679,7 +3680,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item, ItemType::Enum, ItemType::Constant, ItemType::Static, ItemType::Trait, ItemType::Function, ItemType::Typedef, ItemType::Union, ItemType::Impl, ItemType::TyMethod, ItemType::Method, ItemType::StructField, ItemType::Variant, - ItemType::AssociatedType, ItemType::AssociatedConst] { + ItemType::AssociatedType, ItemType::AssociatedConst, ItemType::ForeignType] { if items.iter().any(|it| { if let clean::DefaultImplItem(..) = it.inner { false @@ -3708,6 +3709,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item, ItemType::Primitive => ("primitives", "Primitive Types"), ItemType::AssociatedType => ("associated-types", "Associated Types"), ItemType::AssociatedConst => ("associated-consts", "Associated Constants"), + ItemType::ForeignType => ("foreign-types", "Foreign Types"), }; sidebar.push_str(&format!("
  3. {name}
  4. ", id = short, diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 18270654aa93c..9978435a11243 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -171,10 +171,11 @@ nav.sub { .sidebar { width: 200px; - position: absolute; + position: fixed; left: 0; top: 0; - min-height: 100%; + height: 100vh; + overflow: auto; } .sidebar .current { @@ -820,8 +821,8 @@ span.since { width: 100%; } - .content .out-of-band { - display: none; + .content h4 > .out-of-band { + position: inherit; } .toggle-wrapper > .collapse-toggle { @@ -835,6 +836,10 @@ span.since { #search { margin-left: 0; } + + .content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant { + display: flex; + } } @media print { diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 146629486fabd..959543404d8d2 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -90,7 +90,7 @@ impl<'a> fold::DocFolder for Stripper<'a> { clean::VariantItem(..) | clean::MethodItem(..) | clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) | clean::ConstantItem(..) | clean::UnionItem(..) | - clean::AssociatedConstItem(..) => { + clean::AssociatedConstItem(..) | clean::ForeignTypeItem => { if i.def_id.is_local() { if !self.access_levels.is_exported(i.def_id) { return None; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 8b2c8d2da395a..9316805b9322a 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -238,7 +238,8 @@ fn run_test(test: &str, cratename: &str, filename: &str, cfgs: Vec, libs let data = Arc::new(Mutex::new(Vec::new())); let codemap = Rc::new(CodeMap::new(sessopts.file_path_mapping())); let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()), - Some(codemap.clone())); + Some(codemap.clone()), + false); let old = io::set_panic(Some(box Sink(data.clone()))); let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 866c0038a7fd9..5dd5f8953a00e 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -15,7 +15,6 @@ alloc_jemalloc = { path = "../liballoc_jemalloc", optional = true } alloc_system = { path = "../liballoc_system" } panic_unwind = { path = "../libpanic_unwind", optional = true } panic_abort = { path = "../libpanic_abort" } -collections = { path = "../libcollections" } core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } rand = { path = "../librand" } diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 4e3781ecafab5..327deb9b419be 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -411,10 +411,12 @@ pub trait AsciiExt { fn is_ascii_hexdigit(&self) -> bool { unimplemented!(); } /// Checks if the value is an ASCII punctuation character: + /// /// U+0021 ... U+002F `! " # $ % & ' ( ) * + , - . /` /// U+003A ... U+0040 `: ; < = > ? @` - /// U+005B ... U+0060 `[ \\ ] ^ _ \`` + /// U+005B ... U+0060 ``[ \\ ] ^ _ ` `` /// U+007B ... U+007E `{ | } ~` + /// /// For strings, true if all characters in the string are /// ASCII punctuation. /// diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 3c0fa0860d394..d96a4f40d3f8e 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1113,6 +1113,7 @@ impl HashMap /// assert_eq!(map.get(&2), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn get(&self, k: &Q) -> Option<&V> where K: Borrow, Q: Hash + Eq @@ -2554,6 +2555,7 @@ impl super::Recover for HashMap { type Key = K; + #[inline] fn get(&self, key: &Q) -> Option<&K> { self.search(key).into_occupied_bucket().map(|bucket| bucket.into_refs().0) } @@ -2566,6 +2568,7 @@ impl super::Recover for HashMap self.search_mut(key).into_occupied_bucket().map(|bucket| pop_internal(bucket).0) } + #[inline] fn replace(&mut self, key: K) -> Option { self.reserve(1); diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index a97075ff8d8cd..8c34660f821b7 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -41,7 +41,7 @@ use sys_common::{AsInner, IntoInner, FromInner}; /// # Creating an `OsString` /// /// **From a Rust string**: `OsString` implements -/// [`From`]`<`[`String`]`>`, so you can use `my_string.`[`from`] to +/// [`From`]`<`[`String`]`>`, so you can use `my_string.from` to /// create an `OsString` from a normal Rust string. /// /// **From slices:** Just like you can start with an empty Rust @@ -63,7 +63,6 @@ use sys_common::{AsInner, IntoInner, FromInner}; /// /// [`OsStr`]: struct.OsStr.html /// [`From`]: ../convert/trait.From.html -/// [`from`]: ../convert/trait.From.html#tymethod.from /// [`String`]: ../string/struct.String.html /// [`&str`]: ../primitive.str.html /// [`u8`]: ../primitive.u8.html diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 83cc9ce582e34..012883d08534d 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -254,6 +254,15 @@ #![feature(collections_range)] #![feature(compiler_builtins_lib)] #![feature(const_fn)] +#![feature(const_max_value)] +#![feature(const_atomic_bool_new)] +#![feature(const_atomic_isize_new)] +#![feature(const_atomic_usize_new)] +#![feature(const_unsafe_cell_new)] +#![feature(const_cell_new)] +#![feature(const_once_new)] +#![feature(const_ptr_null)] +#![feature(const_ptr_null_mut)] #![feature(core_float)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] @@ -294,7 +303,7 @@ #![feature(repr_align)] #![feature(repr_simd)] #![feature(rustc_attrs)] -#![cfg_attr(not(stage0), feature(rustc_const_unstable))] +#![feature(rustc_const_unstable)] #![feature(shared)] #![feature(sip_hash_13)] #![feature(slice_bytes)] @@ -318,17 +327,7 @@ #![feature(doc_cfg)] #![feature(doc_masked)] #![cfg_attr(test, feature(update_panic_count))] - -#![cfg_attr(not(stage0), feature(const_max_value))] -#![cfg_attr(not(stage0), feature(const_atomic_bool_new))] -#![cfg_attr(not(stage0), feature(const_atomic_isize_new))] -#![cfg_attr(not(stage0), feature(const_atomic_usize_new))] -#![cfg_attr(all(not(stage0), windows), feature(const_atomic_ptr_new))] -#![cfg_attr(not(stage0), feature(const_unsafe_cell_new))] -#![cfg_attr(not(stage0), feature(const_cell_new))] -#![cfg_attr(not(stage0), feature(const_once_new))] -#![cfg_attr(not(stage0), feature(const_ptr_null))] -#![cfg_attr(not(stage0), feature(const_ptr_null_mut))] +#![cfg_attr(windows, feature(const_atomic_ptr_new))] #![default_lib_allocator] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 8089671f309d2..6318e2e40875f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -490,7 +490,7 @@ pub mod builtin { #[macro_export] macro_rules! file { () => ({ /* compiler built-in */ }) } - /// A macro which stringifies its argument. + /// A macro which stringifies its arguments. /// /// This macro will yield an expression of type `&'static str` which is the /// stringification of all the tokens passed to the macro. No restrictions @@ -507,7 +507,7 @@ pub mod builtin { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] - macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) } + macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) } /// Includes a utf8-encoded file as a string. /// diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 4656cc5a7a781..539ff1df1876f 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -498,18 +498,46 @@ impl TcpStream { /// Moves this TCP stream into or out of nonblocking mode. /// - /// On Unix this corresponds to calling fcntl, and on Windows this - /// corresponds to calling ioctlsocket. + /// This will result in `read`, `write`, `recv` and `send` operations + /// becoming nonblocking, i.e. immediately returning from their calls. + /// If the IO operation is successful, `Ok` is returned and no further + /// action is required. If the IO operation could not be completed and needs + /// to be retried, an error with kind [`io::ErrorKind::WouldBlock`] is + /// returned. + /// + /// On Unix platforms, calling this method corresponds to calling `fcntl` + /// `FIONBIO`. On Windows calling this method corresponds to calling + /// `ioctlsocket` `FIONBIO`. /// /// # Examples /// + /// Reading bytes from a TCP stream in non-blocking mode: + /// /// ```no_run + /// use std::io::{self, Read}; /// use std::net::TcpStream; /// - /// let stream = TcpStream::connect("127.0.0.1:8080") - /// .expect("Couldn't connect to the server..."); + /// let mut stream = TcpStream::connect("127.0.0.1:7878") + /// .expect("Couldn't connect to the server..."); /// stream.set_nonblocking(true).expect("set_nonblocking call failed"); + /// + /// # fn wait_for_fd() { unimplemented!() } + /// let mut buf = vec![]; + /// loop { + /// match stream.read_to_end(&mut buf) { + /// Ok(_) => break, + /// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { + /// // wait until network socket is ready, typically implemented + /// // via platform-specific APIs such as epoll or IOCP + /// wait_for_fd(); + /// } + /// Err(e) => panic!("encountered IO error: {}", e), + /// }; + /// }; + /// println!("bytes: {:?}", buf); /// ``` + /// + /// [`io::ErrorKind::WouldBlock`]: ../io/enum.ErrorKind.html#variant.WouldBlock #[stable(feature = "net2_mutators", since = "1.9.0")] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { self.0.set_nonblocking(nonblocking) @@ -780,17 +808,48 @@ impl TcpListener { /// Moves this TCP stream into or out of nonblocking mode. /// - /// On Unix this corresponds to calling fcntl, and on Windows this - /// corresponds to calling ioctlsocket. + /// This will result in the `accept` operation becoming nonblocking, + /// i.e. immediately returning from their calls. If the IO operation is + /// successful, `Ok` is returned and no further action is required. If the + /// IO operation could not be completed and needs to be retried, an error + /// with kind [`io::ErrorKind::WouldBlock`] is returned. + /// + /// On Unix platforms, calling this method corresponds to calling `fcntl` + /// `FIONBIO`. On Windows calling this method corresponds to calling + /// `ioctlsocket` `FIONBIO`. /// /// # Examples /// + /// Bind a TCP listener to an address, listen for connections, and read + /// bytes in nonblocking mode: + /// /// ```no_run + /// use std::io; /// use std::net::TcpListener; /// - /// let listener = TcpListener::bind("127.0.0.1:80").unwrap(); + /// let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); /// listener.set_nonblocking(true).expect("Cannot set non-blocking"); + /// + /// # fn wait_for_fd() { unimplemented!() } + /// # fn handle_connection(stream: std::net::TcpStream) { unimplemented!() } + /// for stream in listener.incoming() { + /// match stream { + /// Ok(s) => { + /// // do something with the TcpStream + /// handle_connection(s); + /// } + /// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { + /// // wait until network socket is ready, typically implemented + /// // via platform-specific APIs such as epoll or IOCP + /// wait_for_fd(); + /// continue; + /// } + /// Err(e) => panic!("encountered IO error: {}", e), + /// } + /// } /// ``` + /// + /// [`io::ErrorKind::WouldBlock`]: ../io/enum.ErrorKind.html#variant.WouldBlock #[stable(feature = "net2_mutators", since = "1.9.0")] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { self.0.set_nonblocking(nonblocking) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index a8a242846d7ce..84ceaa659510f 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -168,7 +168,7 @@ impl UdpSocket { /// This will return an error when the IP version of the local socket /// does not match that returned from [`ToSocketAddrs`]. /// - /// See https://github.com/rust-lang/rust/issues/34202 for more details. + /// See for more details. /// /// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html /// @@ -721,16 +721,45 @@ impl UdpSocket { /// Moves this UDP socket into or out of nonblocking mode. /// - /// On Unix this corresponds to calling fcntl, and on Windows this - /// corresponds to calling ioctlsocket. + /// This will result in `recv`, `recv_from`, `send`, and `send_to` + /// operations becoming nonblocking, i.e. immediately returning from their + /// calls. If the IO operation is successful, `Ok` is returned and no + /// further action is required. If the IO operation could not be completed + /// and needs to be retried, an error with kind + /// [`io::ErrorKind::WouldBlock`] is returned. + /// + /// On Unix platforms, calling this method corresponds to calling `fcntl` + /// `FIONBIO`. On Windows calling this method corresponds to calling + /// `ioctlsocket` `FIONBIO`. + /// + /// [`io::ErrorKind::WouldBlock`]: ../io/enum.ErrorKind.html#variant.WouldBlock /// /// # Examples /// + /// Create a UDP socket bound to `127.0.0.1:7878` and read bytes in + /// nonblocking mode: + /// /// ```no_run + /// use std::io; /// use std::net::UdpSocket; /// - /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); - /// socket.set_nonblocking(true).expect("set_nonblocking call failed"); + /// let socket = UdpSocket::bind("127.0.0.1:7878").unwrap(); + /// socket.set_nonblocking(true).unwrap(); + /// + /// # fn wait_for_fd() { unimplemented!() } + /// let mut buf = [0; 10]; + /// let (num_bytes_read, _) = loop { + /// match socket.recv_from(&mut buf) { + /// Ok(n) => break n, + /// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { + /// // wait until network socket is ready, typically implemented + /// // via platform-specific APIs such as epoll or IOCP + /// wait_for_fd(); + /// } + /// Err(e) => panic!("encountered IO error: {}", e), + /// } + /// }; + /// println!("bytes: {:?}", &buf[..num_bytes_read]); /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { diff --git a/src/libstd/os/linux/fs.rs b/src/libstd/os/linux/fs.rs index 7ebda5ed744fd..5d37d970e89b6 100644 --- a/src/libstd/os/linux/fs.rs +++ b/src/libstd/os/linux/fs.rs @@ -24,9 +24,25 @@ pub trait MetadataExt { /// Gain a reference to the underlying `stat` structure which contains /// the raw information returned by the OS. /// - /// The contents of the returned `stat` are **not** consistent across + /// The contents of the returned [`stat`] are **not** consistent across /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the /// cross-Unix abstractions contained within the raw stat. + /// + /// [`stat`]: ../../../../std/os/linux/raw/struct.stat.html + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// let stat = meta.as_raw_stat(); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext", since = "1.1.0")] #[rustc_deprecated(since = "1.8.0", reason = "deprecated in favor of the accessor \ @@ -35,54 +51,278 @@ pub trait MetadataExt { fn as_raw_stat(&self) -> &raw::stat; /// Returns the device ID on which this file resides. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_dev()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_dev(&self) -> u64; /// Returns the inode number. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_ino()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_ino(&self) -> u64; /// Returns the file type and mode. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_mode()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_mode(&self) -> u32; /// Returns the number of hard links to file. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_nlink()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_nlink(&self) -> u64; /// Returns the user ID of the file owner. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_uid()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_uid(&self) -> u32; /// Returns the group ID of the file owner. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_gid()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_gid(&self) -> u32; /// Returns the device ID that this file represents. Only relevant for special file. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_rdev()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_rdev(&self) -> u64; /// Returns the size of the file (if it is a regular file or a symbolic link) in bytes. /// /// The size of a symbolic link is the length of the pathname it contains, /// without a terminating null byte. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_size()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_size(&self) -> u64; /// Returns the last access time. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_atime()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_atime(&self) -> i64; /// Returns the last access time, nano seconds part. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_atime_nsec()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_atime_nsec(&self) -> i64; /// Returns the last modification time. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_mtime()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_mtime(&self) -> i64; /// Returns the last modification time, nano seconds part. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_mtime_nsec()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_mtime_nsec(&self) -> i64; /// Returns the last status change time. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_ctime()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_ctime(&self) -> i64; /// Returns the last status change time, nano seconds part. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_ctime_nsec()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_ctime_nsec(&self) -> i64; /// Returns the "preferred" blocksize for efficient filesystem I/O. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_blksize()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_blksize(&self) -> u64; /// Returns the number of blocks allocated to the file, 512-byte units. + /// + /// # Examples + /// + /// ``` + /// use std::fs; + /// use std::os::linux::fs::MetadataExt; + /// + /// # use std::io; + /// # fn f() -> io::Result<()> { + /// let meta = fs::metadata("some_file")?; + /// println!("{}", meta.st_blocks()); + /// # Ok(()) + /// # } + /// ``` #[stable(feature = "metadata_ext2", since = "1.8.0")] fn st_blocks(&self) -> u64; } diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 533f6590f83b2..35c33f4025380 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -10,25 +10,66 @@ //! A module for working with processes. //! -//! # Examples +//! This module is mostly concerned with spawning and interacting with child +//! processes, but it also provides [`abort`] and [`exit`] for terminating the +//! current process. //! -//! Basic usage where we try to execute the `cat` shell command: +//! # Spawning a process //! -//! ```should_panic +//! The [`Command`] struct is used to configure and spawn processes: +//! +//! ``` //! use std::process::Command; //! -//! let mut child = Command::new("/bin/cat") -//! .arg("file.txt") -//! .spawn() -//! .expect("failed to execute child"); +//! let output = Command::new("echo") +//! .arg("Hello world") +//! .output() +//! .expect("Failed to execute command"); +//! +//! assert_eq!(b"Hello world\n", output.stdout.as_slice()); +//! ``` //! -//! let ecode = child.wait() -//! .expect("failed to wait on child"); +//! Several methods on [`Command`], such as [`spawn`] or [`output`], can be used +//! to spawn a process. In particular, [`output`] spawns the child process and +//! waits until the process terminates, while [`spawn`] will return a [`Child`] +//! that represents the spawned child process. +//! +//! # Handling I/O +//! +//! The [`stdout`], [`stdin`], and [`stderr`] of a child process can be +//! configured by passing an [`Stdio`] to the corresponding method on +//! [`Command`]. Once spawned, they can be accessed from the [`Child`]. For +//! example, piping output from one command into another command can be done +//! like so: +//! +//! ```no_run +//! use std::process::{Command, Stdio}; +//! +//! // stdout must be configured with `Stdio::piped` in order to use +//! // `echo_child.stdout` +//! let echo_child = Command::new("echo") +//! .arg("Oh no, a tpyo!") +//! .stdout(Stdio::piped()) +//! .spawn() +//! .expect("Failed to start echo process"); +//! +//! // Note that `echo_child` is moved here, but we won't be needing +//! // `echo_child` anymore +//! let echo_out = echo_child.stdout.expect("Failed to open echo stdout"); +//! +//! let mut sed_child = Command::new("sed") +//! .arg("s/tpyo/typo/") +//! .stdin(Stdio::from(echo_out)) +//! .stdout(Stdio::piped()) +//! .spawn() +//! .expect("Failed to start sed process"); //! -//! assert!(ecode.success()); +//! let output = sed_child.wait_with_output().expect("Failed to wait on sed"); +//! assert_eq!(b"Oh no, a typo!\n", output.stdout.as_slice()); //! ``` //! -//! Calling a command with input and reading its output: +//! Note that [`ChildStderr`] and [`ChildStdout`] implement [`Write`] and +//! [`ChildStdin`] implements [`Read`]: //! //! ```no_run //! use std::process::{Command, Stdio}; @@ -52,6 +93,26 @@ //! //! assert_eq!(b"test", output.stdout.as_slice()); //! ``` +//! +//! [`abort`]: fn.abort.html +//! [`exit`]: fn.exit.html +//! +//! [`Command`]: struct.Command.html +//! [`spawn`]: struct.Command.html#method.spawn +//! [`output`]: struct.Command.html#method.output +//! +//! [`Child`]: struct.Child.html +//! [`ChildStdin`]: struct.ChildStdin.html +//! [`ChildStdout`]: struct.ChildStdout.html +//! [`ChildStderr`]: struct.ChildStderr.html +//! [`Stdio`]: struct.Stdio.html +//! +//! [`stdout`]: struct.Command.html#method.stdout +//! [`stdin`]: struct.Command.html#method.stdin +//! [`stderr`]: struct.Command.html#method.stderr +//! +//! [`Write`]: ../io/trait.Write.html +//! [`Read`]: ../io/trait.Read.html #![stable(feature = "process", since = "1.0.0")] @@ -343,7 +404,7 @@ impl Command { /// The search path to be used may be controlled by setting the /// `PATH` environment variable on the Command, /// but this has some implementation limitations on Windows - /// (see https://github.com/rust-lang/rust/issues/37519). + /// (see ). /// /// # Examples /// @@ -1310,6 +1371,25 @@ pub fn abort() -> ! { unsafe { ::sys::abort_internal() }; } +/// Returns the OS-assigned process identifier associated with this process. +/// +/// # Examples +/// +/// Basic usage: +/// +/// ```no_run +/// #![feature(getpid)] +/// use std::process; +/// +/// println!("My pid is {}", process::id()); +/// ``` +/// +/// +#[unstable(feature = "getpid", issue = "44971", reason = "recently added")] +pub fn id() -> u32 { + ::sys::os::getpid() +} + #[cfg(all(test, not(target_os = "emscripten")))] mod tests { use io::prelude::*; diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 015106fc2e598..2ef99525af5fd 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -103,8 +103,8 @@ unsafe impl Sync for Once {} #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Send for Once {} -/// State yielded to the [`call_once_force`] method which can be used to query -/// whether the [`Once`] was previously poisoned or not. +/// State yielded to [`call_once_force`]’s closure parameter. The state can be +/// used to query the poison status of the [`Once`]. /// /// [`call_once_force`]: struct.Once.html#method.call_once_force /// [`Once`]: struct.Once.html @@ -156,7 +156,7 @@ struct Finish { impl Once { /// Creates a new `Once` value. #[stable(feature = "once_new", since = "1.2.0")] - #[cfg_attr(not(stage0), rustc_const_unstable(feature = "const_once_new"))] + #[rustc_const_unstable(feature = "const_once_new")] pub const fn new() -> Once { Once { state: AtomicUsize::new(INCOMPLETE), @@ -230,17 +230,50 @@ impl Once { /// Performs the same function as [`call_once`] except ignores poisoning. /// + /// Unlike [`call_once`], if this `Once` has been poisoned (i.e. a previous + /// call to `call_once` or `call_once_force` caused a panic), calling + /// `call_once_force` will still invoke the closure `f` and will _not_ + /// result in an immediate panic. If `f` panics, the `Once` will remain + /// in a poison state. If `f` does _not_ panic, the `Once` will no + /// longer be in a poison state and all future calls to `call_once` or + /// `call_one_force` will no-op. + /// + /// The closure `f` is yielded a [`OnceState`] structure which can be used + /// to query the poison status of the `Once`. + /// /// [`call_once`]: struct.Once.html#method.call_once + /// [`OnceState`]: struct.OnceState.html /// - /// If this `Once` has been poisoned (some initialization panicked) then - /// this function will continue to attempt to call initialization functions - /// until one of them doesn't panic. + /// # Examples /// - /// The closure `f` is yielded a [`OnceState`] structure which can be used to query the - /// state of this `Once` (whether initialization has previously panicked or - /// not). + /// ``` + /// #![feature(once_poison)] /// - /// [`OnceState`]: struct.OnceState.html + /// use std::sync::{Once, ONCE_INIT}; + /// use std::thread; + /// + /// static INIT: Once = ONCE_INIT; + /// + /// // poison the once + /// let handle = thread::spawn(|| { + /// INIT.call_once(|| panic!()); + /// }); + /// assert!(handle.join().is_err()); + /// + /// // poisoning propagates + /// let handle = thread::spawn(|| { + /// INIT.call_once(|| {}); + /// }); + /// assert!(handle.join().is_err()); + /// + /// // call_once_force will still run and reset the poisoned state + /// INIT.call_once_force(|state| { + /// assert!(state.poisoned()); + /// }); + /// + /// // once any success happens, we stop propagating the poison + /// INIT.call_once(|| {}); + /// ``` #[unstable(feature = "once_poison", issue = "33577")] pub fn call_once_force(&'static self, f: F) where F: FnOnce(&OnceState) { // same as above, just with a different parameter to `call_inner`. @@ -386,12 +419,47 @@ impl Drop for Finish { } impl OnceState { - /// Returns whether the associated [`Once`] has been poisoned. - /// - /// Once an initialization routine for a [`Once`] has panicked it will forever - /// indicate to future forced initialization routines that it is poisoned. + /// Returns whether the associated [`Once`] was poisoned prior to the + /// invocation of the closure passed to [`call_once_force`]. /// + /// [`call_once_force`]: struct.Once.html#method.call_once_force /// [`Once`]: struct.Once.html + /// + /// # Examples + /// + /// A poisoned `Once`: + /// + /// ``` + /// #![feature(once_poison)] + /// + /// use std::sync::{Once, ONCE_INIT}; + /// use std::thread; + /// + /// static INIT: Once = ONCE_INIT; + /// + /// // poison the once + /// let handle = thread::spawn(|| { + /// INIT.call_once(|| panic!()); + /// }); + /// assert!(handle.join().is_err()); + /// + /// INIT.call_once_force(|state| { + /// assert!(state.poisoned()); + /// }); + /// ``` + /// + /// An unpoisoned `Once`: + /// + /// ``` + /// #![feature(once_poison)] + /// + /// use std::sync::{Once, ONCE_INIT}; + /// + /// static INIT: Once = ONCE_INIT; + /// + /// INIT.call_once_force(|state| { + /// assert!(!state.poisoned()); + /// }); #[unstable(feature = "once_poison", issue = "33577")] pub fn poisoned(&self) -> bool { self.poisoned diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index efddd5f029484..c27e2ee172c6b 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -209,3 +209,7 @@ pub fn exit(code: i32) -> ! { let _ = syscall::exit(code as usize); unreachable!(); } + +pub fn getpid() -> u32 { + syscall::getpid().unwrap() as u32 +} diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs index 89a44b9765783..4f878d8ad1fa8 100644 --- a/src/libstd/sys/unix/condvar.rs +++ b/src/libstd/sys/unix/condvar.rs @@ -92,14 +92,15 @@ impl Condvar { assert_eq!(r, 0); // Nanosecond calculations can't overflow because both values are below 1e9. - let nsec = dur.subsec_nanos() as libc::c_long + now.tv_nsec as libc::c_long; + let nsec = dur.subsec_nanos() + now.tv_nsec as u32; + let sec = saturating_cast_to_time_t(dur.as_secs()) .checked_add((nsec / 1_000_000_000) as libc::time_t) .and_then(|s| s.checked_add(now.tv_sec)); let nsec = nsec % 1_000_000_000; let timeout = sec.map(|s| { - libc::timespec { tv_sec: s, tv_nsec: nsec } + libc::timespec { tv_sec: s, tv_nsec: nsec as _} }).unwrap_or(TIMESPEC_MAX); let r = libc::pthread_cond_timedwait(self.inner.get(), mutex::raw(mutex), diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index c4616c3b395be..a1ca839dc1872 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -132,14 +132,14 @@ impl FileAttr { pub fn modified(&self) -> io::Result { Ok(SystemTime::from(libc::timespec { tv_sec: self.stat.st_mtime as libc::time_t, - tv_nsec: self.stat.st_mtime_nsec as libc::c_long, + tv_nsec: self.stat.st_mtime_nsec as _, })) } pub fn accessed(&self) -> io::Result { Ok(SystemTime::from(libc::timespec { tv_sec: self.stat.st_atime as libc::time_t, - tv_nsec: self.stat.st_atime_nsec as libc::c_long, + tv_nsec: self.stat.st_atime_nsec as _, })) } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index d8c30534eede2..40b73f1b30704 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -511,3 +511,7 @@ pub fn home_dir() -> Option { pub fn exit(code: i32) -> ! { unsafe { libc::exit(code as c_int) } } + +pub fn getpid() -> u32 { + unsafe { libc::getpid() as u32 } +} diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 6c4a332429646..cc889454ce9d6 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -149,7 +149,7 @@ impl Thread { pub fn sleep(dur: Duration) { let mut secs = dur.as_secs(); - let mut nsecs = dur.subsec_nanos() as libc::c_long; + let mut nsecs = dur.subsec_nanos() as _; // If we're awoken with a signal then the return value will be -1 and // nanosleep will fill in `ts` with the remaining time. diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index c1bea95ce91ab..837cd7292e280 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -60,7 +60,7 @@ impl Timespec { Timespec { t: libc::timespec { tv_sec: secs, - tv_nsec: nsec as libc::c_long, + tv_nsec: nsec as _, }, } } @@ -83,7 +83,7 @@ impl Timespec { Timespec { t: libc::timespec { tv_sec: secs, - tv_nsec: nsec as libc::c_long, + tv_nsec: nsec as _, }, } } diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index a532163f61e19..24c41046f263a 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -32,7 +32,7 @@ pub trait FileExt { /// function, it is set to the end of the read. /// /// Reading beyond the end of the file will always return with a length of - /// 0. + /// 0\. /// /// Note that similar to `File::read`, it is not an error to return with a /// short read. When returning from such a short read, the file pointer is diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index a51b458451e86..b94482435597e 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -318,6 +318,10 @@ pub fn exit(code: i32) -> ! { unsafe { c::ExitProcess(code as c::UINT) } } +pub fn getpid() -> u32 { + unsafe { c::GetCurrentProcessId() as u32 } +} + #[cfg(test)] mod tests { use io::Error; diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index cb18eed8ee54b..fcbca38a98f0b 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -190,11 +190,6 @@ macro_rules! __thread_local_inner { } }; ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => { - #[cfg(stage0)] - $(#[$attr])* $vis static $name: $crate::thread::LocalKey<$t> = - __thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init); - - #[cfg(not(stage0))] $(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> = __thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init); } diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 07bbddc62b9f9..28a33c7ec1465 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -171,6 +171,8 @@ use panic; use panicking; use str; use sync::{Mutex, Condvar, Arc}; +use sync::atomic::AtomicUsize; +use sync::atomic::Ordering::SeqCst; use sys::thread as imp; use sys_common::mutex; use sys_common::thread_info; @@ -694,6 +696,11 @@ pub fn sleep(dur: Duration) { imp::Thread::sleep(dur) } +// constants for park/unpark +const EMPTY: usize = 0; +const PARKED: usize = 1; +const NOTIFIED: usize = 2; + /// Blocks unless or until the current thread's token is made available. /// /// A call to `park` does not guarantee that the thread will remain parked @@ -771,11 +778,27 @@ pub fn sleep(dur: Duration) { #[stable(feature = "rust1", since = "1.0.0")] pub fn park() { let thread = current(); - let mut guard = thread.inner.lock.lock().unwrap(); - while !*guard { - guard = thread.inner.cvar.wait(guard).unwrap(); + + // If we were previously notified then we consume this notification and + // return quickly. + if thread.inner.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst).is_ok() { + return + } + + // Otherwise we need to coordinate going to sleep + let mut m = thread.inner.lock.lock().unwrap(); + match thread.inner.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) { + Ok(_) => {} + Err(NOTIFIED) => return, // notified after we locked + Err(_) => panic!("inconsistent park state"), + } + loop { + m = thread.inner.cvar.wait(m).unwrap(); + match thread.inner.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst) { + Ok(_) => return, // got a notification + Err(_) => {} // spurious wakeup, go back to sleep + } } - *guard = false; } /// Use [`park_timeout`]. @@ -842,12 +865,30 @@ pub fn park_timeout_ms(ms: u32) { #[stable(feature = "park_timeout", since = "1.4.0")] pub fn park_timeout(dur: Duration) { let thread = current(); - let mut guard = thread.inner.lock.lock().unwrap(); - if !*guard { - let (g, _) = thread.inner.cvar.wait_timeout(guard, dur).unwrap(); - guard = g; + + // Like `park` above we have a fast path for an already-notified thread, and + // afterwards we start coordinating for a sleep. + // return quickly. + if thread.inner.state.compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst).is_ok() { + return + } + let m = thread.inner.lock.lock().unwrap(); + match thread.inner.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) { + Ok(_) => {} + Err(NOTIFIED) => return, // notified after we locked + Err(_) => panic!("inconsistent park_timeout state"), + } + + // Wait with a timeout, and if we spuriously wake up or otherwise wake up + // from a notification we just want to unconditionally set the state back to + // empty, either consuming a notification or un-flagging ourselves as + // parked. + let (_m, _result) = thread.inner.cvar.wait_timeout(m, dur).unwrap(); + match thread.inner.state.swap(EMPTY, SeqCst) { + NOTIFIED => {} // got a notification, hurray! + PARKED => {} // no notification, alas + n => panic!("inconsistent park_timeout state: {}", n), } - *guard = false; } //////////////////////////////////////////////////////////////////////////////// @@ -914,7 +955,10 @@ impl ThreadId { struct Inner { name: Option, // Guaranteed to be UTF-8 id: ThreadId, - lock: Mutex, // true when there is a buffered unpark + + // state for thread park/unpark + state: AtomicUsize, + lock: Mutex<()>, cvar: Condvar, } @@ -958,7 +1002,8 @@ impl Thread { inner: Arc::new(Inner { name: cname, id: ThreadId::new(), - lock: Mutex::new(false), + state: AtomicUsize::new(EMPTY), + lock: Mutex::new(()), cvar: Condvar::new(), }) } @@ -998,10 +1043,22 @@ impl Thread { /// [park]: fn.park.html #[stable(feature = "rust1", since = "1.0.0")] pub fn unpark(&self) { - let mut guard = self.inner.lock.lock().unwrap(); - if !*guard { - *guard = true; - self.inner.cvar.notify_one(); + loop { + match self.inner.state.compare_exchange(EMPTY, NOTIFIED, SeqCst, SeqCst) { + Ok(_) => return, // no one was waiting + Err(NOTIFIED) => return, // already unparked + Err(PARKED) => {} // gotta go wake someone up + _ => panic!("inconsistent state in unpark"), + } + + // Coordinate wakeup through the mutex and a condvar notification + let _lock = self.inner.lock.lock().unwrap(); + match self.inner.state.compare_exchange(PARKED, NOTIFIED, SeqCst, SeqCst) { + Ok(_) => return self.inner.cvar.notify_one(), + Err(NOTIFIED) => return, // a different thread unparked + Err(EMPTY) => {} // parked thread went away, try again + _ => panic!("inconsistent state in unpark"), + } } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f445def9e0335..d3995d957928e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1178,7 +1178,6 @@ pub struct MethodSig { pub constness: Spanned, pub abi: Abi, pub decl: P, - pub generics: Generics, } /// Represents an item declaration within a trait declaration, @@ -1190,6 +1189,7 @@ pub struct TraitItem { pub id: NodeId, pub ident: Ident, pub attrs: Vec, + pub generics: Generics, pub node: TraitItemKind, pub span: Span, /// See `Item::tokens` for what this is @@ -1211,6 +1211,7 @@ pub struct ImplItem { pub vis: Visibility, pub defaultness: Defaultness, pub attrs: Vec, + pub generics: Generics, pub node: ImplItemKind, pub span: Span, /// See `Item::tokens` for what this is @@ -1787,10 +1788,19 @@ impl PolyTraitRef { } } +#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +pub enum CrateSugar { + /// Source is `pub(crate)` + PubCrate, + + /// Source is (just) `crate` + JustCrate, +} + #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum Visibility { Public, - Crate(Span), + Crate(Span, CrateSugar), Restricted { path: P, id: NodeId }, Inherited, } @@ -1997,13 +2007,16 @@ pub enum ForeignItemKind { /// A foreign static item (`static ext: u8`), with optional mutability /// (the boolean is true when mutable) Static(P, bool), + /// A foreign type + Ty, } impl ForeignItemKind { pub fn descriptive_variant(&self) -> &str { match *self { ForeignItemKind::Fn(..) => "foreign function", - ForeignItemKind::Static(..) => "foreign static item" + ForeignItemKind::Static(..) => "foreign static item", + ForeignItemKind::Ty => "foreign type", } } } diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index 4fc2b92d3cd52..2f5b386346bc8 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -32,6 +32,7 @@ pub fn placeholder(kind: ExpansionKind, id: ast::NodeId) -> Expansion { let ident = keywords::Invalid.ident(); let attrs = Vec::new(); + let generics = ast::Generics::default(); let vis = ast::Visibility::Inherited; let span = DUMMY_SP; let expr_placeholder = || P(ast::Expr { @@ -49,12 +50,12 @@ pub fn placeholder(kind: ExpansionKind, id: ast::NodeId) -> Expansion { tokens: None, }))), ExpansionKind::TraitItems => Expansion::TraitItems(SmallVector::one(ast::TraitItem { - id, span, ident, attrs, + id, span, ident, attrs, generics, node: ast::TraitItemKind::Macro(mac_placeholder()), tokens: None, })), ExpansionKind::ImplItems => Expansion::ImplItems(SmallVector::one(ast::ImplItem { - id, span, ident, vis, attrs, + id, span, ident, vis, attrs, generics, node: ast::ImplItemKind::Macro(mac_placeholder()), defaultness: ast::Defaultness::Final, tokens: None, diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9060a613bc132..30451ec757a9f 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -401,6 +401,12 @@ declare_features! ( // Trait object syntax with `dyn` prefix (active, dyn_trait, "1.22.0", Some(44662)), + + // `crate` as visibility modifier, synonymous to `pub(crate)` + (active, crate_visibility_modifier, "1.23.0", Some(45388)), + + // extern types + (active, extern_types, "1.23.0", Some(43467)), ); declare_features! ( @@ -1395,13 +1401,23 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_foreign_item(&mut self, i: &'a ast::ForeignItem) { - let links_to_llvm = match attr::first_attr_value_str_by_name(&i.attrs, "link_name") { - Some(val) => val.as_str().starts_with("llvm."), - _ => false - }; - if links_to_llvm { - gate_feature_post!(&self, link_llvm_intrinsics, i.span, - "linking to LLVM intrinsics is experimental"); + match i.node { + ast::ForeignItemKind::Fn(..) | + ast::ForeignItemKind::Static(..) => { + let link_name = attr::first_attr_value_str_by_name(&i.attrs, "link_name"); + let links_to_llvm = match link_name { + Some(val) => val.as_str().starts_with("llvm."), + _ => false + }; + if links_to_llvm { + gate_feature_post!(&self, link_llvm_intrinsics, i.span, + "linking to LLVM intrinsics is experimental"); + } + } + ast::ForeignItemKind::Ty => { + gate_feature_post!(&self, extern_types, i.span, + "extern types are experimental"); + } } visit::walk_foreign_item(self, i) @@ -1526,7 +1542,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { span: Span, _node_id: NodeId) { // check for const fn declarations - if let FnKind::ItemFn(_, _, _, Spanned { node: ast::Constness::Const, .. }, _, _, _) = + if let FnKind::ItemFn(_, _, Spanned { node: ast::Constness::Const, .. }, _, _, _) = fn_kind { gate_feature_post!(&self, const_fn, span, "const fn is unstable"); } @@ -1536,7 +1552,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { // point. match fn_kind { - FnKind::ItemFn(_, _, _, _, abi, _, _) | + FnKind::ItemFn(_, _, _, abi, _, _) | FnKind::Method(_, &ast::MethodSig { abi, .. }, _, _) => { self.check_abi(abi, span); } @@ -1582,6 +1598,14 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { visit::walk_impl_item(self, ii); } + fn visit_vis(&mut self, vis: &'a ast::Visibility) { + if let ast::Visibility::Crate(span, ast::CrateSugar::JustCrate) = *vis { + gate_feature_post!(&self, crate_visibility_modifier, span, + "`crate` visibility modifier is experimental"); + } + visit::walk_vis(self, vis); + } + fn visit_generics(&mut self, g: &'a ast::Generics) { for t in &g.ty_params { if !t.attrs.is_empty() { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index d7d491db71f05..fea49424dc8d2 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -943,6 +943,7 @@ pub fn noop_fold_trait_item(i: TraitItem, folder: &mut T) id: folder.new_id(i.id), ident: folder.fold_ident(i.ident), attrs: fold_attrs(i.attrs, folder), + generics: folder.fold_generics(i.generics), node: match i.node { TraitItemKind::Const(ty, default) => { TraitItemKind::Const(folder.fold_ty(ty), @@ -972,6 +973,7 @@ pub fn noop_fold_impl_item(i: ImplItem, folder: &mut T) vis: folder.fold_vis(i.vis), ident: folder.fold_ident(i.ident), attrs: fold_attrs(i.attrs, folder), + generics: folder.fold_generics(i.generics), defaultness: i.defaultness, node: match i.node { ast::ImplItemKind::Const(ty, expr) => { @@ -1067,6 +1069,7 @@ pub fn noop_fold_foreign_item(ni: ForeignItem, folder: &mut T) -> For ForeignItemKind::Static(t, m) => { ForeignItemKind::Static(folder.fold_ty(t), m) } + ForeignItemKind::Ty => ForeignItemKind::Ty, }, span: folder.new_span(ni.span) } @@ -1074,7 +1077,6 @@ pub fn noop_fold_foreign_item(ni: ForeignItem, folder: &mut T) -> For pub fn noop_fold_method_sig(sig: MethodSig, folder: &mut T) -> MethodSig { MethodSig { - generics: folder.fold_generics(sig.generics), abi: sig.abi, unsafety: sig.unsafety, constness: sig.constness, diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index db49ab1034358..b8151819bffed 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -153,17 +153,15 @@ impl Diagnostic { fn from_diagnostic_builder(db: &DiagnosticBuilder, je: &JsonEmitter) -> Diagnostic { - let sugg = db.suggestions.iter().flat_map(|sugg| { - je.render(sugg).into_iter().map(move |rendered| { - Diagnostic { - message: sugg.msg.clone(), - code: None, - level: "help", - spans: DiagnosticSpan::from_suggestion(sugg, je), - children: vec![], - rendered: Some(rendered), - } - }) + let sugg = db.suggestions.iter().map(|sugg| { + Diagnostic { + message: sugg.msg.clone(), + code: None, + level: "help", + spans: DiagnosticSpan::from_suggestion(sugg, je), + children: vec![], + rendered: None, + } }); Diagnostic { message: db.message(), @@ -356,9 +354,3 @@ impl DiagnosticCode { }) } } - -impl JsonEmitter { - fn render(&self, suggestion: &CodeSuggestion) -> Vec { - suggestion.splice_lines(&*self.cm).iter().map(|line| line.0.to_owned()).collect() - } -} diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 1cb7b0eca58d0..d9c3dbb630d0c 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1721,7 +1721,9 @@ mod tests { use std::rc::Rc; fn mk_sess(cm: Rc) -> ParseSess { - let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), Some(cm.clone())); + let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), + Some(cm.clone()), + false); ParseSess { span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)), unstable_features: UnstableFeatures::from_environment(), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8fd2bad4e44a6..a3a265450ab0e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -36,7 +36,7 @@ use ast::SelfKind; use ast::{TraitItem, TraitRef, TraitObjectSyntax}; use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds}; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; -use ast::{Visibility, WhereClause}; +use ast::{Visibility, WhereClause, CrateSugar}; use ast::{BinOpKind, UnOp}; use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; @@ -1033,7 +1033,23 @@ impl<'a> Parser<'a> { } else { if let Err(e) = self.expect(t) { fe(e); - break; + // Attempt to keep parsing if it was a similar separator + if let Some(ref tokens) = t.similar_tokens() { + if tokens.contains(&self.token) { + self.bump(); + } + } + // Attempt to keep parsing if it was an omitted separator + match f(self) { + Ok(t) => { + v.push(t); + continue; + }, + Err(mut e) => { + e.cancel(); + break; + } + } } } } @@ -1287,10 +1303,10 @@ impl<'a> Parser<'a> { mut attrs: Vec) -> PResult<'a, TraitItem> { let lo = self.span; - let (name, node) = if self.eat_keyword(keywords::Type) { + let (name, node, generics) = if self.eat_keyword(keywords::Type) { let TyParam {ident, bounds, default, ..} = self.parse_ty_param(vec![])?; self.expect(&token::Semi)?; - (ident, TraitItemKind::Type(bounds, default)) + (ident, TraitItemKind::Type(bounds, default), ast::Generics::default()) } else if self.is_const_item() { self.expect_keyword(keywords::Const)?; let ident = self.parse_ident()?; @@ -1305,7 +1321,7 @@ impl<'a> Parser<'a> { self.expect(&token::Semi)?; None }; - (ident, TraitItemKind::Const(ty, default)) + (ident, TraitItemKind::Const(ty, default), ast::Generics::default()) } else if self.token.is_path_start() { // trait item macro. // code copied from parse_macro_use_or_failure... abstraction! @@ -1328,7 +1344,7 @@ impl<'a> Parser<'a> { } let mac = respan(lo.to(self.prev_span), Mac_ { path: pth, tts: tts }); - (keywords::Invalid.ident(), ast::TraitItemKind::Macro(mac)) + (keywords::Invalid.ident(), ast::TraitItemKind::Macro(mac), ast::Generics::default()) } else { let (constness, unsafety, abi) = self.parse_fn_front_matter()?; @@ -1341,13 +1357,12 @@ impl<'a> Parser<'a> { // definition... p.parse_arg_general(false) })?; - generics.where_clause = self.parse_where_clause()?; + let sig = ast::MethodSig { unsafety, constness, decl: d, - generics, abi, }; @@ -1370,13 +1385,14 @@ impl<'a> Parser<'a> { return Err(self.fatal(&format!("expected `;` or `{{`, found `{}`", token_str))); } }; - (ident, ast::TraitItemKind::Method(sig, body)) + (ident, ast::TraitItemKind::Method(sig, body), generics) }; Ok(TraitItem { id: ast::DUMMY_NODE_ID, ident: name, attrs, + generics, node, span: lo.to(self.prev_span), tokens: None, @@ -4901,12 +4917,12 @@ impl<'a> Parser<'a> { let lo = self.span; let vis = self.parse_visibility(false)?; let defaultness = self.parse_defaultness()?; - let (name, node) = if self.eat_keyword(keywords::Type) { + let (name, node, generics) = if self.eat_keyword(keywords::Type) { let name = self.parse_ident()?; self.expect(&token::Eq)?; let typ = self.parse_ty()?; self.expect(&token::Semi)?; - (name, ast::ImplItemKind::Type(typ)) + (name, ast::ImplItemKind::Type(typ), ast::Generics::default()) } else if self.is_const_item() { self.expect_keyword(keywords::Const)?; let name = self.parse_ident()?; @@ -4915,11 +4931,11 @@ impl<'a> Parser<'a> { self.expect(&token::Eq)?; let expr = self.parse_expr()?; self.expect(&token::Semi)?; - (name, ast::ImplItemKind::Const(typ, expr)) + (name, ast::ImplItemKind::Const(typ, expr), ast::Generics::default()) } else { - let (name, inner_attrs, node) = self.parse_impl_method(&vis, at_end)?; + let (name, inner_attrs, generics, node) = self.parse_impl_method(&vis, at_end)?; attrs.extend(inner_attrs); - (name, node) + (name, node, generics) }; Ok(ImplItem { @@ -4929,6 +4945,7 @@ impl<'a> Parser<'a> { vis, defaultness, attrs, + generics, node, tokens: None, }) @@ -4986,7 +5003,8 @@ impl<'a> Parser<'a> { /// Parse a method or a macro invocation in a trait impl. fn parse_impl_method(&mut self, vis: &Visibility, at_end: &mut bool) - -> PResult<'a, (Ident, Vec, ast::ImplItemKind)> { + -> PResult<'a, (Ident, Vec, ast::Generics, + ast::ImplItemKind)> { // code copied from parse_macro_use_or_failure... abstraction! if self.token.is_path_start() { // Method macro. @@ -5013,7 +5031,8 @@ impl<'a> Parser<'a> { } let mac = respan(lo.to(self.prev_span), Mac_ { path: pth, tts: tts }); - Ok((keywords::Invalid.ident(), vec![], ast::ImplItemKind::Macro(mac))) + Ok((keywords::Invalid.ident(), vec![], ast::Generics::default(), + ast::ImplItemKind::Macro(mac))) } else { let (constness, unsafety, abi) = self.parse_fn_front_matter()?; let ident = self.parse_ident()?; @@ -5022,8 +5041,7 @@ impl<'a> Parser<'a> { generics.where_clause = self.parse_where_clause()?; *at_end = true; let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; - Ok((ident, inner_attrs, ast::ImplItemKind::Method(ast::MethodSig { - generics, + Ok((ident, inner_attrs, generics, ast::ImplItemKind::Method(ast::MethodSig { abi, unsafety, constness, @@ -5325,6 +5343,10 @@ impl<'a> Parser<'a> { pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> { maybe_whole!(self, NtVis, |x| x); + if self.eat_keyword(keywords::Crate) { + return Ok(Visibility::Crate(self.prev_span, CrateSugar::JustCrate)); + } + if !self.eat_keyword(keywords::Pub) { return Ok(Visibility::Inherited) } @@ -5338,7 +5360,7 @@ impl<'a> Parser<'a> { // `pub(crate)` self.bump(); // `(` self.bump(); // `crate` - let vis = Visibility::Crate(self.prev_span); + let vis = Visibility::Crate(self.prev_span, CrateSugar::PubCrate); self.expect(&token::CloseDelim(token::Paren))?; // `)` return Ok(vis) } else if self.look_ahead(1, |t| t.is_keyword(keywords::In)) { @@ -5665,6 +5687,24 @@ impl<'a> Parser<'a> { }) } + /// Parse a type from a foreign module + fn parse_item_foreign_type(&mut self, vis: ast::Visibility, lo: Span, attrs: Vec) + -> PResult<'a, ForeignItem> { + self.expect_keyword(keywords::Type)?; + + let ident = self.parse_ident()?; + let hi = self.span; + self.expect(&token::Semi)?; + Ok(ast::ForeignItem { + ident: ident, + attrs: attrs, + node: ForeignItemKind::Ty, + id: ast::DUMMY_NODE_ID, + span: lo.to(hi), + vis: vis + }) + } + /// Parse extern crate links /// /// # Examples @@ -6139,6 +6179,10 @@ impl<'a> Parser<'a> { if self.check_keyword(keywords::Fn) { return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?)); } + // FOREIGN TYPE ITEM + if self.check_keyword(keywords::Type) { + return Ok(Some(self.parse_item_foreign_type(visibility, lo, attrs)?)); + } // FIXME #5668: this will occur for a macro invocation: match self.parse_macro_use_or_failure(attrs, true, false, lo, visibility)? { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 20db87cfc82d9..09dc05a4167e6 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -433,6 +433,16 @@ impl Token { }) } + /// Returns tokens that are likely to be typed accidentally instead of the current token. + /// Enables better error recovery when the wrong token is found. + pub fn similar_tokens(&self) -> Option> { + match *self { + Comma => Some(vec![Dot, Lt]), + Semi => Some(vec![Colon]), + _ => None + } + } + /// Returns `true` if the token is either a special identifier or a keyword. pub fn is_reserved_ident(&self) -> bool { self.is_special_ident() || self.is_used_keyword() || self.is_unused_keyword() diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 02f871c58c73c..8a970fd409895 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1112,6 +1112,13 @@ impl<'a> State<'a> { self.end()?; // end the head-ibox self.end() // end the outer cbox } + ast::ForeignItemKind::Ty => { + self.head(&visibility_qualified(&item.vis, "type"))?; + self.print_ident(item.ident)?; + self.s.word(";")?; + self.end()?; // end the head-ibox + self.end() // end the outer cbox + } } } @@ -1440,7 +1447,10 @@ impl<'a> State<'a> { pub fn print_visibility(&mut self, vis: &ast::Visibility) -> io::Result<()> { match *vis { ast::Visibility::Public => self.word_nbsp("pub"), - ast::Visibility::Crate(_) => self.word_nbsp("pub(crate)"), + ast::Visibility::Crate(_, sugar) => match sugar { + ast::CrateSugar::PubCrate => self.word_nbsp("pub(crate)"), + ast::CrateSugar::JustCrate => self.word_nbsp("crate") + } ast::Visibility::Restricted { ref path, .. } => { let path = to_string(|s| s.print_path(path, false, 0, true)); if path == "self" || path == "super" { @@ -1525,6 +1535,7 @@ impl<'a> State<'a> { pub fn print_method_sig(&mut self, ident: ast::Ident, + generics: &ast::Generics, m: &ast::MethodSig, vis: &ast::Visibility) -> io::Result<()> { @@ -1533,7 +1544,7 @@ impl<'a> State<'a> { m.constness.node, m.abi, Some(ident), - &m.generics, + &generics, vis) } @@ -1553,7 +1564,7 @@ impl<'a> State<'a> { if body.is_some() { self.head("")?; } - self.print_method_sig(ti.ident, sig, &ast::Visibility::Inherited)?; + self.print_method_sig(ti.ident, &ti.generics, sig, &ast::Visibility::Inherited)?; if let Some(ref body) = *body { self.nbsp()?; self.print_block_with_attrs(body, &ti.attrs)?; @@ -1592,7 +1603,7 @@ impl<'a> State<'a> { } ast::ImplItemKind::Method(ref sig, ref body) => { self.head("")?; - self.print_method_sig(ii.ident, sig, &ii.vis)?; + self.print_method_sig(ii.ident, &ii.generics, sig, &ii.vis)?; self.nbsp()?; self.print_block_with_attrs(body, &ii.attrs)?; } diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index e9b1976ea472b..a29250ea5f19f 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -60,7 +60,8 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & } let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), - Some(code_map.clone())); + Some(code_map.clone()), + false); let handler = Handler::with_emitter(true, false, Box::new(emitter)); handler.span_err(msp, "foo"); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 521c6030eba2c..96e47a6cc0ff6 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -27,11 +27,13 @@ use abi::Abi; use ast::*; use syntax_pos::Span; use codemap::Spanned; +use parse::token::Token; +use tokenstream::{TokenTree, TokenStream}; #[derive(Copy, Clone, PartialEq, Eq)] pub enum FnKind<'a> { /// fn foo() or extern "Abi" fn foo() - ItemFn(Ident, &'a Generics, Unsafety, Spanned, Abi, &'a Visibility, &'a Block), + ItemFn(Ident, Unsafety, Spanned, Abi, &'a Visibility, &'a Block), /// fn foo(&self) Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a Block), @@ -130,7 +132,17 @@ pub trait Visitor<'ast>: Sized { fn visit_assoc_type_binding(&mut self, type_binding: &'ast TypeBinding) { walk_assoc_type_binding(self, type_binding) } - fn visit_attribute(&mut self, _attr: &'ast Attribute) {} + fn visit_attribute(&mut self, attr: &'ast Attribute) { + walk_attribute(self, attr) + } + fn visit_tt(&mut self, tt: TokenTree) { + walk_tt(self, tt) + } + fn visit_tts(&mut self, tts: TokenStream) { + walk_tts(self, tts) + } + fn visit_token(&mut self, _t: Token) {} + // FIXME: add `visit_interpolated` and `walk_interpolated` fn visit_vis(&mut self, vis: &'ast Visibility) { walk_vis(self, vis) } @@ -247,7 +259,8 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_expr(expr); } ItemKind::Fn(ref declaration, unsafety, constness, abi, ref generics, ref body) => { - visitor.visit_fn(FnKind::ItemFn(item.ident, generics, unsafety, + visitor.visit_generics(generics); + visitor.visit_fn(FnKind::ItemFn(item.ident, unsafety, constness, abi, &item.vis, body), declaration, item.span, @@ -464,6 +477,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, foreign_item: &'a visitor.visit_generics(generics) } ForeignItemKind::Static(ref typ, _) => visitor.visit_ty(typ), + ForeignItemKind::Ty => (), } walk_list!(visitor, visit_attribute, &foreign_item.attrs); @@ -538,13 +552,11 @@ pub fn walk_fn<'a, V>(visitor: &mut V, kind: FnKind<'a>, declaration: &'a FnDecl where V: Visitor<'a>, { match kind { - FnKind::ItemFn(_, generics, _, _, _, _, body) => { - visitor.visit_generics(generics); + FnKind::ItemFn(_, _, _, _, _, body) => { walk_fn_decl(visitor, declaration); visitor.visit_block(body); } - FnKind::Method(_, sig, _, body) => { - visitor.visit_generics(&sig.generics); + FnKind::Method(_, _, _, body) => { walk_fn_decl(visitor, declaration); visitor.visit_block(body); } @@ -558,13 +570,13 @@ pub fn walk_fn<'a, V>(visitor: &mut V, kind: FnKind<'a>, declaration: &'a FnDecl pub fn walk_trait_item<'a, V: Visitor<'a>>(visitor: &mut V, trait_item: &'a TraitItem) { visitor.visit_ident(trait_item.span, trait_item.ident); walk_list!(visitor, visit_attribute, &trait_item.attrs); + visitor.visit_generics(&trait_item.generics); match trait_item.node { TraitItemKind::Const(ref ty, ref default) => { visitor.visit_ty(ty); walk_list!(visitor, visit_expr, default); } TraitItemKind::Method(ref sig, None) => { - visitor.visit_generics(&sig.generics); walk_fn_decl(visitor, &sig.decl); } TraitItemKind::Method(ref sig, Some(ref body)) => { @@ -585,6 +597,7 @@ pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplIt visitor.visit_vis(&impl_item.vis); visitor.visit_ident(impl_item.span, impl_item.ident); walk_list!(visitor, visit_attribute, &impl_item.attrs); + visitor.visit_generics(&impl_item.generics); match impl_item.node { ImplItemKind::Const(ref ty, ref expr) => { visitor.visit_ty(ty); @@ -810,3 +823,20 @@ pub fn walk_vis<'a, V: Visitor<'a>>(visitor: &mut V, vis: &'a Visibility) { visitor.visit_path(path, id); } } + +pub fn walk_attribute<'a, V: Visitor<'a>>(visitor: &mut V, attr: &'a Attribute) { + visitor.visit_tts(attr.tokens.clone()); +} + +pub fn walk_tt<'a, V: Visitor<'a>>(visitor: &mut V, tt: TokenTree) { + match tt { + TokenTree::Token(_, tok) => visitor.visit_token(tok), + TokenTree::Delimited(_, delimed) => visitor.visit_tts(delimed.stream()), + } +} + +pub fn walk_tts<'a, V: Visitor<'a>>(visitor: &mut V, tts: TokenStream) { + for tt in tts.trees() { + visitor.visit_tt(tt); + } +} diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 5c1ca19d635f7..18897047538f1 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -506,6 +506,7 @@ impl<'a> TraitDef<'a> { vis: ast::Visibility::Inherited, defaultness: ast::Defaultness::Final, attrs: Vec::new(), + generics: Generics::default(), node: ast::ImplItemKind::Type(type_def.to_ty(cx, self.span, type_ident, generics)), tokens: None, } @@ -921,12 +922,12 @@ impl<'a> MethodDef<'a> { ast::ImplItem { id: ast::DUMMY_NODE_ID, attrs: self.attributes.clone(), + generics: fn_generics, span: trait_.span, vis: ast::Visibility::Inherited, defaultness: ast::Defaultness::Final, ident: method_ident, node: ast::ImplItemKind::Method(ast::MethodSig { - generics: fn_generics, abi, unsafety, constness: diff --git a/src/stage0.txt b/src/stage0.txt index 892679c192916..6b3aaf2deb264 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2017-08-29 +date: 2017-10-20 rustc: beta cargo: beta diff --git a/src/test/codegen/adjustments.rs b/src/test/codegen/adjustments.rs index 40603845da2b0..bd85e30314348 100644 --- a/src/test/codegen/adjustments.rs +++ b/src/test/codegen/adjustments.rs @@ -13,7 +13,7 @@ #![crate_type = "lib"] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]]) +// CHECK: @helper([[USIZE:i[0-9]+]] %arg0) #[no_mangle] fn helper(_: usize) { } @@ -23,9 +23,9 @@ fn helper(_: usize) { pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] { // We used to generate an extra alloca and memcpy for the block's trailing expression value, so // check that we copy directly to the return value slot -// CHECK: %2 = insertvalue { i8*, [[USIZE]] } undef, i8* %0, 0 -// CHECK: %3 = insertvalue { i8*, [[USIZE]] } %2, [[USIZE]] %1, 1 -// CHECK: ret { i8*, [[USIZE]] } %3 +// CHECK: %0 = insertvalue { i8*, [[USIZE]] } undef, i8* %x.ptr, 0 +// CHECK: %1 = insertvalue { i8*, [[USIZE]] } %0, [[USIZE]] %x.meta, 1 +// CHECK: ret { i8*, [[USIZE]] } %1 { x } } diff --git a/src/test/codegen/align-struct.rs b/src/test/codegen/align-struct.rs index d4828be037a49..ba81e2d6046e8 100644 --- a/src/test/codegen/align-struct.rs +++ b/src/test/codegen/align-struct.rs @@ -42,7 +42,6 @@ pub fn align64(i : i32) -> Align64 { #[no_mangle] pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 { // CHECK: %n64 = alloca %Nested64, align 64 -// CHECK: %a = alloca %Align64, align 64 let n64 = Nested64 { a, b, c, d }; n64 } @@ -51,7 +50,6 @@ pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 { #[no_mangle] pub fn enum64(a: Align64) -> Enum64 { // CHECK: %e64 = alloca %Enum64, align 64 -// CHECK: %a = alloca %Align64, align 64 let e64 = Enum64::A(a); e64 } diff --git a/src/test/codegen/fastcall-inreg.rs b/src/test/codegen/fastcall-inreg.rs index f02e7e9f0ddcf..cc13d4a7b68d2 100644 --- a/src/test/codegen/fastcall-inreg.rs +++ b/src/test/codegen/fastcall-inreg.rs @@ -60,27 +60,27 @@ #![crate_type = "lib"] mod tests { - // CHECK: @f1(i32 inreg, i32 inreg, i32) + // CHECK: @f1(i32 inreg %arg0, i32 inreg %arg1, i32 %arg2) #[no_mangle] extern "fastcall" fn f1(_: i32, _: i32, _: i32) {} - // CHECK: @f2(i32* inreg, i32* inreg, i32*) + // CHECK: @f2(i32* inreg %arg0, i32* inreg %arg1, i32* %arg2) #[no_mangle] extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {} - // CHECK: @f3(float, i32 inreg, i32 inreg, i32) + // CHECK: @f3(float %arg0, i32 inreg %arg1, i32 inreg %arg2, i32 %arg3) #[no_mangle] extern "fastcall" fn f3(_: f32, _: i32, _: i32, _: i32) {} - // CHECK: @f4(i32 inreg, float, i32 inreg, i32) + // CHECK: @f4(i32 inreg %arg0, float %arg1, i32 inreg %arg2, i32 %arg3) #[no_mangle] extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {} - // CHECK: @f5(i64, i32) + // CHECK: @f5(i64 %arg0, i32 %arg1) #[no_mangle] extern "fastcall" fn f5(_: i64, _: i32) {} - // CHECK: @f6(i1 inreg zeroext, i32 inreg, i32) + // CHECK: @f6(i1 inreg zeroext %arg0, i32 inreg %arg1, i32 %arg2) #[no_mangle] extern "fastcall" fn f6(_: bool, _: i32, _: i32) {} } diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index d8bbcd9b7328e..d4c7fe9e80a1c 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -21,62 +21,62 @@ pub struct UnsafeInner { _field: std::cell::UnsafeCell, } -// CHECK: zeroext i1 @boolean(i1 zeroext) +// CHECK: zeroext i1 @boolean(i1 zeroext %x) #[no_mangle] pub fn boolean(x: bool) -> bool { x } -// CHECK: @readonly_borrow(i32* noalias readonly dereferenceable(4)) +// CHECK: @readonly_borrow(i32* noalias readonly dereferenceable(4) %arg0) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn readonly_borrow(_: &i32) { } -// CHECK: @static_borrow(i32* noalias readonly dereferenceable(4)) +// CHECK: @static_borrow(i32* noalias readonly dereferenceable(4) %arg0) // static borrow may be captured #[no_mangle] pub fn static_borrow(_: &'static i32) { } -// CHECK: @named_borrow(i32* noalias readonly dereferenceable(4)) +// CHECK: @named_borrow(i32* noalias readonly dereferenceable(4) %arg0) // borrow with named lifetime may be captured #[no_mangle] pub fn named_borrow<'r>(_: &'r i32) { } -// CHECK: @unsafe_borrow(%UnsafeInner* dereferenceable(2)) +// CHECK: @unsafe_borrow(%UnsafeInner* dereferenceable(2) %arg0) // unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_borrow(_: &UnsafeInner) { } -// CHECK: @mutable_unsafe_borrow(%UnsafeInner* dereferenceable(2)) +// CHECK: @mutable_unsafe_borrow(%UnsafeInner* dereferenceable(2) %arg0) // ... unless this is a mutable borrow, those never alias // ... except that there's this LLVM bug that forces us to not use noalias, see #29485 #[no_mangle] pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) { } -// CHECK: @mutable_borrow(i32* dereferenceable(4)) +// CHECK: @mutable_borrow(i32* dereferenceable(4) %arg0) // FIXME #25759 This should also have `nocapture` // ... there's this LLVM bug that forces us to not use noalias, see #29485 #[no_mangle] pub fn mutable_borrow(_: &mut i32) { } -// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32)) +// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32) %arg0) #[no_mangle] pub fn indirect_struct(_: S) { } -// CHECK: @borrowed_struct(%S* noalias readonly dereferenceable(32)) +// CHECK: @borrowed_struct(%S* noalias readonly dereferenceable(32) %arg0) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn borrowed_struct(_: &S) { } -// CHECK: noalias dereferenceable(4) i32* @_box(i32* noalias dereferenceable(4)) +// CHECK: noalias dereferenceable(4) i32* @_box(i32* noalias dereferenceable(4) %x) #[no_mangle] pub fn _box(x: Box) -> Box { x @@ -91,31 +91,31 @@ pub fn struct_return() -> S { } // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]]) +// CHECK: @helper([[USIZE:i[0-9]+]] %arg0) #[no_mangle] fn helper(_: usize) { } -// CHECK: @slice(i8* noalias nonnull readonly, [[USIZE]]) +// CHECK: @slice(i8* noalias nonnull readonly %arg0.ptr, [[USIZE]] %arg0.meta) // FIXME #25759 This should also have `nocapture` #[no_mangle] fn slice(_: &[u8]) { } -// CHECK: @mutable_slice(i8* nonnull, [[USIZE]]) +// CHECK: @mutable_slice(i8* nonnull %arg0.ptr, [[USIZE]] %arg0.meta) // FIXME #25759 This should also have `nocapture` // ... there's this LLVM bug that forces us to not use noalias, see #29485 #[no_mangle] fn mutable_slice(_: &mut [u8]) { } -// CHECK: @unsafe_slice(%UnsafeInner* nonnull, [[USIZE]]) +// CHECK: @unsafe_slice(%UnsafeInner* nonnull %arg0.ptr, [[USIZE]] %arg0.meta) // unsafe interior means this isn't actually readonly and there may be aliases ... #[no_mangle] pub fn unsafe_slice(_: &[UnsafeInner]) { } -// CHECK: @str(i8* noalias nonnull readonly, [[USIZE]]) +// CHECK: @str(i8* noalias nonnull readonly %arg0.ptr, [[USIZE]] %arg0.meta) // FIXME #25759 This should also have `nocapture` #[no_mangle] fn str(_: &[u8]) { @@ -132,7 +132,7 @@ fn trait_borrow(_: &Drop) { fn trait_box(_: Box) { } -// CHECK: { i16*, [[USIZE]] } @return_slice(i16* noalias nonnull readonly, [[USIZE]]) +// CHECK: { i16*, [[USIZE]] } @return_slice(i16* noalias nonnull readonly %x.ptr, [[USIZE]] %x.meta) #[no_mangle] fn return_slice(x: &[u16]) -> &[u16] { x diff --git a/src/test/codegen/issue-37945.rs b/src/test/codegen/issue-37945.rs index e7c91f309181a..df02426badcc5 100644 --- a/src/test/codegen/issue-37945.rs +++ b/src/test/codegen/issue-37945.rs @@ -13,6 +13,7 @@ // ignore-x86 // ignore-arm // ignore-emscripten +// ignore-gnux32 // ignore 32-bit platforms (LLVM has a bug with them) // See issue #37945. diff --git a/src/test/codegen/move-val-init.rs b/src/test/codegen/move-val-init.rs index 98b7db60b68fc..e2371d6148762 100644 --- a/src/test/codegen/move-val-init.rs +++ b/src/test/codegen/move-val-init.rs @@ -24,6 +24,6 @@ pub struct Big { // CHECK-LABEL: @test_mvi #[no_mangle] pub unsafe fn test_mvi(target: *mut Big, make_big: fn() -> Big) { - // CHECK: call void %1(%Big*{{[^%]*}} %0) + // CHECK: call void %make_big(%Big*{{[^%]*}} %target) move_val_init(target, make_big()); } diff --git a/src/test/codegen/refs.rs b/src/test/codegen/refs.rs index 49ed2229fcd2b..fd1a14020d810 100644 --- a/src/test/codegen/refs.rs +++ b/src/test/codegen/refs.rs @@ -13,7 +13,7 @@ #![crate_type = "lib"] // Hack to get the correct size for the length part in slices -// CHECK: @helper([[USIZE:i[0-9]+]]) +// CHECK: @helper([[USIZE:i[0-9]+]] %arg0) #[no_mangle] fn helper(_: usize) { } @@ -24,9 +24,9 @@ pub fn ref_dst(s: &[u8]) { // We used to generate an extra alloca and memcpy to ref the dst, so check that we copy // directly to the alloca for "x" // CHECK: [[X0:%[0-9]+]] = getelementptr {{.*}} { i8*, [[USIZE]] }* %x, i32 0, i32 0 -// CHECK: store i8* %0, i8** [[X0]] +// CHECK: store i8* %s.ptr, i8** [[X0]] // CHECK: [[X1:%[0-9]+]] = getelementptr {{.*}} { i8*, [[USIZE]] }* %x, i32 0, i32 1 -// CHECK: store [[USIZE]] %1, [[USIZE]]* [[X1]] +// CHECK: store [[USIZE]] %s.meta, [[USIZE]]* [[X1]] let x = &*s; &x; // keep variable in an alloca diff --git a/src/test/codegen/stores.rs b/src/test/codegen/stores.rs index 6135f49eb711b..08f5038fb186e 100644 --- a/src/test/codegen/stores.rs +++ b/src/test/codegen/stores.rs @@ -25,9 +25,9 @@ pub struct Bytes { #[no_mangle] pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) { // CHECK: [[TMP:%.+]] = alloca i32 -// CHECK: %arg1 = alloca [4 x i8] -// CHECK: store i32 %1, i32* [[TMP]] -// CHECK: [[Y8:%[0-9]+]] = bitcast [4 x i8]* %arg1 to i8* +// CHECK: %y = alloca [4 x i8] +// CHECK: store i32 %0, i32* [[TMP]] +// CHECK: [[Y8:%[0-9]+]] = bitcast [4 x i8]* %y to i8* // CHECK: [[TMP8:%[0-9]+]] = bitcast i32* [[TMP]] to i8* // CHECK: call void @llvm.memcpy.{{.*}}(i8* [[Y8]], i8* [[TMP8]], i{{[0-9]+}} 4, i32 1, i1 false) *x = y; @@ -39,9 +39,9 @@ pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) { #[no_mangle] pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) { // CHECK: [[TMP:%.+]] = alloca i32 -// CHECK: %arg1 = alloca %Bytes -// CHECK: store i32 %1, i32* [[TMP]] -// CHECK: [[Y8:%[0-9]+]] = bitcast %Bytes* %arg1 to i8* +// CHECK: %y = alloca %Bytes +// CHECK: store i32 %0, i32* [[TMP]] +// CHECK: [[Y8:%[0-9]+]] = bitcast %Bytes* %y to i8* // CHECK: [[TMP8:%[0-9]+]] = bitcast i32* [[TMP]] to i8* // CHECK: call void @llvm.memcpy.{{.*}}(i8* [[Y8]], i8* [[TMP8]], i{{[0-9]+}} 4, i32 1, i1 false) *x = y; diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs index fc53031e7f226..d3f921e0878ae 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs @@ -12,6 +12,7 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] +#![feature(macro_vis_matcher)] #[macro_use] extern crate rustc; extern crate rustc_plugin; diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs index 490aa0d469312..a0c72243d4821 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs @@ -12,6 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] +#![feature(macro_vis_matcher)] // Load rustc as a plugin to get macros #[macro_use] diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs index 8647797270f9a..cbbfbd8060360 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs @@ -12,6 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] +#![feature(macro_vis_matcher)] extern crate syntax; diff --git a/src/test/compile-fail/E0017.rs b/src/test/compile-fail/E0017.rs index c6bec6090f242..726a6f8c6feb4 100644 --- a/src/test/compile-fail/E0017.rs +++ b/src/test/compile-fail/E0017.rs @@ -13,15 +13,9 @@ const C: i32 = 2; const CR: &'static mut i32 = &mut C; //~ ERROR E0017 //~| NOTE constants require immutable values - //~| ERROR E0017 - //~| NOTE constants require immutable values static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - //~| NOTE statics require immutable values - //~| ERROR E0017 //~| NOTE statics require immutable values //~| ERROR cannot borrow static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 //~| NOTE statics require immutable values - //~| ERROR E0017 - //~| NOTE statics require immutable values fn main() {} diff --git a/src/test/compile-fail/E0388.rs b/src/test/compile-fail/E0388.rs index 2c88039d373e5..c002badfef64c 100644 --- a/src/test/compile-fail/E0388.rs +++ b/src/test/compile-fail/E0388.rs @@ -12,11 +12,8 @@ static X: i32 = 1; const C: i32 = 2; const CR: &'static mut i32 = &mut C; //~ ERROR E0017 - //~| ERROR E0017 static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - //~| ERROR E0017 //~| ERROR cannot borrow static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 - //~| ERROR E0017 fn main() {} diff --git a/src/test/compile-fail/asm-out-assign-imm.rs b/src/test/compile-fail/asm-out-assign-imm.rs index 546d402252e27..f2629fa52ffdd 100644 --- a/src/test/compile-fail/asm-out-assign-imm.rs +++ b/src/test/compile-fail/asm-out-assign-imm.rs @@ -27,8 +27,8 @@ pub fn main() { foo(x); unsafe { asm!("mov $1, $0" : "=r"(x) : "r"(5)); - //~^ ERROR re-assignment of immutable variable `x` - //~| NOTE re-assignment of immutable + //~^ ERROR cannot assign twice to immutable variable `x` + //~| NOTE cannot assign twice to immutable } foo(x); } diff --git a/src/test/compile-fail/assign-imm-local-twice.rs b/src/test/compile-fail/assign-imm-local-twice.rs index 9a5d6289b589e..5b3b7d44bd2b9 100644 --- a/src/test/compile-fail/assign-imm-local-twice.rs +++ b/src/test/compile-fail/assign-imm-local-twice.rs @@ -12,8 +12,8 @@ fn test() { let v: isize; v = 1; //~ NOTE first assignment println!("v={}", v); - v = 2; //~ ERROR re-assignment of immutable variable - //~| NOTE re-assignment of immutable + v = 2; //~ ERROR cannot assign twice to immutable variable + //~| NOTE cannot assign twice to immutable println!("v={}", v); } diff --git a/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs b/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs index 3639db5cfc4cd..ea30911b3cc79 100644 --- a/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs +++ b/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs @@ -26,7 +26,7 @@ struct S { pub fn main() { match 1 { x => { - x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` //[mir]~^ ERROR (Mir) [E0384] //[mir]~| ERROR (Ast) [E0384] } @@ -34,7 +34,7 @@ pub fn main() { match E::Foo(1) { E::Foo(x) => { - x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` //[mir]~^ ERROR (Mir) [E0384] //[mir]~| ERROR (Ast) [E0384] } @@ -42,7 +42,7 @@ pub fn main() { match (S { bar: 1 }) { S { bar: x } => { - x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` //[mir]~^ ERROR (Mir) [E0384] //[mir]~| ERROR (Ast) [E0384] } @@ -50,7 +50,7 @@ pub fn main() { match (1,) { (x,) => { - x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` //[mir]~^ ERROR (Mir) [E0384] //[mir]~| ERROR (Ast) [E0384] } @@ -58,7 +58,7 @@ pub fn main() { match [1,2,3] { [x,_,_] => { - x += 1; //[ast]~ ERROR re-assignment of immutable variable `x` + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` //[mir]~^ ERROR (Mir) [E0384] //[mir]~| ERROR (Ast) [E0384] } diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-call.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-call.rs index 4c20688331b6d..41f3e472cd125 100644 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-call.rs +++ b/src/test/compile-fail/borrowck/borrowck-overloaded-call.rs @@ -67,7 +67,6 @@ fn f() { }; let sp = &mut s; s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable } fn g() { diff --git a/src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs b/src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs index 0f9829ab259a9..4813b4b6a72cd 100644 --- a/src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs +++ b/src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs @@ -11,7 +11,6 @@ fn a isize>(mut f: F) { let g = &mut f; f(1, 2); //~ ERROR cannot borrow `f` as immutable - //~^ ERROR cannot borrow `f` as immutable } fn b isize>(f: F) { diff --git a/src/test/compile-fail/check-static-immutable-mut-slices.rs b/src/test/compile-fail/check-static-immutable-mut-slices.rs index 370cfe9d55012..1804b9e04c2c9 100644 --- a/src/test/compile-fail/check-static-immutable-mut-slices.rs +++ b/src/test/compile-fail/check-static-immutable-mut-slices.rs @@ -12,6 +12,5 @@ static TEST: &'static mut [isize] = &mut []; //~^ ERROR references in statics may only refer to immutable values -//~^^ ERROR references in statics may only refer to immutable values pub fn main() { } diff --git a/src/test/compile-fail/const-err.rs b/src/test/compile-fail/const-err.rs index 944e458c4c0f0..e65194ab56f98 100644 --- a/src/test/compile-fail/const-err.rs +++ b/src/test/compile-fail/const-err.rs @@ -24,8 +24,6 @@ fn black_box(_: T) { const FOO: u8 = [5u8][1]; //~^ ERROR constant evaluation error //~| index out of bounds: the len is 1 but the index is 1 -//~^^^ ERROR constant evaluation error -//~| index out of bounds: the len is 1 but the index is 1 fn main() { let a = -std::i8::MIN; @@ -33,8 +31,7 @@ fn main() { //~| attempt to negate with overflow let b = 200u8 + 200u8 + 200u8; //~^ WARN this expression will panic at run-time - //~| attempt to add with overflow - //~^^^ WARN this expression will panic at run-time + //~^^ WARN this expression will panic at run-time //~| attempt to add with overflow let c = 200u8 * 4; //~^ WARN this expression will panic at run-time diff --git a/src/test/compile-fail/const-err2.rs b/src/test/compile-fail/const-err2.rs index 7c1fb2ccd4729..9889ca1392ac1 100644 --- a/src/test/compile-fail/const-err2.rs +++ b/src/test/compile-fail/const-err2.rs @@ -21,7 +21,6 @@ fn main() { //~^ ERROR attempt to negate with overflow let b = 200u8 + 200u8 + 200u8; //~^ ERROR attempt to add with overflow - //~| ERROR attempt to add with overflow let c = 200u8 * 4; //~^ ERROR attempt to multiply with overflow let d = 42u8 - (42u8 + 1); diff --git a/src/test/compile-fail/const-eval-overflow.rs b/src/test/compile-fail/const-eval-overflow.rs index 3c688d58fd195..058a8d0a1bd4f 100644 --- a/src/test/compile-fail/const-eval-overflow.rs +++ b/src/test/compile-fail/const-eval-overflow.rs @@ -82,7 +82,7 @@ const VALS_I64: (i64, i64, i64, i64) = ); const VALS_U8: (u8, u8, u8, u8) = - ( //~ WARN constant evaluation error: attempt to subtract with overflow. + ( //~ WARN constant evaluation error: attempt to subtract with overflow -(u8::MIN as i8) as u8, u8::MIN - 1, //~^ ERROR constant evaluation error @@ -96,7 +96,7 @@ const VALS_U8: (u8, u8, u8, u8) = ); const VALS_U16: (u16, u16, u16, u16) = - ( //~ WARN constant evaluation error: attempt to subtract with overflow. + ( //~ WARN constant evaluation error: attempt to subtract with overflow -(u16::MIN as i16) as u16, u16::MIN - 1, //~^ ERROR constant evaluation error @@ -110,7 +110,7 @@ const VALS_U16: (u16, u16, u16, u16) = ); const VALS_U32: (u32, u32, u32, u32) = - ( //~ WARN constant evaluation error: attempt to subtract with overflow. + ( //~ WARN constant evaluation error: attempt to subtract with overflow -(u32::MIN as i32) as u32, u32::MIN - 1, //~^ ERROR constant evaluation error @@ -124,7 +124,7 @@ const VALS_U32: (u32, u32, u32, u32) = ); const VALS_U64: (u64, u64, u64, u64) = - ( //~ WARN constant evaluation error: attempt to subtract with overflow. + ( //~ WARN constant evaluation error: attempt to subtract with overflow -(u64::MIN as i64) as u64, u64::MIN - 1, //~^ ERROR constant evaluation error diff --git a/src/test/compile-fail/cycle-trait-default-type-trait.rs b/src/test/compile-fail/cycle-trait-default-type-trait.rs index 6825572b26c83..e6caeb34a8c8f 100644 --- a/src/test/compile-fail/cycle-trait-default-type-trait.rs +++ b/src/test/compile-fail/cycle-trait-default-type-trait.rs @@ -13,7 +13,6 @@ trait Foo> { //~^ ERROR unsupported cyclic reference - //~| ERROR unsupported cyclic reference } fn main() { } diff --git a/src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs index 0b73f5bebb23c..244acbf660533 100644 --- a/src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs +++ b/src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Clone-enum.rs b/src/test/compile-fail/derives-span-Clone-enum.rs index 6944ea38b3726..785a3d3543088 100644 --- a/src/test/compile-fail/derives-span-Clone-enum.rs +++ b/src/test/compile-fail/derives-span-Clone-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Clone-struct.rs b/src/test/compile-fail/derives-span-Clone-struct.rs index 92bf148ccbd94..b1b1dc7bed162 100644 --- a/src/test/compile-fail/derives-span-Clone-struct.rs +++ b/src/test/compile-fail/derives-span-Clone-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Clone-tuple-struct.rs b/src/test/compile-fail/derives-span-Clone-tuple-struct.rs index 21adfc90301b8..d56e21b9a8af2 100644 --- a/src/test/compile-fail/derives-span-Clone-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-Clone-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs index da777e8a14b45..4c25e482c2a68 100644 --- a/src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs +++ b/src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Debug-enum.rs b/src/test/compile-fail/derives-span-Debug-enum.rs index bf5d3f2d81b29..0cb02aa54e69d 100644 --- a/src/test/compile-fail/derives-span-Debug-enum.rs +++ b/src/test/compile-fail/derives-span-Debug-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Debug-struct.rs b/src/test/compile-fail/derives-span-Debug-struct.rs index b0b275fa2d347..33fa82355ec67 100644 --- a/src/test/compile-fail/derives-span-Debug-struct.rs +++ b/src/test/compile-fail/derives-span-Debug-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Debug-tuple-struct.rs b/src/test/compile-fail/derives-span-Debug-tuple-struct.rs index 9689054a7be6d..760ed199f6abd 100644 --- a/src/test/compile-fail/derives-span-Debug-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-Debug-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Default-struct.rs b/src/test/compile-fail/derives-span-Default-struct.rs index 68b99ed25b855..4adfe75adaf91 100644 --- a/src/test/compile-fail/derives-span-Default-struct.rs +++ b/src/test/compile-fail/derives-span-Default-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -15,7 +15,7 @@ struct Error; #[derive(Default)] struct Struct { - x: Error //~ ERROR `Error: std::default::Default` is not satisfied + x: Error //~ ERROR } fn main() {} diff --git a/src/test/compile-fail/derives-span-Default-tuple-struct.rs b/src/test/compile-fail/derives-span-Default-tuple-struct.rs index 822abe975a1cc..a5e3a7cd49f81 100644 --- a/src/test/compile-fail/derives-span-Default-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-Default-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs index fdc74d5fef6b1..6abd1d31e6615 100644 --- a/src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs +++ b/src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Eq-enum.rs b/src/test/compile-fail/derives-span-Eq-enum.rs index 4bf30fdf93f77..f361278a620f4 100644 --- a/src/test/compile-fail/derives-span-Eq-enum.rs +++ b/src/test/compile-fail/derives-span-Eq-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Eq-struct.rs b/src/test/compile-fail/derives-span-Eq-struct.rs index 685188f133786..7067caa6d5cca 100644 --- a/src/test/compile-fail/derives-span-Eq-struct.rs +++ b/src/test/compile-fail/derives-span-Eq-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Eq-tuple-struct.rs b/src/test/compile-fail/derives-span-Eq-tuple-struct.rs index 0e636d027dd37..1a09628b77091 100644 --- a/src/test/compile-fail/derives-span-Eq-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-Eq-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs index bfb6566223cb3..907045cce47d5 100644 --- a/src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs +++ b/src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Hash-enum.rs b/src/test/compile-fail/derives-span-Hash-enum.rs index 99f28b376dfe9..321b9e71a0f29 100644 --- a/src/test/compile-fail/derives-span-Hash-enum.rs +++ b/src/test/compile-fail/derives-span-Hash-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Hash-struct.rs b/src/test/compile-fail/derives-span-Hash-struct.rs index acfd5aa7b2a74..7f69c3a8e2565 100644 --- a/src/test/compile-fail/derives-span-Hash-struct.rs +++ b/src/test/compile-fail/derives-span-Hash-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Hash-tuple-struct.rs b/src/test/compile-fail/derives-span-Hash-tuple-struct.rs index 3d76b29834f09..2dee63c4298d0 100644 --- a/src/test/compile-fail/derives-span-Hash-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-Hash-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs index 06ee588e69f49..8f4e393c96a41 100644 --- a/src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs +++ b/src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Ord-enum.rs b/src/test/compile-fail/derives-span-Ord-enum.rs index af9cfbc911097..b8ceacf3753ef 100644 --- a/src/test/compile-fail/derives-span-Ord-enum.rs +++ b/src/test/compile-fail/derives-span-Ord-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Ord-struct.rs b/src/test/compile-fail/derives-span-Ord-struct.rs index 4477d933a6c7a..2ff62bac2bce1 100644 --- a/src/test/compile-fail/derives-span-Ord-struct.rs +++ b/src/test/compile-fail/derives-span-Ord-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-Ord-tuple-struct.rs b/src/test/compile-fail/derives-span-Ord-tuple-struct.rs index ebc7518641289..24eacb71d7b4a 100644 --- a/src/test/compile-fail/derives-span-Ord-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-Ord-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs b/src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs index 7c98dcc2a6f1d..14d94f1599e5f 100644 --- a/src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs +++ b/src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-PartialEq-enum.rs b/src/test/compile-fail/derives-span-PartialEq-enum.rs index fe6355e456cca..ab58bb938b9dd 100644 --- a/src/test/compile-fail/derives-span-PartialEq-enum.rs +++ b/src/test/compile-fail/derives-span-PartialEq-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-PartialEq-struct.rs b/src/test/compile-fail/derives-span-PartialEq-struct.rs index 10d9d64277683..05a0990ff035a 100644 --- a/src/test/compile-fail/derives-span-PartialEq-struct.rs +++ b/src/test/compile-fail/derives-span-PartialEq-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs b/src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs index c92eb0f63c4da..cdeb7ce45bc4c 100644 --- a/src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs b/src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs index 898104d0ab29c..cf3d69bc16c43 100644 --- a/src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs +++ b/src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -19,12 +19,6 @@ enum Enum { x: Error //~ ERROR //~^ ERROR //~^^ ERROR -//~^^^ ERROR -//~^^^^ ERROR -//~^^^^^ ERROR -//~^^^^^^ ERROR -//~^^^^^^^ ERROR -//~^^^^^^^^ ERROR } } diff --git a/src/test/compile-fail/derives-span-PartialOrd-enum.rs b/src/test/compile-fail/derives-span-PartialOrd-enum.rs index c0585999473b5..c4d587237a52f 100644 --- a/src/test/compile-fail/derives-span-PartialOrd-enum.rs +++ b/src/test/compile-fail/derives-span-PartialOrd-enum.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -19,12 +19,6 @@ enum Enum { Error //~ ERROR //~^ ERROR //~^^ ERROR -//~^^^ ERROR -//~^^^^ ERROR -//~^^^^^ ERROR -//~^^^^^^ ERROR -//~^^^^^^^ ERROR -//~^^^^^^^^ ERROR ) } diff --git a/src/test/compile-fail/derives-span-PartialOrd-struct.rs b/src/test/compile-fail/derives-span-PartialOrd-struct.rs index af05434af9de3..e065abd9b46a2 100644 --- a/src/test/compile-fail/derives-span-PartialOrd-struct.rs +++ b/src/test/compile-fail/derives-span-PartialOrd-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -18,12 +18,6 @@ struct Struct { x: Error //~ ERROR //~^ ERROR //~^^ ERROR -//~^^^ ERROR -//~^^^^ ERROR -//~^^^^^ ERROR -//~^^^^^^ ERROR -//~^^^^^^^ ERROR -//~^^^^^^^^ ERROR } fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs b/src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs index 1afb7bc2b4c47..f2df01222b989 100644 --- a/src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs +++ b/src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -18,12 +18,6 @@ struct Struct( Error //~ ERROR //~^ ERROR //~^^ ERROR -//~^^^ ERROR -//~^^^^ ERROR -//~^^^^^ ERROR -//~^^^^^^ ERROR -//~^^^^^^^ ERROR -//~^^^^^^^^ ERROR ); fn main() {} diff --git a/src/test/compile-fail/extern-types-distinct-types.rs b/src/test/compile-fail/extern-types-distinct-types.rs new file mode 100644 index 0000000000000..8b434bbfc6d33 --- /dev/null +++ b/src/test/compile-fail/extern-types-distinct-types.rs @@ -0,0 +1,22 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_types)] + +extern { + type A; + type B; +} + +fn foo(r: &A) -> &B { + r //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/compile-fail/extern-types-not-sync-send.rs b/src/test/compile-fail/extern-types-not-sync-send.rs new file mode 100644 index 0000000000000..2f00cf812e473 --- /dev/null +++ b/src/test/compile-fail/extern-types-not-sync-send.rs @@ -0,0 +1,28 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure extern types are !Sync and !Send. + +#![feature(extern_types)] + +extern { + type A; +} + +fn assert_sync() { } +fn assert_send() { } + +fn main() { + assert_sync::(); + //~^ ERROR the trait bound `A: std::marker::Sync` is not satisfied + + assert_send::(); + //~^ ERROR the trait bound `A: std::marker::Send` is not satisfied +} diff --git a/src/test/compile-fail/extern-types-unsized.rs b/src/test/compile-fail/extern-types-unsized.rs new file mode 100644 index 0000000000000..faa27894806f8 --- /dev/null +++ b/src/test/compile-fail/extern-types-unsized.rs @@ -0,0 +1,43 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure extern types are !Sized. + +#![feature(extern_types)] + +extern { + type A; +} + +struct Foo { + x: u8, + tail: A, +} + +struct Bar { + x: u8, + tail: T, +} + +fn assert_sized() { } + +fn main() { + assert_sized::(); + //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied + + assert_sized::(); + //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied + + assert_sized::>(); + //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied + + assert_sized::>>(); + //~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied +} diff --git a/src/test/compile-fail/feature-gate-crate_visibility_modifier.rs b/src/test/compile-fail/feature-gate-crate_visibility_modifier.rs new file mode 100644 index 0000000000000..a2937d6de31f3 --- /dev/null +++ b/src/test/compile-fail/feature-gate-crate_visibility_modifier.rs @@ -0,0 +1,18 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +crate struct Bender { //~ ERROR `crate` visibility modifier is experimental + earth: bool, + fire: bool, + air: bool, + water: bool, +} + +fn main() {} diff --git a/src/test/compile-fail/feature-gate-extern_types.rs b/src/test/compile-fail/feature-gate-extern_types.rs new file mode 100644 index 0000000000000..1203b598df3c2 --- /dev/null +++ b/src/test/compile-fail/feature-gate-extern_types.rs @@ -0,0 +1,15 @@ +// Copyright 2016 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + type T; //~ ERROR extern types are experimental +} + +fn main() {} diff --git a/src/test/compile-fail/feature-gate/issue-43106-gating-of-rustc_deprecated.rs b/src/test/compile-fail/feature-gate/issue-43106-gating-of-rustc_deprecated.rs index 4709ec2bc579b..10c1398634923 100644 --- a/src/test/compile-fail/feature-gate/issue-43106-gating-of-rustc_deprecated.rs +++ b/src/test/compile-fail/feature-gate/issue-43106-gating-of-rustc_deprecated.rs @@ -28,7 +28,6 @@ mod rustc_deprecated { #[rustc_deprecated = "1500"] struct S; //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR stability attributes may not be used outside of the standard library #[rustc_deprecated = "1500"] type T = S; //~^ ERROR stability attributes may not be used outside of the standard library diff --git a/src/test/compile-fail/feature-gate/issue-43106-gating-of-stable.rs b/src/test/compile-fail/feature-gate/issue-43106-gating-of-stable.rs index 9627d32d42aad..a6eaabf7a383e 100644 --- a/src/test/compile-fail/feature-gate/issue-43106-gating-of-stable.rs +++ b/src/test/compile-fail/feature-gate/issue-43106-gating-of-stable.rs @@ -28,7 +28,6 @@ mod stable { #[stable = "1300"] struct S; //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR stability attributes may not be used outside of the standard library #[stable = "1300"] type T = S; //~^ ERROR stability attributes may not be used outside of the standard library diff --git a/src/test/compile-fail/feature-gate/issue-43106-gating-of-unstable.rs b/src/test/compile-fail/feature-gate/issue-43106-gating-of-unstable.rs index 0708dc8f728e8..ff0600deb1936 100644 --- a/src/test/compile-fail/feature-gate/issue-43106-gating-of-unstable.rs +++ b/src/test/compile-fail/feature-gate/issue-43106-gating-of-unstable.rs @@ -28,7 +28,6 @@ mod unstable { #[unstable = "1200"] struct S; //~^ ERROR stability attributes may not be used outside of the standard library - //~| ERROR stability attributes may not be used outside of the standard library #[unstable = "1200"] type T = S; //~^ ERROR stability attributes may not be used outside of the standard library diff --git a/src/test/compile-fail/issue-17718-const-bad-values.rs b/src/test/compile-fail/issue-17718-const-bad-values.rs index af356588ed9e7..17ec77d77eea2 100644 --- a/src/test/compile-fail/issue-17718-const-bad-values.rs +++ b/src/test/compile-fail/issue-17718-const-bad-values.rs @@ -10,13 +10,11 @@ const C1: &'static mut [usize] = &mut []; //~^ ERROR: references in constants may only refer to immutable values -//~| ERROR: references in constants may only refer to immutable values static mut S: usize = 3; const C2: &'static mut usize = unsafe { &mut S }; //~^ ERROR: constants cannot refer to statics //~| ERROR: references in constants may only refer to immutable values //~| ERROR: references in constants may only refer to immutable values -//~| ERROR: references in constants may only refer to immutable values fn main() {} diff --git a/src/test/compile-fail/issue-20831-debruijn.rs b/src/test/compile-fail/issue-20831-debruijn.rs index 323cd24d8dda5..3f00f561ae96f 100644 --- a/src/test/compile-fail/issue-20831-debruijn.rs +++ b/src/test/compile-fail/issue-20831-debruijn.rs @@ -38,7 +38,6 @@ impl<'a> Publisher<'a> for MyStruct<'a> { fn subscribe(&mut self, t : Box::Output> + 'a>) { // Not obvious, but there is an implicit lifetime here -------^ //~^^ ERROR cannot infer - //~| ERROR cannot infer // // The fact that `Publisher` is using an implicit lifetime is // what was causing the debruijn accounting to be off, so diff --git a/src/test/compile-fail/issue-27842.rs b/src/test/compile-fail/issue-27842.rs index 8c71761df2fb8..eb28e36dc076e 100644 --- a/src/test/compile-fail/issue-27842.rs +++ b/src/test/compile-fail/issue-27842.rs @@ -14,7 +14,7 @@ fn main() { let _ = tup[0]; //~^ ERROR cannot index into a value of type //~| HELP to access tuple elements, use - //~| SUGGESTION let _ = tup.0 + //~| SUGGESTION tup.0 // the case where we show just a general hint let i = 0_usize; diff --git a/src/test/compile-fail/issue-41255.rs b/src/test/compile-fail/issue-41255.rs index a4585f7bac7da..191b867e7a8b5 100644 --- a/src/test/compile-fail/issue-41255.rs +++ b/src/test/compile-fail/issue-41255.rs @@ -39,8 +39,6 @@ fn main() { match (x, 5) { (3.14, 1) => {}, //~ ERROR floating-point literals cannot be used //~| WARNING hard error - //~| ERROR floating-point literals cannot be used - //~| WARNING hard error _ => {}, } // Or structs @@ -48,8 +46,6 @@ fn main() { match (Foo { x }) { Foo { x: 2.0 } => {}, //~ ERROR floating-point literals cannot be used //~| WARNING hard error - //~| ERROR floating-point literals cannot be used - //~| WARNING hard error _ => {}, } } diff --git a/src/test/compile-fail/issue-44239.rs b/src/test/compile-fail/issue-44239.rs new file mode 100644 index 0000000000000..131c65266425b --- /dev/null +++ b/src/test/compile-fail/issue-44239.rs @@ -0,0 +1,19 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let n = 0; + + struct Foo; + impl Foo { + const N: usize = n; + //~^ ERROR attempt to use a non-constant value + } +} diff --git a/src/test/compile-fail/lint-stability-deprecated.rs b/src/test/compile-fail/lint-stability-deprecated.rs index de455afbd6629..9bc2c021904aa 100644 --- a/src/test/compile-fail/lint-stability-deprecated.rs +++ b/src/test/compile-fail/lint-stability-deprecated.rs @@ -107,7 +107,6 @@ mod cross_crate { struct S1(T::TypeUnstable); struct S2(T::TypeDeprecated); //~^ WARN use of deprecated item - //~| WARN use of deprecated item let _ = DeprecatedStruct { //~ WARN use of deprecated item i: 0 //~ WARN use of deprecated item diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs b/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs index 9d246f8ea5e0e..fa8f264eb5a5f 100644 --- a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs +++ b/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs @@ -11,8 +11,8 @@ fn test() { let v: isize; loop { - v = 1; //~ ERROR re-assignment of immutable variable - //~^ NOTE re-assignment of immutable variable + v = 1; //~ ERROR cannot assign twice to immutable variable + //~^ NOTE cannot assign twice to immutable variable v.clone(); // just to prevent liveness warnings } } diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs b/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs index e1eb3246137d2..bfdd4347de74e 100644 --- a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs +++ b/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs @@ -11,8 +11,8 @@ fn test() { let v: isize; v = 2; //~ NOTE first assignment - v += 1; //~ ERROR re-assignment of immutable variable - //~| NOTE re-assignment of immutable + v += 1; //~ ERROR cannot assign twice to immutable variable + //~| NOTE cannot assign twice to immutable v.clone(); } diff --git a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs b/src/test/compile-fail/liveness-assign-imm-local-with-init.rs index 2468c91f34bbd..f35c1c69acdf8 100644 --- a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs +++ b/src/test/compile-fail/liveness-assign-imm-local-with-init.rs @@ -11,8 +11,8 @@ fn test() { let v: isize = 1; //~ NOTE first assignment v.clone(); - v = 2; //~ ERROR re-assignment of immutable variable - //~| NOTE re-assignment of immutable + v = 2; //~ ERROR cannot assign twice to immutable variable + //~| NOTE cannot assign twice to immutable v.clone(); } diff --git a/src/test/compile-fail/mut-pattern-internal-mutability.rs b/src/test/compile-fail/mut-pattern-internal-mutability.rs index 3a84bd6565e8d..1c7bc9d73037c 100644 --- a/src/test/compile-fail/mut-pattern-internal-mutability.rs +++ b/src/test/compile-fail/mut-pattern-internal-mutability.rs @@ -15,9 +15,9 @@ fn main() { let foo = &mut 1; let &mut x = foo; - x += 1; //[ast]~ ERROR re-assignment of immutable variable - //[mir]~^ ERROR re-assignment of immutable variable `x` (Ast) - //[mir]~| ERROR re-assignment of immutable variable `x` (Mir) + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable + //[mir]~^ ERROR cannot assign twice to immutable variable `x` (Ast) + //[mir]~| ERROR cannot assign twice to immutable variable `x` (Mir) // explicitly mut-ify internals let &mut mut x = foo; diff --git a/src/test/compile-fail/patkind-litrange-no-expr.rs b/src/test/compile-fail/patkind-litrange-no-expr.rs index afb2cbb7db397..d57a23f26c479 100644 --- a/src/test/compile-fail/patkind-litrange-no-expr.rs +++ b/src/test/compile-fail/patkind-litrange-no-expr.rs @@ -28,8 +28,7 @@ enum_number!(Change { Pos = 1, Neg = -1, Arith = 1 + 1, //~ ERROR arbitrary expressions aren't allowed in patterns - //~^ ERROR arbitrary expressions aren't allowed in patterns - //~^^ ERROR only char and numeric types are allowed in range patterns + //~^ ERROR only char and numeric types are allowed in range patterns }); fn main() {} diff --git a/src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs b/src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs index 82d14ddb502b3..c4ab96c845619 100644 --- a/src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs +++ b/src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs @@ -8,14 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(crate_visibility_modifier)] + pub(crate) struct Crate; + #[derive(Default)] pub struct Universe { pub x: i32, - pub(crate) y: i32 + pub(crate) y: i32, + crate z: i32, } impl Universe { pub fn f(&self) {} pub(crate) fn g(&self) {} + crate fn h(&self) {} } diff --git a/src/test/compile-fail/privacy/restricted/private-in-public.rs b/src/test/compile-fail/privacy/restricted/private-in-public.rs index 0fdfbaa84bb5a..4d3f537779740 100644 --- a/src/test/compile-fail/privacy/restricted/private-in-public.rs +++ b/src/test/compile-fail/privacy/restricted/private-in-public.rs @@ -8,12 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(crate_visibility_modifier)] + mod foo { struct Priv; mod bar { use foo::Priv; pub(super) fn f(_: Priv) {} pub(crate) fn g(_: Priv) {} //~ ERROR E0446 + crate fn h(_: Priv) {} //~ ERROR E0446 } } diff --git a/src/test/compile-fail/privacy/restricted/test.rs b/src/test/compile-fail/privacy/restricted/test.rs index 2e065ac051b20..7f076ebf287e2 100644 --- a/src/test/compile-fail/privacy/restricted/test.rs +++ b/src/test/compile-fail/privacy/restricted/test.rs @@ -50,8 +50,10 @@ fn main() { let u = Universe::default(); let _ = u.x; let _ = u.y; //~ ERROR private + let _ = u.z; //~ ERROR private u.f(); u.g(); //~ ERROR private + u.h(); //~ ERROR private } mod pathological { diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs index d17b604717e70..d4ea76d6c2655 100644 --- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs +++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs @@ -13,5 +13,5 @@ mod foo { struct S1(pub(in foo) (), pub(T), pub(crate) (), pub(((), T))); struct S2(pub((foo)) ()); //~^ ERROR expected `,`, found `(` - //~| ERROR expected one of `;` or `where`, found `(` + //~| ERROR cannot find type `foo` in this scope } diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs index 166d5e27e8d96..fed9432c6a0e9 100644 --- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs +++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs @@ -14,7 +14,6 @@ macro_rules! define_struct { struct S2(pub (in foo) ()); struct S3(pub $t ()); //~^ ERROR expected `,`, found `(` - //~| ERROR expected one of `;` or `where`, found `(` } } diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs index edab175f4cd91..dd2cb0e218422 100644 --- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs +++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs @@ -14,7 +14,6 @@ macro_rules! define_struct { struct S2(pub (in foo) ()); struct S3(pub($t) ()); //~^ ERROR expected `,`, found `(` - //~| ERROR expected one of `;` or `where`, found `(` } } diff --git a/src/test/compile-fail/range_traits-1.rs b/src/test/compile-fail/range_traits-1.rs index cf5c40bd1761d..f1ea8b04e5ace 100644 --- a/src/test/compile-fail/range_traits-1.rs +++ b/src/test/compile-fail/range_traits-1.rs @@ -12,75 +12,38 @@ use std::ops::*; -// FIXME #34229 duplicated errors #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] struct AllTheRanges { a: Range, //~^ ERROR PartialOrd //~^^ ERROR Ord - //~^^^ ERROR binary operation - //~^^^^ ERROR binary operation - //~^^^^^ ERROR binary operation - //~^^^^^^ ERROR binary operation - //~^^^^^^^ ERROR binary operation - //~^^^^^^^^ ERROR binary operation - //~^^^^^^^^^ ERROR binary operation - //~^^^^^^^^^^ ERROR binary operation + //~^^^ ERROR binary operation `<` cannot be applied to type + //~^^^^ ERROR binary operation `>` cannot be applied to type b: RangeTo, //~^ ERROR PartialOrd //~^^ ERROR Ord - //~^^^ ERROR binary operation - //~^^^^ ERROR binary operation - //~^^^^^ ERROR binary operation - //~^^^^^^ ERROR binary operation - //~^^^^^^^ ERROR binary operation - //~^^^^^^^^ ERROR binary operation - //~^^^^^^^^^ ERROR binary operation - //~^^^^^^^^^^ ERROR binary operation + //~^^^ ERROR binary operation `<` cannot be applied to type + //~^^^^ ERROR binary operation `>` cannot be applied to type c: RangeFrom, //~^ ERROR PartialOrd //~^^ ERROR Ord - //~^^^ ERROR binary operation - //~^^^^ ERROR binary operation - //~^^^^^ ERROR binary operation - //~^^^^^^ ERROR binary operation - //~^^^^^^^ ERROR binary operation - //~^^^^^^^^ ERROR binary operation - //~^^^^^^^^^ ERROR binary operation - //~^^^^^^^^^^ ERROR binary operation + //~^^^ ERROR binary operation `<` cannot be applied to type + //~^^^^ ERROR binary operation `>` cannot be applied to type d: RangeFull, //~^ ERROR PartialOrd //~^^ ERROR Ord - //~^^^ ERROR binary operation - //~^^^^ ERROR binary operation - //~^^^^^ ERROR binary operation - //~^^^^^^ ERROR binary operation - //~^^^^^^^ ERROR binary operation - //~^^^^^^^^ ERROR binary operation - //~^^^^^^^^^ ERROR binary operation - //~^^^^^^^^^^ ERROR binary operation + //~^^^ ERROR binary operation `<` cannot be applied to type + //~^^^^ ERROR binary operation `>` cannot be applied to type e: RangeInclusive, //~^ ERROR PartialOrd //~^^ ERROR Ord - //~^^^ ERROR binary operation - //~^^^^ ERROR binary operation - //~^^^^^ ERROR binary operation - //~^^^^^^ ERROR binary operation - //~^^^^^^^ ERROR binary operation - //~^^^^^^^^ ERROR binary operation - //~^^^^^^^^^ ERROR binary operation - //~^^^^^^^^^^ ERROR binary operation + //~^^^ ERROR binary operation `<` cannot be applied to type + //~^^^^ ERROR binary operation `>` cannot be applied to type f: RangeToInclusive, //~^ ERROR PartialOrd //~^^ ERROR Ord - //~^^^ ERROR binary operation - //~^^^^ ERROR binary operation - //~^^^^^ ERROR binary operation - //~^^^^^^ ERROR binary operation - //~^^^^^^^ ERROR binary operation - //~^^^^^^^^ ERROR binary operation - //~^^^^^^^^^ ERROR binary operation - //~^^^^^^^^^^ ERROR binary operation + //~^^^ ERROR binary operation `<` cannot be applied to type + //~^^^^ ERROR binary operation `>` cannot be applied to type } fn main() {} diff --git a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs index 1d4ffe0690d2f..617de2c5dfe84 100644 --- a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs +++ b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs @@ -35,7 +35,6 @@ impl<'a, 't> Foo<'a, 't> for &'a isize { fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { //~^ ERROR method not compatible with trait - //~^^ ERROR method not compatible with trait // // Note: This is a terrible error message. It is caused // because, in the trait, 'b is early bound, and in the impl, diff --git a/src/test/compile-fail/regions-close-object-into-object-5.rs b/src/test/compile-fail/regions-close-object-into-object-5.rs index 152c65cb69bf2..6cbe5234ce0e8 100644 --- a/src/test/compile-fail/regions-close-object-into-object-5.rs +++ b/src/test/compile-fail/regions-close-object-into-object-5.rs @@ -31,7 +31,6 @@ fn f<'a, T, U>(v: Box+'static>) -> Box { //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough } fn main() {} diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index 5067b571ee68b..9351a4b05f151 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -370,9 +370,7 @@ impl Foo { #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] impl Foo { - // FIXME(michaelwoerister): This is curious but an unused lifetime parameter doesn't seem to - // show up in any of the derived data structures. - #[rustc_clean(cfg="cfail2", except="Hir,HirBody")] + #[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeckTables")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] @@ -395,7 +393,7 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="Hir,HirBody,GenericsOfItem,PredicatesOfItem,TypeOfItem", + except="Hir,HirBody,GenericsOfItem,PredicatesOfItem,TypeOfItem,TypeckTables", )] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] @@ -441,7 +439,8 @@ impl Foo { #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] impl Foo { - #[rustc_clean(cfg="cfail2", except="Hir,HirBody,GenericsOfItem,PredicatesOfItem,TypeOfItem")] + #[rustc_clean(cfg="cfail2", except="Hir,HirBody,GenericsOfItem,PredicatesOfItem,\ + TypeOfItem,TypeckTables")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] @@ -462,7 +461,7 @@ impl Foo { #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] impl Foo { - #[rustc_clean(cfg="cfail2", except="Hir,HirBody,PredicatesOfItem")] + #[rustc_clean(cfg="cfail2", except="Hir,HirBody,PredicatesOfItem,TypeckTables")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] diff --git a/src/test/mir-opt/copy_propagation.rs b/src/test/mir-opt/copy_propagation.rs index 0b0d2f45f1c55..a45e7f21023bf 100644 --- a/src/test/mir-opt/copy_propagation.rs +++ b/src/test/mir-opt/copy_propagation.rs @@ -19,13 +19,12 @@ fn main() { } // START rustc.node4.CopyPropagation.before.mir // bb0: { // ... -// _2 = _1; +// _3 = _1; // ... -// _4 = _2; -// _3 = _4; +// _2 = _3; // ... -// _5 = _3; -// _0 = _5; +// _4 = _2; +// _0 = _4; // ... // return; // } diff --git a/src/test/mir-opt/deaggregator_test.rs b/src/test/mir-opt/deaggregator_test.rs index ce2b13ecda7b7..9fe17a277a759 100644 --- a/src/test/mir-opt/deaggregator_test.rs +++ b/src/test/mir-opt/deaggregator_test.rs @@ -26,8 +26,7 @@ fn main() {} // ... // _2 = _1; // ... -// _3 = _2; -// _0 = Baz { x: _3, y: const 0f32, z: const false }; +// _0 = Baz { x: _2, y: const 0f32, z: const false }; // ... // return; // } @@ -37,8 +36,7 @@ fn main() {} // ... // _2 = _1; // ... -// _3 = _2; -// (_0.0: usize) = _3; +// (_0.0: usize) = _2; // (_0.1: f32) = const 0f32; // (_0.2: bool) = const false; // ... diff --git a/src/test/mir-opt/deaggregator_test_enum.rs b/src/test/mir-opt/deaggregator_test_enum.rs index d77dcb627817f..d2c713b320f53 100644 --- a/src/test/mir-opt/deaggregator_test_enum.rs +++ b/src/test/mir-opt/deaggregator_test_enum.rs @@ -30,10 +30,7 @@ fn main() { // bb0: { // StorageLive(_2); // _2 = _1; -// StorageLive(_3); -// _3 = _2; -// _0 = Baz::Foo { x: _3 }; -// StorageDead(_3); +// _0 = Baz::Foo { x: _2 }; // StorageDead(_2); // return; // } @@ -42,11 +39,8 @@ fn main() { // bb0: { // StorageLive(_2); // _2 = _1; -// StorageLive(_3); -// _3 = _2; -// ((_0 as Foo).0: usize) = _3; +// ((_0 as Foo).0: usize) = _2; // discriminant(_0) = 1; -// StorageDead(_3); // StorageDead(_2); // return; // } diff --git a/src/test/mir-opt/deaggregator_test_enum_2.rs b/src/test/mir-opt/deaggregator_test_enum_2.rs index e65830bddc4d3..2780f11b9e640 100644 --- a/src/test/mir-opt/deaggregator_test_enum_2.rs +++ b/src/test/mir-opt/deaggregator_test_enum_2.rs @@ -28,35 +28,35 @@ fn main() {} // END RUST SOURCE // START rustc.node12.Deaggregator.before.mir // bb1: { -// StorageLive(_6); -// _6 = _4; -// _0 = Foo::A(_6,); -// StorageDead(_6); +// StorageLive(_4); +// _4 = _2; +// _0 = Foo::A(_4,); +// StorageDead(_4); // goto -> bb3; // } // bb2: { -// StorageLive(_7); -// _7 = _4; -// _0 = Foo::B(_7,); -// StorageDead(_7); +// StorageLive(_5); +// _5 = _2; +// _0 = Foo::B(_5,); +// StorageDead(_5); // goto -> bb3; // } // END rustc.node12.Deaggregator.before.mir // START rustc.node12.Deaggregator.after.mir // bb1: { -// StorageLive(_6); -// _6 = _4; -// ((_0 as A).0: i32) = _6; +// StorageLive(_4); +// _4 = _2; +// ((_0 as A).0: i32) = _4; // discriminant(_0) = 0; -// StorageDead(_6); +// StorageDead(_4); // goto -> bb3; // } // bb2: { -// StorageLive(_7); -// _7 = _4; -// ((_0 as B).0: i32) = _7; +// StorageLive(_5); +// _5 = _2; +// ((_0 as B).0: i32) = _5; // discriminant(_0) = 1; -// StorageDead(_7); +// StorageDead(_5); // goto -> bb3; // } // END rustc.node12.Deaggregator.after.mir diff --git a/src/test/mir-opt/deaggregator_test_multiple.rs b/src/test/mir-opt/deaggregator_test_multiple.rs index ed68d3bf5f750..ede3b2e6e299d 100644 --- a/src/test/mir-opt/deaggregator_test_multiple.rs +++ b/src/test/mir-opt/deaggregator_test_multiple.rs @@ -25,15 +25,14 @@ fn main() { } // START rustc.node10.Deaggregator.before.mir // bb0: { // ... -// _2 = _1; +// _3 = _1; // ... -// _4 = _2; -// _3 = Foo::A(_4,); +// _2 = Foo::A(_3,); // ... -// _6 = _2; -// _5 = Foo::A(_6,); +// _5 = _1; +// _4 = Foo::A(_5,); // ... -// _0 = [_3, _5]; +// _0 = [_2, _4]; // ... // return; // } @@ -41,17 +40,16 @@ fn main() { } // START rustc.node10.Deaggregator.after.mir // bb0: { // ... -// _2 = _1; +// _3 = _1; // ... -// _4 = _2; -// ((_3 as A).0: i32) = _4; -// discriminant(_3) = 0; +// ((_2 as A).0: i32) = _3; +// discriminant(_2) = 0; // ... -// _6 = _2; -// ((_5 as A).0: i32) = _6; -// discriminant(_5) = 0; +// _5 = _1; +// ((_4 as A).0: i32) = _5; +// discriminant(_4) = 0; // ... -// _0 = [_3, _5]; +// _0 = [_2, _4]; // ... // return; // } diff --git a/src/test/mir-opt/validate_1.rs b/src/test/mir-opt/validate_1.rs index 22788d7a8985e..53454c0cc9ae6 100644 --- a/src/test/mir-opt/validate_1.rs +++ b/src/test/mir-opt/validate_1.rs @@ -30,7 +30,7 @@ fn main() { // END RUST SOURCE // START rustc.node12.EraseRegions.after.mir // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[e36f]::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[e36f]::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[317d]::{{impl}}[0]::foo[0] }, BrAnon(0)) Test, _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:5) => validate_1[317d]::{{impl}}[0]::foo[0] }, BrAnon(1)) mut i32]); // ... // return; // } @@ -62,19 +62,16 @@ fn main() { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[e36f]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[e36f]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:11) => validate_1[317d]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // StorageLive(_3); -// _3 = _2; +// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 }))), [(*_2): i32]); +// _3 = &ReErased (*_2); +// Validate(Acquire, [(*_3): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 })) (imm)]); // StorageLive(_4); -// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 }))), [(*_3): i32]); -// _4 = &ReErased (*_3); -// Validate(Acquire, [(*_4): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 })) (imm)]); -// StorageLive(_5); -// _5 = (*_4); -// _0 = _5; -// StorageDead(_5); -// EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 }))); +// _4 = (*_3); +// _0 = _4; // StorageDead(_4); +// EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(22), first_statement_index: 0 }))); // StorageDead(_3); // return; // } diff --git a/src/test/mir-opt/validate_4.rs b/src/test/mir-opt/validate_4.rs index d2852cf522618..042edca82a650 100644 --- a/src/test/mir-opt/validate_4.rs +++ b/src/test/mir-opt/validate_4.rs @@ -51,12 +51,9 @@ fn main() { // fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[e36f]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[e36f]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); -// StorageLive(_3); -// _3 = _2; -// (*_3) = const 23i32; -// StorageDead(_3); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[317d]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_4[317d]::write_42[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(22)], _2: *mut i32]); +// (*_2) = const 23i32; // return; // } // } @@ -65,14 +62,14 @@ fn main() { // fn test(_1: &ReErased mut i32) -> () { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[e36f]::test[0] }, BrAnon(0)) mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[e36f]::test[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[317d]::test[0] }, BrAnon(0)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_4[317d]::test[0] }, BrAnon(0)) mut i32]); // ... -// _3 = const write_42(_4) -> bb1; +// _2 = const write_42(_3) -> bb1; // } // bb1: { -// Validate(Acquire, [_3: bool]); -// Validate(Release, [_3: bool]); +// Validate(Acquire, [_2: bool]); +// Validate(Release, [_2: bool]); // ... // } // } @@ -81,11 +78,11 @@ fn main() { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[e36f]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[e36f]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); -// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[e36f]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[e36f]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:10) => validate_4[317d]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // StorageLive(_3); // ... -// _0 = const write_42(_4) -> bb1; +// _0 = const write_42(_3) -> bb1; // } // ... // } diff --git a/src/test/mir-opt/validate_5.rs b/src/test/mir-opt/validate_5.rs index 98c553d6b35af..fc849c5aee33b 100644 --- a/src/test/mir-opt/validate_5.rs +++ b/src/test/mir-opt/validate_5.rs @@ -37,10 +37,10 @@ fn main() { // fn test(_1: &ReErased mut i32) -> () { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_5[e36f]::test[0] }, BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(0:4) => validate_5[317d]::test[0] }, BrAnon(0)) mut i32]); // ... -// Validate(Release, [_3: bool, _4: *mut i32]); -// _3 = const write_42(_4) -> bb1; +// Validate(Release, [_2: bool, _3: *mut i32]); +// _2 = const write_42(_3) -> bb1; // } // ... // } @@ -49,19 +49,17 @@ fn main() { // fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[e36f]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[e36f]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[317d]::main[0]::{{closure}}[0] }, BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), index: DefIndex(1:9) => validate_5[317d]::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); // StorageLive(_3); -// _3 = _2; // StorageLive(_4); -// StorageLive(_5); -// Validate(Suspend(ReScope(Node(ItemLocalId(9)))), [(*_3): i32]); -// _5 = &ReErased mut (*_3); -// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(9)))]); -// _4 = _5 as *mut i32 (Misc); +// Validate(Suspend(ReScope(Node(ItemLocalId(9)))), [(*_2): i32]); +// _4 = &ReErased mut (*_2); +// Validate(Acquire, [(*_4): i32/ReScope(Node(ItemLocalId(9)))]); +// _3 = _4 as *mut i32 (Misc); // EndRegion(ReScope(Node(ItemLocalId(9)))); -// StorageDead(_5); -// Validate(Release, [_0: bool, _4: *mut i32]); -// _0 = const write_42(_4) -> bb1; +// StorageDead(_4); +// Validate(Release, [_0: bool, _3: *mut i32]); +// _0 = const write_42(_3) -> bb1; // } // ... // } diff --git a/src/test/parse-fail/issue-20711-2.rs b/src/test/parse-fail/issue-20711-2.rs index a489864e3f737..3a330d8bee21b 100644 --- a/src/test/parse-fail/issue-20711-2.rs +++ b/src/test/parse-fail/issue-20711-2.rs @@ -16,6 +16,6 @@ impl Foo { fn foo() {} #[stable(feature = "rust1", since = "1.0.0")] -} //~ ERROR expected one of `const`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe` +} //~ ERROR expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe` fn main() {} diff --git a/src/test/parse-fail/issue-20711.rs b/src/test/parse-fail/issue-20711.rs index d9789d55a6faf..cd79fa8be7c65 100644 --- a/src/test/parse-fail/issue-20711.rs +++ b/src/test/parse-fail/issue-20711.rs @@ -14,6 +14,6 @@ struct Foo; impl Foo { #[stable(feature = "rust1", since = "1.0.0")] -} //~ ERROR expected one of `const`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe` +} //~ ERROR expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe` fn main() {} diff --git a/src/test/parse-fail/removed-syntax-static-fn.rs b/src/test/parse-fail/removed-syntax-static-fn.rs index b4c25a75c9086..3b783aa79e281 100644 --- a/src/test/parse-fail/removed-syntax-static-fn.rs +++ b/src/test/parse-fail/removed-syntax-static-fn.rs @@ -15,4 +15,4 @@ struct S; impl S { static fn f() {} } -//~^^ ERROR expected one of `const`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}` +//~^^ ERROR expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe` diff --git a/src/test/run-make/extern-fn-with-extern-types/Makefile b/src/test/run-make/extern-fn-with-extern-types/Makefile new file mode 100644 index 0000000000000..8977e14c3ad1a --- /dev/null +++ b/src/test/run-make/extern-fn-with-extern-types/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,ctest) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-extern-types/ctest.c b/src/test/run-make/extern-fn-with-extern-types/ctest.c new file mode 100644 index 0000000000000..c3d6166fb1284 --- /dev/null +++ b/src/test/run-make/extern-fn-with-extern-types/ctest.c @@ -0,0 +1,17 @@ +// ignore-license +#include +#include + +typedef struct data { + uint32_t magic; +} data; + +data* data_create(uint32_t magic) { + static data d; + d.magic = magic; + return &d; +} + +uint32_t data_get(data* p) { + return p->magic; +} diff --git a/src/test/run-make/extern-fn-with-extern-types/test.rs b/src/test/run-make/extern-fn-with-extern-types/test.rs new file mode 100644 index 0000000000000..9d6c87885b16e --- /dev/null +++ b/src/test/run-make/extern-fn-with-extern-types/test.rs @@ -0,0 +1,27 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_types)] + +#[link(name = "ctest", kind = "static")] +extern { + type data; + + fn data_create(magic: u32) -> *mut data; + fn data_get(data: *mut data) -> u32; +} + +const MAGIC: u32 = 0xdeadbeef; +fn main() { + unsafe { + let data = data_create(MAGIC); + assert_eq!(data_get(data), MAGIC); + } +} diff --git a/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs b/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs index fc53031e7f226..d3f921e0878ae 100644 --- a/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs +++ b/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs @@ -12,6 +12,7 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] +#![feature(macro_vis_matcher)] #[macro_use] extern crate rustc; extern crate rustc_plugin; diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs index cf1a631937ba4..29b6cc012b393 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(box_syntax, plugin, plugin_registrar, rustc_private)] +#![feature(macro_vis_matcher)] #![crate_type = "dylib"] #[macro_use] diff --git a/src/test/run-pass/associated-types-project-from-type-param-via-bound-in-where-clause.rs b/src/test/run-pass/associated-types-project-from-type-param-via-bound-in-where.rs similarity index 100% rename from src/test/run-pass/associated-types-project-from-type-param-via-bound-in-where-clause.rs rename to src/test/run-pass/associated-types-project-from-type-param-via-bound-in-where.rs diff --git a/src/test/run-pass/ctfe/assoc-const.rs b/src/test/run-pass/ctfe/assoc-const.rs new file mode 100644 index 0000000000000..6a740dc1dd30b --- /dev/null +++ b/src/test/run-pass/ctfe/assoc-const.rs @@ -0,0 +1,28 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Nat { + const VALUE: usize; +} + +struct Zero; +struct Succ(N); + +impl Nat for Zero { + const VALUE: usize = 0; +} + +impl Nat for Succ { + const VALUE: usize = N::VALUE + 1; +} + +fn main() { + let x: [i32; >>>>::VALUE] = [1, 2, 3, 4]; +} diff --git a/src/test/run-pass/extern-types-inherent-impl.rs b/src/test/run-pass/extern-types-inherent-impl.rs new file mode 100644 index 0000000000000..4e44af3690064 --- /dev/null +++ b/src/test/run-pass/extern-types-inherent-impl.rs @@ -0,0 +1,27 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that inherent impls can be defined for extern types. + +#![feature(extern_types)] + +extern { + type A; +} + +impl A { + fn foo(&self) { } +} + +fn use_foo(x: &A) { + x.foo(); +} + +fn main() { } diff --git a/src/test/run-pass/extern-types-manual-sync-send.rs b/src/test/run-pass/extern-types-manual-sync-send.rs new file mode 100644 index 0000000000000..c6530c3ea773a --- /dev/null +++ b/src/test/run-pass/extern-types-manual-sync-send.rs @@ -0,0 +1,28 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that unsafe impl for Sync/Send can be provided for extern types. + +#![feature(extern_types)] + +extern { + type A; +} + +unsafe impl Sync for A { } +unsafe impl Send for A { } + +fn assert_sync() { } +fn assert_send() { } + +fn main() { + assert_sync::(); + assert_send::(); +} diff --git a/src/test/run-pass/extern-types-pointer-cast.rs b/src/test/run-pass/extern-types-pointer-cast.rs new file mode 100644 index 0000000000000..628a570665a33 --- /dev/null +++ b/src/test/run-pass/extern-types-pointer-cast.rs @@ -0,0 +1,40 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that pointers to extern types can be casted from/to usize, +// despite being !Sized. + +#![feature(extern_types)] + +extern { + type A; +} + +struct Foo { + x: u8, + tail: A, +} + +struct Bar { + x: u8, + tail: T, +} + +#[cfg(target_pointer_width = "32")] +const MAGIC: usize = 0xdeadbeef; +#[cfg(target_pointer_width = "64")] +const MAGIC: usize = 0x12345678deadbeef; + +fn main() { + assert_eq!((MAGIC as *const A) as usize, MAGIC); + assert_eq!((MAGIC as *const Foo) as usize, MAGIC); + assert_eq!((MAGIC as *const Bar) as usize, MAGIC); + assert_eq!((MAGIC as *const Bar>) as usize, MAGIC); +} diff --git a/src/test/run-pass/extern-types-size_of_val.rs b/src/test/run-pass/extern-types-size_of_val.rs new file mode 100644 index 0000000000000..0aabce99debe8 --- /dev/null +++ b/src/test/run-pass/extern-types-size_of_val.rs @@ -0,0 +1,26 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_types)] + +use std::mem::{size_of_val, align_of_val}; + +extern { + type A; +} + +fn main() { + let x: &A = unsafe { + &*(1usize as *const A) + }; + + assert_eq!(size_of_val(x), 0); + assert_eq!(align_of_val(x), 1); +} diff --git a/src/test/run-pass/extern-types-thin-pointer.rs b/src/test/run-pass/extern-types-thin-pointer.rs new file mode 100644 index 0000000000000..c2444a58b5a1b --- /dev/null +++ b/src/test/run-pass/extern-types-thin-pointer.rs @@ -0,0 +1,51 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that pointers and references to extern types are thin, ie they have the same size and +// alignment as a pointer to (). + +#![feature(extern_types)] + +use std::mem::{align_of, size_of}; + +extern { + type A; +} + +struct Foo { + x: u8, + tail: A, +} + +struct Bar { + x: u8, + tail: T, +} + +fn assert_thin() { + assert_eq!(size_of::<*const T>(), size_of::<*const ()>()); + assert_eq!(align_of::<*const T>(), align_of::<*const ()>()); + + assert_eq!(size_of::<*mut T>(), size_of::<*mut ()>()); + assert_eq!(align_of::<*mut T>(), align_of::<*mut ()>()); + + assert_eq!(size_of::<&T>(), size_of::<&()>()); + assert_eq!(align_of::<&T>(), align_of::<&()>()); + + assert_eq!(size_of::<&mut T>(), size_of::<&mut ()>()); + assert_eq!(align_of::<&mut T>(), align_of::<&mut ()>()); +} + +fn main() { + assert_thin::(); + assert_thin::(); + assert_thin::>(); + assert_thin::>>(); +} diff --git a/src/test/run-pass/extern-types-trait-impl.rs b/src/test/run-pass/extern-types-trait-impl.rs new file mode 100644 index 0000000000000..0f61c936deb61 --- /dev/null +++ b/src/test/run-pass/extern-types-trait-impl.rs @@ -0,0 +1,35 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that traits can be implemented for extern types. + +#![feature(extern_types)] + +extern { + type A; +} + +trait Foo { + fn foo(&self) { } +} + +impl Foo for A { + fn foo(&self) { } +} + +fn assert_foo() { } + +fn use_foo(x: &Foo) { + x.foo(); +} + +fn main() { + assert_foo::(); +} diff --git a/src/test/run-pass/issue-44851.rs b/src/test/run-pass/issue-44851.rs new file mode 100644 index 0000000000000..62d675b13be30 --- /dev/null +++ b/src/test/run-pass/issue-44851.rs @@ -0,0 +1,24 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! a { + () => { "a" } +} + +macro_rules! b { + ($doc:expr) => { + #[doc = $doc] + pub struct B; + } +} + +b!(a!()); + +fn main() {} diff --git a/src/test/run-pass/macro-pub-matcher.rs b/src/test/run-pass/macro-pub-matcher.rs index d79f4b65b69e1..32145277252cb 100644 --- a/src/test/run-pass/macro-pub-matcher.rs +++ b/src/test/run-pass/macro-pub-matcher.rs @@ -9,7 +9,7 @@ // except according to those terms. #![allow(dead_code, unused_imports)] -#![feature(macro_vis_matcher)] +#![feature(macro_vis_matcher, crate_visibility_modifier)] /** Ensure that `:vis` matches can be captured in existing positions, and passed @@ -64,6 +64,18 @@ mod with_pub_restricted { vis_passthru! { pub(crate) use A as I; } } +mod with_crate { + vis_passthru! { crate const A: i32 = 0; } + vis_passthru! { crate enum B {} } + vis_passthru! { crate extern "C" fn c() {} } + vis_passthru! { crate mod d {} } + vis_passthru! { crate static E: i32 = 0; } + vis_passthru! { crate struct F; } + vis_passthru! { crate trait G {} } + vis_passthru! { crate type H = i32; } + vis_passthru! { crate use A as I; } +} + mod garden { mod with_pub_restricted_path { vis_passthru! { pub(in garden) const A: i32 = 0; } diff --git a/src/test/run-pass/unboxed-closures-infer-argument-types-from-expected-bound.rs b/src/test/run-pass/unboxed-closures-infer-arg-types-from-expected-bound.rs similarity index 100% rename from src/test/run-pass/unboxed-closures-infer-argument-types-from-expected-bound.rs rename to src/test/run-pass/unboxed-closures-infer-arg-types-from-expected-bound.rs diff --git a/src/test/run-pass/unboxed-closures-infer-argument-types-from-expected-object-type.rs b/src/test/run-pass/unboxed-closures-infer-arg-types-from-expected-object-type.rs similarity index 100% rename from src/test/run-pass/unboxed-closures-infer-argument-types-from-expected-object-type.rs rename to src/test/run-pass/unboxed-closures-infer-arg-types-from-expected-object-type.rs diff --git a/src/test/run-pass/unboxed-closures-infer-argument-types-with-bound-regions-from-expected-bound.rs b/src/test/run-pass/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs similarity index 100% rename from src/test/run-pass/unboxed-closures-infer-argument-types-with-bound-regions-from-expected-bound.rs rename to src/test/run-pass/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs diff --git a/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs index 490aa0d469312..a0c72243d4821 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs @@ -12,6 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] +#![feature(macro_vis_matcher)] // Load rustc as a plugin to get macros #[macro_use] diff --git a/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs b/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs index 8647797270f9a..cbbfbd8060360 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs @@ -12,6 +12,7 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] +#![feature(macro_vis_matcher)] extern crate syntax; diff --git a/src/test/ui/const-eval/issue-43197.stderr b/src/test/ui/const-eval/issue-43197.stderr index 5ff80060eac7a..58dedcfd9b103 100644 --- a/src/test/ui/const-eval/issue-43197.stderr +++ b/src/test/ui/const-eval/issue-43197.stderr @@ -1,4 +1,4 @@ -warning: constant evaluation error: attempt to subtract with overflow. This will become a HARD ERROR in the future +warning: constant evaluation error: attempt to subtract with overflow --> $DIR/issue-43197.rs:18:20 | 18 | const X: u32 = 0-1; @@ -6,7 +6,7 @@ warning: constant evaluation error: attempt to subtract with overflow. This will | = note: #[warn(const_err)] on by default -warning: constant evaluation error: attempt to subtract with overflow. This will become a HARD ERROR in the future +warning: constant evaluation error: attempt to subtract with overflow --> $DIR/issue-43197.rs:19:20 | 19 | const Y: u32 = foo(0-1); diff --git a/src/test/ui/e0119/auxiliary/complex_impl_support.rs b/src/test/ui/e0119/auxiliary/complex_impl_support.rs new file mode 100644 index 0000000000000..b30db9660992c --- /dev/null +++ b/src/test/ui/e0119/auxiliary/complex_impl_support.rs @@ -0,0 +1,32 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker::PhantomData; + +pub trait External {} + +pub struct M<'a, 'b, 'c, T, U, V> { + a: PhantomData<&'a ()>, + b: PhantomData<&'b ()>, + c: PhantomData<&'c ()>, + d: PhantomData, + e: PhantomData, + f: PhantomData, +} + +impl<'a, 'b, 'c, T, U, V, W> External for (T, M<'a, 'b, 'c, Box, V, W>) +where + 'b: 'a, + T: 'a, + U: (FnOnce(T) -> V) + 'static, + V: Iterator + Clone, + W: std::ops::Add, + W::Output: Copy, +{} diff --git a/src/test/ui/e0119/auxiliary/issue_23563_a.rs b/src/test/ui/e0119/auxiliary/issue_23563_a.rs new file mode 100644 index 0000000000000..57a0da0248d5c --- /dev/null +++ b/src/test/ui/e0119/auxiliary/issue_23563_a.rs @@ -0,0 +1,35 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ref: https://github.com/rust-lang/rust/issues/23563#issuecomment-260751672 + +pub trait LolTo { + fn convert_to(&self) -> T; +} + +pub trait LolInto: Sized { + fn convert_into(self) -> T; +} + +pub trait LolFrom { + fn from(T) -> Self; +} + +impl<'a, T: ?Sized, U> LolInto for &'a T where T: LolTo { + fn convert_into(self) -> U { + self.convert_to() + } +} + +impl LolFrom for U where T: LolInto { + fn from(t: T) -> U { + t.convert_into() + } +} diff --git a/src/test/ui/e0119/complex-impl.rs b/src/test/ui/e0119/complex-impl.rs new file mode 100644 index 0000000000000..f0d2630b9d0ce --- /dev/null +++ b/src/test/ui/e0119/complex-impl.rs @@ -0,0 +1,21 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:complex_impl_support.rs + +extern crate complex_impl_support; + +use complex_impl_support::{External, M}; + +struct Q; + +impl External for (Q, R) {} + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/e0119/complex-impl.stderr b/src/test/ui/e0119/complex-impl.stderr new file mode 100644 index 0000000000000..ff7c8a160a4a8 --- /dev/null +++ b/src/test/ui/e0119/complex-impl.stderr @@ -0,0 +1,18 @@ +error[E0119]: conflicting implementations of trait `complex_impl_support::External` for type `(Q, complex_impl_support::M<'_, '_, '_, std::boxed::Box<_>, _, _>)`: + --> $DIR/complex-impl.rs:19:1 + | +19 | impl External for (Q, R) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `complex_impl_support`: + - impl<'a, 'b, 'c, T, U, V, W> complex_impl_support::External for (T, complex_impl_support::M<'a, 'b, 'c, std::boxed::Box, V, W>) + where >::Output == V, ::Item == T, 'b : 'a, T : 'a, U: std::ops::FnOnce<(T,)>, U : 'static, V: std::iter::Iterator, V: std::clone::Clone, W: std::ops::Add, ::Output: std::marker::Copy; + +error[E0210]: type parameter `R` must be used as the type parameter for some local type (e.g. `MyStruct`); only traits defined in the current crate can be implemented for a type parameter + --> $DIR/complex-impl.rs:19:1 + | +19 | impl External for (Q, R) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/e0119/conflict-with-std.rs b/src/test/ui/e0119/conflict-with-std.rs new file mode 100644 index 0000000000000..ead62256a598e --- /dev/null +++ b/src/test/ui/e0119/conflict-with-std.rs @@ -0,0 +1,38 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(try_from)] + +use std::marker::PhantomData; +use std::convert::{TryFrom, AsRef}; + +struct Q; +impl AsRef for Box { + fn as_ref(&self) -> &Q { + &**self + } +} + +struct S; +impl From for S { + fn from(s: S) -> S { + s + } +} + +struct X; +impl TryFrom for X { + type Error = (); + fn try_from(u: X) -> Result { + Ok(u) + } +} + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/e0119/conflict-with-std.stderr b/src/test/ui/e0119/conflict-with-std.stderr new file mode 100644 index 0000000000000..f3e33291ef5bd --- /dev/null +++ b/src/test/ui/e0119/conflict-with-std.stderr @@ -0,0 +1,44 @@ +error[E0119]: conflicting implementations of trait `std::convert::AsRef` for type `std::boxed::Box`: + --> $DIR/conflict-with-std.rs:17:1 + | +17 | / impl AsRef for Box { +18 | | fn as_ref(&self) -> &Q { +19 | | &**self +20 | | } +21 | | } + | |_^ + | + = note: conflicting implementation in crate `alloc`: + - impl std::convert::AsRef for std::boxed::Box + where T: ?Sized; + +error[E0119]: conflicting implementations of trait `std::convert::From` for type `S`: + --> $DIR/conflict-with-std.rs:24:1 + | +24 | / impl From for S { +25 | | fn from(s: S) -> S { +26 | | s +27 | | } +28 | | } + | |_^ + | + = note: conflicting implementation in crate `core`: + - impl std::convert::From for T; + +error[E0119]: conflicting implementations of trait `std::convert::TryFrom` for type `X`: + --> $DIR/conflict-with-std.rs:31:1 + | +31 | / impl TryFrom for X { +32 | | type Error = (); +33 | | fn try_from(u: X) -> Result { +34 | | Ok(u) +35 | | } +36 | | } + | |_^ + | + = note: conflicting implementation in crate `core`: + - impl std::convert::TryFrom for T + where T: std::convert::From; + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/e0119/issue-23563.rs b/src/test/ui/e0119/issue-23563.rs new file mode 100644 index 0000000000000..67710af9369d1 --- /dev/null +++ b/src/test/ui/e0119/issue-23563.rs @@ -0,0 +1,39 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_23563_a.rs + +// Ref: https://github.com/rust-lang/rust/issues/23563#issuecomment-260751672 + +extern crate issue_23563_a as a; + +use a::LolFrom; +use a::LolInto; +use a::LolTo; + +struct LocalType(Option); + +impl<'a, T> LolFrom<&'a [T]> for LocalType { + fn from(_: &'a [T]) -> LocalType { LocalType(None) } +} + +impl LolInto> for LocalType { + fn convert_into(self) -> LocalType { + self + } +} + +impl LolTo> for [u8] { + fn convert_to(&self) -> LocalType { + LocalType(None) + } +} + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/e0119/issue-23563.stderr b/src/test/ui/e0119/issue-23563.stderr new file mode 100644 index 0000000000000..dcb76d71b3dc8 --- /dev/null +++ b/src/test/ui/e0119/issue-23563.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `a::LolFrom<&[_]>` for type `LocalType<_>`: + --> $DIR/issue-23563.rs:23:1 + | +23 | / impl<'a, T> LolFrom<&'a [T]> for LocalType { +24 | | fn from(_: &'a [T]) -> LocalType { LocalType(None) } +25 | | } + | |_^ + | + = note: conflicting implementation in crate `issue_23563_a`: + - impl a::LolFrom for U + where T: a::LolInto; + +error: aborting due to previous error + diff --git a/src/test/ui/e0119/issue-27403.rs b/src/test/ui/e0119/issue-27403.rs new file mode 100644 index 0000000000000..c880921b65b1d --- /dev/null +++ b/src/test/ui/e0119/issue-27403.rs @@ -0,0 +1,21 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct GenX { + inner: S, +} + +impl Into for GenX { + fn into(self) -> S { + self.inner + } +} + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/e0119/issue-27403.stderr b/src/test/ui/e0119/issue-27403.stderr new file mode 100644 index 0000000000000..d03171fc10a89 --- /dev/null +++ b/src/test/ui/e0119/issue-27403.stderr @@ -0,0 +1,16 @@ +error[E0119]: conflicting implementations of trait `std::convert::Into<_>` for type `GenX<_>`: + --> $DIR/issue-27403.rs:15:1 + | +15 | / impl Into for GenX { +16 | | fn into(self) -> S { +17 | | self.inner +18 | | } +19 | | } + | |_^ + | + = note: conflicting implementation in crate `core`: + - impl std::convert::Into for T + where U: std::convert::From; + +error: aborting due to previous error + diff --git a/src/test/ui/e0119/issue-28981.rs b/src/test/ui/e0119/issue-28981.rs new file mode 100644 index 0000000000000..06018286b319f --- /dev/null +++ b/src/test/ui/e0119/issue-28981.rs @@ -0,0 +1,17 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Deref; + +struct Foo; + +impl Deref for Foo { } + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/e0119/issue-28981.stderr b/src/test/ui/e0119/issue-28981.stderr new file mode 100644 index 0000000000000..c6c7c117a426e --- /dev/null +++ b/src/test/ui/e0119/issue-28981.stderr @@ -0,0 +1,18 @@ +error[E0119]: conflicting implementations of trait `std::ops::Deref` for type `&_`: + --> $DIR/issue-28981.rs:15:1 + | +15 | impl Deref for Foo { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl<'a, T> std::ops::Deref for &'a T + where T: ?Sized; + +error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g. `MyStruct`); only traits defined in the current crate can be implemented for a type parameter + --> $DIR/issue-28981.rs:15:1 + | +15 | impl Deref for Foo { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/e0119/so-37347311.rs b/src/test/ui/e0119/so-37347311.rs new file mode 100644 index 0000000000000..0d21120eac333 --- /dev/null +++ b/src/test/ui/e0119/so-37347311.rs @@ -0,0 +1,27 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ref: https://stackoverflow.com/q/37347311 + +trait Storage { + type Error; +} + +enum MyError { + StorageProblem(S::Error), +} + +impl From for MyError { + fn from(error: S::Error) -> MyError { + MyError::StorageProblem(error) + } +} + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/e0119/so-37347311.stderr b/src/test/ui/e0119/so-37347311.stderr new file mode 100644 index 0000000000000..8a26597a1c2f8 --- /dev/null +++ b/src/test/ui/e0119/so-37347311.stderr @@ -0,0 +1,15 @@ +error[E0119]: conflicting implementations of trait `std::convert::From>` for type `MyError<_>`: + --> $DIR/so-37347311.rs:21:1 + | +21 | / impl From for MyError { +22 | | fn from(error: S::Error) -> MyError { +23 | | MyError::StorageProblem(error) +24 | | } +25 | | } + | |_^ + | + = note: conflicting implementation in crate `core`: + - impl std::convert::From for T; + +error: aborting due to previous error + diff --git a/src/test/ui/issue-42106.rs b/src/test/ui/issue-42106.rs new file mode 100644 index 0000000000000..f13f1dd114517 --- /dev/null +++ b/src/test/ui/issue-42106.rs @@ -0,0 +1,16 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn do_something(collection: &mut Vec) { + let _a = &collection; + collection.swap(1, 2); +} + +fn main() {} diff --git a/src/test/ui/issue-42106.stderr b/src/test/ui/issue-42106.stderr new file mode 100644 index 0000000000000..481cdb5f5b2f6 --- /dev/null +++ b/src/test/ui/issue-42106.stderr @@ -0,0 +1,12 @@ +error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable + --> $DIR/issue-42106.rs:13:5 + | +12 | let _a = &collection; + | ---------- immutable borrow occurs here +13 | collection.swap(1, 2); + | ^^^^^^^^^^ mutable borrow occurs here +14 | } + | - immutable borrow ends here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/lint/suggestions.rs b/src/test/ui/lint/suggestions.rs index e078056ab5e0a..bf2b5769bf830 100644 --- a/src/test/ui/lint/suggestions.rs +++ b/src/test/ui/lint/suggestions.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![warn(unused_mut)] // UI tests pass `-A unused`—see Issue #43896 +#![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 #![feature(no_debug)] #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub` diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 7a498b56413a9..a00146668362a 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -4,7 +4,11 @@ warning: unnecessary parentheses around assigned value 30 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | - = note: #[warn(unused_parens)] on by default +note: lint level defined here + --> $DIR/suggestions.rs:11:21 + | +11 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 + | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 --> $DIR/suggestions.rs:27:1 @@ -25,7 +29,7 @@ warning: variable does not need to be mutable note: lint level defined here --> $DIR/suggestions.rs:11:9 | -11 | #![warn(unused_mut)] // UI tests pass `-A unused`—see Issue #43896 +11 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 | ^^^^^^^^^^ warning: static is marked #[no_mangle], but not exported diff --git a/src/test/ui/lint/unused_parens_json_suggestion.rs b/src/test/ui/lint/unused_parens_json_suggestion.rs index 9decb0cff365f..15251795d5e08 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_json_suggestion.rs @@ -16,6 +16,8 @@ // stripping away any starting or ending parenthesis characters—hence this // test of the JSON error format. +#![warn(unused_parens)] + fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` diff --git a/src/test/ui/lint/unused_parens_json_suggestion.stderr b/src/test/ui/lint/unused_parens_json_suggestion.stderr index 4b4dd92855da0..ae5b53da17503 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_json_suggestion.stderr @@ -1 +1 @@ -{"message":"unnecessary parentheses around assigned value","code":null,"level":"warning","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":976,"byte_end":989,"line_start":22,"line_end":22,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"#[warn(unused_parens)] on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":976,"byte_end":989,"line_start":22,"line_end":22,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":"1 / (2 + 3)","expansion":null}],"children":[],"rendered":" let _a = 1 / (2 + 3);"}],"rendered":null} +{"message":"unnecessary parentheses around assigned value","code":null,"level":"warning","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":1001,"byte_end":1014,"line_start":24,"line_end":24,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":847,"byte_end":860,"line_start":19,"line_end":19,"column_start":9,"column_end":22,"is_primary":true,"text":[{"text":"#![warn(unused_parens)]","highlight_start":9,"highlight_end":22}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":1001,"byte_end":1014,"line_start":24,"line_end":24,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":"1 / (2 + 3)","expansion":null}],"children":[],"rendered":null}],"rendered":null} diff --git a/src/test/ui/lint/use_suggestion_json.rs b/src/test/ui/lint/use_suggestion_json.rs new file mode 100644 index 0000000000000..20c24d6405042 --- /dev/null +++ b/src/test/ui/lint/use_suggestion_json.rs @@ -0,0 +1,21 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --error-format json + +// The output for humans should just highlight the whole span without showing +// the suggested replacement, but we also want to test that suggested +// replacement only removes one set of parentheses, rather than naïvely +// stripping away any starting or ending parenthesis characters—hence this +// test of the JSON error format. + +fn main() { + let x: Iter; +} diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr new file mode 100644 index 0000000000000..2ebe212b93ddb --- /dev/null +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -0,0 +1,2 @@ +{"message":"cannot find type `Iter` in this scope","code":{"code":"E0412","explanation":"/nThe type name used is not in scope./n/nErroneous code examples:/n/n```compile_fail,E0412/nimpl Something {} // error: type name `Something` is not in scope/n/n// or:/n/ntrait Foo {/n fn bar(N); // error: type name `N` is not in scope/n}/n/n// or:/n/nfn foo(x: T) {} // type name `T` is not in scope/n```/n/nTo fix this error, please verify you didn't misspell the type name, you did/ndeclare it or imported it into the scope. Examples:/n/n```/nstruct Something;/n/nimpl Something {} // ok!/n/n// or:/n/ntrait Foo {/n type N;/n/n fn bar(_: Self::N); // ok!/n}/n/n// or:/n/nfn foo(x: T) {} // ok!/n```/n/nAnother case that causes this error is when a type is imported into a parent/nmodule. To fix this, you can follow the suggestion and use File directly or/n`use super::File;` which will import the types from the parent namespace. An/nexample that causes this error is below:/n/n```compile_fail,E0412/nuse std::fs::File;/n/nmod foo {/n fn some_function(f: File) {}/n}/n```/n/n```/nuse std::fs::File;/n/nmod foo {/n // either/n use super::File;/n // or/n // use std::fs::File;/n fn foo(f: File) {}/n}/n# fn main() {} // don't insert it for us; that'll break imports/n```/n"},"level":"error","spans":[{"file_name":"$DIR/use_suggestion_json.rs","byte_start":862,"byte_end":866,"line_start":20,"line_end":20,"column_start":12,"column_end":16,"is_primary":true,"text":[{"text":" let x: Iter;","highlight_start":12,"highlight_end":16}],"label":"not found in this scope","suggested_replacement":null,"expansion":null}],"children":[{"message":"possible candidates are found in other modules, you can import them into scope","code":null,"level":"help","spans":[{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::collections::binary_heap::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::collections::btree_map::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::collections::btree_set::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::collections::hash_map::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::collections::hash_set::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::collections::linked_list::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::collections::vec_deque::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::option::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::path::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::result::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::slice::Iter;/n/n","expansion":null},{"file_name":"$DIR/use_suggestion_json.rs","byte_start":839,"byte_end":839,"line_start":19,"line_end":19,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"fn main() {","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":"use std::sync::mpsc::Iter;/n/n","expansion":null}],"children":[],"rendered":null}],"rendered":null} +{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":null} diff --git a/src/test/ui/path-lookahead.stderr b/src/test/ui/path-lookahead.stderr index 19e22b3f6f94f..059312b2851c6 100644 --- a/src/test/ui/path-lookahead.stderr +++ b/src/test/ui/path-lookahead.stderr @@ -4,7 +4,12 @@ warning: unnecessary parentheses around `return` value 18 | return (::to_string(&arg)); //~WARN unnecessary parentheses around `return` value | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses | - = note: #[warn(unused_parens)] on by default +note: lint level defined here + --> $DIR/path-lookahead.rs:13:9 + | +13 | #![warn(unused)] + | ^^^^^^ + = note: #[warn(unused_parens)] implied by #[warn(unused)] warning: function is never used: `with_parens` --> $DIR/path-lookahead.rs:17:1 diff --git a/src/test/ui/short-error-format.rs b/src/test/ui/short-error-format.rs new file mode 100644 index 0000000000000..3e6802c51c3a6 --- /dev/null +++ b/src/test/ui/short-error-format.rs @@ -0,0 +1,19 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --error-format=short + +fn foo(_: u32) {} + +fn main() { + foo("Bonjour".to_owned()); + let x = 0u32; + x.salut(); +} diff --git a/src/test/ui/short-error-format.stderr b/src/test/ui/short-error-format.stderr new file mode 100644 index 0000000000000..debe60b463226 --- /dev/null +++ b/src/test/ui/short-error-format.stderr @@ -0,0 +1,3 @@ +$DIR/short-error-format.rs:16:9 - error[E0308]: mismatched types +$DIR/short-error-format.rs:18:7 - error[E0599]: no method named `salut` found for type `u32` in the current scope +error: aborting due to 2 previous errors diff --git a/src/test/ui/similar-tokens.rs b/src/test/ui/similar-tokens.rs new file mode 100644 index 0000000000000..986382bc8ee85 --- /dev/null +++ b/src/test/ui/similar-tokens.rs @@ -0,0 +1,19 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod x { + pub struct A; + pub struct B; +} + +// `.` is similar to `,` so list parsing should continue to closing `}` +use x::{A. B}; + +fn main() {} diff --git a/src/test/ui/similar-tokens.stderr b/src/test/ui/similar-tokens.stderr new file mode 100644 index 0000000000000..cf0ed646db708 --- /dev/null +++ b/src/test/ui/similar-tokens.stderr @@ -0,0 +1,8 @@ +error: expected one of `,` or `as`, found `.` + --> $DIR/similar-tokens.rs:17:10 + | +17 | use x::{A. B}; + | ^ expected one of `,` or `as` here + +error: aborting due to previous error + diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 1d2f7bb2f07e9..017a449d96f46 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -4,12 +4,6 @@ error: unexpected generic arguments in path 20 | m!(MyTrait<>); | ^^^^^^^^^ -error: unexpected generic arguments in path - --> $DIR/macro-ty-params.rs:20:8 - | -20 | m!(MyTrait<>); - | ^^^^^^^^^ - error: generic arguments in macro path --> $DIR/macro-ty-params.rs:18:8 | diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 8c1b130b11652..5f680cafcca3e 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -11,7 +11,6 @@ extern crate toml; #[macro_use] extern crate serde_derive; -extern crate serde; use std::collections::BTreeMap; use std::env; @@ -175,9 +174,9 @@ struct Builder { digests: BTreeMap, s3_address: String, date: String, - rust_version: String, - cargo_version: String, - rls_version: String, + rust_version: Option, + cargo_version: Option, + rls_version: Option, rust_git_commit_hash: Option, cargo_git_commit_hash: Option, rls_git_commit_hash: Option, @@ -205,9 +204,9 @@ fn main() { digests: BTreeMap::new(), s3_address, date, - rust_version: String::new(), - cargo_version: String::new(), - rls_version: String::new(), + rust_version: None, + cargo_version: None, + rls_version: None, rust_git_commit_hash: None, cargo_git_commit_hash: None, rls_git_commit_hash: None, @@ -258,10 +257,17 @@ impl Builder { self.package("rls-preview", &mut manifest.pkg, HOSTS); self.package("rust-analysis", &mut manifest.pkg, TARGETS); - manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() }); + let rls_present = manifest.pkg.contains_key("rls-preview"); + + if rls_present { + manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() }); + } let mut pkg = Package { - version: self.cached_version("rust").to_string(), + version: self.cached_version("rust") + .as_ref() + .expect("Couldn't find Rust version") + .clone(), git_commit_hash: self.cached_git_commit_hash("rust").clone(), target: BTreeMap::new(), }; @@ -294,10 +300,12 @@ impl Builder { }); } - extensions.push(Component { - pkg: "rls-preview".to_string(), - target: host.to_string(), - }); + if rls_present { + extensions.push(Component { + pkg: "rls-preview".to_string(), + target: host.to_string(), + }); + } extensions.push(Component { pkg: "rust-analysis".to_string(), target: host.to_string(), @@ -334,6 +342,14 @@ impl Builder { pkgname: &str, dst: &mut BTreeMap, targets: &[&str]) { + let version = match *self.cached_version(pkgname) { + Some(ref version) => version.clone(), + None => { + println!("Skipping package {}", pkgname); + return; + } + }; + let targets = targets.iter().map(|name| { let filename = self.filename(pkgname, name); let digest = match self.digests.remove(&filename) { @@ -355,7 +371,7 @@ impl Builder { }).collect(); dst.insert(pkgname.to_string(), Package { - version: self.cached_version(pkgname).to_string(), + version, git_commit_hash: self.cached_git_commit_hash(pkgname).clone(), target: targets, }); @@ -380,7 +396,7 @@ impl Builder { } } - fn cached_version(&self, component: &str) -> &str { + fn cached_version(&self, component: &str) -> &Option { if component == "cargo" { &self.cargo_version } else if component == "rls" || component == "rls-preview" { @@ -400,7 +416,7 @@ impl Builder { } } - fn version(&self, component: &str, target: &str) -> String { + fn version(&self, component: &str, target: &str) -> Option { let mut cmd = Command::new("tar"); let filename = self.filename(component, target); cmd.arg("xf") @@ -408,13 +424,12 @@ impl Builder { .arg(format!("{}/version", filename.replace(".tar.gz", ""))) .arg("-O"); let output = t!(cmd.output()); - if !output.status.success() { - panic!("failed to learn version:\n\n{:?}\n\n{}\n\n{}", - cmd, - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr)); + if output.status.success() { + Some(String::from_utf8_lossy(&output.stdout).trim().to_string()) + } else { + // Perhaps we didn't build this package. + None } - String::from_utf8_lossy(&output.stdout).trim().to_string() } fn git_commit_hash(&self, component: &str, target: &str) -> Option { @@ -428,10 +443,6 @@ impl Builder { if output.status.success() { Some(String::from_utf8_lossy(&output.stdout).trim().to_string()) } else { - // This is always called after `.version()`. - // So if that didn’t fail but this does, - // that’s very probably because the tarball is valid - // but does not contain a `git-commit-hash` file. None } } diff --git a/src/tools/cargo b/src/tools/cargo index e447ac7e94b7f..859c2305b5d7f 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit e447ac7e94b7f56ab13e361f9e324dafe3eb0a34 +Subproject commit 859c2305b5d7ff820d7f7af158bbca999cbd8bf3 diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 0a9da26d9968d..00276ee34d4d8 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -19,6 +19,7 @@ struct Test { name: &'static str, sha: &'static str, lock: Option<&'static str>, + packages: &'static [&'static str], } const TEST_REPOS: &'static [Test] = &[ @@ -27,30 +28,51 @@ const TEST_REPOS: &'static [Test] = &[ repo: "https://github.com/iron/iron", sha: "21c7dae29c3c214c08533c2a55ac649b418f2fe3", lock: Some(include_str!("lockfiles/iron-Cargo.lock")), + packages: &[], }, Test { name: "ripgrep", repo: "https://github.com/BurntSushi/ripgrep", sha: "b65bb37b14655e1a89c7cd19c8b011ef3e312791", lock: None, + packages: &[], }, Test { name: "tokei", repo: "https://github.com/Aaronepower/tokei", sha: "5e11c4852fe4aa086b0e4fe5885822fbe57ba928", lock: None, + packages: &[], }, Test { name: "treeify", repo: "https://github.com/dzamlo/treeify", sha: "999001b223152441198f117a68fb81f57bc086dd", lock: None, + packages: &[], }, Test { name: "xsv", repo: "https://github.com/BurntSushi/xsv", sha: "4b308adbe48ac81657fd124b90b44f7c3263f771", lock: None, + packages: &[], + }, + Test { + name: "servo", + repo: "https://github.com/servo/servo", + sha: "38fe9533b93e985657f99a29772bf3d3c8694822", + lock: None, + // Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox. + // This takes much less time to build than all of Servo and supports stable Rust. + packages: &["stylo_tests", "selectors"], + }, + Test { + name: "webrender", + repo: "https://github.com/servo/webrender", + sha: "57250b2b8fa63934f80e5376a29f7dcb3f759ad6", + lock: None, + packages: &[], }, ]; @@ -74,7 +96,7 @@ fn test_repo(cargo: &Path, out_dir: &Path, test: &Test) { .write_all(lockfile.as_bytes()) .expect(""); } - if !run_cargo_test(cargo, &dir) { + if !run_cargo_test(cargo, &dir, test.packages) { panic!("tests failed for {}", test.repo); } } @@ -134,9 +156,13 @@ fn clone_repo(test: &Test, out_dir: &Path) -> PathBuf { out_dir } -fn run_cargo_test(cargo_path: &Path, crate_path: &Path) -> bool { - let status = Command::new(cargo_path) - .arg("test") +fn run_cargo_test(cargo_path: &Path, crate_path: &Path, packages: &[&str]) -> bool { + let mut command = Command::new(cargo_path); + command.arg("test"); + for name in packages { + command.arg("-p").arg(name); + } + let status = command // Disable rust-lang/cargo's cross-compile tests .env("CFG_DISABLE_CROSS_TESTS", "1") .current_dir(crate_path) diff --git a/src/tools/clippy b/src/tools/clippy index b62b1b68edcdf..f76225e388717 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit b62b1b68edcdf23a70cb12f31403c80e97f13634 +Subproject commit f76225e3887170743403af9204887918b5db5a80 diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 77ee93c30078b..8e9cd1a12faac 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -36,6 +36,7 @@ struct DiagnosticSpan { column_end: usize, is_primary: bool, label: Option, + suggested_replacement: Option, expansion: Option>, } @@ -164,15 +165,15 @@ fn push_expected_errors(expected_errors: &mut Vec, } // If the message has a suggestion, register that. - if let Some(ref rendered) = diagnostic.rendered { - let start_line = primary_spans.iter().map(|s| s.line_start).min().expect("\ - every suggestion should have at least one span"); - for (index, line) in rendered.lines().enumerate() { - expected_errors.push(Error { - line_num: start_line + index, - kind: Some(ErrorKind::Suggestion), - msg: line.to_string(), - }); + for span in primary_spans { + if let Some(ref suggested_replacement) = span.suggested_replacement { + for (index, line) in suggested_replacement.lines().enumerate() { + expected_errors.push(Error { + line_num: span.line_start + index, + kind: Some(ErrorKind::Suggestion), + msg: line.to_string(), + }); + } } } diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 85fa38bbd3be7..bd4044b4df3b4 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -73,7 +73,7 @@ pub fn get_env(triple: &str) -> Option<&str> { } pub fn get_pointer_width(triple: &str) -> &'static str { - if triple.contains("64") || triple.starts_with("s390x") { + if (triple.contains("64") && !triple.ends_with("gnux32")) || triple.starts_with("s390x") { "64bit" } else { "32bit" diff --git a/src/tools/rls b/src/tools/rls index 93b47d14cef57..e0348594a7245 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 93b47d14cef5720bba7cfb4dcb8078fbf1f706c1 +Subproject commit e0348594a724571f1d2387e03943efeb4df20e12 diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 16a478368c8dc..cf0d494dda744 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 16a478368c8dcc0c0ee47372a9f663b23d28b097 +Subproject commit cf0d494dda7447bacaab743a70c47e28bea55c6f diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 38df657769430..bc2767c7bcc5d 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -35,11 +35,8 @@ static EXCEPTIONS: &'static [&'static str] = &[ "thread-id", // Apache-2.0, mdbook "cssparser", // MPL-2.0, rustdoc "smallvec", // MPL-2.0, rustdoc - // FIXME: remove magenta references when "everything" has moved over to using the zircon name. - "magenta-sys", // BSD-3-Clause, rustdoc - "magenta", // BSD-3-Clause, rustdoc - "zircon-sys", // BSD-3-Clause, rustdoc - "zircon", // BSD-3-Clause, rustdoc + "fuchsia-zircon-sys", // BSD-3-Clause, rustdoc, rustc, cargo + "fuchsia-zircon", // BSD-3-Clause, rustdoc, rustc, cargo (jobserver & tempdir) "cssparser-macros", // MPL-2.0, rustdoc "selectors", // MPL-2.0, rustdoc ];