Fix error message for `-C panic=xxx`.
Fixes rust-lang/cargo#6334
+Version 1.31.0 (2018-12-06)
+==========================
+
+Language
+--------
+- 🎉 [This version marks the release of the 2018 edition of Rust.][54057] 🎉
+- [New lifetime elision rules now allow for eliding lifetimes in functions and
+ impl headers.][54778] E.g. `impl<'a> Reader for BufReader<'a> {}` can now be
+ `impl Reader for BufReader<'_> {}`. Lifetimes are still required to be defined
+ in structs.
+- [You can now define and use `const` functions.][54835] These are currently
+ a strict minimal subset of the [const fn RFC][RFC-911]. Refer to the
+ [language reference][const-reference] for what exactly is available.
+- [You can now use tool lints, which allow you to scope lints from external
+ tools using attributes.][54870] E.g. `#[allow(clippy::filter_map)]`.
+- [`#[no_mangle]` and `#[export_name]` attributes can now be located anywhere in
+ a crate, not just in exported functions.][54451]
+- [You can now use parentheses in pattern matches.][54497]
+
+Compiler
+--------
+- [Updated musl to 1.1.20][54430]
+
+Libraries
+---------
+- [You can now convert `num::NonZero*` types to their raw equivalvents using the
+ `From` trait.][54240] E.g. `u8` now implements `From<NonZeroU8>`.
+- [You can now convert a `&Option<T>` into `Option<&T>` and `&mut Option<T>`
+ into `Option<&mut T>` using the `From` trait.][53218]
+- [You can now multiply (`*`) a `time::Duration` by a `u32`.][52813]
+
+
+Stabilized APIs
+---------------
+- [`slice::align_to`]
+- [`slice::align_to_mut`]
+- [`slice::chunks_exact`]
+- [`slice::chunks_exact_mut`]
+- [`slice::rchunks`]
+- [`slice::rchunks_mut`]
+- [`slice::rchunks_exact`]
+- [`slice::rchunks_exact_mut`]
+- [`Option::replace`]
+
+Cargo
+-----
+- [Cargo will now download crates in parallel using HTTP/2.][cargo/6005]
+- [You can now rename packages in your Cargo.toml][cargo/6319] We have a guide
+ on [how to use the `package` key in your dependencies.][cargo-rename-reference]
+
+[52813]: https://github.com/rust-lang/rust/pull/52813/
+[53218]: https://github.com/rust-lang/rust/pull/53218/
+[53555]: https://github.com/rust-lang/rust/issues/53555/
+[54057]: https://github.com/rust-lang/rust/pull/54057/
+[54240]: https://github.com/rust-lang/rust/pull/54240/
+[54430]: https://github.com/rust-lang/rust/pull/54430/
+[54451]: https://github.com/rust-lang/rust/pull/54451/
+[54497]: https://github.com/rust-lang/rust/pull/54497/
+[54778]: https://github.com/rust-lang/rust/pull/54778/
+[54835]: https://github.com/rust-lang/rust/pull/54835/
+[54870]: https://github.com/rust-lang/rust/pull/54870/
+[RFC-911]: https://github.com/rust-lang/rfcs/pull/911
+[`Option::replace`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.replace
+[`slice::align_to_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.align_to_mut
+[`slice::align_to`]: https://doc.rust-lang.org/std/primitive.slice.html#method.align_to
+[`slice::chunks_exact_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.chunks_exact_mut
+[`slice::chunks_exact`]: https://doc.rust-lang.org/std/primitive.slice.html#method.chunks_exact
+[`slice::rchunks_exact_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks_mut
+[`slice::rchunks_exact`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks_exact
+[`slice::rchunks_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks_mut
+[`slice::rchunks`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks
+[cargo/6005]: https://github.com/rust-lang/cargo/pull/6005/
+[cargo/6319]: https://github.com/rust-lang/cargo/pull/6319/
+[cargo-rename-reference]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml
+[const-reference]: https://doc.rust-lang.org/reference/items/functions.html#const-functions
+
+
Version 1.30.0 (2018-10-25)
==========================
[[package]]
name = "derive_more"
-version = "0.11.0"
+version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "ena"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "env_logger"
version = "0.5.12"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
-version = "0.4.13"
+version = "0.4.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "racer"
-version = "2.1.9"
+version = "2.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "derive_more 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "rls"
-version = "0.130.5"
+version = "1.31.6"
dependencies = [
"cargo 0.33.0",
"cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ordslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "racer 2.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "racer 2.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-analysis 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-blacklist 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-analysis 0.16.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-data 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-rustc 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-workspace-hack 1.0.0",
"rustc_tools_util 0.1.0",
- "rustfmt-nightly 0.99.6",
+ "rustfmt-nightly 1.0.0",
"serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rls-analysis"
-version = "0.16.1"
+version = "0.16.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rls-blacklist"
-version = "0.1.2"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
[[package]]
name = "rls-vfs"
-version = "0.4.6"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-ap-arena"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rustc-ap-rustc_data_structures 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "rustc-ap-graphviz"
+version = "297.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "rustc-ap-rustc_cratesio_shim"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rustc-ap-rustc_data_structures"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_cratesio_shim 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-graphviz 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rustc-ap-rustc_errors"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_cratesio_shim 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_data_structures 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax_pos 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"termcolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-ap-rustc_target"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_cratesio_shim 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-ap-serialize"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rustc-ap-syntax"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_data_structures 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_errors 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_target 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax_pos 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_errors 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_target 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-ap-syntax_pos"
-version = "274.0.0"
+version = "297.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-arena 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_data_structures 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-serialize 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-arena 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.0.0"
dependencies = [
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ena 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"graphviz 0.0.0",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rustfmt-nightly"
-version = "0.99.6"
+version = "1.0.0"
dependencies = [
"assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-rustc_target 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-ap-syntax_pos 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-rustc_target 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-workspace-hack 1.0.0",
"serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)",
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.14.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "syn"
+version = "0.15.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"checksum curl-sys 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "721c204978be2143fab0a84b708c49d79d1f6100b8785610f456043a90708870"
"checksum datafrog 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16d724bf4ffe77cdceeecd461009b5f8d9e23c5d645d68bedb4586bf43e7e142"
"checksum derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ceed73957c449214f8440eec8ad7fa282b67dc9eacbb24a3085b15d60397a17a"
-"checksum derive_more 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46c7f14685a20f5dd08e7f754f2ea8cc064d8f4214ae21116c106a2768ba7b9b"
+"checksum derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f57d78cf3bd45270dad4e70c21ec77a960b36c7a841ff9db76aaa775a8fb871"
"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum elasticlunr-rs 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4837d77a1e157489a3933b743fd774ae75074e0e390b2b7f071530048a0d87ee"
+"checksum ena 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25b4e5febb25f08c49f1b07dc33a182729a6b21edfb562b5aef95f78e0dbe5bb"
"checksum ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dc8393b3c7352f94092497f6b52019643e493b6b890eb417cdb7c46117e621"
"checksum env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "f4d7e69c283751083d53d01eac767407343b8b69c4bd70058e08adc2637cb257"
"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e"
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
"checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
"checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7"
-"checksum proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ee5697238f0d893c7f0ecc59c0999f18d2af85e424de441178bcacc9f9e6cf67"
+"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09"
"checksum proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "926d0604475349f463fe44130aae73f2294b5309ab2ca0310b998bd334ef191f"
"checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
-"checksum racer 2.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5eeddfffd44c83eb03eedf5eb336e9c75303534fe28728a9f6b39a6e6f07ccff"
+"checksum racer 2.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "344a53b68d889ab5f44d0617f2bbe1f696abe6a730bd41fa619cfc6fa83a6078"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2"
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
-"checksum rls-analysis 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a625690e3bf1204ce27b50f71e508ee788214b2d51e26e4e5db884a83627673"
-"checksum rls-blacklist 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4a9cc2545ccb7e05b355bfe047b8039a6ec12270d5f3c996b766b340a50f7d2"
+"checksum rls-analysis 0.16.8 (registry+https://github.com/rust-lang/crates.io-index)" = "2a1d3a2a8c03e380331aefb8b5e3e06f3065602fbaa6657ba0ac649dc99d8537"
+"checksum rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ce1fdac03e138c4617ff87b194e1ff57a39bb985a044ccbd8673d30701e411"
"checksum rls-data 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a209ce46bb52813cbe0786a7baadc0c1a3f5543ef93f179eda3b841ed72cf2e"
"checksum rls-rustc 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9dba7390427aefa953608429701e3665192ca810ba8ae09301e001b7c7bed0"
"checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
-"checksum rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ecbc8541b4c341d6271eae10f869dd9d36db871afe184f5b6f9bffbd6ed0373f"
-"checksum rustc-ap-arena 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "866fda692855b38f9d6562f0e952c75c6ebe4032d7dd63c608a88e7c4d3f8087"
-"checksum rustc-ap-rustc_cratesio_shim 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c2343e11a97b4eb3bee29cd5f9314ea409a87baee5d3fec8d1516d1633412e"
-"checksum rustc-ap-rustc_data_structures 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b88f905f7ab99bf14220a3a87eff60ec143af8136fd0ca8573641c78be532ec8"
-"checksum rustc-ap-rustc_errors 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c86fda6cf42e0355b7ecf40f14888340c20b7b864c9d37f6ffca85fe87200652"
-"checksum rustc-ap-rustc_target 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8fa8622299beac8c40270e8536a7b0509ca80f227a2b56550019a325fa5a60c0"
-"checksum rustc-ap-serialize 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d16cc3d014af9a524c0bed6ca806c3170e39d5987180f0f8ce8fb7df5113576c"
-"checksum rustc-ap-syntax 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a29f280f04f4f45e1bdd773ab5e667b36e757bfbbd01193c330815b9e76d05a"
-"checksum rustc-ap-syntax_pos 274.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c2ea27b65311571c7614deb393691eb18c5e41fd4fd9d8490304e128e1358646"
+"checksum rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72d56425bd5aa86d9d4372b76f0381d3b4bda9c0220e71956c9fcc929f45c1f1"
+"checksum rustc-ap-arena 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b69fd4a0e8a3ecd99b497965d05f6f04dd2e4601a6146a841dbe4c8e77c2b30c"
+"checksum rustc-ap-graphviz 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8136418dbc491bab74aa0565eaa2086754a7a81a5e74a1d84d6168d18e889e7"
+"checksum rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a972feda82332d1d05b1ba5a097e915cd9c9c8f1af2bd7b08af09fb88c753d5f"
+"checksum rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "582584c6c48b0ece4b8aef3f9bb59d94d17c5665612bc87a71f509e45a3113b5"
+"checksum rustc-ap-rustc_errors 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd852096944d0ac6af1aefa9639a2ae6dede217606ce97f88ff0dcc8c86d6ff6"
+"checksum rustc-ap-rustc_target 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98301a272ecfeec29d2d4e97b07238707c2b89d86fc3a4a5f31a00728f14e288"
+"checksum rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f13510e617e2e322e3297038fd6a7346f2297124af9e10e33a627c5d544e9d"
+"checksum rustc-ap-syntax 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0792f5a9ccfc5ec13bb5b0472fa49e145481029c39f6bf5b1a36decc99c3328f"
+"checksum rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0df9f97f41650d23b14f92f7267f8c61089655efb4533d82bf8991f99245198d"
"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
"checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b"
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
+"checksum syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)" = "816b7af21405b011a23554ea2dc3f6576dc86ca557047c34098c1d741f10f823"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7"
"checksum tar 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "69e16840a1e0a1f1a880b739ef1cc6a4b85496c99b8aa786ccffce6e0c15624c"
let compiler = self.compiler;
let target = self.target;
let name = self.name;
- // build book first edition
+
+ // build book
builder.ensure(Rustbook {
target,
- name: INTERNER.intern_string(format!("{}/first-edition", name)),
+ name: INTERNER.intern_string(name.to_string()),
});
- // build book second edition
+ // building older edition redirects
+
+ let source_name = format!("{}/first-edition", name);
builder.ensure(Rustbook {
target,
- name: INTERNER.intern_string(format!("{}/second-edition", name)),
+ name: INTERNER.intern_string(source_name),
});
- // build book 2018 edition
+ let source_name = format!("{}/second-edition", name);
builder.ensure(Rustbook {
target,
- name: INTERNER.intern_string(format!("{}/2018-edition", name)),
+ name: INTERNER.intern_string(source_name),
+ });
+
+ let source_name = format!("{}/2018-edition", name);
+ builder.ensure(Rustbook {
+ target,
+ name: INTERNER.intern_string(source_name),
});
// build the version info page and CSS
target,
});
- // build the index page
- let index = format!("{}/index.md", name);
- builder.info(&format!("Documenting book index ({})", target));
- invoke_rustdoc(builder, compiler, target, &index);
-
// build the redirect pages
builder.info(&format!("Documenting book redirect pages ({})", target));
for file in t!(fs::read_dir(builder.src.join("src/doc/book/redirects"))) {
use compile;
use native;
use channel::GitInfo;
+use channel;
use cache::Interned;
use toolstate::ToolState;
cargo.env("CFG_RELEASE_CHANNEL", &builder.config.channel);
cargo.env("CFG_VERSION", builder.rust_version());
+ cargo.env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM);
let info = GitInfo::new(&builder.config, &dir);
if let Some(sha) = info.sha() {
-Subproject commit e871c4598925594421d63e929fee292e6e071f97
+Subproject commit 616fe4172b688393aeee5f34935cc25733c9c062
-Subproject commit 7f7a597b47ed6c35c2a0f0ee6a69050fe2d5e013
+Subproject commit f8a4e96feb2e5a6ed1ef170ad40e3509a7755cb4
-Subproject commit b9fb838054b8441223c22eeae5b6d8e498071cd0
+Subproject commit 60077efda319c95a89fe39609803c5433567adbf
-Subproject commit bc342a475c09b6df8004d518382e6d5b6bcb49f7
+Subproject commit 2ce92beabb912d417a7314d6da83ac9b50dc2afb
The RFC is: [rfc#1576].
-With this feature gate enabled, the [list of fragment specifiers][frags] gains one more entry:
+With this feature gate enabled, the [list of designators] gains one more entry:
* `literal`: a literal. Examples: 2, "string", 'c'
[rfc#1576]: http://rust-lang.github.io/rfcs/1576-macros-literal-matcher.html
[#35625]: https://github.com/rust-lang/rust/issues/35625
-[frags]: ../book/first-edition/macros.html#syntactic-requirements
+[list of designators]: ../reference/macros-by-example.html
------------------------
## Tips and tricks
-Some of the [macro debugging tips](../book/first-edition/macros.html#debugging-macro-code) are applicable.
-
You can use `syntax::parse` to turn token trees into
higher-level syntax elements like expressions:
def to_string(self):
(tail, head, data_ptr, cap) = \
rustpp.extract_tail_head_ptr_and_cap_from_std_vecdeque(self.__val)
+ if head >= tail:
+ size = head - tail
+ else:
+ size = cap + head - tail
return (self.__val.type.get_unqualified_type_name() +
- ("(len: %i, cap: %i)" % (head - tail, cap)))
+ ("(len: %i, cap: %i)" % (size, cap)))
def children(self):
(tail, head, data_ptr, cap) = \
rustpp.extract_tail_head_ptr_and_cap_from_std_vecdeque(self.__val)
gdb_ptr = data_ptr.get_wrapped_value()
- for index in xrange(tail, head):
- yield (str(index), (gdb_ptr + index).dereference())
+ if head >= tail:
+ size = head - tail
+ else:
+ size = cap + head - tail
+ for index in xrange(0, size):
+ yield (str(index), (gdb_ptr + ((tail + index) % cap)).dereference())
class RustStdBTreeSetPrinter(object):
//!
//! `Rc<T>` automatically dereferences to `T` (via the [`Deref`] trait),
//! so you can call `T`'s methods on a value of type [`Rc<T>`][`Rc`]. To avoid name
-//! clashes with `T`'s methods, the methods of [`Rc<T>`][`Rc`] itself are [associated
-//! functions][assoc], called using function-like syntax:
+//! clashes with `T`'s methods, the methods of [`Rc<T>`][`Rc`] itself are associated
+//! functions, called using function-like syntax:
//!
//! ```
//! use std::rc::Rc;
//! [downgrade]: struct.Rc.html#method.downgrade
//! [upgrade]: struct.Weak.html#method.upgrade
//! [`None`]: ../../std/option/enum.Option.html#variant.None
-//! [assoc]: ../../book/first-edition/method-syntax.html#associated-functions
//! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable
#![stable(feature = "rust1", since = "1.0.0")]
///
/// `Arc<T>` automatically dereferences to `T` (via the [`Deref`][deref] trait),
/// so you can call `T`'s methods on a value of type `Arc<T>`. To avoid name
-/// clashes with `T`'s methods, the methods of `Arc<T>` itself are [associated
-/// functions][assoc], called using function-like syntax:
+/// clashes with `T`'s methods, the methods of `Arc<T>` itself are associated
+/// functions, called using function-like syntax:
///
/// ```
/// use std::sync::Arc;
/// [downgrade]: struct.Arc.html#method.downgrade
/// [upgrade]: struct.Weak.html#method.upgrade
/// [`None`]: ../../std/option/enum.Option.html#variant.None
-/// [assoc]: ../../book/first-edition/method-syntax.html#associated-functions
/// [`RefCell<T>`]: ../../std/cell/struct.RefCell.html
/// [`std::sync`]: ../../std/sync/index.html
/// [`Arc::clone(&from)`]: #method.clone
//!
//! // Logger function for any type that implements Debug.
//! fn log<T: Any + Debug>(value: &T) {
-//! let value_any = value as &Any;
+//! let value_any = value as &dyn Any;
//!
//! // try to convert our value to a String. If successful, we want to
//! // output the String's length as well as its value. If not, it's a
///
/// use std::any::{Any, TypeId};
///
- /// fn is_string(s: &Any) -> bool {
+ /// fn is_string(s: &dyn Any) -> bool {
/// TypeId::of::<String>() == s.get_type_id()
/// }
///
/// ```
/// use std::any::Any;
///
- /// fn is_string(s: &Any) {
+ /// fn is_string(s: &dyn Any) {
/// if s.is::<String>() {
/// println!("It's a string!");
/// } else {
/// ```
/// use std::any::Any;
///
- /// fn print_if_string(s: &Any) {
+ /// fn print_if_string(s: &dyn Any) {
/// if let Some(string) = s.downcast_ref::<String>() {
/// println!("It's a string({}): '{}'", string.len(), string);
/// } else {
/// ```
/// use std::any::Any;
///
- /// fn modify_if_u32(s: &mut Any) {
+ /// fn modify_if_u32(s: &mut dyn Any) {
/// if let Some(num) = s.downcast_mut::<u32>() {
/// *num = 42;
/// }
/// ```
/// use std::any::Any;
///
- /// fn is_string(s: &(Any + Send)) {
+ /// fn is_string(s: &(dyn Any + Send)) {
/// if s.is::<String>() {
/// println!("It's a string!");
/// } else {
/// ```
/// use std::any::Any;
///
- /// fn print_if_string(s: &(Any + Send)) {
+ /// fn print_if_string(s: &(dyn Any + Send)) {
/// if let Some(string) = s.downcast_ref::<String>() {
/// println!("It's a string({}): '{}'", string.len(), string);
/// } else {
/// ```
/// use std::any::Any;
///
- /// fn modify_if_u32(s: &mut (Any + Send)) {
+ /// fn modify_if_u32(s: &mut (dyn Any + Send)) {
/// if let Some(num) = s.downcast_mut::<u32>() {
/// *num = 42;
/// }
/// ```
/// use std::any::Any;
///
- /// fn is_string(s: &(Any + Send + Sync)) {
+ /// fn is_string(s: &(dyn Any + Send + Sync)) {
/// if s.is::<String>() {
/// println!("It's a string!");
/// } else {
/// ```
/// use std::any::Any;
///
- /// fn print_if_string(s: &(Any + Send + Sync)) {
+ /// fn print_if_string(s: &(dyn Any + Send + Sync)) {
/// if let Some(string) = s.downcast_ref::<String>() {
/// println!("It's a string({}): '{}'", string.len(), string);
/// } else {
/// ```
/// use std::any::Any;
///
- /// fn modify_if_u32(s: &mut (Any + Send + Sync)) {
+ /// fn modify_if_u32(s: &mut (dyn Any + Send + Sync)) {
/// if let Some(num) = s.downcast_mut::<u32>() {
/// *num = 42;
/// }
/// Converts a `u32` to a `char`.
///
/// Note that all [`char`]s are valid [`u32`]s, and can be cast to one with
-/// [`as`]:
+/// `as`:
///
/// ```
/// let c = '💯';
///
/// [`char`]: ../../std/primitive.char.html
/// [`u32`]: ../../std/primitive.u32.html
-/// [`as`]: ../../book/first-edition/casting-between-types.html#as
///
/// For an unsafe version of this function which ignores these checks, see
/// [`from_u32_unchecked`].
/// Converts a `u32` to a `char`, ignoring validity.
///
/// Note that all [`char`]s are valid [`u32`]s, and can be cast to one with
-/// [`as`]:
+/// `as`:
///
/// ```
/// let c = '💯';
///
/// [`char`]: ../../std/primitive.char.html
/// [`u32`]: ../../std/primitive.u32.html
-/// [`as`]: ../../book/first-edition/casting-between-types.html#as
///
/// # Safety
///
/// If you're doing some sort of looping for a side effect, it's considered
/// more idiomatic to use [`for`] than `map()`.
///
- /// [`for`]: ../../book/first-edition/loops.html#for
+ /// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
///
/// # Examples
///
/// cases `for_each` may also be faster than a loop, because it will use
/// internal iteration on adaptors like `Chain`.
///
- /// [`for`]: ../../book/first-edition/loops.html#for
+ /// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
///
/// # Examples
///
/// use a `for` loop with a list of things to build up a result. Those
/// can be turned into `fold()`s:
///
- /// [`for`]: ../../book/first-edition/loops.html#for
+ /// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
///
/// ```
/// let numbers = [1, 2, 3, 4, 5];
use cmp;
use fmt;
use iter_private::TrustedRandomAccess;
-use ops::{self, Try};
+use ops::Try;
use usize;
use intrinsics;
-use mem;
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::iterator::Iterator;
#[inline]
fn next(&mut self) -> Option<Self::Item> {
- <Self as StepBySpecIterator>::spec_next(self)
+ if self.first_take {
+ self.first_take = false;
+ self.iter.next()
+ } else {
+ self.iter.nth(self.step)
+ }
}
#[inline]
}
}
-// hidden trait for specializing iterator methods
-// could be generalized but is currently only used for StepBy
-trait StepBySpecIterator {
- type Item;
- fn spec_next(&mut self) -> Option<Self::Item>;
-}
-
-impl<I> StepBySpecIterator for StepBy<I>
-where
- I: Iterator,
-{
- type Item = I::Item;
-
- #[inline]
- default fn spec_next(&mut self) -> Option<I::Item> {
- if self.first_take {
- self.first_take = false;
- self.iter.next()
- } else {
- self.iter.nth(self.step)
- }
- }
-}
-
-impl<T> StepBySpecIterator for StepBy<ops::Range<T>>
-where
- T: Step,
-{
- #[inline]
- fn spec_next(&mut self) -> Option<Self::Item> {
- self.first_take = false;
- if !(self.iter.start < self.iter.end) {
- return None;
- }
- // add 1 to self.step to get original step size back
- // it was decremented for the general case on construction
- if let Some(n) = self.iter.start.add_usize(self.step+1) {
- let next = mem::replace(&mut self.iter.start, n);
- Some(next)
- } else {
- let last = self.iter.start.clone();
- self.iter.start = self.iter.end.clone();
- Some(last)
- }
- }
-}
-
-impl<T> StepBySpecIterator for StepBy<ops::RangeInclusive<T>>
-where
- T: Step,
-{
- #[inline]
- fn spec_next(&mut self) -> Option<Self::Item> {
- self.first_take = false;
- self.iter.compute_is_empty();
- if self.iter.is_empty.unwrap_or_default() {
- return None;
- }
- // add 1 to self.step to get original step size back
- // it was decremented for the general case on construction
- if let Some(n) = self.iter.start.add_usize(self.step+1) {
- self.iter.is_empty = Some(!(n <= self.iter.end));
- let next = mem::replace(&mut self.iter.start, n);
- Some(next)
- } else {
- let last = self.iter.start.clone();
- self.iter.is_empty = Some(true);
- Some(last)
- }
- }
-}
-
// StepBy can only make the iterator shorter, so the len will still fit.
#[stable(feature = "iterator_step_by", since = "1.28.0")]
impl<I> ExactSizeIterator for StepBy<I> where I: ExactSizeIterator {}
/// [uninit]: fn.uninitialized.html
/// [clone]: ../clone/trait.Clone.html
/// [swap]: fn.swap.html
-/// [FFI]: ../../book/first-edition/ffi.html
/// [box]: ../../std/boxed/struct.Box.html
/// [leak]: ../../std/boxed/struct.Box.html#method.leak
/// [into_raw]: ../../std/boxed/struct.Box.html#method.into_raw
///
/// This has the same effect as allocating space with
/// [`mem::uninitialized`][uninit] and then zeroing it out. It is useful for
-/// [FFI] sometimes, but should generally be avoided.
+/// FFI sometimes, but should generally be avoided.
///
/// There is no guarantee that an all-zero byte-pattern represents a valid value of
/// some type `T`. If `T` has a destructor and the value is destroyed (due to
/// many of the same caveats.
///
/// [uninit]: fn.uninitialized.html
-/// [FFI]: ../../book/first-edition/ffi.html
/// [ub]: ../../reference/behavior-considered-undefined.html
///
/// # Examples
/// **This is incredibly dangerous and should not be done lightly. Deeply
/// consider initializing your memory with a default value instead.**
///
-/// This is useful for [FFI] functions and initializing arrays sometimes,
+/// This is useful for FFI functions and initializing arrays sometimes,
/// but should generally be avoided.
///
-/// [FFI]: ../../book/first-edition/ffi.html
-///
/// # Undefined behavior
///
/// It is [undefined behavior][ub] to read uninitialized memory, even just an
/// While this does call the argument's implementation of [`Drop`][drop],
/// it will not release any borrows, as borrows are based on lexical scope.
///
-/// This effectively does nothing for
-/// [types which implement `Copy`](../../book/first-edition/ownership.html#copy-types),
-/// e.g. integers. Such values are copied and _then_ moved into the function,
-/// so the value persists after this function call.
+/// This effectively does nothing for types which implement `Copy`, e.g.
+/// integers. Such values are copied and _then_ moved into the function, so the
+/// value persists after this function call.
///
/// This function is not magic; it is literally defined as
///
impl<T: ?Sized> Deref for ManuallyDrop<T> {
type Target = T;
#[inline]
- fn deref(&self) -> &Self::Target {
+ fn deref(&self) -> &T {
&self.value
}
}
#[stable(feature = "manually_drop", since = "1.20.0")]
impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
#[inline]
- fn deref_mut(&mut self) -> &mut Self::Target {
+ fn deref_mut(&mut self) -> &mut T {
&mut self.value
}
}
//! [`NonNull::dangling`] in such cases.
//!
//! [aliasing]: ../../nomicon/aliasing.html
-//! [book]: ../../book/second-edition/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer
+//! [book]: ../../book/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer
//! [ub]: ../../reference/behavior-considered-undefined.html
//! [null]: ./fn.null.html
//! [zst]: ../../nomicon/exotic-sizes.html#zero-sized-types-zsts
/// The representation of a trait object like `&SomeTrait`.
///
/// This struct has the same layout as types like `&SomeTrait` and
-/// `Box<AnotherTrait>`. The [Trait Objects chapter of the
-/// Book][moreinfo] contains more details about the precise nature of
-/// these internals.
-///
-/// [moreinfo]: ../../book/first-edition/trait-objects.html#representation
+/// `Box<AnotherTrait>`.
///
/// `TraitObject` is guaranteed to match layouts, but it is not the
/// type of trait objects (e.g. the fields are not directly accessible
assert_eq!((isize::MIN..isize::MAX).step_by(1).size_hint(), (usize::MAX, Some(usize::MAX)));
}
+#[test]
+fn test_step_by_skip() {
+ assert_eq!((0..640).step_by(128).skip(1).collect::<Vec<_>>(), [128, 256, 384, 512]);
+ assert_eq!((0..=50).step_by(10).nth(3), Some(30));
+ assert_eq!((200..=255u8).step_by(10).nth(3), Some(230));
+}
+
#[test]
fn test_range_inclusive_step() {
assert_eq!((0..=50).step_by(10).collect::<Vec<_>>(), [0, 10, 20, 30, 40, 50]);
DepGraph {
data: Some(Lrc::new(DepGraphData {
previous_work_products: prev_work_products,
- dep_node_debug: Lock::new(Default::default()),
+ dep_node_debug: Default::default(),
current: Lock::new(CurrentDepGraph::new()),
previous: prev_graph,
colors: Lock::new(DepNodeColorMap::new(prev_graph_node_count)),
- loaded_from_cache: Lock::new(Default::default()),
+ loaded_from_cache: Default::default(),
})),
fingerprints: Lrc::new(Lock::new(fingerprints)),
}
loop_scopes: Vec::new(),
is_in_loop_condition: false,
anonymous_lifetime_mode: AnonymousLifetimeMode::PassThrough,
- type_def_lifetime_params: DefIdMap(),
+ type_def_lifetime_params: Default::default(),
current_hir_id_owner: vec![(CRATE_DEF_INDEX, 0)],
- item_local_id_counters: NodeMap(),
+ item_local_id_counters: Default::default(),
node_id_to_hir_id: IndexVec::new(),
is_generator: false,
is_in_trait_impl: false,
hir::TyKind::BareFn(P(hir::BareFnTy {
generic_params: this.lower_generic_params(
&f.generic_params,
- &NodeMap(),
+ &NodeMap::default(),
ImplTraitContext::disallowed(),
),
unsafety: this.lower_unsafety(f.unsafety),
// FIXME: This could probably be done with less rightward drift. Also looks like two control
// paths where report_error is called are also the only paths that advance to after
// the match statement, so the error reporting could probably just be moved there.
- let mut add_bounds: NodeMap<Vec<_>> = NodeMap();
+ let mut add_bounds: NodeMap<Vec<_>> = Default::default();
for pred in &generics.where_clause.predicates {
if let WherePredicate::BoundPredicate(ref bound_pred) = *pred {
'next_bound: for bound in &bound_pred.bounds {
hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate {
bound_generic_params: this.lower_generic_params(
bound_generic_params,
- &NodeMap(),
+ &NodeMap::default(),
ImplTraitContext::disallowed(),
),
bounded_ty: this.lower_ty(bounded_ty, ImplTraitContext::disallowed()),
p: &PolyTraitRef,
mut itctx: ImplTraitContext<'_>,
) -> hir::PolyTraitRef {
- let bound_generic_params =
- self.lower_generic_params(&p.bound_generic_params, &NodeMap(), itctx.reborrow());
+ let bound_generic_params = self.lower_generic_params(
+ &p.bound_generic_params,
+ &NodeMap::default(),
+ itctx.reborrow(),
+ );
let trait_ref = self.with_parent_impl_lifetime_defs(
&bound_generic_params,
|this| this.lower_trait_ref(&p.trait_ref, itctx),
/// Internally the DefPathTable holds a tree of DefKeys, where each DefKey
/// stores the DefIndex of its parent.
/// There is one DefPathTable for each crate.
+#[derive(Default)]
pub struct DefPathTable {
index_to_key: [Vec<DefKey>; 2],
def_path_hashes: [Vec<DefPathHash>; 2],
/// The definition table containing node definitions.
/// It holds the DefPathTable for local DefIds/DefPaths and it also stores a
/// mapping from NodeIds to local DefIds.
-#[derive(Clone)]
+#[derive(Clone, Default)]
pub struct Definitions {
table: DefPathTable,
node_to_def_index: NodeMap<DefIndex>,
/// ascending order.
///
/// FIXME: there is probably a better place to put this comment.
- pub fn new() -> Definitions {
- Definitions {
- table: DefPathTable {
- index_to_key: [vec![], vec![]],
- def_path_hashes: [vec![], vec![]],
- },
- node_to_def_index: NodeMap(),
- def_index_to_node: [vec![], vec![]],
- node_to_hir_id: IndexVec::new(),
- parent_modules_of_macro_defs: Default::default(),
- expansions_that_defined: Default::default(),
- next_disambiguator: Default::default(),
- def_index_to_span: Default::default(),
- }
+ pub fn new() -> Self {
+ Self::default()
}
pub fn def_path_table(&self) -> &DefPathTable {
// times, we cache a stable hash of it and hash that instead of
// recursing every time.
thread_local! {
- static CACHE: RefCell<FxHashMap<hygiene::Mark, u64>> =
- RefCell::new(Default::default());
+ static CACHE: RefCell<FxHashMap<hygiene::Mark, u64>> = Default::default();
}
let sub_hash: u64 = CACHE.with(|cache| {
ByRef(id, alloc, offset),
}
);
+impl_stable_hash_for!(struct ::mir::interpret::RawConst<'tcx> {
+ alloc_id,
+ ty,
+});
impl_stable_hash_for! {
impl<Tag> for struct mir::interpret::Pointer<Tag> {
parent_def_id,
body_id,
param_env,
- opaque_types: DefIdMap(),
+ opaque_types: Default::default(),
obligations: vec![],
};
let value = instantiator.instantiate_opaque_types_in_map(value);
mod taint;
+#[derive(Default)]
pub struct RegionConstraintCollector<'tcx> {
/// For each `RegionVid`, the corresponding `RegionVariableOrigin`.
var_infos: IndexVec<RegionVid, RegionVariableInfo>,
}
impl<'tcx> RegionConstraintCollector<'tcx> {
- pub fn new() -> RegionConstraintCollector<'tcx> {
- RegionConstraintCollector {
- var_infos: VarInfos::default(),
- data: RegionConstraintData::default(),
- lubs: Default::default(),
- glbs: Default::default(),
- bound_count: 0,
- undo_log: Vec::new(),
- unification_table: ut::UnificationTable::new(),
- any_unifications: false,
- }
+ pub fn new() -> Self {
+ Self::default()
}
pub fn num_region_vars(&self) -> usize {
"warn about missing code example in an item's documentation"
}
+declare_lint! {
+ pub PRIVATE_DOC_TESTS,
+ Allow,
+ "warn about doc test in private item"
+}
+
declare_lint! {
pub WHERE_CLAUSES_OBJECT_SAFETY,
Warn,
DUPLICATE_MACRO_EXPORTS,
INTRA_DOC_LINK_RESOLUTION_FAILURE,
MISSING_DOC_CODE_EXAMPLES,
+ PRIVATE_DOC_TESTS,
WHERE_CLAUSES_OBJECT_SAFETY,
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
MACRO_USE_EXTERN_CRATE,
let (passes, buffered) = if pre_expansion {
(
sess.lint_store.borrow_mut().pre_expansion_passes.take(),
- LintBuffer::new(),
+ LintBuffer::default(),
)
} else {
(
pub use self::levels::{LintLevelSets, LintLevelMap};
+#[derive(Default)]
pub struct LintBuffer {
map: NodeMap<Vec<BufferedEarlyLint>>,
}
impl LintBuffer {
- pub fn new() -> LintBuffer {
- LintBuffer { map: NodeMap() }
- }
-
pub fn add_lint(&mut self,
lint: &'static Lint,
id: ast::NodeId,
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
pub enum SignalledError { SawSomeError, NoErrorsSeen }
+impl Default for SignalledError {
+ fn default() -> SignalledError {
+ SignalledError::NoErrorsSeen
+ }
+}
+
impl_stable_hash_for!(enum self::SignalledError { SawSomeError, NoErrorsSeen });
-#[derive(Debug, RustcEncodable, RustcDecodable)]
+#[derive(Debug, Default, RustcEncodable, RustcDecodable)]
pub struct BorrowCheckResult {
pub used_mut_nodes: FxHashSet<HirId>,
pub signalled_any_error: SignalledError,
tcx,
num_live_nodes: 0,
num_vars: 0,
- live_node_map: HirIdMap(),
- variable_map: HirIdMap(),
- capture_info_map: NodeMap(),
+ live_node_map: HirIdMap::default(),
+ variable_map: HirIdMap::default(),
+ capture_info_map: Default::default(),
var_kinds: Vec::new(),
lnks: Vec::new(),
}
fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, pat: &P<hir::Pat>) {
// For struct patterns, take note of which fields used shorthand
// (`x` rather than `x: x`).
- let mut shorthand_field_ids = HirIdSet();
+ let mut shorthand_field_ids = HirIdSet::default();
let mut pats = VecDeque::new();
pats.push_back(pat);
while let Some(pat) = pats.pop_front() {
s: specials,
successors: vec![invalid_node(); num_live_nodes],
rwu_table: RWUTable::new(num_live_nodes * num_vars),
- break_ln: NodeMap(),
- cont_ln: NodeMap(),
+ break_ln: Default::default(),
+ cont_ln: Default::default(),
}
}
let mut reachable_context = ReachableContext {
tcx,
tables: &ty::TypeckTables::empty(None),
- reachable_symbols: NodeSet(),
+ reachable_symbols: Default::default(),
worklist: Vec::new(),
any_library,
};
fn krate<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> NamedRegionMap {
let krate = tcx.hir.krate();
let mut map = NamedRegionMap {
- defs: NodeMap(),
- late_bound: NodeSet(),
+ defs: Default::default(),
+ late_bound: Default::default(),
object_lifetime_defaults: compute_object_lifetime_defaults(tcx),
};
{
trait_ref_hack: false,
is_in_fn_syntax: false,
labels_in_fn: vec![],
- xcrate_object_lifetime_defaults: DefIdMap(),
- lifetime_uses: &mut DefIdMap(),
+ xcrate_object_lifetime_defaults: Default::default(),
+ lifetime_uses: &mut Default::default(),
};
for (_, item) in &krate.items {
visitor.visit_item(item);
fn compute_object_lifetime_defaults(
tcx: TyCtxt<'_, '_, '_>,
) -> NodeMap<Vec<ObjectLifetimeDefault>> {
- let mut map = NodeMap();
+ let mut map = NodeMap::default();
for item in tcx.hir.krate().items.values() {
match item.node {
hir::ItemKind::Struct(_, ref generics)
} = self;
let labels_in_fn = replace(&mut self.labels_in_fn, vec![]);
let xcrate_object_lifetime_defaults =
- replace(&mut self.xcrate_object_lifetime_defaults, DefIdMap());
+ replace(&mut self.xcrate_object_lifetime_defaults, DefIdMap::default());
let mut this = LifetimeContext {
tcx: *tcx,
map: map,
constrained_by_input.visit_ty(arg_ty);
}
- let mut appears_in_output = AllCollector {
- regions: Default::default(),
- };
+ let mut appears_in_output = AllCollector::default();
intravisit::walk_fn_ret_ty(&mut appears_in_output, &decl.output);
debug!(
//
// Subtle point: because we disallow nested bindings, we can just
// ignore binders here and scrape up all names we see.
- let mut appears_in_where_clause = AllCollector {
- regions: Default::default(),
- };
+ let mut appears_in_where_clause = AllCollector::default();
appears_in_where_clause.visit_generics(generics);
for param in &generics.params {
}
}
+ #[derive(Default)]
struct AllCollector {
regions: FxHashSet<hir::LifetimeName>,
}
use ty::layout::{Size, Align, LayoutError};
use rustc_target::spec::abi::Abi;
-use super::{Pointer, InboundsCheck, ScalarMaybeUndef};
+use super::{RawConst, Pointer, InboundsCheck, ScalarMaybeUndef};
use backtrace::Backtrace;
}
}
+pub type ConstEvalRawResult<'tcx> = Result<RawConst<'tcx>, ErrorHandled>;
pub type ConstEvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ErrorHandled>;
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub use self::error::{
EvalError, EvalResult, EvalErrorKind, AssertMessage, ConstEvalErr, struct_error,
- FrameInfo, ConstEvalResult, ErrorHandled,
+ FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
};
-pub use self::value::{Scalar, ConstValue, ScalarMaybeUndef};
+pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};
pub use self::allocation::{
InboundsCheck, Allocation, AllocationExtra,
use std::fmt;
-use ty::layout::{HasDataLayout, Size};
-use ty::subst::Substs;
-use hir::def_id::DefId;
+use crate::ty::{Ty, subst::Substs, layout::{HasDataLayout, Size}};
+use crate::hir::def_id::DefId;
use super::{EvalResult, Pointer, PointerArithmetic, Allocation, AllocId, sign_extend, truncate};
+/// Represents the result of a raw const operation, pre-validation.
+#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Hash)]
+pub struct RawConst<'tcx> {
+ // the value lives here, at offset 0, and that allocation definitely is a `AllocType::Memory`
+ // (so you can use `AllocMap::unwrap_memory`).
+ pub alloc_id: AllocId,
+ pub ty: Ty<'tcx>,
+}
+
/// Represents a constant value in Rust. Scalar and ScalarPair are optimizations which
/// matches the LocalValue optimizations for easy conversions between Value and ConstValue.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)]
/// Never returned from the `const_eval` query, but the HIR contains these frequently in order
/// to allow HIR creation to happen for everything before needing to be able to run constant
/// evaluation
+ /// FIXME: The query should then return a type that does not even have this variant.
Unevaluated(DefId, &'tcx Substs<'tcx>),
/// Used only for types with layout::abi::Scalar ABI and ZSTs
local_crate_source_file,
working_dir,
lint_store: RwLock::new(lint::LintStore::new()),
- buffered_lints: Lock::new(Some(lint::LintBuffer::new())),
+ buffered_lints: Lock::new(Some(Default::default())),
one_time_diagnostics: Default::default(),
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
plugin_attributes: OneThread::new(RefCell::new(Vec::new())),
if let Some(found_span) = found_span {
err.span_label(found_span, format!("takes {}", found_str));
+ // move |_| { ... }
+ // ^^^^^^^^-- def_span
+ //
+ // move |_| { ... }
+ // ^^^^^-- prefix
+ let prefix_span = self.tcx.sess.source_map().span_until_non_whitespace(found_span);
+ // move |_| { ... }
+ // ^^^-- pipe_span
+ let pipe_span = if let Some(span) = found_span.trim_start(prefix_span) {
+ span
+ } else {
+ found_span
+ };
+
// Suggest to take and ignore the arguments with expected_args_length `_`s if
// found arguments is empty (assume the user just wants to ignore args in this case).
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
if found_args.is_empty() && is_closure {
let underscores = vec!["_"; expected_args.len()].join(", ");
err.span_suggestion_with_applicability(
- found_span,
+ pipe_span,
&format!(
"consider changing the closure to take and ignore the expected argument{}",
if expected_args.len() < 2 {
pub fn empty(local_id_root: Option<DefId>) -> TypeckTables<'tcx> {
TypeckTables {
local_id_root,
- type_dependent_defs: ItemLocalMap(),
- field_indices: ItemLocalMap(),
- user_provided_tys: ItemLocalMap(),
+ type_dependent_defs: Default::default(),
+ field_indices: Default::default(),
+ user_provided_tys: Default::default(),
user_provided_sigs: Default::default(),
- node_types: ItemLocalMap(),
- node_substs: ItemLocalMap(),
- user_substs: ItemLocalMap(),
- adjustments: ItemLocalMap(),
- pat_binding_modes: ItemLocalMap(),
- pat_adjustments: ItemLocalMap(),
+ node_types: Default::default(),
+ node_substs: Default::default(),
+ user_substs: Default::default(),
+ adjustments: Default::default(),
+ pat_binding_modes: Default::default(),
+ pat_adjustments: Default::default(),
upvar_capture_map: Default::default(),
- closure_kind_origins: ItemLocalMap(),
- liberated_fn_sigs: ItemLocalMap(),
- fru_field_types: ItemLocalMap(),
- cast_kinds: ItemLocalMap(),
- used_trait_imports: Lrc::new(DefIdSet()),
+ closure_kind_origins: Default::default(),
+ liberated_fn_sigs: Default::default(),
+ fru_field_types: Default::default(),
+ cast_kinds: Default::default(),
+ used_trait_imports: Lrc::new(Default::default()),
tainted_by_errors: false,
free_region_map: Default::default(),
concrete_existential_types: Default::default(),
/// rather, you should request the vector for a specific type via
/// `tcx.inherent_impls(def_id)` so as to minimize your dependencies
/// (constructing this map requires touching the entire crate).
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Default)]
pub struct CrateInherentImpls {
pub inherent_impls: DefIdMap<Lrc<Vec<DefId>>>,
}
use middle::lib_features::LibFeatures;
use middle::lang_items::{LanguageItems, LangItem};
use middle::exported_symbols::{SymbolExportLevel, ExportedSymbol};
-use mir::interpret::ConstEvalResult;
+use mir::interpret::{ConstEvalRawResult, ConstEvalResult};
use mir::mono::CodegenUnit;
use mir;
use mir::interpret::GlobalId;
/// validation. Please add a comment to every use site explaining why using `const_eval`
/// isn't sufficient
[] fn const_eval_raw: const_eval_raw_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
- -> ConstEvalResult<'tcx>,
+ -> ConstEvalRawResult<'tcx>,
/// Results of evaluating const items or constants embedded in
/// other items (such as enum variant explicit discriminants).
//! An efficient hash map for node IDs
-#![allow(non_snake_case)]
-
use hir::def_id::DefId;
use hir::{HirId, ItemLocalId};
use syntax::ast;
macro_rules! define_id_collections {
($map_name:ident, $set_name:ident, $key:ty) => {
pub type $map_name<T> = FxHashMap<$key, T>;
- pub fn $map_name<T>() -> $map_name<T> { Default::default() }
pub type $set_name = FxHashSet<$key>;
- pub fn $set_name() -> $set_name { Default::default() }
}
}
created_files: Default::default(),
created_enum_disr_types: Default::default(),
type_map: Default::default(),
- namespace_map: RefCell::new(DefIdMap()),
+ namespace_map: RefCell::new(Default::default()),
composite_types_completed: Default::default(),
}
}
}
fn exported_symbols(tcx: TyCtxt, crate_type: CrateType) -> Vec<String> {
+ if let Some(ref exports) = tcx.sess.target.target.options.override_export_symbols {
+ return exports.clone()
+ }
+
let mut symbols = Vec::new();
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
assert_eq!(cnum, LOCAL_CRATE);
if !tcx.sess.opts.output_types.should_codegen() {
- return Lrc::new(DefIdMap())
+ return Default::default();
}
// Check to see if this crate is a "special runtime crate". These
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
- let mut instances: DefIdMap<FxHashMap<_, _>> = DefIdMap();
+ let mut instances: DefIdMap<FxHashMap<_, _>> = Default::default();
let cnum_stable_ids: IndexVec<CrateNum, Fingerprint> = {
let mut cnum_stable_ids = IndexVec::from_elem_n(Fingerprint::ZERO,
crate-type = ["dylib"]
[dependencies]
-ena = "0.9.3"
+ena = "0.10.1"
log = "0.4"
rustc_cratesio_shim = { path = "../librustc_cratesio_shim" }
serialize = { path = "../libserialize" }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub use rustc_hash::FxHashMap;
-pub use rustc_hash::FxHashSet;
-pub use rustc_hash::FxHasher;
+pub use rustc_hash::{FxHasher, FxHashMap, FxHashSet};
undo_log: Vec<UndoLog<K, V>>,
}
+// HACK(eddyb) manual impl avoids `Default` bounds on `K` and `V`.
+impl<K, V> Default for SnapshotMap<K, V>
+ where K: Hash + Clone + Eq
+{
+ fn default() -> Self {
+ SnapshotMap {
+ map: Default::default(),
+ undo_log: Default::default(),
+ }
+ }
+}
+
pub struct Snapshot {
len: usize,
}
Noop,
}
-impl<K, V> Default for SnapshotMap<K, V>
- where K: Hash + Clone + Eq
-{
- fn default() -> Self {
- SnapshotMap {
- map: FxHashMap::default(),
- undo_log: vec![],
- }
- }
-}
-
impl<K, V> SnapshotMap<K, V>
where K: Hash + Clone + Eq
{
closure: Lock<Option<BitMatrix<usize, usize>>>,
}
+// HACK(eddyb) manual impl avoids `Default` bound on `T`.
+impl<T: Clone + Debug + Eq + Hash> Default for TransitiveRelation<T> {
+ fn default() -> Self {
+ TransitiveRelation {
+ elements: Default::default(),
+ map: Default::default(),
+ edges: Default::default(),
+ closure: Default::default(),
+ }
+ }
+}
+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)]
struct Index(usize);
target: Index,
}
-impl<T: Clone + Debug + Eq + Hash> Default for TransitiveRelation<T> {
- fn default() -> TransitiveRelation<T> {
- TransitiveRelation {
- elements: vec![],
- map: FxHashMap::default(),
- edges: vec![],
- closure: Lock::new(None),
- }
- }
-}
-
impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
pub fn is_empty(&self) -> bool {
self.edges.is_empty()
};
if self.impling_types.is_none() {
- let mut impls = NodeSet();
+ let mut impls = NodeSet::default();
cx.tcx.for_each_impl(debug, |d| {
if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def.did) {
}
let t = cx.tables.expr_ty(&expr);
- // FIXME(varkor): replace with `t.is_unit() || t.conservative_is_uninhabited()`.
- let type_permits_no_use = match t.sty {
- ty::Tuple(ref tys) if tys.is_empty() => true,
- ty::Never => true,
- ty::Adt(def, _) => {
- if def.variants.is_empty() {
- true
- } else {
- check_must_use(cx, def.did, s.span, "")
+ let type_permits_lack_of_use = if t.is_unit()
+ || cx.tcx.is_ty_uninhabited_from(cx.tcx.hir.get_module_parent(expr.id), t) {
+ true
+ } else {
+ match t.sty {
+ ty::Adt(def, _) => check_must_use(cx, def.did, s.span, "", ""),
+ ty::Opaque(def, _) => {
+ let mut must_use = false;
+ for (predicate, _) in &cx.tcx.predicates_of(def).predicates {
+ if let ty::Predicate::Trait(ref poly_trait_predicate) = predicate {
+ let trait_ref = poly_trait_predicate.skip_binder().trait_ref;
+ if check_must_use(cx, trait_ref.def_id, s.span, "implementer of ", "") {
+ must_use = true;
+ break;
+ }
+ }
+ }
+ must_use
+ }
+ ty::Dynamic(binder, _) => {
+ let mut must_use = false;
+ for predicate in binder.skip_binder().iter() {
+ if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate {
+ if check_must_use(cx, trait_ref.def_id, s.span, "", " trait object") {
+ must_use = true;
+ break;
+ }
+ }
+ }
+ must_use
}
+ _ => false,
}
- _ => false,
};
let mut fn_warned = false;
};
if let Some(def) = maybe_def {
let def_id = def.def_id();
- fn_warned = check_must_use(cx, def_id, s.span, "return value of ");
- } else if type_permits_no_use {
+ fn_warned = check_must_use(cx, def_id, s.span, "return value of ", "");
+ } else if type_permits_lack_of_use {
// We don't warn about unused unit or uninhabited types.
// (See https://github.com/rust-lang/rust/issues/43806 for details.)
return;
op_warned = true;
}
- if !(type_permits_no_use || fn_warned || op_warned) {
+ if !(type_permits_lack_of_use || fn_warned || op_warned) {
cx.span_lint(UNUSED_RESULTS, s.span, "unused result");
}
- fn check_must_use(cx: &LateContext, def_id: DefId, sp: Span, describe_path: &str) -> bool {
+ fn check_must_use(
+ cx: &LateContext,
+ def_id: DefId,
+ sp: Span,
+ descr_pre_path: &str,
+ descr_post_path: &str,
+ ) -> bool {
for attr in cx.tcx.get_attrs(def_id).iter() {
if attr.check_name("must_use") {
- let msg = format!("unused {}`{}` that must be used",
- describe_path, cx.tcx.item_path_str(def_id));
+ let msg = format!("unused {}`{}`{} that must be used",
+ descr_pre_path, cx.tcx.item_path_str(def_id), descr_post_path);
let mut err = cx.struct_span_lint(UNUSED_MUST_USE, sp, &msg);
// check for #[must_use = "..."]
if let Some(note) = attr.value_str() {
use std::collections::hash_map::Entry;
assert_eq!(cnum, LOCAL_CRATE);
- let mut visible_parent_map: DefIdMap<DefId> = DefIdMap();
+ let mut visible_parent_map: DefIdMap<DefId> = Default::default();
// Issue 46112: We want the map to prefer the shortest
// paths when reporting the path to an item. Therefore we
1,
),
upvar_decls,
- var_indices: NodeMap(),
+ var_indices: Default::default(),
unit_temp: None,
cached_resume_block: None,
cached_return_block: None,
use syntax::ast::Mutability;
use syntax::source_map::{Span, DUMMY_SP};
-use interpret::{self,
- PlaceTy, MemPlace, OpTy, Operand, Immediate, Scalar, ConstValue, Pointer,
+use crate::interpret::{self,
+ PlaceTy, MPlaceTy, MemPlace, OpTy, Operand, Immediate, Scalar, RawConst, ConstValue, Pointer,
EvalResult, EvalError, EvalErrorKind, GlobalId, EvalContext, StackPopCleanup,
Allocation, AllocId, MemoryKind,
snapshot, RefTracking,
cid: GlobalId<'tcx>,
mir: &'mir mir::Mir<'tcx>,
param_env: ty::ParamEnv<'tcx>,
-) -> EvalResult<'tcx, OpTy<'tcx>> {
+) -> EvalResult<'tcx, MPlaceTy<'tcx>> {
let mut ecx = mk_borrowck_eval_cx(tcx, cid.instance, mir, DUMMY_SP).unwrap();
eval_body_using_ecx(&mut ecx, cid, Some(mir), param_env)
}
+// FIXME: These two conversion functions are bad hacks. We should just always use allocations.
pub fn op_to_const<'tcx>(
ecx: &CompileTimeEvalContext<'_, '_, 'tcx>,
op: OpTy<'tcx>,
};
Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty))
}
+pub fn const_to_op<'tcx>(
+ ecx: &CompileTimeEvalContext<'_, '_, 'tcx>,
+ cnst: &ty::Const<'tcx>,
+) -> EvalResult<'tcx, OpTy<'tcx>> {
+ let op = ecx.const_value_to_op(cnst.val)?;
+ Ok(OpTy { op, layout: ecx.layout_of(cnst.ty)? })
+}
fn eval_body_and_ecx<'a, 'mir, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
cid: GlobalId<'tcx>,
mir: Option<&'mir mir::Mir<'tcx>>,
param_env: ty::ParamEnv<'tcx>,
-) -> (EvalResult<'tcx, OpTy<'tcx>>, CompileTimeEvalContext<'a, 'mir, 'tcx>) {
+) -> (EvalResult<'tcx, MPlaceTy<'tcx>>, CompileTimeEvalContext<'a, 'mir, 'tcx>) {
// we start out with the best span we have
// and try improving it down the road when more information is available
let span = tcx.def_span(cid.instance.def_id());
cid: GlobalId<'tcx>,
mir: Option<&'mir mir::Mir<'tcx>>,
param_env: ty::ParamEnv<'tcx>,
-) -> EvalResult<'tcx, OpTy<'tcx>> {
+) -> EvalResult<'tcx, MPlaceTy<'tcx>> {
debug!("eval_body_using_ecx: {:?}, {:?}", cid, param_env);
let tcx = ecx.tcx.tcx;
let mut mir = match mir {
ecx.memory.intern_static(ret.ptr.to_ptr()?.alloc_id, mutability)?;
debug!("eval_body_using_ecx done: {:?}", *ret);
- Ok(ret.into())
+ Ok(ret)
}
impl<'tcx> Into<EvalError<'tcx>> for ConstEvalError {
let ecx = mk_eval_cx(tcx, instance, param_env).unwrap();
let result = (|| {
// get the operand again
- let op = ecx.const_to_op(value)?;
+ let op = const_to_op(&ecx, value)?;
// downcast
let down = match variant {
None => op,
) -> EvalResult<'tcx, VariantIdx> {
trace!("const_variant_index: {:?}, {:?}", instance, val);
let ecx = mk_eval_cx(tcx, instance, param_env).unwrap();
- let op = ecx.const_to_op(val)?;
+ let op = const_to_op(&ecx, val)?;
Ok(ecx.read_discriminant(op)?.1)
}
ConstEvalErr { error: error.kind, stacktrace, span: ecx.tcx.span }
}
-fn validate_const<'a, 'tcx>(
+fn validate_and_turn_into_const<'a, 'tcx>(
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
- constant: &'tcx ty::Const<'tcx>,
+ constant: RawConst<'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
let cid = key.value;
let ecx = mk_eval_cx(tcx, cid.instance, key.param_env).unwrap();
let val = (|| {
- let op = ecx.const_to_op(constant)?;
+ let op = ecx.raw_const_to_mplace(constant)?.into();
+ // FIXME: Once the visitor infrastructure landed, change validation to
+ // work directly on `MPlaceTy`.
let mut ref_tracking = RefTracking::new(op);
while let Some((op, path)) = ref_tracking.todo.pop() {
ecx.validate_operand(
/* const_mode */ true,
)?;
}
- Ok(constant)
+ // Now that we validated, turn this into a proper constant
+ let def_id = cid.instance.def.def_id();
+ let normalize = tcx.is_static(def_id).is_none() && cid.promoted.is_none();
+ op_to_const(&ecx, op, normalize)
})();
val.map_err(|error| {
}
}
tcx.const_eval_raw(key).and_then(|val| {
- validate_const(tcx, val, key)
+ validate_and_turn_into_const(tcx, val, key)
})
}
pub fn const_eval_raw_provider<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
-) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
+) -> ::rustc::mir::interpret::ConstEvalRawResult<'tcx> {
// Because the constant is computed twice (once per value of `Reveal`), we are at risk of
// reporting the same error twice here. To resolve this, we check whether we can evaluate the
// constant in the more restrictive `Reveal::UserFacing`, which most likely already was
};
let (res, ecx) = eval_body_and_ecx(tcx, cid, None, key.param_env);
- res.and_then(|op| {
- let normalize = tcx.is_static(def_id).is_none() && cid.promoted.is_none();
- if !normalize {
- // Sanity check: These must always be a MemPlace
- match op.op {
- Operand::Indirect(_) => { /* all is good */ },
- Operand::Immediate(_) => bug!("const eval gave us an Immediate"),
- }
- }
- op_to_const(&ecx, op, normalize)
+ res.and_then(|place| {
+ Ok(RawConst {
+ alloc_id: place.to_ptr().expect("we allocated this ptr!").alloc_id,
+ ty: place.layout.ty
+ })
}).map_err(|error| {
let err = error_to_const_error(&ecx, error);
// errors in statics are always emitted as fatal errors
Ok(())
}
- pub fn const_eval(&self, gid: GlobalId<'tcx>) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> {
+ pub fn const_eval_raw(
+ &self,
+ gid: GlobalId<'tcx>,
+ ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
let param_env = if self.tcx.is_static(gid.instance.def_id()).is_some() {
ty::ParamEnv::reveal_all()
} else {
self.param_env
};
- self.tcx.const_eval(param_env.and(gid)).map_err(|err| {
+ // We use `const_eval_raw` here, and get an unvalidated result. That is okay:
+ // Our result will later be validated anyway, and there seems no good reason
+ // to have to fail early here. This is also more consistent with
+ // `Memory::get_static_alloc` which has to use `const_eval_raw` to avoid cycles.
+ let val = self.tcx.const_eval_raw(param_env.and(gid)).map_err(|err| {
match err {
- ErrorHandled::Reported => EvalErrorKind::ReferencedConstant.into(),
- ErrorHandled::TooGeneric => EvalErrorKind::TooGeneric.into(),
+ ErrorHandled::Reported => EvalErrorKind::ReferencedConstant,
+ ErrorHandled::TooGeneric => EvalErrorKind::TooGeneric,
}
- })
+ })?;
+ self.raw_const_to_mplace(val)
}
pub fn dump_place(&self, place: Place<M::PointerTag>) {
use syntax::ast::Mutability;
use super::{
- Pointer, AllocId, Allocation, ConstValue, GlobalId, AllocationExtra, InboundsCheck,
+ Pointer, AllocId, Allocation, GlobalId, AllocationExtra, InboundsCheck,
EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic,
Machine, AllocMap, MayLeak, ScalarMaybeUndef, ErrorHandled,
};
ErrorHandled::Reported => EvalErrorKind::ReferencedConstant.into(),
ErrorHandled::TooGeneric => EvalErrorKind::TooGeneric.into(),
}
- }).map(|const_val| {
- if let ConstValue::ByRef(_, allocation, _) = const_val.val {
- // We got tcx memory. Let the machine figure out whether and how to
- // turn that into memory with the right pointer tag.
- M::adjust_static_allocation(allocation)
- } else {
- bug!("Matching on non-ByRef static")
- }
+ }).map(|raw_const| {
+ let allocation = tcx.alloc_map.lock().unwrap_memory(raw_const.alloc_id);
+ // We got tcx memory. Let the machine figure out whether and how to
+ // turn that into memory with the right pointer tag.
+ M::adjust_static_allocation(allocation)
})
}
use std::convert::TryInto;
-use rustc::{mir, ty};
+use rustc::mir;
use rustc::ty::layout::{self, Size, LayoutOf, TyLayout, HasDataLayout, IntegerExt, VariantIdx};
use rustc::mir::interpret::{
.collect()
}
- // Also used e.g. when miri runs into a constant.
- pub(super) fn const_value_to_op(
+ // Used when miri runs into a constant, and by CTFE.
+ // FIXME: CTFE should use allocations, then we can make this private (embed it into
+ // `eval_operand`, ideally).
+ pub(crate) fn const_value_to_op(
&self,
val: ConstValue<'tcx>,
) -> EvalResult<'tcx, Operand<M::PointerTag>> {
match val {
ConstValue::Unevaluated(def_id, substs) => {
let instance = self.resolve(def_id, substs)?;
- self.global_to_op(GlobalId {
+ Ok(*OpTy::from(self.const_eval_raw(GlobalId {
instance,
promoted: None,
- })
+ })?))
}
ConstValue::ByRef(id, alloc, offset) => {
// We rely on mutability being set correctly in that allocation to prevent writes
Ok(Operand::Immediate(Immediate::Scalar(x.into())).with_default_tag()),
}
}
- pub fn const_to_op(
- &self,
- cnst: &ty::Const<'tcx>,
- ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> {
- let op = self.const_value_to_op(cnst.val)?;
- Ok(OpTy { op, layout: self.layout_of(cnst.ty)? })
- }
-
- pub(super) fn global_to_op(
- &self,
- gid: GlobalId<'tcx>
- ) -> EvalResult<'tcx, Operand<M::PointerTag>> {
- let cv = self.const_eval(gid)?;
- self.const_value_to_op(cv.val)
- }
/// Read discriminant, return the runtime value as well as the variant index.
pub fn read_discriminant(
use rustc::ty::{self, Ty};
use rustc::ty::layout::{self, Size, Align, LayoutOf, TyLayout, HasDataLayout, VariantIdx};
-use rustc::mir::interpret::{
- GlobalId, AllocId, Allocation, Scalar, EvalResult, Pointer, PointerArithmetic
-};
use super::{
+ GlobalId, AllocId, Allocation, Scalar, EvalResult, Pointer, PointerArithmetic,
EvalContext, Machine, AllocMap, AllocationExtra,
- Immediate, ImmTy, ScalarMaybeUndef, Operand, OpTy, MemoryKind
+ RawConst, Immediate, ImmTy, ScalarMaybeUndef, Operand, OpTy, MemoryKind
};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
Ok(match *mir_place {
Promoted(ref promoted) => {
let instance = self.frame().instance;
- let op = self.global_to_op(GlobalId {
+ self.const_eval_raw(GlobalId {
instance,
promoted: Some(promoted.0),
- })?;
- let mplace = op.to_mem_place(); // these are always in memory
- let ty = self.monomorphize(promoted.1, self.substs());
- MPlaceTy {
- mplace,
- layout: self.layout_of(ty)?,
- }
+ })?
}
Static(ref static_) => {
Ok(OpTy { op, layout: place.layout })
}
+ pub fn raw_const_to_mplace(
+ &self,
+ raw: RawConst<'tcx>,
+ ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
+ // This must be an allocation in `tcx`
+ assert!(self.tcx.alloc_map.lock().get(raw.alloc_id).is_some());
+ let layout = self.layout_of(raw.ty)?;
+ Ok(MPlaceTy::from_aligned_ptr(
+ Pointer::new(raw.alloc_id, Size::ZERO).with_default_tag(),
+ layout,
+ ))
+ }
+
/// Turn a place with a `dyn Trait` type into a place with the actual dynamic type.
/// Also return some more information so drop doesn't have to run the same code twice.
pub(super) fn unpack_dyn_trait(&self, mplace: MPlaceTy<'tcx, M::PointerTag>)
time(tcx.sess, "collecting mono items", || {
par_iter(roots).for_each(|root| {
- let mut recursion_depths = DefIdMap();
+ let mut recursion_depths = DefIdMap::default();
collect_items_rec(tcx,
root,
visited,
};
use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind};
-use const_eval::{CompileTimeInterpreter, error_to_const_error, eval_promoted, mk_borrowck_eval_cx};
+use const_eval::{
+ CompileTimeInterpreter, const_to_op, error_to_const_error, eval_promoted, mk_borrowck_eval_cx
+};
use transform::{MirPass, MirSource};
pub struct ConstProp;
source_info: SourceInfo,
) -> Option<Const<'tcx>> {
self.ecx.tcx.span = source_info.span;
- match self.ecx.const_to_op(c.literal) {
+ match const_to_op(&self.ecx, c.literal) {
Ok(op) => {
Some((op, c.span))
},
eval_promoted(this.tcx, cid, this.mir, this.param_env)
})?;
trace!("evaluated promoted {:?} to {:?}", promoted, res);
- Some((res, source_info.span))
+ Some((res.into(), source_info.span))
},
_ => None,
}
-> Lrc<DefIdSet> {
assert_eq!(krate, LOCAL_CRATE);
- let mut set = DefIdSet();
+ let mut set = DefIdSet::default();
// All body-owners have MIR associated with them.
set.extend(tcx.body_owners());
cleanup: _,
} => check_operand(tcx, mir, cond, span),
- | TerminatorKind::FalseUnwind { .. } => span_bug!(
- terminator.source_info.span,
- "min_const_fn encountered `{:#?}`",
- terminator
- ),
+ TerminatorKind::FalseUnwind { .. } => {
+ Err((span, "loops are not allowed in const fn".into()))
+ },
}
}
tables: &ty::TypeckTables::empty(None),
in_fn: false,
in_static: false,
- mut_rvalue_borrows: NodeSet(),
+ mut_rvalue_borrows: Default::default(),
param_env: ty::ParamEnv::empty(),
identity_substs: Substs::empty(),
- result: ItemLocalSet(),
+ result: ItemLocalSet::default(),
};
// `def_id` should be a `Body` owner
tcx,
access_levels: &visitor.access_levels,
in_variant: false,
- old_error_set: NodeSet(),
+ old_error_set: Default::default(),
};
intravisit::walk_crate(&mut visitor, krate);
let mut visitor = UnusedImportCheckVisitor {
resolver,
- unused_imports: NodeMap(),
+ unused_imports: Default::default(),
base_id: ast::DUMMY_NODE_ID,
item_span: DUMMY_SP,
};
use syntax::ext::base::SyntaxExtension;
use syntax::ext::base::Determinacy::{self, Determined, Undetermined};
use syntax::ext::base::MacroKind;
-use syntax::feature_gate::{emit_feature_err, GateIssue};
use syntax::symbol::{Symbol, keywords};
use syntax::util::lev_distance::find_best_match_for_name;
primitive_type_table: PrimitiveTypeTable::new(),
- def_map: NodeMap(),
- import_map: NodeMap(),
- freevars: NodeMap(),
- freevars_seen: NodeMap(),
+ def_map: Default::default(),
+ import_map: Default::default(),
+ freevars: Default::default(),
+ freevars_seen: Default::default(),
export_map: FxHashMap::default(),
- trait_map: NodeMap(),
+ trait_map: Default::default(),
module_map,
- block_map: NodeMap(),
+ block_map: Default::default(),
extern_module_map: FxHashMap::default(),
binding_parent_modules: FxHashMap::default(),
make_glob_map: make_glob_map == MakeGlobMap::Yes,
- glob_map: NodeMap(),
+ glob_map: Default::default(),
used_imports: FxHashSet::default(),
- maybe_unused_trait_imports: NodeSet(),
+ maybe_unused_trait_imports: Default::default(),
maybe_unused_extern_crates: Vec::new(),
unused_labels: FxHashMap::default(),
name_already_seen: FxHashMap::default(),
whitelisted_legacy_custom_derives: Vec::new(),
potentially_unused_imports: Vec::new(),
- struct_constructors: DefIdMap(),
+ struct_constructors: Default::default(),
found_unresolved_macro: false,
unused_macros: FxHashSet::default(),
current_type_ascription: Vec::new(),
if !module.no_implicit_prelude {
if ns == TypeNS {
- if let Some(binding) = self.extern_prelude_get(ident, !record_used, false) {
+ if let Some(binding) = self.extern_prelude_get(ident, !record_used) {
return Some(LexicalScopeBinding::Item(binding));
}
}
self.name_already_seen.insert(name, span);
}
- fn extern_prelude_get(&mut self, ident: Ident, speculative: bool, skip_feature_gate: bool)
+ fn extern_prelude_get(&mut self, ident: Ident, speculative: bool)
-> Option<&'a NameBinding<'a>> {
if ident.is_path_segment_keyword() {
// Make sure `self`, `super` etc produce an error when passed to here.
}
self.extern_prelude.get(&ident.modern()).cloned().and_then(|entry| {
if let Some(binding) = entry.extern_crate_item {
- if !speculative && !skip_feature_gate && entry.introduced_by_item &&
- !self.session.features_untracked().extern_crate_item_prelude {
- emit_feature_err(&self.session.parse_sess, "extern_crate_item_prelude",
- ident.span, GateIssue::Language,
- "use of extern prelude names introduced \
- with `extern crate` items is unstable");
- }
Some(binding)
} else {
let crate_id = if !speculative {
}
WhereToResolve::ExternPrelude => {
if use_prelude {
- match self.extern_prelude_get(ident, !record_used,
- innermost_result.is_some()) {
+ match self.extern_prelude_get(ident, !record_used) {
Some(binding) => Ok((binding, Flags::PRELUDE)),
None => Err(Determinacy::determined(
self.graph_root.unresolved_invocations.borrow().is_empty()
// but its `Def` should coincide with a crate passed with `--extern`
// (otherwise there would be ambiguity) and we can skip feature error in this case.
if ns != TypeNS || !use_prelude ||
- self.extern_prelude_get(ident, true, false).is_none() {
+ self.extern_prelude_get(ident, true).is_none() {
let msg = "imports can only refer to extern crate names \
passed with `--extern` on stable channel";
let mut err = feature_err(&self.session.parse_sess, "uniform_paths",
assert!(!restricted_shadowing);
match uniform_root_kind {
UniformRootKind::ExternPrelude => {
- return if let Some(binding) =
- self.extern_prelude_get(ident, !record_used, false) {
+ return if let Some(binding) = self.extern_prelude_get(ident, !record_used) {
Ok(binding)
} else if !self.graph_root.unresolved_invocations.borrow().is_empty() {
// Macro-expanded `extern crate` items can add names to extern prelude.
module
}
PathResult::Failed(span, msg, false) => {
- assert!(directive.imported_module.get().is_none());
+ assert!(!self.ambiguity_errors.is_empty() ||
+ directive.imported_module.get().is_none());
resolve_error(self, span, ResolutionError::FailedToResolve(&msg));
return None;
}
PathResult::Failed(span, msg, true) => {
- assert!(directive.imported_module.get().is_none());
+ assert!(!self.ambiguity_errors.is_empty() ||
+ directive.imported_module.get().is_none());
return if let Some((suggested_path, note)) = self.make_path_suggestion(
span, directive.module_path.clone(), &directive.parent_scope
) {
None => continue,
};
- if binding.is_import() || binding.is_macro_def() {
+ // Filter away "empty import canaries".
+ let is_non_canary_import =
+ binding.is_import() && binding.vis != ty::Visibility::Invisible;
+ if is_non_canary_import || binding.is_macro_def() {
let def = binding.def();
if def != Def::Err {
if let Some(def_id) = def.opt_def_id() {
("riscv32imac-unknown-none-elf", riscv32imac_unknown_none_elf),
("aarch64-unknown-none", aarch64_unknown_none),
+
+ ("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),
}
/// Everything `rustc` knows about how to compile for a specific target.
/// target features. This is `true` by default, and `false` for targets like
/// wasm32 where the whole program either has simd or not.
pub simd_types_indirect: bool,
+
+ /// If set, have the linker export exactly these symbols, instead of using
+ /// the usual logic to figure this out from the crate itself.
+ pub override_export_symbols: Option<Vec<String>>
}
impl Default for TargetOptions {
emit_debug_gdb_scripts: true,
requires_uwtable: false,
simd_types_indirect: true,
+ override_export_symbols: None,
}
}
}
)
);
} );
+ ($key_name:ident, opt_list) => ( {
+ let name = (stringify!($key_name)).replace("_", "-");
+ obj.find(&name[..]).map(|o| o.as_array()
+ .map(|v| base.options.$key_name = Some(v.iter()
+ .map(|a| a.as_string().unwrap().to_string()).collect())
+ )
+ );
+ } );
($key_name:ident, optional) => ( {
let name = (stringify!($key_name)).replace("_", "-");
if let Some(o) = obj.find(&name[..]) {
key!(emit_debug_gdb_scripts, bool);
key!(requires_uwtable, bool);
key!(simd_types_indirect, bool);
+ key!(override_export_symbols, opt_list);
if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) {
for name in array.iter().filter_map(|abi| abi.as_string()) {
target_option_val!(emit_debug_gdb_scripts);
target_option_val!(requires_uwtable);
target_option_val!(simd_types_indirect);
+ target_option_val!(override_export_symbols);
if default.abi_blacklist != self.options.abi_blacklist {
d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter()
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::iter;
+
+use super::{LinkerFlavor, Target, TargetOptions, PanicStrategy};
+
+pub fn target() -> Result<Target, String> {
+ const PRE_LINK_ARGS: &[&str] = &[
+ "-Wl,--as-needed",
+ "-Wl,-z,noexecstack",
+ "-m64",
+ "-fuse-ld=gold",
+ "-nostdlib",
+ "-shared",
+ "-Wl,-e,sgx_entry",
+ "-Wl,-Bstatic",
+ "-Wl,--gc-sections",
+ "-Wl,-z,text",
+ "-Wl,-z,norelro",
+ "-Wl,--rosegment",
+ "-Wl,--no-undefined",
+ "-Wl,--error-unresolved-symbols",
+ "-Wl,--no-undefined-version",
+ "-Wl,-Bsymbolic",
+ "-Wl,--export-dynamic",
+ ];
+ const EXPORT_SYMBOLS: &[&str] = &[
+ "sgx_entry",
+ "HEAP_BASE",
+ "HEAP_SIZE",
+ "RELA",
+ "RELACOUNT",
+ "ENCLAVE_SIZE",
+ "CFGDATA_BASE",
+ "DEBUG",
+ ];
+ let opts = TargetOptions {
+ dynamic_linking: false,
+ executables: true,
+ linker_is_gnu: true,
+ max_atomic_width: Some(64),
+ panic_strategy: PanicStrategy::Abort,
+ cpu: "x86-64".into(),
+ position_independent_executables: true,
+ pre_link_args: iter::once(
+ (LinkerFlavor::Gcc, PRE_LINK_ARGS.iter().cloned().map(String::from).collect())
+ ).collect(),
+ override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(String::from).collect()),
+ ..Default::default()
+ };
+ Ok(Target {
+ llvm_target: "x86_64-unknown-linux-gnu".into(),
+ target_endian: "little".into(),
+ target_pointer_width: "64".into(),
+ target_c_int_width: "32".into(),
+ target_os: "unknown".into(),
+ target_env: "sgx".into(),
+ target_vendor: "fortanix".into(),
+ data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".into(),
+ arch: "x86_64".into(),
+ linker_flavor: LinkerFlavor::Gcc,
+ options: opts,
+ })
+}
},
infcx,
fulfillment_cx: RefCell::new(TraitEngine::new(tcx)),
- locals: RefCell::new(NodeMap()),
- deferred_call_resolutions: RefCell::new(DefIdMap()),
+ locals: RefCell::new(Default::default()),
+ deferred_call_resolutions: RefCell::new(Default::default()),
deferred_cast_checks: RefCell::new(Vec::new()),
deferred_generator_interiors: RefCell::new(Vec::new()),
- opaque_types: RefCell::new(DefIdMap()),
+ opaque_types: RefCell::new(Default::default()),
implicit_region_bound,
body_id,
}
has_errors: Cell::new(false),
enclosing_breakables: RefCell::new(EnclosingBreakables {
stack: Vec::new(),
- by_id: NodeMap(),
+ by_id: Default::default(),
}),
inh,
}
let used_trait_imports = mem::replace(
&mut self.tables.borrow_mut().used_trait_imports,
- Lrc::new(DefIdSet()),
+ Lrc::new(DefIdSet::default()),
);
debug!(
"used_trait_imports({:?}) = {:?}",
use rustc_data_structures::fx::FxHashMap;
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
- let mut used_trait_imports = DefIdSet();
+ let mut used_trait_imports = DefIdSet::default();
for &body_id in tcx.hir.krate().bodies.keys() {
let item_def_id = tcx.hir.body_owner_def_id(body_id);
let imports = tcx.used_trait_imports(item_def_id);
use rustc::hir;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::ty::{self, CrateInherentImpls, TyCtxt};
-use rustc::util::nodemap::DefIdMap;
use rustc_data_structures::sync::Lrc;
use syntax::ast;
let krate = tcx.hir.krate();
let mut collect = InherentCollect {
tcx,
- impls_map: CrateInherentImpls {
- inherent_impls: DefIdMap()
- }
+ impls_map: Default::default(),
};
krate.visit_all_item_likes(&mut collect);
Lrc::new(collect.impls_map)
let mut terms_cx = TermsContext {
tcx,
arena,
- inferred_starts: NodeMap(),
+ inferred_starts: Default::default(),
inferred_terms: vec![],
lang_items: lang_items(tcx),
let warnings_lint_name = lint::builtin::WARNINGS.name;
let missing_docs = rustc_lint::builtin::MISSING_DOCS.name;
let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name;
+ let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;
// In addition to those specific lints, we also need to whitelist those given through
// command line, otherwise they'll get ignored and we don't want that.
let mut whitelisted_lints = vec![warnings_lint_name.to_owned(),
intra_link_resolution_failure_name.to_owned(),
missing_docs.to_owned(),
- missing_doc_example.to_owned()];
+ missing_doc_example.to_owned(),
+ private_doc_tests.to_owned()];
whitelisted_lints.extend(lint_opts.iter().map(|(lint, _)| lint).cloned());
use core::DocContext;
use fold::DocFolder;
-use html::markdown::{find_testable_code, markdown_links, ErrorCodes, LangString};
+use html::markdown::markdown_links;
-use passes::Pass;
+use passes::{look_for_tests, Pass};
pub const COLLECT_INTRA_DOC_LINKS: Pass =
Pass::early("collect-intra-doc-links", collect_intra_doc_links,
}
}
-fn look_for_tests<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx>(
- cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>,
- dox: &str,
- item: &Item,
-) {
- if (item.is_mod() && cx.tcx.hir.as_local_node_id(item.def_id).is_none()) ||
- cx.as_local_node_id(item.def_id).is_none() {
- // If non-local, no need to check anything.
- return;
- }
-
- struct Tests {
- found_tests: usize,
- }
-
- impl ::test::Tester for Tests {
- fn add_test(&mut self, _: String, _: LangString, _: usize) {
- self.found_tests += 1;
- }
- }
-
- let mut tests = Tests {
- found_tests: 0,
- };
-
- if find_testable_code(&dox, &mut tests, ErrorCodes::No).is_ok() {
- if tests.found_tests == 0 {
- let mut diag = cx.tcx.struct_span_lint_node(
- lint::builtin::MISSING_DOC_CODE_EXAMPLES,
- NodeId::from_u32(0),
- span_of_attrs(&item.attrs),
- "Missing code example in this documentation");
- diag.emit();
- }
- }
-}
-
impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for LinkCollector<'a, 'tcx, 'rcx, 'cstore> {
fn fold_item(&mut self, mut item: Item) -> Option<Item> {
let item_node_id = if item.is_mod() {
let cx = self.cx;
let dox = item.attrs.collapsed_doc_value().unwrap_or_else(String::new);
- look_for_tests(&cx, &dox, &item);
+ look_for_tests(&cx, &dox, &item, true);
if !self.is_nightly_build {
return None;
None
}
-fn span_of_attrs(attrs: &Attributes) -> syntax_pos::Span {
+pub fn span_of_attrs(attrs: &Attributes) -> syntax_pos::Span {
if attrs.doc_strings.is_empty() {
return DUMMY_SP;
}
//! process.
use rustc::hir::def_id::DefId;
+use rustc::lint as lint;
use rustc::middle::privacy::AccessLevels;
use rustc::util::nodemap::DefIdSet;
use std::mem;
use std::fmt;
+use syntax::ast::NodeId;
use clean::{self, GetDefId, Item};
-use core::DocContext;
+use core::{DocContext, DocAccessLevels};
use fold;
use fold::StripItem;
+use html::markdown::{find_testable_code, ErrorCodes, LangString};
+
+use self::collect_intra_doc_links::span_of_attrs;
+
mod collapse_docs;
pub use self::collapse_docs::COLLAPSE_DOCS;
mod collect_intra_doc_links;
pub use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS;
+mod private_items_doc_tests;
+pub use self::private_items_doc_tests::CHECK_PRIVATE_ITEMS_DOC_TESTS;
+
mod collect_trait_impls;
pub use self::collect_trait_impls::COLLECT_TRAIT_IMPLS;
/// The full list of passes.
pub const PASSES: &'static [Pass] = &[
+ CHECK_PRIVATE_ITEMS_DOC_TESTS,
STRIP_HIDDEN,
UNINDENT_COMMENTS,
COLLAPSE_DOCS,
/// The list of passes run by default.
pub const DEFAULT_PASSES: &'static [&'static str] = &[
"collect-trait-impls",
+ "check-private-items-doc-tests",
"strip-hidden",
"strip-private",
"collect-intra-doc-links",
/// The list of default passes run with `--document-private-items` is passed to rustdoc.
pub const DEFAULT_PRIVATE_PASSES: &'static [&'static str] = &[
"collect-trait-impls",
+ "check-private-items-doc-tests",
"strip-priv-imports",
"collect-intra-doc-links",
"collapse-docs",
}
}
}
+
+pub fn look_for_tests<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx>(
+ cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>,
+ dox: &str,
+ item: &Item,
+ check_missing_code: bool,
+) {
+ if cx.as_local_node_id(item.def_id).is_none() {
+ // If non-local, no need to check anything.
+ return;
+ }
+
+ struct Tests {
+ found_tests: usize,
+ }
+
+ impl ::test::Tester for Tests {
+ fn add_test(&mut self, _: String, _: LangString, _: usize) {
+ self.found_tests += 1;
+ }
+ }
+
+ let mut tests = Tests {
+ found_tests: 0,
+ };
+
+ if find_testable_code(&dox, &mut tests, ErrorCodes::No).is_ok() {
+ if check_missing_code == true && tests.found_tests == 0 {
+ let mut diag = cx.tcx.struct_span_lint_node(
+ lint::builtin::MISSING_DOC_CODE_EXAMPLES,
+ NodeId::from_u32(0),
+ span_of_attrs(&item.attrs),
+ "Missing code example in this documentation");
+ diag.emit();
+ } else if check_missing_code == false &&
+ tests.found_tests > 0 &&
+ !cx.renderinfo.borrow().access_levels.is_doc_reachable(item.def_id) {
+ let mut diag = cx.tcx.struct_span_lint_node(
+ lint::builtin::PRIVATE_DOC_TESTS,
+ NodeId::from_u32(0),
+ span_of_attrs(&item.attrs),
+ "Documentation test in private item");
+ diag.emit();
+ }
+ }
+}
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use clean::*;
+
+use core::DocContext;
+use fold::DocFolder;
+
+use passes::{look_for_tests, Pass};
+
+pub const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass =
+ Pass::early("check-private-items-doc-tests", check_private_items_doc_tests,
+ "check private items doc tests");
+
+struct PrivateItemDocTestLinter<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> {
+ cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>,
+}
+
+impl<'a, 'tcx, 'rcx, 'cstore> PrivateItemDocTestLinter<'a, 'tcx, 'rcx, 'cstore> {
+ fn new(cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>) -> Self {
+ PrivateItemDocTestLinter {
+ cx,
+ }
+ }
+}
+
+pub fn check_private_items_doc_tests(krate: Crate, cx: &DocContext) -> Crate {
+ let mut coll = PrivateItemDocTestLinter::new(cx);
+
+ coll.fold_crate(krate)
+}
+
+impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for PrivateItemDocTestLinter<'a, 'tcx, 'rcx, 'cstore> {
+ fn fold_item(&mut self, item: Item) -> Option<Item> {
+ let cx = self.cx;
+ let dox = item.attrs.collapsed_doc_value().unwrap_or_else(String::new);
+
+ look_for_tests(&cx, &dox, &item, false);
+
+ self.fold_item_recur(item)
+ }
+}
/// Strip items marked `#[doc(hidden)]`
pub fn strip_hidden(krate: clean::Crate, _: &DocContext) -> clean::Crate {
- let mut retained = DefIdSet();
+ let mut retained = DefIdSet::default();
// strip all #[doc(hidden)] items
let krate = {
/// crate, specified by the `xcrate` flag.
pub fn strip_private(mut krate: clean::Crate, cx: &DocContext) -> clean::Crate {
// This stripper collects all *retained* nodes.
- let mut retained = DefIdSet();
+ let mut retained = DefIdSet::default();
let access_levels = cx.renderinfo.borrow().access_levels.clone();
// strip all private items
/// use std::collections::HashMap;
///
/// let mut map: HashMap<&str, u32> = HashMap::new();
- /// map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 12);
///
- /// assert_eq!(map["poneyland"], 12);
+ /// map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 3);
+ /// assert_eq!(map["poneyland"], 3);
///
- /// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 12).1 += 10;
- /// assert_eq!(map["poneyland"], 22);
+ /// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 *= 2;
+ /// assert_eq!(map["poneyland"], 6);
/// ```
#[unstable(feature = "hash_raw_entry", issue = "54043")]
pub fn or_insert(self, default_key: K, default_val: V) -> (&'a mut K, &'a mut V)
/// use std::collections::HashMap;
///
/// let mut map: HashMap<&str, u32> = HashMap::new();
- /// map.entry("poneyland").or_insert(12);
///
- /// assert_eq!(map["poneyland"], 12);
+ /// map.entry("poneyland").or_insert(3);
+ /// assert_eq!(map["poneyland"], 3);
///
- /// *map.entry("poneyland").or_insert(12) += 10;
- /// assert_eq!(map["poneyland"], 22);
+ /// *map.entry("poneyland").or_insert(10) *= 2;
+ /// assert_eq!(map["poneyland"], 6);
/// ```
pub fn or_insert(self, default: V) -> &'a mut V {
match self {
//! [slice]: primitive.slice.html
//! [`atomic`]: sync/atomic/index.html
//! [`collections`]: collections/index.html
-//! [`for`]: ../book/first-edition/loops.html#for
+//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
//! [`format!`]: macro.format.html
//! [`fs`]: fs/index.html
//! [`io`]: io/index.html
//! [`sync`]: sync/index.html
//! [`thread`]: thread/index.html
//! [`use std::env`]: env/index.html
-//! [`use`]: ../book/first-edition/crates-and-modules.html#importing-modules-with-use
-//! [crate root]: ../book/first-edition/crates-and-modules.html#basic-terminology-crates-and-modules
+//! [`use`]: ../book/ch07-02-modules-and-use-to-control-scope-and-privacy.html#the-use-keyword-to-bring-paths-into-a-scope
+//! [crate root]: ../book/ch07-01-packages-and-crates-for-making-libraries-and-executables.html
//! [crates.io]: https://crates.io
-//! [deref-coercions]: ../book/second-edition/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
+//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
//! [files]: fs/struct.File.html
//! [multithreading]: thread/index.html
//! [other]: #what-is-in-the-standard-library-documentation
-//! [primitive types]: ../book/first-edition/primitive-types.html
+//! [primitive types]: ../book/ch03-02-data-types.html
#![stable(feature = "rust1", since = "1.0.0")]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
///
/// [`Result`] enum is often a better solution for recovering from errors than
/// using the `panic!` macro. This macro should be used to avoid proceeding using
-/// incorrect values, such as from external sources. Detailed information about
+/// incorrect values, such as from external sources. Detailed information about
/// error handling is found in the [book].
///
/// The multi-argument form of this macro panics with a string and has the
/// [`Result`]: ../std/result/enum.Result.html
/// [`format!`]: ../std/macro.format.html
/// [`compile_error!`]: ../std/macro.compile_error.html
-/// [book]: ../book/second-edition/ch09-01-unrecoverable-errors-with-panic.html
+/// [book]: ../book/ch09-00-error-handling.html
///
/// # Current implementation
///
/// boolean expression evaluation of configuration flags. This frequently
/// leads to less duplicated code.
///
- /// The syntax given to this macro is the same syntax as [the `cfg`
- /// attribute](../book/first-edition/conditional-compilation.html).
+ /// The syntax given to this macro is the same syntax as the `cfg`
+ /// attribute.
///
/// # Examples
///
/// Unsafe code relies on `assert!` to enforce run-time invariants that, if
/// violated could lead to unsafety.
///
- /// Other use-cases of `assert!` include [testing] and enforcing run-time
+ /// Other use-cases of `assert!` include testing and enforcing run-time
/// invariants in safe code (whose violation cannot result in unsafety).
///
/// # Custom Messages
///
/// [`panic!`]: macro.panic.html
/// [`debug_assert!`]: macro.debug_assert.html
- /// [testing]: ../book/second-edition/ch11-01-writing-tests.html#checking-results-with-the-assert-macro
/// [`std::fmt`]: ../std/fmt/index.html
///
/// # Examples
/// `bool` implements various traits, such as [`BitAnd`], [`BitOr`], [`Not`], etc.,
/// which allow us to perform boolean operations using `&`, `|` and `!`.
///
-/// [`if`] always demands a `bool` value. [`assert!`], being an important macro in testing,
+/// `if` always demands a `bool` value. [`assert!`], being an important macro in testing,
/// checks whether an expression returns `true`.
///
/// ```
/// ```
///
/// [`assert!`]: macro.assert.html
-/// [`if`]: ../book/first-edition/if.html
/// [`BitAnd`]: ops/trait.BitAnd.html
/// [`BitOr`]: ops/trait.BitOr.html
/// [`Not`]: ops/trait.Not.html
/// assert_eq!(tuple.2, 'c');
/// ```
///
-/// For more about tuples, see [the book](../book/first-edition/primitive-types.html#tuples).
+/// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type).
///
/// # Trait implementations
///
// Allows `const _: TYPE = VALUE`
(active, underscore_const_names, "1.31.0", Some(54912), None),
- // `extern crate foo as bar;` puts `bar` into extern prelude.
- (active, extern_crate_item_prelude, "1.31.0", Some(55599), None),
-
// `reason = ` in lint attributes and `expect` lint attribute
(active, lint_reasons, "1.31.0", Some(54503), None),
);
// impl<I:Iterator> Iterator for &mut Iterator
// impl Debug for Foo<'_>
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
+ // `extern crate foo as bar;` puts `bar` into extern prelude.
+ (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
);
// If you change this, please modify src/doc/unstable-book as well. You must
}
}
+ ast::ItemKind::Static(..) |
ast::ItemKind::Const(_,_) => {
if i.ident.name == "_" {
gate_feature_post!(&self, underscore_const_names, i.span,
fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> {
maybe_whole!(self, NtArg, |x| x);
+ if let Ok(Some(_)) = self.parse_self_arg() {
+ let mut err = self.struct_span_err(self.prev_span,
+ "unexpected `self` argument in function");
+ err.span_label(self.prev_span,
+ "`self` is only valid as the first argument of an associated function");
+ return Err(err);
+ }
+
let (pat, ty) = if require_name || self.is_named_argument() {
debug!("parse_arg_general parse_pat (require_name:{})",
require_name);
fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
-> PResult<'a, (Vec<Arg> , bool)> {
+ self.expect(&token::OpenDelim(token::Paren))?;
+
let sp = self.span;
let mut variadic = false;
let args: Vec<Option<Arg>> =
- self.parse_unspanned_seq(
- &token::OpenDelim(token::Paren),
+ self.parse_seq_to_before_end(
&token::CloseDelim(token::Paren),
SeqSep::trailing_allowed(token::Comma),
|p| {
}
)?;
+ self.eat(&token::CloseDelim(token::Paren));
+
let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
if variadic && args.is_empty() {
//
// Instead the "probably equal" check here is "does each token
// recursively have the same discriminant?" We basically don't look at
- // the token values here and assume that such fine grained modifications
- // of token streams doesn't happen.
+ // the token values here and assume that such fine grained token stream
+ // modifications, including adding/removing typically non-semantic
+ // tokens such as extra braces and commas, don't happen.
if let Some(tokens) = tokens {
if tokens.probably_equal_for_proc_macro(&tokens_for_real) {
return tokens
use ext::base;
use ext::tt::{macro_parser, quoted};
use parse::Directory;
-use parse::token::{self, Token};
+use parse::token::{self, DelimToken, Token};
use print::pprust;
use serialize::{Decoder, Decodable, Encoder, Encodable};
use util::RcVec;
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub struct Delimited {
/// The type of delimiter
- pub delim: token::DelimToken,
+ pub delim: DelimToken,
/// The delimited sequence of token trees
pub tts: ThinTokenStream,
}
// This is otherwise the same as `eq_unspanned`, only recursing with a
// different method.
pub fn probably_equal_for_proc_macro(&self, other: &TokenStream) -> bool {
- let mut t1 = self.trees();
- let mut t2 = other.trees();
+ // When checking for `probably_eq`, we ignore certain tokens that aren't
+ // preserved in the AST. Because they are not preserved, the pretty
+ // printer arbitrarily adds or removes them when printing as token
+ // streams, making a comparison between a token stream generated from an
+ // AST and a token stream which was parsed into an AST more reliable.
+ fn semantic_tree(tree: &TokenTree) -> bool {
+ match tree {
+ // The pretty printer tends to add trailing commas to
+ // everything, and in particular, after struct fields.
+ | TokenTree::Token(_, Token::Comma)
+ // The pretty printer emits `NoDelim` as whitespace.
+ | TokenTree::Token(_, Token::OpenDelim(DelimToken::NoDelim))
+ | TokenTree::Token(_, Token::CloseDelim(DelimToken::NoDelim))
+ // The pretty printer collapses many semicolons into one.
+ | TokenTree::Token(_, Token::Semi)
+ // The pretty printer collapses whitespace arbitrarily and can
+ // introduce whitespace from `NoDelim`.
+ | TokenTree::Token(_, Token::Whitespace) => false,
+ _ => true
+ }
+ }
+
+ let mut t1 = self.trees().filter(semantic_tree);
+ let mut t2 = other.trees().filter(semantic_tree);
for (t1, t2) in t1.by_ref().zip(t2.by_ref()) {
if !t1.probably_equal_for_proc_macro(&t2) {
return false;
// gdb-command: print vec_deque
// gdb-check:$3 = VecDeque<i32>(len: 3, cap: 8) = {5, 3, 7}
+// gdb-command: print vec_deque2
+// gdb-check:$4 = VecDeque<i32>(len: 7, cap: 8) = {2, 3, 4, 5, 6, 7, 8}
+
#![allow(unused_variables)]
use std::collections::BTreeSet;
use std::collections::BTreeMap;
vec_deque.push_back(3);
vec_deque.push_back(7);
+ // VecDeque where an element was popped.
+ let mut vec_deque2 = VecDeque::new();
+ for i in 1..8 {
+ vec_deque2.push_back(i)
+ }
+ vec_deque2.pop_front();
+ vec_deque2.push_back(8);
+
zzz(); // #break
}
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(private_doc_tests)]
+
+mod foo {
+ /// private doc test
+ ///
+ /// ```
+ /// assert!(false);
+ /// ```
+ fn bar() {}
+}
--- /dev/null
+error: Documentation test in private item
+ --> $DIR/private-item-doc-test.rs:14:5
+ |
+LL | / /// private doc test
+LL | | ///
+LL | | /// ```
+LL | | /// assert!(false);
+LL | | /// ```
+ | |___________^
+ |
+note: lint level defined here
+ --> $DIR/private-item-doc-test.rs:11:9
+ |
+LL | #![deny(private_doc_tests)]
+ | ^^^^^^^^^^^^^^^^^
+
--- /dev/null
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_attribute]
+pub fn foo(_: TokenStream, input: TokenStream) -> TokenStream {
+ input.into_iter().collect()
+}
// compile-pass
// edition:2018
-#![feature(extern_crate_item_prelude)]
-
extern crate proc_macro;
use proc_macro::TokenStream; // OK
--- /dev/null
+// aux-build:span-preservation.rs
+
+// For each of these, we should get the appropriate type mismatch error message,
+// and the function should be echoed.
+
+extern crate span_preservation as foo;
+
+use foo::foo;
+
+#[foo]
+fn a() {
+ let x: usize = "hello";;;;;
+}
+
+#[foo]
+fn b(x: Option<isize>) -> usize {
+ match x {
+ Some(x) => { return x },
+ None => 10
+ }
+}
+
+#[foo]
+fn c() {
+ struct Foo {
+ a: usize
+ }
+
+ struct Bar {
+ a: usize,
+ b: usize
+ }
+
+ let x = Foo { a: 10isize };
+ let y = Foo { a: 10, b: 10isize };
+}
+
+// FIXME: This doesn't work at the moment. See the one below. The pretty-printer
+// injects a "C" between `extern` and `fn` which causes a "probably_eq"
+// `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST.
+#[foo]
+extern fn bar() {
+ 0
+}
+
+#[foo]
+extern "C" fn baz() {
+ 0
+}
+
+fn main() {}
--- /dev/null
+error[E0308]: mismatched types
+ |
+ = note: expected type `()`
+ found type `{integer}`
+
+error[E0308]: mismatched types
+ --> $DIR/span-preservation.rs:12:20
+ |
+LL | let x: usize = "hello";;;;;
+ | ^^^^^^^ expected usize, found reference
+ |
+ = note: expected type `usize`
+ found type `&'static str`
+
+error[E0308]: mismatched types
+ --> $DIR/span-preservation.rs:18:29
+ |
+LL | Some(x) => { return x },
+ | ^ expected usize, found isize
+
+error[E0308]: mismatched types
+ --> $DIR/span-preservation.rs:34:22
+ |
+LL | let x = Foo { a: 10isize };
+ | ^^^^^^^ expected usize, found isize
+
+error[E0560]: struct `c::Foo` has no field named `b`
+ --> $DIR/span-preservation.rs:35:26
+ |
+LL | let y = Foo { a: 10, b: 10isize };
+ | ^ `c::Foo` does not have this field
+ |
+ = note: available fields are: `a`
+
+error[E0308]: mismatched types
+ --> $DIR/span-preservation.rs:48:5
+ |
+LL | extern "C" fn baz() {
+ | - possibly return type missing here?
+LL | 0
+ | ^ expected (), found integral variable
+ |
+ = note: expected type `()`
+ found type `{integer}`
+
+error: aborting due to 6 previous errors
+
+Some errors occurred: E0308, E0560.
+For more information about an error, try `rustc --explain E0308`.
enum Bar {
Boo = [unsafe { Foo { b: () }.a }; 4][3],
- //~^ ERROR evaluation of constant value failed
+ //~^ ERROR it is undefined behavior to use this value
}
fn main() {
-error[E0080]: evaluation of constant value failed
+error[E0080]: it is undefined behavior to use this value
--> $DIR/const-err4.rs:18:11
|
LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error: aborting due to previous error
//~^ ERROR it is undefined behavior to use this value
const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
- //~^ ERROR any use of this value will cause an error
+ //~^ ERROR it is undefined behavior to use this value
const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
//~^ ERROR any use of this value will cause an error
//~^ ERROR it is undefined behavior to use this value
const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
- //~^ ERROR any use of this value will cause an error
+ //~^ ERROR it is undefined behavior to use this value
const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
//~^ ERROR any use of this value will cause an error
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
-error: any use of this value will cause an error
+error[E0080]: it is undefined behavior to use this value
--> $DIR/const-pointer-values-in-various-types.rs:39:5
|
LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error: any use of this value will cause an error
--> $DIR/const-pointer-values-in-various-types.rs:42:5
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
-error: any use of this value will cause an error
+error[E0080]: it is undefined behavior to use this value
--> $DIR/const-pointer-values-in-various-types.rs:54:5
|
LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
+ |
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error: any use of this value will cause an error
--> $DIR/const-pointer-values-in-various-types.rs:57:5
A = 0,
}
union TransmuteEnum {
- a: &'static u8,
- out: Enum,
+ in1: &'static u8,
+ out1: Enum,
}
// A pointer is guaranteed non-null
-const BAD_ENUM: Enum = unsafe { TransmuteEnum { a: &1 }.out };
+const BAD_ENUM: Enum = unsafe { TransmuteEnum { in1: &1 }.out1 };
//~^ ERROR is undefined behavior
// (Potentially) invalid enum discriminant
const BAD_ENUM4: Wrap<Enum2> = unsafe { TransmuteEnum2 { in2: &0 }.out2 };
//~^ ERROR is undefined behavior
-// Undef enum discriminant. In an arry to avoid `Scalar` layout.
-const BAD_ENUM_UNDEF: [Enum2; 2] = [unsafe { TransmuteEnum2 { in3: () }.out1 }; 2];
+// Undef enum discriminant.
+const BAD_ENUM_UNDEF : Enum2 = unsafe { TransmuteEnum2 { in3: () }.out1 };
//~^ ERROR is undefined behavior
// Pointer value in an enum with a niche that is not just 0.
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:24:1
|
-LL | const BAD_ENUM: Enum = unsafe { TransmuteEnum { a: &1 }.out };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected a valid enum discriminant
+LL | const BAD_ENUM: Enum = unsafe { TransmuteEnum { in1: &1 }.out1 };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected a valid enum discriminant
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:52:1
|
-LL | const BAD_ENUM_UNDEF: [Enum2; 2] = [unsafe { TransmuteEnum2 { in3: () }.out1 }; 2];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes at [0], but expected a valid enum discriminant
+LL | const BAD_ENUM_UNDEF : Enum2 = unsafe { TransmuteEnum2 { in3: () }.out1 };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a valid enum discriminant
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
}
const fn read_field3() -> Field3 {
- const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR any use of this value
+ const FIELD3: Field3 = unsafe { UNION.field3 };
+ //~^ ERROR it is undefined behavior to use this value
FIELD3
}
-error: any use of this value will cause an error
+error[E0080]: it is undefined behavior to use this value
--> $DIR/union-const-eval-field.rs:37:5
|
-LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR any use of this value
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
+LL | const FIELD3: Field3 = unsafe { UNION.field3 };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
|
- = note: #[deny(const_err)] on by default
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0080`.
const UNION: DummyUnion = DummyUnion { field1: 1065353216 };
-const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR will cause an error
+const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR it is undefined behavior to use this value
const FIELD_PATH: Struct = Struct { //~ ERROR it is undefined behavior to use this value
a: 42,
-error: any use of this value will cause an error
+error[E0080]: it is undefined behavior to use this value
--> $DIR/union-ice.rs:23:1
|
-LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR will cause an error
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
+LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR it is undefined behavior to use this value
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
|
- = note: #[deny(const_err)] on by default
+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error[E0080]: it is undefined behavior to use this value
--> $DIR/union-ice.rs:25:1
--- /dev/null
+const fn foo() {
+ loop {} //~ ERROR loops are not allowed in const fn
+}
+
+fn main() {}
--- /dev/null
+error: loops are not allowed in const fn
+ --> $DIR/loop_ice.rs:2:5
+ |
+LL | loop {} //~ ERROR loops are not allowed in const fn
+ | ^^^^^^^
+
+error: aborting due to previous error
+
+++ /dev/null
-// edition:2018
-
-#![feature(alloc, underscore_imports)]
-
-extern crate alloc;
-
-mod in_scope {
- fn check() {
- let v = alloc::vec![0];
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
- type A = alloc::boxed::Box<u8>;
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
- }
-}
-
-mod absolute {
- fn check() {
- let v = ::alloc::vec![0];
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
- type A = ::alloc::boxed::Box<u8>;
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
- }
-}
-
-mod import_in_scope {
- use alloc as _;
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
- use alloc::boxed;
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
-}
-
-mod import_absolute {
- use ::alloc;
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
- use ::alloc::boxed;
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
-}
-
-extern crate alloc as core;
-
-mod unrelated_crate_renamed {
- type A = core::boxed::Box<u8>;
- //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
-}
-
-fn main() {}
+++ /dev/null
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:26:9
- |
-LL | use alloc as _;
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:28:9
- |
-LL | use alloc::boxed;
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:33:11
- |
-LL | use ::alloc;
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:35:11
- |
-LL | use ::alloc::boxed;
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:9:17
- |
-LL | let v = alloc::vec![0];
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:11:18
- |
-LL | type A = alloc::boxed::Box<u8>;
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:18:19
- |
-LL | let v = ::alloc::vec![0];
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:20:20
- |
-LL | type A = ::alloc::boxed::Box<u8>;
- | ^^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
- --> $DIR/feature-gate-extern_crate_item_prelude.rs:42:14
- |
-LL | type A = core::boxed::Box<u8>;
- | ^^^^
- |
- = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
-
-error: aborting due to 9 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
--- /dev/null
+mod m {}
+
+// These two imports should not conflict when this crate is loaded from some other crate.
+use m::{};
+use m::{};
--- /dev/null
+pub mod last_segment {
+ pub mod issue_56125 {}
+}
+
+pub mod non_last_segment {
+ pub mod non_last_segment {
+ pub mod issue_56125 {}
+ }
+}
// compile-pass
// edition:2018
-#![feature(extern_crate_item_prelude)]
-
macro_rules! define_iso { () => {
extern crate std as iso;
}}
// compile-pass
// compile-flags:--cfg my_feature
-#![feature(extern_crate_item_prelude)]
#![no_std]
#[cfg(my_feature)]
// compile-pass
// aux-build:two_macros.rs
-#![feature(extern_crate_item_prelude)]
-
extern crate two_macros;
mod m {
// aux-build:two_macros.rs
-#![feature(extern_crate_item_prelude)]
-
macro_rules! define_vec {
() => {
extern crate std as Vec;
}
}
+macro_rules! define_other_core {
+ () => {
+ extern crate std as core;
+ //~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
+ }
+}
+
+define_other_core!();
+
fn main() {}
+error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
+ --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:19:9
+ |
+LL | extern crate std as core;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | define_other_core!();
+ | --------------------- in this macro invocation
+
error[E0659]: `Vec` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
- --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:15:9
+ --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9
|
LL | Vec::panic!(); //~ ERROR `Vec` is ambiguous
| ^^^ ambiguous name
|
= note: `Vec` could refer to a struct from prelude
note: `Vec` could also refer to the extern crate imported here
- --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:7:9
+ --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:5:9
|
LL | extern crate std as Vec;
| ^^^^^^^^^^^^^^^^^^^^^^^^
LL | define_vec!();
| -------------- in this macro invocation
-error: aborting due to previous error
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0659`.
--- /dev/null
+// compile-pass
+// aux-build:two_macros.rs
+
+extern crate two_macros as core;
+
+mod m {
+ fn check() {
+ core::m!(); // OK
+ }
+}
+
+fn main() {}
--- /dev/null
+// compile-pass
+// aux-build:issue-55811.rs
+
+extern crate issue_55811;
+
+fn main() {}
--- /dev/null
+// edition:2018
+// compile-flags:--extern issue_56125
+// aux-build:issue-56125.rs
+
+use issue_56125::last_segment::*;
+//~^ ERROR `issue_56125` is ambiguous
+//~| ERROR unresolved import `issue_56125::last_segment`
+use issue_56125::non_last_segment::non_last_segment::*;
+//~^ ERROR `issue_56125` is ambiguous
+//~| ERROR failed to resolve: could not find `non_last_segment` in `issue_56125`
+
+fn main() {}
--- /dev/null
+error[E0433]: failed to resolve: could not find `non_last_segment` in `issue_56125`
+ --> $DIR/issue-56125.rs:8:18
+ |
+LL | use issue_56125::non_last_segment::non_last_segment::*;
+ | ^^^^^^^^^^^^^^^^ could not find `non_last_segment` in `issue_56125`
+
+error[E0432]: unresolved import `issue_56125::last_segment`
+ --> $DIR/issue-56125.rs:5:18
+ |
+LL | use issue_56125::last_segment::*;
+ | ^^^^^^^^^^^^ could not find `last_segment` in `issue_56125`
+
+error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
+ --> $DIR/issue-56125.rs:5:5
+ |
+LL | use issue_56125::last_segment::*;
+ | ^^^^^^^^^^^ ambiguous name
+ |
+ = note: `issue_56125` could refer to an extern crate passed with `--extern`
+ = help: use `::issue_56125` to refer to this extern crate unambiguously
+note: `issue_56125` could also refer to the module imported here
+ --> $DIR/issue-56125.rs:5:5
+ |
+LL | use issue_56125::last_segment::*;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: use `self::issue_56125` to refer to this module unambiguously
+
+error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution)
+ --> $DIR/issue-56125.rs:8:5
+ |
+LL | use issue_56125::non_last_segment::non_last_segment::*;
+ | ^^^^^^^^^^^ ambiguous name
+ |
+ = note: `issue_56125` could refer to an extern crate passed with `--extern`
+ = help: use `::issue_56125` to refer to this extern crate unambiguously
+note: `issue_56125` could also refer to the module imported here
+ --> $DIR/issue-56125.rs:5:5
+ |
+LL | use issue_56125::last_segment::*;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: use `self::issue_56125` to refer to this module unambiguously
+
+error: aborting due to 4 previous errors
+
+Some errors occurred: E0432, E0433, E0659.
+For more information about an error, try `rustc --explain E0432`.
--- /dev/null
+fn a(&self) { }
+//~^ ERROR unexpected `self` argument in function
+//~| NOTE `self` is only valid as the first argument of an associated function
+
+fn main() { }
--- /dev/null
+error: unexpected `self` argument in function
+ --> $DIR/bare-fn-start.rs:1:7
+ |
+LL | fn a(&self) { }
+ | ^^^^ `self` is only valid as the first argument of an associated function
+
+error: aborting due to previous error
+
--- /dev/null
+fn b(foo: u32, &mut self) { }
+//~^ ERROR unexpected `self` argument in function
+//~| NOTE `self` is only valid as the first argument of an associated function
+
+fn main() { }
--- /dev/null
+error: unexpected `self` argument in function
+ --> $DIR/bare-fn.rs:1:21
+ |
+LL | fn b(foo: u32, &mut self) { }
+ | ^^^^ `self` is only valid as the first argument of an associated function
+
+error: aborting due to previous error
+
--- /dev/null
+struct Foo {}
+
+impl Foo {
+ fn c(foo: u32, self) {}
+ //~^ ERROR unexpected `self` argument in function
+ //~| NOTE `self` is only valid as the first argument of an associated function
+
+ fn good(&mut self, foo: u32) {}
+}
+
+fn main() { }
--- /dev/null
+error: unexpected `self` argument in function
+ --> $DIR/trait-fn.rs:4:20
+ |
+LL | fn c(foo: u32, self) {}
+ | ^^^^ `self` is only valid as the first argument of an associated function
+
+error: aborting due to previous error
+
--- /dev/null
+#![deny(unused_must_use)]
+
+#[must_use]
+trait Critical {}
+
+trait NotSoCritical {}
+
+trait DecidedlyUnimportant {}
+
+struct Anon;
+
+impl Critical for Anon {}
+impl NotSoCritical for Anon {}
+impl DecidedlyUnimportant for Anon {}
+
+fn get_critical() -> impl NotSoCritical + Critical + DecidedlyUnimportant {
+ Anon {}
+}
+
+fn main() {
+ get_critical(); //~ ERROR unused implementer of `Critical` that must be used
+}
--- /dev/null
+error: unused implementer of `Critical` that must be used
+ --> $DIR/must_use-trait.rs:21:5
+ |
+LL | get_critical(); //~ ERROR unused implementer of `Critical` that must be used
+ | ^^^^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/must_use-trait.rs:1:9
+ |
+LL | #![deny(unused_must_use)]
+ | ^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
//~^ ERROR closure is expected to take
f(|| panic!());
//~^ ERROR closure is expected to take
+ f( move || panic!());
+ //~^ ERROR closure is expected to take
let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i);
//~^ ERROR closure is expected to take
LL | f(|_| panic!());
| ^^^
+error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments
+ --> $DIR/closure-arg-count.rs:25:5
+ |
+LL | f( move || panic!());
+ | ^ ---------- takes 0 arguments
+ | |
+ | expected closure that takes 1 argument
+ |
+note: required by `f`
+ --> $DIR/closure-arg-count.rs:13:1
+ |
+LL | fn f<F: Fn<usize>>(_: F) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+help: consider changing the closure to take and ignore the expected argument
+ |
+LL | f( move |_| panic!());
+ | ^^^
+
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
- --> $DIR/closure-arg-count.rs:26:53
+ --> $DIR/closure-arg-count.rs:28:53
|
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i);
| ^^^ ------ takes 2 distinct arguments
| ^^^^^^^^
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
- --> $DIR/closure-arg-count.rs:28:53
+ --> $DIR/closure-arg-count.rs:30:53
|
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i);
| ^^^ ------------- takes 2 distinct arguments
| ^^^^^^^^
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments
- --> $DIR/closure-arg-count.rs:30:53
+ --> $DIR/closure-arg-count.rs:32:53
|
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i);
| ^^^ --------- takes 3 distinct arguments
| expected closure that takes a single 2-tuple as argument
error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments
- --> $DIR/closure-arg-count.rs:32:53
+ --> $DIR/closure-arg-count.rs:34:53
|
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
| ^^^ expected function that takes a single 2-tuple as argument
| -------- takes 0 arguments
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments
- --> $DIR/closure-arg-count.rs:35:53
+ --> $DIR/closure-arg-count.rs:37:53
|
LL | let bar = |i, x, y| i;
| --------- takes 3 distinct arguments
| ^^^ expected closure that takes a single 2-tuple as argument
error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
- --> $DIR/closure-arg-count.rs:37:53
+ --> $DIR/closure-arg-count.rs:39:53
|
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(qux);
| ^^^ expected function that takes a single 2-tuple as argument
| -------------------------- takes 2 distinct arguments
error[E0593]: function is expected to take 1 argument, but it takes 2 arguments
- --> $DIR/closure-arg-count.rs:40:41
+ --> $DIR/closure-arg-count.rs:42:41
|
LL | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add);
| ^^^ expected function that takes 1 argument
error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
- --> $DIR/closure-arg-count.rs:43:5
+ --> $DIR/closure-arg-count.rs:45:5
|
LL | call(Foo);
| ^^^^ expected function that takes 0 arguments
| --------------- takes 1 argument
|
note: required by `call`
- --> $DIR/closure-arg-count.rs:50:1
+ --> $DIR/closure-arg-count.rs:52:1
|
LL | fn call<F, R>(_: F) where F: FnOnce() -> R {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 13 previous errors
+error: aborting due to 14 previous errors
For more information about this error, try `rustc --explain E0593`.
--- /dev/null
+// Copyright 2012-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+const _: () = (); //~ ERROR is unstable
+static _: () = (); //~ ERROR is unstable
+
+fn main() {}
--- /dev/null
+error[E0658]: naming constants with `_` is unstable (see issue #54912)
+ --> $DIR/underscore_const_names_feature_gate.rs:11:1
+ |
+LL | const _: () = (); //~ ERROR is unstable
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = help: add #![feature(underscore_const_names)] to the crate attributes to enable
+
+error[E0658]: naming constants with `_` is unstable (see issue #54912)
+ --> $DIR/underscore_const_names_feature_gate.rs:12:1
+ |
+LL | static _: () = (); //~ ERROR is unstable
+ | ^^^^^^^^^^^^^^^^^^
+ |
+ = help: add #![feature(underscore_const_names)] to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
self.package("lldb-preview", &mut manifest.pkg, TARGETS);
manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() });
+ manifest.renames.insert("rustfmt".to_owned(), Rename { to: "rustfmt-preview".to_owned() });
+ manifest.renames.insert("clippy".to_owned(), Rename { to: "clippy-preview".to_owned() });
let mut pkg = Package {
version: self.cached_version("rust")
-Subproject commit 1c755efed6ee265c762f4d3fec73de8a989637a5
+Subproject commit daa138ce7f222559e9a339600b44a715101a3f4d
-Subproject commit 750b25261380b776de2518fd6863fe63f98d2722
+Subproject commit 1cc61cfc2b29ae3f29a924b4c8feb1bcb09aa5fc