+Version 1.24.0 (2018-02-15)
+==========================
+
+Language
+--------
+- [External `sysv64` ffi is now available.][46528]
+ eg. `extern "sysv64" fn foo () {}`
+
+Compiler
+--------
+- [rustc now uses 16 codegen units by default for release builds.][46910]
+ For the fastest builds, utilize `codegen-units=1`.
+- [Added `armv4t-unknown-linux-gnueabi` target.][47018]
+- [Add `aarch64-unknown-openbsd` support][46760]
+
+Libraries
+---------
+- [`str::find::<char>` now uses memchr.][46735] This should lead to a 10x
+ improvement in performance in the majority of cases.
+- [`OsStr`'s `Debug` implementation is now lossless and consistent
+ with Windows.][46798]
+- [`time::{SystemTime, Instant}` now implement `Hash`.][46828]
+- [impl `From<bool>` for `AtomicBool`][46293]
+- [impl `From<{CString, &CStr}>` for `{Arc<CStr>, Rc<CStr>}`][45990]
+- [impl `From<{OsString, &OsStr}>` for `{Arc<OsStr>, Rc<OsStr>}`][45990]
+- [impl `From<{PathBuf, &Path}>` for `{Arc<Path>, Rc<Path>}`][45990]
+- [float::from_bits now just uses transmute.][46012] This provides
+ some optimisations from LLVM.
+- [Copied `AsciiExt` methods onto `char`][46077]
+- [Remove `T: Sized` requirement on `ptr::is_null()`][46094]
+- [impl `From<RecvError>` for `{TryRecvError, RecvTimeoutError}`][45506]
+- [Optimised `f32::{min, max}` to generate more efficent x86 assembly][47080]
+- [`[u8]::contains` now uses memchr which provides a 3x speed improvement][46713]
+
+Stabilized APIs
+---------------
+- [`RefCell::replace`]
+- [`RefCell::swap`]
+- [`atomic::spin_loop_hint`]
+
+The following functions can now be used in a constant expression.
+eg. `let buffer: [u8; size_of::<usize>()];`, `static COUNTER: AtomicUsize = AtomicUsize::new(1);`
+
+- [`AtomicBool::new`][46287]
+- [`AtomicUsize::new`][46287]
+- [`AtomicIsize::new`][46287]
+- [`AtomicPtr::new`][46287]
+- [`Cell::new`][46287]
+- [`{integer}::min_value`][46287]
+- [`{integer}::max_value`][46287]
+- [`mem::size_of`][46287]
+- [`mem::align_of`][46287]
+- [`ptr::null`][46287]
+- [`ptr::null_mut`][46287]
+- [`RefCell::new`][46287]
+- [`UnsafeCell::new`][46287]
+
+Cargo
+-----
+- [Added a `workspace.default-members` config that
+ overrides implied `--all` in virtual workspaces.][cargo/4743]
+- [Enable incremental by default on development builds.][cargo/4817] Also added
+ configuration keys to `Cargo.toml` and `.cargo/config` to disable on a
+ per-project or global basis respectively.
+
+Misc
+----
+
+Compatibility Notes
+-------------------
+- [Floating point types `Debug` impl now always prints a decimal point.][46831]
+- [`Ipv6Addr` now rejects superfluous `::`'s in IPv6 addresses][46671] This is
+ in accordance with IETF RFC 4291 §2.2.
+- [Unwinding will no longer go past FFI boundaries, and will instead abort.][46833]
+- [`Formatter::flags` method is now deprecated.][46284] The `sign_plus`,
+ `sign_minus`, `alternate`, and `sign_aware_zero_pad` should be used instead.
+- [Leading zeros in tuple struct members is now an error][47084]
+- [`column!()` macro is one-based instead of zero-based][46977]
+- [`fmt::Arguments` can no longer be shared across threads][45198]
+- [Access to `#[repr(packed)]` struct fields is now unsafe][44884]
+
+[44884]: https://github.com/rust-lang/rust/pull/44884
+[45198]: https://github.com/rust-lang/rust/pull/45198
+[45506]: https://github.com/rust-lang/rust/pull/45506
+[45904]: https://github.com/rust-lang/rust/pull/45904
+[45990]: https://github.com/rust-lang/rust/pull/45990
+[46012]: https://github.com/rust-lang/rust/pull/46012
+[46077]: https://github.com/rust-lang/rust/pull/46077
+[46094]: https://github.com/rust-lang/rust/pull/46094
+[46284]: https://github.com/rust-lang/rust/pull/46284
+[46287]: https://github.com/rust-lang/rust/pull/46287
+[46293]: https://github.com/rust-lang/rust/pull/46293
+[46528]: https://github.com/rust-lang/rust/pull/46528
+[46671]: https://github.com/rust-lang/rust/pull/46671
+[46713]: https://github.com/rust-lang/rust/pull/46713
+[46735]: https://github.com/rust-lang/rust/pull/46735
+[46749]: https://github.com/rust-lang/rust/pull/46749
+[46760]: https://github.com/rust-lang/rust/pull/46760
+[46798]: https://github.com/rust-lang/rust/pull/46798
+[46828]: https://github.com/rust-lang/rust/pull/46828
+[46831]: https://github.com/rust-lang/rust/pull/46831
+[46833]: https://github.com/rust-lang/rust/pull/46833
+[46910]: https://github.com/rust-lang/rust/pull/46910
+[46977]: https://github.com/rust-lang/rust/pull/46977
+[47018]: https://github.com/rust-lang/rust/pull/47018
+[47080]: https://github.com/rust-lang/rust/pull/47080
+[47084]: https://github.com/rust-lang/rust/pull/47084
+[cargo/4743]: https://github.com/rust-lang/cargo/pull/4743
+[cargo/4817]: https://github.com/rust-lang/cargo/pull/4817
+[`RefCell::replace`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.replace
+[`RefCell::swap`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.swap
+[`atomic::spin_loop_hint`]: https://doc.rust-lang.org/std/sync/atomic/fn.spin_loop_hint.html
+
+
Version 1.23.0 (2018-01-04)
==========================
# default.
#extended = false
+# Installs choosen set of extended tools if enables. By default builds all.
+# If choosen tool failed to build the installation fails.
+#tools = ["cargo", "rls", "rustfmt", "analysis", "src"]
+
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
#verbose = 0
# Flag indicating whether git info will be retrieved from .git automatically.
# Having the git information can cause a lot of rebuilds during development.
-# Note: If this attribute is not explicity set (e.g. if left commented out) it
+# Note: If this attribute is not explicitly set (e.g. if left commented out) it
# will default to true if channel = "dev", but will default to false otherwise.
#ignore-git = true
# bootstrap)
#codegen-backends = ["llvm"]
-# Flag indicating whether `libstd` calls an imported function to hande basic IO
-# when targetting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
+# Flag indicating whether `libstd` calls an imported function to handle basic IO
+# when targeting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
# target, as without this option the test output will not be captured.
#wasm-syscall = false
#linker = "cc"
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
-# against. Note that if this is specifed we don't compile LLVM at all for this
+# against. Note that if this is specified we don't compile LLVM at all for this
# target.
#llvm-config = "../path/to/llvm/root/bin/llvm-config"
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clippy"
-version = "0.0.174"
+version = "0.0.186"
dependencies = [
"cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "clippy-mini-macro-test 0.1.0",
- "clippy_lints 0.0.174",
- "compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "clippy-mini-macro-test 0.2.0",
+ "clippy_lints 0.0.186",
+ "compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "clippy-mini-macro-test"
-version = "0.1.0"
+version = "0.2.0"
[[package]]
name = "clippy_lints"
-version = "0.0.174"
+version = "0.0.186"
dependencies = [
"if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
"quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "compiletest_rs"
-version = "0.3.3"
+version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"xz2 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "is-match"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "itertools"
version = "0.6.5"
"either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "itertools"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "itoa"
version = "0.3.4"
[[package]]
name = "mdbook"
-version = "0.0.28"
+version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"handlebars 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
dependencies = [
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "rls-data"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "rls-rustc"
version = "0.2.1"
version = "0.1.0"
dependencies = [
"clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "mdbook 0.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
+ "mdbook 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.0.0"
dependencies = [
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "rustdoc-themes"
+version = "0.1.0"
+
[[package]]
name = "rustdoc-tool"
version = "0.0.0"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "shlex"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "siphasher"
version = "0.2.2"
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "toml-query"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "unicode-bidi"
version = "0.3.4"
"checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd"
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
-"checksum compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "562bafeec9aef1e3e08f1c5b0c542220bb80ff2894e5373a1f9d17c346412c66"
+"checksum compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6c5aafb5d4a77c6b5fa384fe93c7a9a3561bd88c4b8b8e45187cf5e779b1badc"
"checksum core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8047f547cd6856d45b1cdd75ef8d2f21f3d0e4bf1dab0a0041b0ae9a5dda9c0e"
"checksum core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "152195421a2e6497a8179195672e9d4ee8e45ed8c465b626f1606d27a08ebcd5"
"checksum crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8"
"checksum ignore 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bb2f0238094bd1b41800fb6eb9b16fdd5e9832ed6053ed91409f0cd5bf28dcfd"
+"checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053"
"checksum itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3f2be4da1690a039e9ae5fd575f706a63ad5a2120f161b1d653c9da3930dd21"
+"checksum itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b07332223953b5051bceb67e8c4700aa65291535568e1f12408c43c4a42c0394"
"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
"checksum jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "565f6106bd87b394398f813bea4e5ecad6d6b0f6aa077592d088f882a506481d"
"checksum json 0.11.12 (registry+https://github.com/rust-lang/crates.io-index)" = "39ebf0fac977ee3a4a3242b6446004ff64514889e3e2730bbd4f764a67a2e483"
"checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
"checksum markup5ever 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "047150a0e03b57e638fc45af33a0b63a0362305d5b9f92ecef81df472a4cceb0"
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
-"checksum mdbook 0.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "1ee8ba20c002000546681dc78d7f7e91fd35832058b1e2fdd492ca842bb6e9be"
+"checksum mdbook 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fef236caad7ba3b5b3944df946f19ab3e190bca53c111dd00fe05fa8d879f2fd"
"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
"checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4"
"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
"checksum rls-analysis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "38841e3c5271715a574ac220d9b408b59ed9e2626909c3bc54b5853b4eaadb7b"
"checksum rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8024f1feaca72d0aa4ae1e2a8d454a31b9a33ed02f8d0e9c8559bf53c267ec3c"
+"checksum rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bea04462e94b5512a78499837eecb7db182ff082144cd1b4bc32ef5d43de6510"
"checksum rls-rustc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85cfb9dde19e313da3e47738008f8a472e470cc42d910b71595a9238494701f2"
"checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
"checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff"
"checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb"
"checksum shared_child 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "099b38928dbe4a0a01fcd8c233183072f14a7d126a34bed05880869be66e14cc"
"checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8"
+"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
"checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537"
"checksum smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f8266519bc1d17d0b5b16f6c21295625d562841c708f6376f49028a43e9c11e"
"checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9"
"checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098"
"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4"
"checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e"
+"checksum toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6854664bfc6df0360c695480836ee90e2d0c965f06db291d10be9344792d43e8"
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
"checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f"
"checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946"
"tools/rls",
"tools/rustfmt",
"tools/miri",
+ "tools/rustdoc-themes",
# FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude
"tools/rls/test_data/bin_lib",
"tools/rls/test_data/borrow_error",
-Subproject commit 1c9bf65aa0e371b84755a8ddd6e79497fac57171
+Subproject commit 17841e155edf858c8ea7802dd5f5ecbef54b989f
serde_json = "1.0.2"
toml = "0.4"
lazy_static = "0.2"
+time = "0.1"
test::HostCompiletest, test::Crate, test::CrateLibrustc, test::Rustdoc,
test::Linkcheck, test::Cargotest, test::Cargo, test::Rls, test::Docs,
test::ErrorIndex, test::Distcheck, test::Rustfmt, test::Miri, test::Clippy,
- test::RustdocJS),
+ test::RustdocJS, test::RustdocTheme),
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon,
// build scripts in that situation.
//
// If LLVM support is disabled we need to use the snapshot compiler to compile
- // build scripts, as the new compiler doesnt support executables.
+ // build scripts, as the new compiler doesn't support executables.
if mode == Mode::Libstd || !self.build.config.llvm_enabled {
cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc)
.env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir());
//
// FIXME: the guard against msvc shouldn't need to be here
if !target.contains("msvc") {
- let cc = self.cc(target);
- cargo.env(format!("CC_{}", target), cc)
- .env("CC", cc);
+ let ccache = self.config.ccache.as_ref();
+ let ccacheify = |s: &Path| {
+ let ccache = match ccache {
+ Some(ref s) => s,
+ None => return s.display().to_string(),
+ };
+ // FIXME: the cc-rs crate only recognizes the literal strings
+ // `ccache` and `sccache` when doing caching compilations, so we
+ // mirror that here. It should probably be fixed upstream to
+ // accept a new env var or otherwise work with custom ccache
+ // vars.
+ match &ccache[..] {
+ "ccache" | "sccache" => format!("{} {}", ccache, s.display()),
+ _ => s.display().to_string(),
+ }
+ };
+ let cc = ccacheify(&self.cc(target));
+ cargo.env(format!("CC_{}", target), &cc)
+ .env("CC", &cc);
let cflags = self.cflags(target).join(" ");
cargo.env(format!("CFLAGS_{}", target), cflags.clone())
}
if let Ok(cxx) = self.cxx(target) {
- cargo.env(format!("CXX_{}", target), cxx)
- .env("CXX", cxx)
+ let cxx = ccacheify(&cxx);
+ cargo.env(format!("CXX_{}", target), &cxx)
+ .env("CXX", &cxx)
.env(format!("CXXFLAGS_{}", target), cflags.clone())
.env("CXXFLAGS", cflags);
}
pub fn librustc_stamp(build: &Build, compiler: Compiler, target: Interned<String>) -> PathBuf {
build.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp")
}
-
//! This module implements parsing `config.toml` configuration files to tweak
//! how the build runs.
-use std::collections::HashMap;
+use std::collections::{HashMap, HashSet};
use std::env;
use std::fs::File;
use std::io::prelude::*;
pub target_config: HashMap<Interned<String>, Target>,
pub full_bootstrap: bool,
pub extended: bool,
+ pub tools: Option<HashSet<String>>,
pub sanitizers: bool,
pub profiler: bool,
pub ignore_git: bool,
python: Option<String>,
full_bootstrap: Option<bool>,
extended: Option<bool>,
+ tools: Option<HashSet<String>>,
verbose: Option<usize>,
sanitizers: Option<bool>,
profiler: Option<bool>,
set(&mut config.vendor, build.vendor);
set(&mut config.full_bootstrap, build.full_bootstrap);
set(&mut config.extended, build.extended);
+ config.tools = build.tools;
set(&mut config.verbose, build.verbose);
set(&mut config.sanitizers, build.sanitizers);
set(&mut config.profiler, build.profiler);
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two")
o("extended", "build.extended", "build an extended rust tool set")
+v("tools", "build.tools", "List of extended tools will be installed")
v("build", "build.build", "GNUs ./configure syntax LLVM build triple")
v("host", None, "GNUs ./configure syntax LLVM host triples")
v("target", None, "GNUs ./configure syntax LLVM target triples")
use util::{cp_r, libdir, is_dylib, cp_filtered, copy, replace_in_file};
use builder::{Builder, RunConfig, ShouldRun, Step};
use compile;
+use native;
use tool::{self, Tool};
use cache::{INTERNER, Interned};
+use time;
pub fn pkgname(build: &Build, component: &str) -> String {
if component == "cargo" {
t!(fs::create_dir_all(image.join("share/man/man1")));
let man_src = build.src.join("src/doc/man");
let man_dst = image.join("share/man/man1");
- let date_output = output(Command::new("date").arg("+%B %Y"));
- let month_year = date_output.trim();
+ let month_year = t!(time::strftime("%B %Y", &time::now()));
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
// to hardlink, and we don't want to edit the source templates
for entry_result in t!(fs::read_dir(man_src)) {
t!(fs::copy(&page_src, &page_dst));
// template in month/year and version number
replace_in_file(&page_dst,
- &[("<INSERT DATE HERE>", month_year),
+ &[("<INSERT DATE HERE>", &month_year),
("<INSERT VERSION HERE>", channel::CFG_RELEASE_NUM)]);
}
.arg("--vers").arg(CARGO_VENDOR_VERSION)
.arg("cargo-vendor")
.env("RUSTC", &build.initial_rustc);
+ if let Some(dir) = build.openssl_install_dir(build.config.build) {
+ builder.ensure(native::Openssl {
+ target: build.config.build,
+ });
+ cmd.env("OPENSSL_DIR", dir);
+ }
build.run(&mut cmd);
}
use builder::{Builder, RunConfig, ShouldRun, Step};
use cache::Interned;
+use config::Config;
pub fn install_docs(builder: &Builder, stage: u32, host: Interned<String>) {
install_sh(builder, "docs", "rust-docs", stage, Some(host));
pub host: Interned<String>,
}
+ impl $name {
+ #[allow(dead_code)]
+ fn should_build(config: &Config) -> bool {
+ config.extended && config.tools.as_ref()
+ .map_or(true, |t| t.contains($path))
+ }
+
+ #[allow(dead_code)]
+ fn should_install(builder: &Builder) -> bool {
+ builder.config.tools.as_ref().map_or(false, |t| t.contains($path))
+ }
+ }
+
impl Step for $name {
type Output = ();
const DEFAULT: bool = true;
install_std(builder, self.stage, *target);
}
};
- Cargo, "cargo", _config.extended, only_hosts: true, {
+ Cargo, "cargo", Self::should_build(_config), only_hosts: true, {
builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
install_cargo(builder, self.stage, self.target);
};
- Rls, "rls", _config.extended, only_hosts: true, {
- if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() {
+ Rls, "rls", Self::should_build(_config), only_hosts: true, {
+ if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() ||
+ Self::should_install(builder) {
install_rls(builder, self.stage, self.target);
} else {
println!("skipping Install RLS stage{} ({})", self.stage, self.target);
}
};
- Rustfmt, "rustfmt", _config.extended, only_hosts: true, {
- if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() {
+ Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, {
+ if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() ||
+ Self::should_install(builder) {
install_rustfmt(builder, self.stage, self.target);
} else {
println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target);
}
};
- Analysis, "analysis", _config.extended, only_hosts: false, {
+ Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
builder.ensure(dist::Analysis {
compiler: builder.compiler(self.stage, self.host),
target: self.target
});
install_analysis(builder, self.stage, self.target);
};
- Src, "src", _config.extended, only_hosts: true, {
+ Src, "src", Self::should_build(_config) , only_hosts: true, {
builder.ensure(dist::Src);
install_src(builder, self.stage);
}, ONLY_BUILD;
extern crate getopts;
extern crate num_cpus;
extern crate toml;
+extern crate time;
#[cfg(unix)]
extern crate libc;
}
}
- /// Returns the path to the linker for the given target if it needs to be overriden.
+ /// Returns the path to the linker for the given target if it needs to be overridden.
fn linker(&self, target: Interned<String>) -> Option<&Path> {
if let Some(linker) = self.config.target_config.get(&target)
.and_then(|c| c.linker.as_ref()) {
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
+ // By default, LLVM will automatically find OCaml and, if it finds it,
+ // install the LLVM bindings in LLVM_OCAML_INSTALL_PATH, which defaults
+ // to /usr/bin/ocaml.
+ // This causes problem for non-root builds of Rust. Side-step the issue
+ // by setting LLVM_OCAML_INSTALL_PATH to a relative path, so it installs
+ // in the prefix.
+ cfg.define("LLVM_OCAML_INSTALL_PATH",
+ env::var_os("LLVM_OCAML_INSTALL_PATH").unwrap_or_else(|| "usr/lib/ocaml".into()));
// This setting makes the LLVM tools link to the dynamic LLVM library,
// which saves both memory during parallel links and overall disk space
}
// http://llvm.org/docs/HowToCrossCompileLLVM.html
- if target != build.build {
+ if target != build.build && !emscripten {
builder.ensure(Llvm {
target: build.build,
emscripten: false,
let _time = util::timeit();
try_run(build, builder.tool_cmd(Tool::Linkchecker)
- .arg(build.out.join(host).join("doc")));
+ .arg(build.out.join(host).join("doc")));
}
fn should_run(run: ShouldRun) -> ShouldRun {
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
}
+#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
+pub struct RustdocTheme {
+ pub compiler: Compiler,
+}
+
+impl Step for RustdocTheme {
+ type Output = ();
+ const DEFAULT: bool = true;
+ const ONLY_HOSTS: bool = true;
+
+ fn should_run(run: ShouldRun) -> ShouldRun {
+ run.path("src/tools/rustdoc-themes")
+ }
+
+ fn make_run(run: RunConfig) {
+ let compiler = run.builder.compiler(run.builder.top_stage, run.host);
+
+ run.builder.ensure(RustdocTheme {
+ compiler: compiler,
+ });
+ }
+
+ fn run(self, builder: &Builder) {
+ let rustdoc = builder.rustdoc(self.compiler.host);
+ let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
+ cmd.arg(rustdoc.to_str().unwrap())
+ .arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap())
+ .env("RUSTC_STAGE", self.compiler.stage.to_string())
+ .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
+ .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
+ .env("CFG_RELEASE_CHANNEL", &builder.build.config.channel)
+ .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
+ .env("RUSTDOC_CRATE_VERSION", builder.build.rust_version())
+ .env("RUSTC_BOOTSTRAP", "1");
+ if let Some(linker) = builder.build.linker(self.compiler.host) {
+ cmd.env("RUSTC_TARGET_LINKER", linker);
+ }
+ try_run(builder.build, &mut cmd);
+ }
+}
+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocJS {
pub host: Interned<String>,
mode: "incremental",
suite: "incremental-fulldeps",
},
- Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" },
Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" },
Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" },
Test { path: "src/test/run-pass-valgrind/pretty", mode: "pretty", suite: "run-pass-valgrind" },
Test { path: "src/test/run-pass-fulldeps/pretty", mode: "pretty", suite: "run-pass-fulldeps" },
Test { path: "src/test/run-fail-fulldeps/pretty", mode: "pretty", suite: "run-fail-fulldeps" },
+ Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" },
];
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
}
}
if suite == "run-make" && !build.config.llvm_enabled {
- println!("Ignoring run-make test suite as they generally dont work without LLVM");
+ println!("Ignoring run-make test suite as they generally don't work without LLVM");
return;
}
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd;
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd;
+ RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::Libstd;
);
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
-FROM ubuntu:16.04
+FROM ubuntu:18.04
RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
--enable-extended \
--enable-sanitizers \
--enable-profiler \
- --enable-emscripten
+ --enable-emscripten \
+ --build=i686-unknown-linux-gnu
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
# This is the only builder which will create source tarballs
# The options, in order, do the following
# * this is an unprivileged build
# * output to a predictable location
-# * disable various uneeded stuff
+# * disable various unneeded stuff
MKUNPRIVED=yes TOOLDIR=/x-tools/x86_64-unknown-netbsd \
MKSHARE=no MKDOC=no MKHTML=no MKINFO=no MKKMOD=no MKLINT=no MKMAN=no MKNLS=no MKPROFILE=no \
hide_output ./build.sh -j10 -m amd64 tools
# If this PR is intended to update one of these tools, do not let the build pass
# when they do not test-pass.
-for TOOL in rls rustfmt miri clippy; do
+for TOOL in rls rustfmt clippy; do
echo "Verifying status of $TOOL..."
if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]src/tools/$TOOL$"; then
echo "This PR updated 'src/tools/$TOOL', verifying if status is 'test-pass'..."
-Subproject commit d3812c3accaee7ad23068ed4fc089cc05c7a538f
+Subproject commit 9b2dcac06c3e23235f8997b3c5f2325a6d3382df
-Subproject commit 194eb8d5f1753fb5f4501011cebdc1b585712474
+Subproject commit ec5660820dea91df470dab0b9eb26ef798f20889
-Subproject commit fec3182d0b0a3cf8122e192b3270064a5b19be5b
+Subproject commit ad5ddd62c098d5b424151beda574ae7df2154df1
-Subproject commit 1d791b55b23ec5389fbd5b3cee80db3f8bbdd162
+Subproject commit 254df654a9b75abf6ca08806535dbe1fad41be3f
-Subproject commit 4ebb8169dfe569b3dcbeab560607800bb717978a
+Subproject commit 919980be7df4ea7d45a9dca8efc34da89bcf7d6b
--- /dev/null
+# `macro_at_most_once_rep`
+
+The tracking issue for this feature is: TODO(mark-i-m)
+
+With this feature gate enabled, one can use `?` as a Kleene operator meaning "0
+or 1 repetitions" in a macro definition. Previously only `+` and `*` were allowed.
+
+For example:
+```rust
+macro_rules! foo {
+ (something $(,)?) // `?` indicates `,` is "optional"...
+ => {}
+}
+```
+
+------------------------
+
+++ /dev/null
-# `match_beginning_vert`
-
-The tracking issue for this feature is [#44101].
-
-With this feature enabled, you are allowed to add a '|' to the beginning of a
-match arm:
-
-```rust
-#![feature(match_beginning_vert)]
-
-enum Foo { A, B, C }
-
-fn main() {
- let x = Foo::A;
- match x {
- | Foo::A
- | Foo::B => println!("AB"),
- | Foo::C => println!("C"),
- }
-}
-```
-
-[#44101]: https://github.com/rust-lang/rust/issues/44101
\ No newline at end of file
+++ /dev/null
-# `use_nested_groups`
-
-The tracking issue for this feature is: [#44494]
-
-[#44494]: https://github.com/rust-lang/rust/issues/44494
-
-------------------------
-
-The `use_nested_groups` feature allows you to import multiple items from a
-complex module tree easily, by nesting different imports in the same
-declaration. For example:
-
-```rust
-#![feature(use_nested_groups)]
-# #![allow(unused_imports, dead_code)]
-#
-# mod foo {
-# pub mod bar {
-# pub type Foo = ();
-# }
-# pub mod baz {
-# pub mod quux {
-# pub type Bar = ();
-# }
-# }
-# }
-
-use foo::{
- bar::{self, Foo},
- baz::{*, quux::Bar},
-};
-#
-# fn main() {}
-```
-
-## Snippet for the book's new features appendix
-
-When stabilizing, add this to
-`src/doc/book/second-edition/src/appendix-07-newest-features.md`:
-
-### Nested groups in `use` declarations
-
-If you have a complex module tree with many different submodules and you need
-to import a few items from each one, it might be useful to group all the
-imports in the same declaration to keep your code clean and avoid repeating the
-base modules' name.
-
-The `use` declaration supports nesting to help you in those cases, both with
-simple imports and glob ones. For example this snippets imports `bar`, `Foo`,
-all the items in `baz` and `Bar`:
-
-```rust
-# #![feature(use_nested_groups)]
-# #![allow(unused_imports, dead_code)]
-#
-# mod foo {
-# pub mod bar {
-# pub type Foo = ();
-# }
-# pub mod baz {
-# pub mod quux {
-# pub type Bar = ();
-# }
-# }
-# }
-#
-use foo::{
- bar::{self, Foo},
- baz::{*, quux::Bar},
-};
-#
-# fn main() {}
-```
-
-## Updated reference
-
-When stabilizing, replace the shortcut list in
-`src/doc/reference/src/items/use-declarations.md` with this updated one:
-
-* Simultaneously binding a list of paths with a common prefix, using the
- glob-like brace syntax `use a::b::{c, d, e::f, g::h::i};`
-* Simultaneously binding a list of paths with a common prefix and their common
- parent module, using the `self` keyword, such as `use a::b::{self, c, d::e};`
-* Rebinding the target name as a new local name, using the syntax `use p::q::r
- as x;`. This can also be used with the last two features:
- `use a::b::{self as ab, c as abc}`.
-* Binding all paths matching a given prefix, using the asterisk wildcard syntax
- `use a::b::*;`.
-* Nesting groups of the previous features multiple times, such as
- `use a::b::{self as ab, c d::{*, e::f}};`
<!-- Upgrade code should be different for each platform -->
<?if $(sys.BUILDARCH)="x64" ?>
<?if $(env.CFG_ABI)="GNU" ?>
- <!-- UpgradeCode shoud stay the same for all MSI versions in channel -->
+ <!-- UpgradeCode should stay the same for all MSI versions in channel -->
<?if $(env.CFG_CHANNEL)="stable" ?>
<?define UpgradeCode="B440B077-F8D1-4730-8E1D-D6D37702B4CE" ?>
<?elseif $(env.CFG_CHANNEL)="beta" ?>
<!-- Path of cmd.exe for the shortcut -->
<Property Id="SHORTCUTTARGET" Value="%windir%\System32\cmd.exe" />
- <!-- Microsoft Installer will resolve any Enviroment Variables in the working directory at install time -->
+ <!-- Microsoft Installer will resolve any Environment Variables in the working directory at install time -->
<Property Id="SHORTCUTWKDIR" Value="%SystemDrive%\" />
<InstallUISequence>
The X86 architecture is specified as multiple files (for the different
instruction sets that x86 supports). To generate the compiler
definitions one needs to pass the script a "platform information file"
- (with the -i flag) next to the files of the different intruction sets.
+ (with the -i flag) next to the files of the different instruction sets.
For example, to generate the X86 compiler-definitions for SSE4.2, just:
python generator.py --format compiler-defs -i x86/info.json sse42.json
(as a fraction, using the ``fractions`` module).
Given an input string and the corresponding float computed via Rust, simply
-decode the float into f * 2^k (for intergers f, k) and the ULP.
+decode the float into f * 2^k (for integers f, k) and the ULP.
We can now easily compute the error and check if it is within 0.5 ULP as it
should be. Zero and infinites are handled similarly:
# While some portion of DIR does not yet exist...
while test ! -d "$my_directory_path"; do
# ...make a list in topmost first order. Use a colon delimited
- # list incase some portion of path contains whitespace.
+ # list in case some portion of path contains whitespace.
my_dir_list="$my_directory_path:$my_dir_list"
# If the last portion added has no slash in it, the list is done
goto end;
file_header_view_valid = 1;
- // The endianess of the slice may be different than the fat image
+ // The endianness of the slice may be different than the fat image
switch (*(uint32_t *) file_header_view.data)
{
case MH_MAGIC:
-Subproject commit 0a95675bab808c49f86208bacc89c5d9c53ac43f
+Subproject commit 345447948f7a51eca970fa036cefd613d54a4f79
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[cfg(stage0)]
pub fn of<T: ?Sized + 'static>() -> TypeId {
TypeId {
t: unsafe { intrinsics::type_id::<T>() },
}
}
+
+ /// Returns the `TypeId` of the type this generic function has been
+ /// instantiated with.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::any::{Any, TypeId};
+ ///
+ /// fn is_string<T: ?Sized + Any>(_s: &T) -> bool {
+ /// TypeId::of::<String>() == TypeId::of::<T>()
+ /// }
+ ///
+ /// fn main() {
+ /// assert_eq!(is_string(&0), false);
+ /// assert_eq!(is_string(&"cookie monster".to_string()), true);
+ /// }
+ /// ```
+ #[stable(feature = "rust1", since = "1.0.0")]
+ #[rustc_const_unstable(feature="const_type_id")]
+ #[cfg(not(stage0))]
+ pub const fn of<T: ?Sized + 'static>() -> TypeId {
+ TypeId {
+ t: unsafe { intrinsics::type_id::<T>() },
+ }
+ }
}
/// An error which can be returned when parsing a char.
#[stable(feature = "char_from_str", since = "1.20.0")]
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ParseCharError {
kind: CharErrorKind,
}
///
/// # Generic Implementations
///
-/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable
-/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type
-/// `&mut Foo` or `&&mut Foo`)
+/// - `AsMut` auto-dereferences if the inner type is a mutable reference
+/// (e.g.: `foo.as_mut()` will work the same if `foo` has type `&mut Foo`
+/// or `&mut &mut Foo`)
///
/// # Examples
///
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \
- defined in your crate, add `#[derive(Debug)]` or \
- manually implement it"]
+#[rustc_on_unimplemented(
+ on(crate_local, label="`{Self}` cannot be formatted using `:?`; \
+ add `#[derive(Debug)]` or manually implement `{Debug}`"),
+ message="`{Self}` doesn't implement `{Debug}`",
+ label="`{Self}` cannot be formatted using `:?` because it doesn't implement `{Debug}`",
+)]
#[lang = "debug_trait"]
pub trait Debug {
/// Formats the value using the given formatter.
///
/// println!("The origin is: {}", origin);
/// ```
-#[rustc_on_unimplemented = "`{Self}` cannot be formatted with the default \
- formatter; try using `:?` instead if you are using \
- a format string"]
+#[rustc_on_unimplemented(
+ message="`{Self}` doesn't implement `{Display}`",
+ label="`{Self}` cannot be formatted with the default formatter; \
+ try using `:?` instead if you are using a format string",
+)]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Display {
/// Formats the value using the given formatter.
/// [module-level documentation]: index.html
/// [impl]: index.html#implementing-iterator
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling \
- `.iter()` or a similar method"]
+#[rustc_on_unimplemented(
+ on(
+ _Self="&str",
+ label="`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
+ ),
+ label="`{Self}` is not an iterator; maybe try calling `.iter()` or a similar method"
+)]
#[doc(spotlight)]
pub trait Iterator {
/// The type of the elements being iterated over.
/// Folding is useful whenever you have a collection of something, and want
/// to produce a single value from it.
///
+ /// Note: `fold()`, and similar methods that traverse the entire iterator,
+ /// may not terminate for infinite iterators, even on traits for which a
+ /// result is determinable in finite time.
+ ///
/// # Examples
///
/// Basic usage:
//!
//! This will print the numbers `0` through `4`, each on their own line.
//!
+//! Bear in mind that methods on infinite iterators, even those for which a
+//! result can be determined mathematically in finite time, may not terminate.
+//! Specifically, methods such as [`min`], which in the general case require
+//! traversing every element in the iterator, are likely not to return
+//! successfully for any infinite iterators.
+//!
+//! ```no_run
+//! let ones = std::iter::repeat(1);
+//! let least = ones.min().unwrap(); // Oh no! An infinite loop!
+//! // `ones.min()` causes an infinite loop, so we won't reach this point!
+//! println!("The smallest number one is {}.", least);
+//! ```
+//!
//! [`take`]: trait.Iterator.html#method.take
+//! [`min`]: trait.Iterator.html#method.min
#![stable(feature = "rust1", since = "1.0.0")]
#[unstable(feature = "fused", issue = "35602")]
impl<I> FusedIterator for Take<I> where I: FusedIterator {}
+#[unstable(feature = "trusted_len", issue = "37572")]
+unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}
+
/// An iterator to maintain state while iterating another iterator.
///
/// This `struct` is created by the [`scan`] method on [`Iterator`]. See its
use convert::TryFrom;
use mem;
-use ops::{self, Add, Sub};
+use ops::{self, Add, Sub, Try};
use usize;
use super::{FusedIterator, TrustedLen};
#[unstable(feature = "fused", issue = "35602")]
impl<A: Step> FusedIterator for ops::RangeFrom<A> {}
+#[unstable(feature = "trusted_len", issue = "37572")]
+unsafe impl<A: Step> TrustedLen for ops::RangeFrom<A> {}
+
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
impl<A: Step> Iterator for ops::RangeInclusive<A> {
type Item = A;
#[inline]
fn next(&mut self) -> Option<A> {
- use cmp::Ordering::*;
-
- match self.start.partial_cmp(&self.end) {
- Some(Less) => {
+ if self.start <= self.end {
+ if self.start < self.end {
let n = self.start.add_one();
Some(mem::replace(&mut self.start, n))
- },
- Some(Equal) => {
+ } else {
let last = self.start.replace_one();
self.end.replace_zero();
Some(last)
- },
- _ => None,
+ }
+ } else {
+ None
}
}
fn max(mut self) -> Option<A> {
self.next_back()
}
+
+ #[inline]
+ fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R where
+ Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
+ {
+ let mut accum = init;
+ if self.start <= self.end {
+ loop {
+ let (x, done) =
+ if self.start < self.end {
+ let n = self.start.add_one();
+ (mem::replace(&mut self.start, n), false)
+ } else {
+ self.end.replace_zero();
+ (self.start.replace_one(), true)
+ };
+ accum = f(accum, x)?;
+ if done { break }
+ }
+ }
+ Try::from_ok(accum)
+ }
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
#[inline]
fn next_back(&mut self) -> Option<A> {
- use cmp::Ordering::*;
-
- match self.start.partial_cmp(&self.end) {
- Some(Less) => {
+ if self.start <= self.end {
+ if self.start < self.end {
let n = self.end.sub_one();
Some(mem::replace(&mut self.end, n))
- },
- Some(Equal) => {
+ } else {
let last = self.end.replace_zero();
self.start.replace_one();
Some(last)
- },
- _ => None,
+ }
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R where
+ Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
+ {
+ let mut accum = init;
+ if self.start <= self.end {
+ loop {
+ let (x, done) =
+ if self.start < self.end {
+ let n = self.end.sub_one();
+ (mem::replace(&mut self.end, n), false)
+ } else {
+ self.start.replace_one();
+ (self.end.replace_zero(), true)
+ };
+ accum = f(accum, x)?;
+ if done { break }
+ }
}
+ Try::from_ok(accum)
}
}
#[unstable(feature = "fused", issue = "35602")]
impl<A: Clone> FusedIterator for Repeat<A> {}
+#[unstable(feature = "trusted_len", issue = "37572")]
+unsafe impl<A: Clone> TrustedLen for Repeat<A> {}
+
/// Creates a new iterator that endlessly repeats a single element.
///
/// The `repeat()` function repeats a single value over and over and over and
/// The iterator reports a size hint where it is either exact
/// (lower bound is equal to upper bound), or the upper bound is [`None`].
/// The upper bound must only be [`None`] if the actual iterator length is
-/// larger than [`usize::MAX`].
+/// larger than [`usize::MAX`]. In that case, the lower bound must be
+/// [`usize::MAX`], resulting in a [`.size_hint`] of `(usize::MAX, None)`.
///
-/// The iterator must produce exactly the number of elements it reported.
+/// The iterator must produce exactly the number of elements it reported
+/// or diverge before reaching the end.
///
/// # Safety
///
#![feature(untagged_unions)]
#![feature(unwind_attributes)]
#![feature(doc_spotlight)]
+#![feature(rustc_const_unstable)]
#[prelude_import]
#[allow(unused)]
/// }
/// }
///
-/// // The prefered method of quick returning Errors
+/// // The preferred method of quick returning Errors
/// fn write_to_file_question() -> Result<(), MyError> {
/// let mut file = File::create("my_best_friends.txt")?;
/// file.write_all(b"This is a list of my best friends.")?;
/// ```
#[lang = "add"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} + {RHS}`"]
+#[rustc_on_unimplemented(
+ on(
+ all(_Self="{integer}", RHS="{float}"),
+ message="cannot add a float to an integer",
+ ),
+ on(
+ all(_Self="{float}", RHS="{integer}"),
+ message="cannot add an integer to a float",
+ ),
+ message="cannot add `{RHS}` to `{Self}`",
+ label="no implementation for `{Self} + {RHS}`",
+)]
pub trait Add<RHS=Self> {
/// The resulting type after applying the `+` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "sub"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} - {RHS}`"]
+#[rustc_on_unimplemented(message="cannot subtract `{RHS}` from `{Self}`",
+ label="no implementation for `{Self} - {RHS}`")]
pub trait Sub<RHS=Self> {
/// The resulting type after applying the `-` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "mul"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} * {RHS}`"]
+#[rustc_on_unimplemented(message="cannot multiply `{RHS}` to `{Self}`",
+ label="no implementation for `{Self} * {RHS}`")]
pub trait Mul<RHS=Self> {
/// The resulting type after applying the `*` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "div"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} / {RHS}`"]
+#[rustc_on_unimplemented(message="cannot divide `{Self}` by `{RHS}`",
+ label="no implementation for `{Self} / {RHS}`")]
pub trait Div<RHS=Self> {
/// The resulting type after applying the `/` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "rem"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} % {RHS}`"]
+#[rustc_on_unimplemented(message="cannot mod `{Self}` by `{RHS}`",
+ label="no implementation for `{Self} % {RHS}`")]
pub trait Rem<RHS=Self> {
/// The resulting type after applying the `%` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "add_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} += {Rhs}`"]
+#[rustc_on_unimplemented(message="cannot add-assign `{Rhs}` to `{Self}`",
+ label="no implementation for `{Self} += {Rhs}`")]
pub trait AddAssign<Rhs=Self> {
/// Performs the `+=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "sub_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} -= {Rhs}`"]
+#[rustc_on_unimplemented(message="cannot subtract-assign `{Rhs}` from `{Self}`",
+ label="no implementation for `{Self} -= {Rhs}`")]
pub trait SubAssign<Rhs=Self> {
/// Performs the `-=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "mul_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} *= {Rhs}`"]
+#[rustc_on_unimplemented(message="cannot multiply-assign `{Rhs}` to `{Self}`",
+ label="no implementation for `{Self} *= {Rhs}`")]
pub trait MulAssign<Rhs=Self> {
/// Performs the `*=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "div_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} /= {Rhs}`"]
+#[rustc_on_unimplemented(message="cannot divide-assign `{Self}` by `{Rhs}`",
+ label="no implementation for `{Self} /= {Rhs}`")]
pub trait DivAssign<Rhs=Self> {
/// Performs the `/=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "rem_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} %= {Rhs}`"]
+#[rustc_on_unimplemented(message="cannot mod-assign `{Self}` by `{Rhs}``",
+ label="no implementation for `{Self} %= {Rhs}`")]
pub trait RemAssign<Rhs=Self> {
/// Performs the `%=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "bitand"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} & {RHS}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} & {RHS}`",
+ label="no implementation for `{Self} & {RHS}`")]
pub trait BitAnd<RHS=Self> {
/// The resulting type after applying the `&` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "bitor"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} | {RHS}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} | {RHS}`",
+ label="no implementation for `{Self} | {RHS}`")]
pub trait BitOr<RHS=Self> {
/// The resulting type after applying the `|` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "bitxor"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} ^ {RHS}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} ^ {RHS}`",
+ label="no implementation for `{Self} ^ {RHS}`")]
pub trait BitXor<RHS=Self> {
/// The resulting type after applying the `^` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "shl"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} << {RHS}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} << {RHS}`",
+ label="no implementation for `{Self} << {RHS}`")]
pub trait Shl<RHS> {
/// The resulting type after applying the `<<` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "shr"]
#[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} >> {RHS}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} >> {RHS}`",
+ label="no implementation for `{Self} >> {RHS}`")]
pub trait Shr<RHS> {
/// The resulting type after applying the `>>` operator.
#[stable(feature = "rust1", since = "1.0.0")]
/// ```
#[lang = "bitand_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} &= {Rhs}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} &= {Rhs}`",
+ label="no implementation for `{Self} &= {Rhs}`")]
pub trait BitAndAssign<Rhs=Self> {
/// Performs the `&=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "bitor_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} |= {Rhs}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} |= {Rhs}`",
+ label="no implementation for `{Self} |= {Rhs}`")]
pub trait BitOrAssign<Rhs=Self> {
/// Performs the `|=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "bitxor_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} ^= {Rhs}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} ^= {Rhs}`",
+ label="no implementation for `{Self} ^= {Rhs}`")]
pub trait BitXorAssign<Rhs=Self> {
/// Performs the `^=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "shl_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} <<= {Rhs}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} <<= {Rhs}`",
+ label="no implementation for `{Self} <<= {Rhs}`")]
pub trait ShlAssign<Rhs> {
/// Performs the `<<=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
/// ```
#[lang = "shr_assign"]
#[stable(feature = "op_assign_traits", since = "1.8.0")]
-#[rustc_on_unimplemented = "no implementation for `{Self} >>= {Rhs}`"]
+#[rustc_on_unimplemented(message="no implementation for `{Self} >>= {Rhs}`",
+ label="no implementation for `{Self} >>= {Rhs}`")]
pub trait ShrAssign<Rhs=Self> {
/// Performs the `>>=` operation.
#[stable(feature = "op_assign_traits", since = "1.8.0")]
}
/// Previous name of `NonNull`.
-#[rustc_deprecated(since = "1.24", reason = "renamed to `NonNull`")]
+#[rustc_deprecated(since = "1.25.0", reason = "renamed to `NonNull`")]
#[unstable(feature = "shared", issue = "27730")]
pub type Shared<T> = NonNull<T>;
/// Usually this won't be necessary; covariance is correct for most safe abstractions,
/// such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they
/// provide a public API that follows the normal shared XOR mutable rules of Rust.
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
pub struct NonNull<T: ?Sized> {
pointer: NonZero<*const T>,
}
-#[stable(feature = "nonnull", since = "1.24.0")]
-impl<T: ?Sized> fmt::Debug for NonNull<T> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Pointer::fmt(&self.as_ptr(), f)
- }
-}
-
/// `NonNull` pointers are not `Send` because the data they reference may be aliased.
// NB: This impl is unnecessary, but should provide better error messages.
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized> !Send for NonNull<T> { }
/// `NonNull` pointers are not `Sync` because the data they reference may be aliased.
// NB: This impl is unnecessary, but should provide better error messages.
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized> !Sync for NonNull<T> { }
impl<T: Sized> NonNull<T> {
///
/// This is useful for initializing types which lazily allocate, like
/// `Vec::new` does.
- #[stable(feature = "nonnull", since = "1.24.0")]
+ #[stable(feature = "nonnull", since = "1.25.0")]
pub fn dangling() -> Self {
unsafe {
let ptr = mem::align_of::<T>() as *mut T;
/// # Safety
///
/// `ptr` must be non-null.
- #[stable(feature = "nonnull", since = "1.24.0")]
+ #[stable(feature = "nonnull", since = "1.25.0")]
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
NonNull { pointer: NonZero::new_unchecked(ptr) }
}
/// Creates a new `NonNull` if `ptr` is non-null.
- #[stable(feature = "nonnull", since = "1.24.0")]
+ #[stable(feature = "nonnull", since = "1.25.0")]
pub fn new(ptr: *mut T) -> Option<Self> {
NonZero::new(ptr as *const T).map(|nz| NonNull { pointer: nz })
}
/// Acquires the underlying `*mut` pointer.
- #[stable(feature = "nonnull", since = "1.24.0")]
+ #[stable(feature = "nonnull", since = "1.25.0")]
pub fn as_ptr(self) -> *mut T {
self.pointer.get() as *mut T
}
/// The resulting lifetime is bound to self so this behaves "as if"
/// it were actually an instance of T that is getting borrowed. If a longer
/// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
- #[stable(feature = "nonnull", since = "1.24.0")]
+ #[stable(feature = "nonnull", since = "1.25.0")]
pub unsafe fn as_ref(&self) -> &T {
&*self.as_ptr()
}
/// The resulting lifetime is bound to self so this behaves "as if"
/// it were actually an instance of T that is getting borrowed. If a longer
/// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
- #[stable(feature = "nonnull", since = "1.24.0")]
+ #[stable(feature = "nonnull", since = "1.25.0")]
pub unsafe fn as_mut(&mut self) -> &mut T {
&mut *self.as_ptr()
}
+
+ /// Cast to a pointer of another type
+ #[unstable(feature = "nonnull_cast", issue = "47653")]
+ pub fn cast<U>(self) -> NonNull<U> {
+ unsafe {
+ NonNull::new_unchecked(self.as_ptr() as *mut U)
+ }
+ }
}
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized> Clone for NonNull<T> {
fn clone(&self) -> Self {
*self
}
}
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized> Copy for NonNull<T> { }
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> { }
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
+impl<T: ?Sized> fmt::Debug for NonNull<T> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fmt::Pointer::fmt(&self.as_ptr(), f)
+ }
+}
+
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized> fmt::Pointer for NonNull<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Pointer::fmt(&self.as_ptr(), f)
}
}
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
+impl<T: ?Sized> Eq for NonNull<T> {}
+
+#[stable(feature = "nonnull", since = "1.25.0")]
+impl<T: ?Sized> PartialEq for NonNull<T> {
+ fn eq(&self, other: &Self) -> bool {
+ self.as_ptr() == other.as_ptr()
+ }
+}
+
+#[stable(feature = "nonnull", since = "1.25.0")]
+impl<T: ?Sized> Ord for NonNull<T> {
+ fn cmp(&self, other: &Self) -> Ordering {
+ self.as_ptr().cmp(&other.as_ptr())
+ }
+}
+
+#[stable(feature = "nonnull", since = "1.25.0")]
+impl<T: ?Sized> PartialOrd for NonNull<T> {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ self.as_ptr().partial_cmp(&other.as_ptr())
+ }
+}
+
+#[stable(feature = "nonnull", since = "1.25.0")]
+impl<T: ?Sized> hash::Hash for NonNull<T> {
+ fn hash<H: hash::Hasher>(&self, state: &mut H) {
+ self.as_ptr().hash(state)
+ }
+}
+
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: ?Sized> From<Unique<T>> for NonNull<T> {
fn from(unique: Unique<T>) -> Self {
NonNull { pointer: unique.pointer }
}
}
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
fn from(reference: &'a mut T) -> Self {
NonNull { pointer: NonZero::from(reference) }
}
}
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<'a, T: ?Sized> From<&'a T> for NonNull<T> {
fn from(reference: &'a T) -> Self {
NonNull { pointer: NonZero::from(reference) }
$stable_debug:meta,
$stable_access:meta,
$stable_from:meta,
+ $stable_nand:meta,
$s_int_type:expr, $int_ref:expr,
$int_type:ident $atomic_type:ident $atomic_init:ident) => {
/// An integer type which can be safely shared between threads.
unsafe { atomic_and(self.v.get(), val, order) }
}
+ /// Bitwise "nand" with the current value.
+ ///
+ /// Performs a bitwise "nand" operation on the current value and the argument `val`, and
+ /// sets the new value to the result.
+ ///
+ /// Returns the previous value.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(atomic_nand)]
+ ///
+ /// use std::sync::atomic::{AtomicIsize, Ordering};
+ ///
+ /// let foo = AtomicIsize::new(0xf731);
+ /// assert_eq!(foo.fetch_nand(0x137f, Ordering::SeqCst), 0xf731);
+ /// assert_eq!(foo.load(Ordering::SeqCst), !(0xf731 & 0x137f));
+ #[inline]
+ #[$stable_nand]
+ pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type {
+ unsafe { atomic_nand(self.v.get(), val, order) }
+ }
+
/// Bitwise "or" with the current value.
///
/// Performs a bitwise "or" operation on the current value and the argument `val`, and
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"i8", "../../../std/primitive.i8.html",
i8 AtomicI8 ATOMIC_I8_INIT
}
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"u8", "../../../std/primitive.u8.html",
u8 AtomicU8 ATOMIC_U8_INIT
}
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"i16", "../../../std/primitive.i16.html",
i16 AtomicI16 ATOMIC_I16_INIT
}
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"u16", "../../../std/primitive.u16.html",
u16 AtomicU16 ATOMIC_U16_INIT
}
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"i32", "../../../std/primitive.i32.html",
i32 AtomicI32 ATOMIC_I32_INIT
}
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"u32", "../../../std/primitive.u32.html",
u32 AtomicU32 ATOMIC_U32_INIT
}
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"i64", "../../../std/primitive.i64.html",
i64 AtomicI64 ATOMIC_I64_INIT
}
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
unstable(feature = "integer_atomics", issue = "32976"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"u64", "../../../std/primitive.u64.html",
u64 AtomicU64 ATOMIC_U64_INIT
}
stable(feature = "atomic_debug", since = "1.3.0"),
stable(feature = "atomic_access", since = "1.15.0"),
stable(feature = "atomic_from", since = "1.23.0"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"isize", "../../../std/primitive.isize.html",
isize AtomicIsize ATOMIC_ISIZE_INIT
}
stable(feature = "atomic_debug", since = "1.3.0"),
stable(feature = "atomic_access", since = "1.15.0"),
stable(feature = "atomic_from", since = "1.23.0"),
+ unstable(feature = "atomic_nand", issue = "13226"),
"usize", "../../../std/primitive.usize.html",
usize AtomicUsize ATOMIC_USIZE_INIT
}
}
}
+#[inline]
+unsafe fn atomic_nand<T>(dst: *mut T, val: T, order: Ordering) -> T {
+ match order {
+ Acquire => intrinsics::atomic_nand_acq(dst, val),
+ Release => intrinsics::atomic_nand_rel(dst, val),
+ AcqRel => intrinsics::atomic_nand_acqrel(dst, val),
+ Relaxed => intrinsics::atomic_nand_relaxed(dst, val),
+ SeqCst => intrinsics::atomic_nand(dst, val),
+ __Nonexhaustive => panic!("invalid memory ordering"),
+ }
+}
+
#[inline]
unsafe fn atomic_or<T>(dst: *mut T, val: T, order: Ordering) -> T {
match order {
assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
}
+#[test]
+fn uint_nand() {
+ let x = AtomicUsize::new(0xf731);
+ assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f));
+}
+
#[test]
fn uint_or() {
let x = AtomicUsize::new(0xf731);
assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
}
+#[test]
+fn int_nand() {
+ let x = AtomicIsize::new(0xf731);
+ assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f));
+}
+
#[test]
fn int_or() {
let x = AtomicIsize::new(0xf731);
assert_eq!(r.next_back(), Some(10));
assert_eq!(r, 1..=0);
+ let mut r = 10..=12;
+ assert_eq!(r.next(), Some(10));
+ assert_eq!(r.next(), Some(11));
+ assert_eq!(r.next(), Some(12));
+ assert_eq!(r, 1..=0);
+
+ let mut r = 10..=12;
+ assert_eq!(r.next_back(), Some(12));
+ assert_eq!(r.next_back(), Some(11));
+ assert_eq!(r.next_back(), Some(10));
+ assert_eq!(r, 1..=0);
+
let mut r = 10..=12;
assert_eq!(r.nth(2), Some(12));
assert_eq!(r, 1..=0);
assert_eq!(r.nth(5), None);
assert_eq!(r, 1..=0);
+ let mut r = 100..=10;
+ assert_eq!(r.next(), None);
+ assert_eq!(r, 100..=10);
+
+ let mut r = 100..=10;
+ assert_eq!(r.next_back(), None);
+ assert_eq!(r, 100..=10);
}
#[test]
assert_eq!(r, 16..);
assert_eq!(r.nth(10), Some(26));
assert_eq!(r, 27..);
+
+ assert_eq!((0..).size_hint(), (usize::MAX, None));
+}
+
+fn is_trusted_len<I: TrustedLen>(_: I) {}
+
+#[test]
+fn test_range_from_take() {
+ let mut it = (0..).take(3);
+ assert_eq!(it.next(), Some(0));
+ assert_eq!(it.next(), Some(1));
+ assert_eq!(it.next(), Some(2));
+ assert_eq!(it.next(), None);
+ is_trusted_len((0..).take(3));
+ assert_eq!((0..).take(3).size_hint(), (3, Some(3)));
+ assert_eq!((0..).take(0).size_hint(), (0, Some(0)));
+ assert_eq!((0..).take(usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
+}
+
+#[test]
+fn test_range_from_take_collect() {
+ let v: Vec<_> = (0..).take(3).collect();
+ assert_eq!(v, vec![0, 1, 2]);
}
#[test]
assert_eq!(r.min(), None);
}
+#[test]
+fn test_range_inclusive_folds() {
+ assert_eq!((1..=10).sum::<i32>(), 55);
+ assert_eq!((1..=10).rev().sum::<i32>(), 55);
+
+ let mut it = 40..=50;
+ assert_eq!(it.try_fold(0, i8::checked_add), None);
+ assert_eq!(it, 44..=50);
+ assert_eq!(it.try_rfold(0, i8::checked_add), None);
+ assert_eq!(it, 44..=47);
+
+ let mut it = 10..=20;
+ assert_eq!(it.try_fold(0, |a,b| Some(a+b)), Some(165));
+ assert_eq!(it, 1..=0);
+
+ let mut it = 10..=20;
+ assert_eq!(it.try_rfold(0, |a,b| Some(a+b)), Some(165));
+ assert_eq!(it, 1..=0);
+}
+
#[test]
fn test_repeat() {
let mut it = repeat(42);
assert_eq!(it.next(), Some(42));
assert_eq!(it.next(), Some(42));
assert_eq!(it.next(), Some(42));
+ assert_eq!(repeat(42).size_hint(), (usize::MAX, None));
+}
+
+#[test]
+fn test_repeat_take() {
+ let mut it = repeat(42).take(3);
+ assert_eq!(it.next(), Some(42));
+ assert_eq!(it.next(), Some(42));
+ assert_eq!(it.next(), Some(42));
+ assert_eq!(it.next(), None);
+ is_trusted_len(repeat(42).take(3));
+ assert_eq!(repeat(42).take(3).size_hint(), (3, Some(3)));
+ assert_eq!(repeat(42).take(0).size_hint(), (0, Some(0)));
+ assert_eq!(repeat(42).take(usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
+}
+
+#[test]
+fn test_repeat_take_collect() {
+ let v: Vec<_> = repeat(42).take(3).collect();
+ assert_eq!(v, vec![42, 42, 42]);
}
#[test]
#![feature(try_from)]
#![feature(try_trait)]
#![feature(exact_chunks)]
+#![feature(atomic_nand)]
extern crate core;
extern crate test;
/// Enum describing where an argument for a format can be located.
#[derive(Copy, Clone, PartialEq)]
pub enum Position<'a> {
- /// The arugment is implied to be located at an index
+ /// The argument is implied to be located at an index
ArgumentImplicitlyIs(usize),
/// The argument is located at a specific index given in the format
ArgumentIs(usize),
})
}
- DotEq => unreachable!(),
+ DotEq => joint!('.', Eq),
OpenDelim(..) | CloseDelim(..) => unreachable!(),
Whitespace | Comment | Shebang(..) | Eof => unreachable!(),
};
}
```
+### The trait cannot contain associated constants
+
+Just like static functions, associated constants aren't stored on the method
+table. If the trait or any subtrait contain an associated constant, they cannot
+be made into an object.
+
+```compile_fail,E0038
+trait Foo {
+ const X: i32;
+}
+
+impl Foo {}
+```
+
+A simple workaround is to use a helper method instead:
+
+```
+trait Foo {
+ fn x(&self) -> i32;
+}
+```
+
### The trait cannot use `Self` as a type parameter in the supertrait listing
This is similar to the second sub-error, but subtler. It happens in situations
walk_list!(visitor, visit_expr, subexpressions);
}
ExprCall(ref callee_expression, ref arguments) => {
+ visitor.visit_expr(callee_expression);
walk_list!(visitor, visit_expr, arguments);
- visitor.visit_expr(callee_expression)
}
ExprMethodCall(ref segment, _, ref arguments) => {
visitor.visit_path_segment(expression.span, segment);
impl_stable_hash_for!(struct mir::GeneratorLayout<'tcx> { fields });
impl_stable_hash_for!(struct mir::SourceInfo { span, scope });
impl_stable_hash_for!(enum mir::Mutability { Mut, Not });
-impl_stable_hash_for!(enum mir::BorrowKind { Shared, Unique, Mut });
impl_stable_hash_for!(enum mir::LocalKind { Var, Temp, Arg, ReturnPointer });
impl_stable_hash_for!(struct mir::LocalDecl<'tcx> {
mutability,
impl_stable_hash_for!(struct mir::UnsafetyViolation { source_info, description, kind });
impl_stable_hash_for!(struct mir::UnsafetyCheckResult { violations, unsafe_blocks });
+impl<'gcx> HashStable<StableHashingContext<'gcx>>
+for mir::BorrowKind {
+ #[inline]
+ fn hash_stable<W: StableHasherResult>(&self,
+ hcx: &mut StableHashingContext<'gcx>,
+ hasher: &mut StableHasher<W>) {
+ mem::discriminant(self).hash_stable(hcx, hasher);
+
+ match *self {
+ mir::BorrowKind::Shared |
+ mir::BorrowKind::Unique => {}
+ mir::BorrowKind::Mut { allow_two_phase_borrow } => {
+ allow_two_phase_borrow.hash_stable(hcx, hasher);
+ }
+ }
+ }
+}
+
+
impl<'gcx> HashStable<StableHashingContext<'gcx>>
for mir::UnsafetyViolationKind {
#[inline]
target.hash_stable(hcx, hasher);
}
}
+ mir::TerminatorKind::FalseUnwind { ref real_target, ref unwind } => {
+ real_target.hash_stable(hcx, hasher);
+ unwind.hash_stable(hcx, hasher);
+ }
}
}
}
impl_stable_hash_for!(struct ty::adjustment::OverloadedDeref<'tcx> { region, mutbl });
impl_stable_hash_for!(struct ty::UpvarBorrow<'tcx> { kind, region });
+impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::adjustment::AutoBorrowMutability {
+ fn hash_stable<W: StableHasherResult>(&self,
+ hcx: &mut StableHashingContext<'gcx>,
+ hasher: &mut StableHasher<W>) {
+ mem::discriminant(self).hash_stable(hcx, hasher);
+ match *self {
+ ty::adjustment::AutoBorrowMutability::Mutable { ref allow_two_phase_borrow } => {
+ allow_two_phase_borrow.hash_stable(hcx, hasher);
+ }
+ ty::adjustment::AutoBorrowMutability::Immutable => {}
+ }
+ }
+}
+
impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id });
impl_stable_hash_for!(enum ty::BorrowKind {
#![feature(macro_vis_matcher)]
#![feature(match_default_bindings)]
#![feature(never_type)]
+#![feature(non_exhaustive)]
#![feature(nonzero)]
#![feature(quote)]
#![feature(refcell_replace_swap)]
// Put the lint store levels and passes back in the session.
cx.lint_sess.restore(&sess.lint_store);
- // Emit all buffered lints from early on in the session now that we've
- // calculated the lint levels for all AST nodes.
- for (_id, lints) in cx.buffered.map {
- for early_lint in lints {
- span_bug!(early_lint.span, "failed to process buffered lint here");
+ // All of the buffered lints should have been emitted at this point.
+ // If not, that means that we somehow buffered a lint for a node id
+ // that was not lint-checked (perhaps it doesn't exist?). This is a bug.
+ //
+ // Rustdoc runs everybody-loops before the early lints and removes
+ // function bodies, so it's totally possible for linted
+ // node ids to not exist (e.g. macros defined within functions for the
+ // unused_macro lint) anymore. So we only run this check
+ // when we're not in rustdoc mode. (see issue #47639)
+ if !sess.opts.actually_rustdoc {
+ for (_id, lints) in cx.buffered.map {
+ for early_lint in lints {
+ span_bug!(early_lint.span, "failed to process buffered lint here");
+ }
}
}
}
err.emit();
this.session.abort_if_errors();
} else {
+ if this.session.teach(&err.get_code().unwrap()) {
+ err.note("If you don't know the basics of Rust, you can go look to the Rust Book \
+ to get started: https://doc.rust-lang.org/book/");
+ }
err.emit();
}
}
expr.span,
cmt_base,
r,
- ty::BorrowKind::from_mutbl(m),
+ ty::BorrowKind::from_mutbl(m.into()),
AutoRef);
}
use hir::def::*;
use ty::{self, TyCtxt};
use lint;
-use util::nodemap::NodeMap;
+use util::nodemap::{NodeMap, NodeSet};
use std::{fmt, usize};
use std::io::prelude::*;
#[derive(Copy, Clone, Debug)]
struct LocalInfo {
id: NodeId,
- name: ast::Name
+ name: ast::Name,
+ is_shorthand: bool,
}
#[derive(Copy, Clone, Debug)]
}
}
+ fn variable_is_shorthand(&self, var: Variable) -> bool {
+ match self.var_kinds[var.get()] {
+ Local(LocalInfo { is_shorthand, .. }) => is_shorthand,
+ Arg(..) | CleanExit => false
+ }
+ }
+
fn set_captures(&mut self, node_id: NodeId, cs: Vec<CaptureInfo>) {
self.capture_info_map.insert(node_id, Rc::new(cs));
}
let name = path1.node;
ir.add_live_node_for_node(p_id, VarDefNode(sp));
ir.add_variable(Local(LocalInfo {
- id: p_id,
- name,
+ id: p_id,
+ name,
+ is_shorthand: false,
}));
});
intravisit::walk_local(ir, local);
fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) {
for pat in &arm.pats {
+ // for struct patterns, take note of which fields used shorthand (`x`
+ // rather than `x: x`)
+ //
+ // FIXME: according to the rust-lang-nursery/rustc-guide book and
+ // librustc/README.md, `NodeId`s are to be phased out in favor of
+ // `HirId`s; however, we need to match the signature of `each_binding`,
+ // which uses `NodeIds`.
+ let mut shorthand_field_ids = NodeSet();
+ if let hir::PatKind::Struct(_, ref fields, _) = pat.node {
+ for field in fields {
+ if field.node.is_shorthand {
+ shorthand_field_ids.insert(field.node.pat.id);
+ }
+ }
+ }
+
pat.each_binding(|bm, p_id, sp, path1| {
debug!("adding local variable {} from match with bm {:?}",
p_id, bm);
ir.add_live_node_for_node(p_id, VarDefNode(sp));
ir.add_variable(Local(LocalInfo {
id: p_id,
- name,
+ name: name,
+ is_shorthand: shorthand_field_ids.contains(&p_id)
}));
})
}
self.assigned_on_exit(ln, var).is_some()
};
+ let suggest_underscore_msg = format!("consider using `_{}` instead",
+ name);
if is_assigned {
- self.ir.tcx.lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp,
- &format!("variable `{}` is assigned to, but never used",
- name),
- &format!("to avoid this warning, consider using `_{}` instead",
- name));
+ self.ir.tcx
+ .lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp,
+ &format!("variable `{}` is assigned to, but never used",
+ name),
+ &suggest_underscore_msg);
} else if name != "self" {
- self.ir.tcx.lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp,
- &format!("unused variable: `{}`", name),
- &format!("to avoid this warning, consider using `_{}` instead",
- name));
+ let msg = format!("unused variable: `{}`", name);
+ let mut err = self.ir.tcx
+ .struct_span_lint_node(lint::builtin::UNUSED_VARIABLES, id, sp, &msg);
+ if self.ir.variable_is_shorthand(var) {
+ err.span_suggestion(sp, "try ignoring the field",
+ format!("{}: _", name));
+ } else {
+ err.span_suggestion_short(sp, &suggest_underscore_msg,
+ format!("_{}", name));
+ }
+ err.emit()
}
}
true
Unique,
/// Data is mutable and not aliasable.
- Mut,
+ Mut {
+ /// True if this borrow arose from method-call auto-ref
+ /// (i.e. `adjustment::Adjust::Borrow`)
+ allow_two_phase_borrow: bool
+ }
+}
+
+impl BorrowKind {
+ pub fn allows_two_phase_borrow(&self) -> bool {
+ match *self {
+ BorrowKind::Shared | BorrowKind::Unique => false,
+ BorrowKind::Mut { allow_two_phase_borrow } => allow_two_phase_borrow,
+ }
+ }
}
///////////////////////////////////////////////////////////////////////////
/// Indicates the end of the dropping of a generator
GeneratorDrop,
+ /// A block where control flow only ever takes one real path, but borrowck
+ /// needs to be more conservative.
FalseEdges {
+ /// The target normal control flow will take
real_target: BasicBlock,
- imaginary_targets: Vec<BasicBlock>
+ /// The list of blocks control flow could conceptually take, but won't
+ /// in practice
+ imaginary_targets: Vec<BasicBlock>,
+ },
+ /// A terminator for blocks that only take one path in reality, but where we
+ /// reserve the right to unwind in borrowck, even if it won't happen in practice.
+ /// This can arise in infinite loops with no function calls for example.
+ FalseUnwind {
+ /// The target normal control flow will take
+ real_target: BasicBlock,
+ /// The imaginary cleanup block link. This particular path will never be taken
+ /// in practice, but in order to avoid fragility we want to always
+ /// consider it in borrowck. We don't want to accept programs which
+ /// pass borrowck only when panic=abort or some assertions are disabled
+ /// due to release vs. debug mode builds. This needs to be an Option because
+ /// of the remove_noop_landing_pads and no_landing_pads passes
+ unwind: Option<BasicBlock>,
},
}
s.extend_from_slice(imaginary_targets);
s.into_cow()
}
+ FalseUnwind { real_target: t, unwind: Some(u) } => vec![t, u].into_cow(),
+ FalseUnwind { real_target: ref t, unwind: None } => slice::from_ref(t).into_cow(),
}
}
s.extend(imaginary_targets.iter_mut());
s
}
+ FalseUnwind { real_target: ref mut t, unwind: Some(ref mut u) } => vec![t, u],
+ FalseUnwind { ref mut real_target, unwind: None } => vec![real_target],
}
}
TerminatorKind::Call { cleanup: ref mut unwind, .. } |
TerminatorKind::Assert { cleanup: ref mut unwind, .. } |
TerminatorKind::DropAndReplace { ref mut unwind, .. } |
- TerminatorKind::Drop { ref mut unwind, .. } => {
+ TerminatorKind::Drop { ref mut unwind, .. } |
+ TerminatorKind::FalseUnwind { ref mut unwind, .. } => {
Some(unwind)
}
}
write!(fmt, ")")
},
- FalseEdges { .. } => write!(fmt, "falseEdges")
+ FalseEdges { .. } => write!(fmt, "falseEdges"),
+ FalseUnwind { .. } => write!(fmt, "falseUnwind"),
}
}
l.resize(imaginary_targets.len() + 1, "imaginary".into());
l
}
+ FalseUnwind { unwind: Some(_), .. } => vec!["real".into(), "cleanup".into()],
+ FalseUnwind { unwind: None, .. } => vec!["real".into()],
}
}
}
Array(Ty<'tcx>),
Tuple,
- /// The second field is variant number (discriminant), it's equal
- /// to 0 for struct and union expressions. The fourth field is
+ /// The second field is the variant index. It's equal to 0 for struct
+ /// and union expressions. The fourth field is
/// active field number and is present only for union expressions
/// -- e.g. for a union expression `SomeUnion { c: .. }`, the
/// active field index would identity the field `c`
Ref(region, borrow_kind, ref place) => {
let kind_str = match borrow_kind {
BorrowKind::Shared => "",
- BorrowKind::Mut | BorrowKind::Unique => "mut ",
+ BorrowKind::Mut { .. } | BorrowKind::Unique => "mut ",
};
// When printing regions, add trailing space if necessary.
/// the location is within this block
pub block: BasicBlock,
- /// the location is the start of the this statement; or, if `statement_index`
+ /// the location is the start of the statement; or, if `statement_index`
/// == num-statements, then the start of the terminator.
pub statement_index: usize,
}
Return => Return,
Unreachable => Unreachable,
FalseEdges { real_target, ref imaginary_targets } =>
- FalseEdges { real_target, imaginary_targets: imaginary_targets.clone() }
+ FalseEdges { real_target, imaginary_targets: imaginary_targets.clone() },
+ FalseUnwind { real_target, unwind } => FalseUnwind { real_target, unwind },
};
Terminator {
source_info: self.source_info,
Return |
GeneratorDrop |
Unreachable |
- FalseEdges { .. } => false
+ FalseEdges { .. } |
+ FalseUnwind { .. } => false
}
}
}
if let ty::TyAdt(adt_def, _) = ty.sty {
adt_def.repr.discr_type().to_ty(tcx)
} else {
- // Undefined behaviour, bug for now; may want to return something for
- // the `discriminant` intrinsic later.
- bug!("Rvalue::Discriminant on Place of type {:?}", ty);
+ // This can only be `0`, for now, so `u8` will suffice.
+ tcx.types.u8
}
}
Rvalue::NullaryOp(NullOp::Box, t) => tcx.mk_box(t),
impl BorrowKind {
pub fn to_mutbl_lossy(self) -> hir::Mutability {
match self {
- BorrowKind::Mut => hir::MutMutable,
+ BorrowKind::Mut { .. } => hir::MutMutable,
BorrowKind::Shared => hir::MutImmutable,
// We have no type corresponding to a unique imm borrow, so
self.visit_operand(value, source_location);
self.visit_branch(block, resume);
drop.map(|t| self.visit_branch(block, t));
-
}
- TerminatorKind::FalseEdges { real_target, ref imaginary_targets } => {
+ TerminatorKind::FalseEdges { real_target, ref imaginary_targets} => {
self.visit_branch(block, real_target);
for target in imaginary_targets {
self.visit_branch(block, *target);
}
}
+
+ TerminatorKind::FalseUnwind { real_target, unwind } => {
+ self.visit_branch(block, real_target);
+ if let Some(unwind) = unwind {
+ self.visit_branch(block, unwind);
+ }
+ }
}
}
pub fn is_mutating_use(&self) -> bool {
match *self {
PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call |
- PlaceContext::Borrow { kind: BorrowKind::Mut, .. } |
+ PlaceContext::Borrow { kind: BorrowKind::Mut { .. }, .. } |
PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop => true,
+
PlaceContext::Inspect |
PlaceContext::Borrow { kind: BorrowKind::Shared, .. } |
PlaceContext::Borrow { kind: BorrowKind::Unique, .. } |
PlaceContext::Borrow { kind: BorrowKind::Unique, .. } |
PlaceContext::Projection(Mutability::Not) |
PlaceContext::Copy | PlaceContext::Move => true,
- PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store |
+
+ PlaceContext::Borrow { kind: BorrowKind::Mut { .. }, .. } | PlaceContext::Store |
PlaceContext::AsmOutput |
PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) |
PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead |
DepInfo,
}
+/// The epoch of the compiler (RFC 2052)
+#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq)]
+#[non_exhaustive]
+pub enum Epoch {
+ // epochs must be kept in order, newest to oldest
+
+ /// The 2015 epoch
+ Epoch2015,
+ /// The 2018 epoch
+ Epoch2018,
+
+ // when adding new epochs, be sure to update:
+ //
+ // - the list in the `parse_epoch` static
+ // - the match in the `parse_epoch` function
+ // - add a `rust_####()` function to the session
+ // - update the enum in Cargo's sources as well
+ //
+ // When -Zepoch becomes --epoch, there will
+ // also be a check for the epoch being nightly-only
+ // somewhere. That will need to be updated
+ // whenever we're stabilizing/introducing a new epoch
+ // as well as changing the default Cargo template.
+}
+
impl_stable_hash_for!(enum self::OutputType {
Bitcode,
Assembly,
pub fn filestem(&self) -> String {
format!("{}{}", self.out_filestem, self.extra)
}
-
- pub fn contains_path(&self, input_path: &PathBuf) -> bool {
- let input_path = input_path.canonicalize().ok();
- if input_path.is_none() {
- return false
- }
- match self.single_output_file {
- Some(ref output_path) => output_path.canonicalize().ok() == input_path,
- None => {
- for k in self.outputs.keys() {
- let output_path = self.path(k.to_owned());
- if output_path.canonicalize().ok() == input_path {
- return true;
- }
- }
- false
- }
- }
- }
}
pub fn host_triple() -> &'static str {
Some("`string` or `string=string`");
pub const parse_lto: Option<&'static str> =
Some("one of `thin`, `fat`, or omitted");
+ pub const parse_epoch: Option<&'static str> =
+ Some("one of: `2015`, `2018`");
}
#[allow(dead_code)]
mod $mod_set {
- use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto};
+ use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto, Epoch};
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use std::path::PathBuf;
};
true
}
+
+ fn parse_epoch(slot: &mut Epoch, v: Option<&str>) -> bool {
+ match v {
+ Some("2015") => *slot = Epoch::Epoch2015,
+ Some("2018") => *slot = Epoch::Epoch2018,
+ _ => return false,
+ }
+ true
+ }
}
) }
"select which borrowck is used (`ast`, `mir`, or `compare`)"),
two_phase_borrows: bool = (false, parse_bool, [UNTRACKED],
"use two-phase reserved/active distinction for `&mut` borrows in MIR borrowck"),
+ two_phase_beyond_autoref: bool = (false, parse_bool, [UNTRACKED],
+ "when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"),
time_passes: bool = (false, parse_bool, [UNTRACKED],
"measure time of each rustc pass"),
count_llvm_insns: bool = (false, parse_bool,
`everybody_loops` (all function bodies replaced with `loop {}`),
`hir` (the HIR), `hir,identified`, or
`hir,typed` (HIR with types for each node)."),
+ epoch: Epoch = (Epoch::Epoch2015, parse_epoch, [TRACKED],
+ "The epoch to build Rust with. Newer epochs may include features
+ that require breaking changes. The default epoch is 2015 (the first
+ epoch). Crates compiled with different epochs can be linked together."),
+ run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
+ "run `dsymutil` and delete intermediate object files"),
}
pub fn default_lib_output() -> CrateType {
use std::path::PathBuf;
use std::collections::hash_map::DefaultHasher;
use super::{Passes, CrateType, OptLevel, DebugInfoLevel, Lto,
- OutputTypes, Externs, ErrorOutputType, Sanitizer};
+ OutputTypes, Externs, ErrorOutputType, Sanitizer, Epoch};
use syntax::feature_gate::UnstableFeatures;
use rustc_back::{PanicStrategy, RelroLevel};
impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind);
impl_dep_tracking_hash_via_hash!(Sanitizer);
impl_dep_tracking_hash_via_hash!(Option<Sanitizer>);
+ impl_dep_tracking_hash_via_hash!(Epoch);
impl_dep_tracking_hash_for_sortable_vec_of!(String);
impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf);
use middle::allocator::AllocatorKind;
use middle::dependency_format;
use session::search_paths::PathKind;
-use session::config::{BorrowckMode, DebugInfoLevel, OutputType};
+use session::config::{BorrowckMode, DebugInfoLevel, OutputType, Epoch};
use ty::tls;
use util::nodemap::{FxHashMap, FxHashSet};
use util::common::{duration_to_secs_str, ErrorReported};
pub fn teach(&self, code: &DiagnosticId) -> bool {
self.opts.debugging_opts.teach && !self.parse_sess.span_diagnostic.code_emitted(code)
}
+
+ /// Are we allowed to use features from the Rust 2018 epoch?
+ pub fn rust_2018(&self) -> bool {
+ self.opts.debugging_opts.epoch >= Epoch::Epoch2018
+ }
}
pub fn build_session(sopts: config::Options,
if direct {
// this is a "direct", user-specified, rather than derived,
// obligation.
- flags.push(("direct", None));
+ flags.push(("direct".to_string(), None));
}
if let ObligationCauseCode::ItemObligation(item) = obligation.cause.code {
// Currently I'm leaving it for what I need for `try`.
if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) {
method = self.tcx.item_name(item);
- flags.push(("from_method", None));
- flags.push(("from_method", Some(&*method)));
+ flags.push(("from_method".to_string(), None));
+ flags.push(("from_method".to_string(), Some(method.to_string())));
}
}
if let Some(k) = obligation.cause.span.compiler_desugaring_kind() {
desugaring = k.as_symbol().as_str();
- flags.push(("from_desugaring", None));
- flags.push(("from_desugaring", Some(&*desugaring)));
+ flags.push(("from_desugaring".to_string(), None));
+ flags.push(("from_desugaring".to_string(), Some(desugaring.to_string())));
+ }
+ let generics = self.tcx.generics_of(def_id);
+ let self_ty = trait_ref.self_ty();
+ let self_ty_str = self_ty.to_string();
+ flags.push(("_Self".to_string(), Some(self_ty_str.clone())));
+
+ for param in generics.types.iter() {
+ let name = param.name.as_str().to_string();
+ let ty = trait_ref.substs.type_for_def(param);
+ let ty_str = ty.to_string();
+ flags.push((name.clone(),
+ Some(ty_str.clone())));
+ }
+
+ if let Some(true) = self_ty.ty_to_def_id().map(|def_id| def_id.is_local()) {
+ flags.push(("crate_local".to_string(), None));
}
if let Ok(Some(command)) = OnUnimplementedDirective::of_item(
self.tcx, trait_ref.def_id, def_id
) {
- command.evaluate(self.tcx, trait_ref, &flags)
+ command.evaluate(self.tcx, trait_ref, &flags[..])
} else {
OnUnimplementedNote::empty()
}
.map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t)))
.unwrap_or((String::new(), String::new()));
- let OnUnimplementedNote { message, label }
+ let OnUnimplementedNote { message, label, note }
= self.on_unimplemented_note(trait_ref, obligation);
let have_alt_message = message.is_some() || label.is_some();
trait_ref,
trait_ref.self_ty()));
}
+ if let Some(ref s) = note {
+ // If it has a custom "#[rustc_on_unimplemented]" note, let's display it
+ err.note(s.as_str());
+ }
self.suggest_borrow_on_unsized_slice(&obligation.cause.code, &mut err);
} else {
let (closure_span, found) = found_did
.and_then(|did| self.tcx.hir.get_if_local(did))
- .map(|node| self.get_fn_like_arguments(node))
- .unwrap_or((found_span.unwrap(), found));
+ .map(|node| {
+ let (found_span, found) = self.get_fn_like_arguments(node);
+ (Some(found_span), found)
+ }).unwrap_or((found_span, found));
self.report_arg_count_mismatch(span,
closure_span,
fn report_arg_count_mismatch(
&self,
span: Span,
- found_span: Span,
+ found_span: Option<Span>,
expected_args: Vec<ArgKind>,
found_args: Vec<ArgKind>,
is_closure: bool,
);
err.span_label(span, format!( "expected {} that takes {}", kind, expected_str));
- err.span_label(found_span, format!("takes {}", found_str));
-
- if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] {
- if fields.len() == expected_args.len() {
- let sugg = fields.iter()
- .map(|(name, _)| name.to_owned())
- .collect::<Vec<String>>().join(", ");
- err.span_suggestion(found_span,
- "change the closure to take multiple arguments instead of \
- a single tuple",
- format!("|{}|", sugg));
+
+ if let Some(found_span) = found_span {
+ err.span_label(found_span, format!("takes {}", found_str));
+
+ if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] {
+ if fields.len() == expected_args.len() {
+ let sugg = fields.iter()
+ .map(|(name, _)| name.to_owned())
+ .collect::<Vec<String>>().join(", ");
+ err.span_suggestion(found_span,
+ "change the closure to take multiple arguments instead of \
+ a single tuple",
+ format!("|{}|", sugg));
+ }
}
- }
- if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] {
- if fields.len() == found_args.len() && is_closure {
- let sugg = format!(
- "|({}){}|",
- found_args.iter()
- .map(|arg| match arg {
- ArgKind::Arg(name, _) => name.to_owned(),
- _ => "_".to_owned(),
- })
- .collect::<Vec<String>>()
- .join(", "),
- // add type annotations if available
- if found_args.iter().any(|arg| match arg {
- ArgKind::Arg(_, ty) => ty != "_",
- _ => false,
- }) {
- format!(": ({})",
- fields.iter()
- .map(|(_, ty)| ty.to_owned())
- .collect::<Vec<String>>()
- .join(", "))
- } else {
- "".to_owned()
- },
- );
- err.span_suggestion(found_span,
- "change the closure to accept a tuple instead of individual \
- arguments",
- sugg);
+ if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] {
+ if fields.len() == found_args.len() && is_closure {
+ let sugg = format!(
+ "|({}){}|",
+ found_args.iter()
+ .map(|arg| match arg {
+ ArgKind::Arg(name, _) => name.to_owned(),
+ _ => "_".to_owned(),
+ })
+ .collect::<Vec<String>>()
+ .join(", "),
+ // add type annotations if available
+ if found_args.iter().any(|arg| match arg {
+ ArgKind::Arg(_, ty) => ty != "_",
+ _ => false,
+ }) {
+ format!(": ({})",
+ fields.iter()
+ .map(|(_, ty)| ty.to_owned())
+ .collect::<Vec<String>>()
+ .join(", "))
+ } else {
+ "".to_owned()
+ },
+ );
+ err.span_suggestion(found_span,
+ "change the closure to accept a tuple instead of \
+ individual arguments",
+ sugg);
+ }
}
}
{
self.note_obligation_cause_code(err,
&obligation.predicate,
- &obligation.cause.code);
+ &obligation.cause.code,
+ &mut vec![]);
}
fn note_obligation_cause_code<T>(&self,
err: &mut DiagnosticBuilder,
predicate: &T,
- cause_code: &ObligationCauseCode<'tcx>)
+ cause_code: &ObligationCauseCode<'tcx>,
+ obligated_types: &mut Vec<&ty::TyS<'tcx>>)
where T: fmt::Display
{
let tcx = self.tcx;
}
ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
- err.note(&format!("required because it appears within the type `{}`",
- parent_trait_ref.0.self_ty()));
+ let ty = parent_trait_ref.0.self_ty();
+ err.note(&format!("required because it appears within the type `{}`", ty));
+ obligated_types.push(ty);
+
let parent_predicate = parent_trait_ref.to_predicate();
- self.note_obligation_cause_code(err,
- &parent_predicate,
- &data.parent_code);
+ if !self.is_recursive_obligation(obligated_types, &data.parent_code) {
+ self.note_obligation_cause_code(err,
+ &parent_predicate,
+ &data.parent_code,
+ obligated_types);
+ }
}
ObligationCauseCode::ImplDerivedObligation(ref data) => {
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
parent_trait_ref.0.self_ty()));
let parent_predicate = parent_trait_ref.to_predicate();
self.note_obligation_cause_code(err,
- &parent_predicate,
- &data.parent_code);
+ &parent_predicate,
+ &data.parent_code,
+ obligated_types);
}
ObligationCauseCode::CompareImplMethodObligation { .. } => {
err.note(
err.help(&format!("consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate",
suggested_limit));
}
+
+ fn is_recursive_obligation(&self,
+ obligated_types: &mut Vec<&ty::TyS<'tcx>>,
+ cause_code: &ObligationCauseCode<'tcx>) -> bool {
+ if let ObligationCauseCode::BuiltinDerivedObligation(ref data) = cause_code {
+ let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
+ for obligated_type in obligated_types {
+ if obligated_type == &parent_trait_ref.0.self_ty() {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
enum ArgKind {
pub subcommands: Vec<OnUnimplementedDirective>,
pub message: Option<OnUnimplementedFormatString>,
pub label: Option<OnUnimplementedFormatString>,
+ pub note: Option<OnUnimplementedFormatString>,
}
pub struct OnUnimplementedNote {
pub message: Option<String>,
pub label: Option<String>,
+ pub note: Option<String>,
}
impl OnUnimplementedNote {
pub fn empty() -> Self {
- OnUnimplementedNote { message: None, label: None }
+ OnUnimplementedNote { message: None, label: None, note: None }
}
}
let mut message = None;
let mut label = None;
+ let mut note = None;
let mut subcommands = vec![];
for item in item_iter {
if item.check_name("message") && message.is_none() {
tcx, trait_def_id, label_.as_str(), span)?);
continue;
}
+ } else if item.check_name("note") && note.is_none() {
+ if let Some(note_) = item.value_str() {
+ note = Some(OnUnimplementedFormatString::try_parse(
+ tcx, trait_def_id, note_.as_str(), span)?);
+ continue;
+ }
} else if item.check_name("on") && is_root &&
- message.is_none() && label.is_none()
+ message.is_none() && label.is_none() && note.is_none()
{
if let Some(items) = item.meta_item_list() {
if let Ok(subcommand) =
if errored {
Err(ErrorReported)
} else {
- Ok(OnUnimplementedDirective { condition, message, label, subcommands })
+ Ok(OnUnimplementedDirective { condition, message, label, subcommands, note })
}
}
message: None,
subcommands: vec![],
label: Some(OnUnimplementedFormatString::try_parse(
- tcx, trait_def_id, value.as_str(), attr.span)?)
+ tcx, trait_def_id, value.as_str(), attr.span)?),
+ note: None,
}))
} else {
return Err(parse_error(tcx, attr.span,
pub fn evaluate(&self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
trait_ref: ty::TraitRef<'tcx>,
- options: &[(&str, Option<&str>)])
+ options: &[(String, Option<String>)])
-> OnUnimplementedNote
{
let mut message = None;
let mut label = None;
- info!("evaluate({:?}, trait_ref={:?}, options={:?})",
- self, trait_ref, options);
+ let mut note = None;
+ info!("evaluate({:?}, trait_ref={:?}, options={:?})", self, trait_ref, options);
for command in self.subcommands.iter().chain(Some(self)).rev() {
if let Some(ref condition) = command.condition {
if !attr::eval_condition(condition, &tcx.sess.parse_sess, &mut |c| {
- options.contains(&(&c.name().as_str(),
- match c.value_str().map(|s| s.as_str()) {
- Some(ref s) => Some(s),
+ options.contains(&(c.name().as_str().to_string(),
+ match c.value_str().map(|s| s.as_str().to_string()) {
+ Some(s) => Some(s),
None => None
}))
}) {
if let Some(ref label_) = command.label {
label = Some(label_.clone());
}
+
+ if let Some(ref note_) = command.note {
+ note = Some(note_.clone());
+ }
}
OnUnimplementedNote {
label: label.map(|l| l.format(tcx, trait_ref)),
- message: message.map(|m| m.format(tcx, trait_ref))
+ message: message.map(|m| m.format(tcx, trait_ref)),
+ note: note.map(|n| n.format(tcx, trait_ref)),
}
}
}
}
}
+#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)]
+pub enum AutoBorrowMutability {
+ Mutable { allow_two_phase_borrow: bool },
+ Immutable,
+}
+
+impl From<AutoBorrowMutability> for hir::Mutability {
+ fn from(m: AutoBorrowMutability) -> Self {
+ match m {
+ AutoBorrowMutability::Mutable { .. } => hir::MutMutable,
+ AutoBorrowMutability::Immutable => hir::MutImmutable,
+ }
+ }
+}
+
#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)]
pub enum AutoBorrow<'tcx> {
/// Convert from T to &T.
- Ref(ty::Region<'tcx>, hir::Mutability),
+ Ref(ty::Region<'tcx>, AutoBorrowMutability),
/// Convert from T to *T.
RawPtr(hir::Mutability),
#![allow(non_snake_case)]
use hir::def_id::DefId;
-use hir::ItemLocalId;
+use hir::{HirId, ItemLocalId};
use syntax::ast;
pub use rustc_data_structures::fx::FxHashMap;
pub type NodeMap<T> = FxHashMap<ast::NodeId, T>;
pub type DefIdMap<T> = FxHashMap<DefId, T>;
+pub type HirIdMap<T> = FxHashMap<HirId, T>;
pub type ItemLocalMap<T> = FxHashMap<ItemLocalId, T>;
pub type NodeSet = FxHashSet<ast::NodeId>;
pub type DefIdSet = FxHashSet<DefId>;
+pub type HirIdSet = FxHashSet<HirId>;
pub type ItemLocalSet = FxHashSet<ItemLocalId>;
pub fn NodeMap<T>() -> NodeMap<T> { FxHashMap() }
#include <stdint.h>
#include <string>
+#include <sstream>
#include <stdlib.h>
#include "s2wasm.h"
struct BinaryenRustModule {
BufferWithRandomAccess buffer;
+ std::string sourceMapJSON;
};
struct BinaryenRustModuleOptions {
bool ignoreUnknownSymbols;
bool debugInfo;
std::string startFunction;
+ std::string sourceMapUrl;
BinaryenRustModuleOptions() :
globalBase(0),
importMemory(false),
ignoreUnknownSymbols(false),
debugInfo(false),
- startFunction("")
+ startFunction(""),
+ sourceMapUrl("")
{}
};
options->startFunction = start;
}
+extern "C" void
+BinaryenRustModuleOptionsSetSourceMapUrl(BinaryenRustModuleOptions *options,
+ char *sourceMapUrl) {
+ options->sourceMapUrl = sourceMapUrl;
+}
+
extern "C" void
BinaryenRustModuleOptionsSetStackAllocation(BinaryenRustModuleOptions *options,
uint64_t stack) {
{
WasmBinaryWriter writer(&linker.getOutput().wasm, ret->buffer, options->debug);
writer.setNamesSection(options->debugInfo);
- // FIXME: support source maps?
- // writer.setSourceMap(sourceMapStream.get(), sourceMapUrl);
+
+ std::unique_ptr<std::ostringstream> sourceMapStream = nullptr;
+ {
+ sourceMapStream = make_unique<std::ostringstream>();
+ writer.setSourceMap(sourceMapStream.get(), options->sourceMapUrl);
+ }
// FIXME: support symbol maps?
// writer.setSymbolMap(symbolMap);
writer.write();
+
+ if (sourceMapStream) {
+ ret->sourceMapJSON = sourceMapStream->str();
+ }
}
return ret.release();
}
return M->buffer.size();
}
+extern "C" const char*
+BinaryenRustModuleSourceMapPtr(const BinaryenRustModule *M) {
+ return M->sourceMapJSON.data();
+}
+
+extern "C" size_t
+BinaryenRustModuleSourceMapLen(const BinaryenRustModule *M) {
+ return M->sourceMapJSON.length();
+}
+
extern "C" void
BinaryenRustModuleFree(BinaryenRustModule *M) {
delete M;
slice::from_raw_parts(ptr, len)
}
}
+
+ /// Returns the data of the source map JSON.
+ pub fn source_map(&self) -> &[u8] {
+ unsafe {
+ let ptr = BinaryenRustModuleSourceMapPtr(self.ptr);
+ let len = BinaryenRustModuleSourceMapLen(self.ptr);
+ slice::from_raw_parts(ptr, len)
+ }
+ }
}
impl Drop for Module {
self
}
+ /// Configures a `sourceMappingURL` custom section value for the module.
+ pub fn source_map_url(&mut self, url: &str) -> &mut Self {
+ let url = CString::new(url).unwrap();
+ unsafe {
+ BinaryenRustModuleOptionsSetSourceMapUrl(self.ptr, url.as_ptr());
+ }
+ self
+ }
+
/// Configures how much stack is initially allocated for the module. 1MB is
/// probably good enough for now.
pub fn stack(&mut self, amt: u64) -> &mut Self {
-> *mut BinaryenRustModule;
fn BinaryenRustModulePtr(module: *const BinaryenRustModule) -> *const u8;
fn BinaryenRustModuleLen(module: *const BinaryenRustModule) -> usize;
+ fn BinaryenRustModuleSourceMapPtr(module: *const BinaryenRustModule) -> *const u8;
+ fn BinaryenRustModuleSourceMapLen(module: *const BinaryenRustModule) -> usize;
fn BinaryenRustModuleFree(module: *mut BinaryenRustModule);
fn BinaryenRustModuleOptionsCreate()
debuginfo: bool);
fn BinaryenRustModuleOptionsSetStart(module: *mut BinaryenRustModuleOptions,
start: *const libc::c_char);
+ fn BinaryenRustModuleOptionsSetSourceMapUrl(module: *mut BinaryenRustModuleOptions,
+ sourceMapUrl: *const libc::c_char);
fn BinaryenRustModuleOptionsSetStackAllocation(
module: *mut BinaryenRustModuleOptions,
stack: u64,
};
match cause {
- mc::AliasableStatic => {
- // This happens when we have an `&mut` or assignment to a
- // static. We should have already reported a mutability
- // violation first, but may have continued compiling.
- self.tcx.sess.delay_span_bug(
- span,
- &format!("aliasability violation for static `{}`", prefix)
- );
- return;
- }
mc::AliasableStaticMut => {
// This path cannot occur. `static mut X` is not checked
// for aliasability violations.
span_bug!(span, "aliasability violation for static mut `{}`", prefix)
}
- mc::AliasableBorrowed => {}
+ mc::AliasableStatic | mc::AliasableBorrowed => {}
};
let blame = cmt.immutability_blame();
let mut err = match blame {
return Ok(mk_const(Integral(Usize(ConstUsize::new(align,
tcx.sess.target.usize_ty).unwrap()))));
}
+ "type_id" => {
+ let type_id = tcx.type_id_hash(substs.type_at(0));
+ return Ok(mk_const(Integral(U64(type_id))));
+ }
_ => signal!(e, TypeckError)
}
}
BindingMode::ByValue => mutability == Mutability::Mut,
BindingMode::ByRef(_, bk) => {
write!(f, "ref ")?;
- bk == BorrowKind::Mut
+ match bk { BorrowKind::Mut { .. } => true, _ => false }
}
};
if is_mut {
(Mutability::Not, BindingMode::ByValue),
ty::BindByReference(hir::MutMutable) =>
(Mutability::Not, BindingMode::ByRef(
- region.unwrap(), BorrowKind::Mut)),
+ region.unwrap(), BorrowKind::Mut { allow_two_phase_borrow: false })),
ty::BindByReference(hir::MutImmutable) =>
(Mutability::Not, BindingMode::ByRef(
region.unwrap(), BorrowKind::Shared)),
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-
-// An implementation of the Blake2b cryptographic hash function.
-// The implementation closely follows: https://tools.ietf.org/html/rfc7693
-//
-// "BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and
-// SHA-3, yet is at least as secure as the latest standard SHA-3."
-// according to their own website :)
-//
-// Indeed this implementation is two to three times as fast as our SHA-256
-// implementation. If you have the luxury of being able to use crates from
-// crates.io, you can go there and find still faster implementations.
-
-use std::mem;
-use std::slice;
-
-#[repr(C)]
-struct Blake2bCtx {
- b: [u8; 128],
- h: [u64; 8],
- t: [u64; 2],
- c: usize,
- outlen: u16,
- finalized: bool,
-
- #[cfg(debug_assertions)]
- fnv_hash: u64,
-}
-
-#[cfg(debug_assertions)]
-impl ::std::fmt::Debug for Blake2bCtx {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- write!(fmt, "{:x}", self.fnv_hash)
- }
-}
-
-#[cfg(not(debug_assertions))]
-impl ::std::fmt::Debug for Blake2bCtx {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- write!(fmt, "Enable debug_assertions() for more info.")
- }
-}
-
-#[inline(always)]
-fn b2b_g(v: &mut [u64; 16],
- a: usize,
- b: usize,
- c: usize,
- d: usize,
- x: u64,
- y: u64)
-{
- v[a] = v[a].wrapping_add(v[b]).wrapping_add(x);
- v[d] = (v[d] ^ v[a]).rotate_right(32);
- v[c] = v[c].wrapping_add(v[d]);
- v[b] = (v[b] ^ v[c]).rotate_right(24);
- v[a] = v[a].wrapping_add(v[b]).wrapping_add(y);
- v[d] = (v[d] ^ v[a]).rotate_right(16);
- v[c] = v[c].wrapping_add(v[d]);
- v[b] = (v[b] ^ v[c]).rotate_right(63);
-}
-
-// Initialization vector
-const BLAKE2B_IV: [u64; 8] = [
- 0x6A09E667F3BCC908, 0xBB67AE8584CAA73B,
- 0x3C6EF372FE94F82B, 0xA54FF53A5F1D36F1,
- 0x510E527FADE682D1, 0x9B05688C2B3E6C1F,
- 0x1F83D9ABFB41BD6B, 0x5BE0CD19137E2179
-];
-
-fn blake2b_compress(ctx: &mut Blake2bCtx, last: bool) {
-
- const SIGMA: [[usize; 16]; 12] = [
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ],
- [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 ],
- [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 ],
- [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 ],
- [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 ],
- [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 ],
- [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 ],
- [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 ],
- [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 ],
- [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 ],
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ],
- [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 ]
- ];
-
- let mut v: [u64; 16] = [
- ctx.h[0],
- ctx.h[1],
- ctx.h[2],
- ctx.h[3],
- ctx.h[4],
- ctx.h[5],
- ctx.h[6],
- ctx.h[7],
-
- BLAKE2B_IV[0],
- BLAKE2B_IV[1],
- BLAKE2B_IV[2],
- BLAKE2B_IV[3],
- BLAKE2B_IV[4],
- BLAKE2B_IV[5],
- BLAKE2B_IV[6],
- BLAKE2B_IV[7],
- ];
-
- v[12] ^= ctx.t[0]; // low 64 bits of offset
- v[13] ^= ctx.t[1]; // high 64 bits
- if last {
- v[14] = !v[14];
- }
-
- {
- // Re-interpret the input buffer in the state as an array
- // of little-endian u64s, converting them to machine
- // endianness. It's OK to modify the buffer in place
- // since this is the last time this data will be accessed
- // before it's overwritten.
-
- let m: &mut [u64; 16] = unsafe {
- let b: &mut [u8; 128] = &mut ctx.b;
- ::std::mem::transmute(b)
- };
-
- if cfg!(target_endian = "big") {
- for word in &mut m[..] {
- *word = u64::from_le(*word);
- }
- }
-
- for i in 0 .. 12 {
- b2b_g(&mut v, 0, 4, 8, 12, m[SIGMA[i][ 0]], m[SIGMA[i][ 1]]);
- b2b_g(&mut v, 1, 5, 9, 13, m[SIGMA[i][ 2]], m[SIGMA[i][ 3]]);
- b2b_g(&mut v, 2, 6, 10, 14, m[SIGMA[i][ 4]], m[SIGMA[i][ 5]]);
- b2b_g(&mut v, 3, 7, 11, 15, m[SIGMA[i][ 6]], m[SIGMA[i][ 7]]);
- b2b_g(&mut v, 0, 5, 10, 15, m[SIGMA[i][ 8]], m[SIGMA[i][ 9]]);
- b2b_g(&mut v, 1, 6, 11, 12, m[SIGMA[i][10]], m[SIGMA[i][11]]);
- b2b_g(&mut v, 2, 7, 8, 13, m[SIGMA[i][12]], m[SIGMA[i][13]]);
- b2b_g(&mut v, 3, 4, 9, 14, m[SIGMA[i][14]], m[SIGMA[i][15]]);
- }
- }
-
- for i in 0 .. 8 {
- ctx.h[i] ^= v[i] ^ v[i + 8];
- }
-}
-
-fn blake2b_new(outlen: usize, key: &[u8]) -> Blake2bCtx {
- assert!(outlen > 0 && outlen <= 64 && key.len() <= 64);
-
- let mut ctx = Blake2bCtx {
- b: [0; 128],
- h: BLAKE2B_IV,
- t: [0; 2],
- c: 0,
- outlen: outlen as u16,
- finalized: false,
-
- #[cfg(debug_assertions)]
- fnv_hash: 0xcbf29ce484222325,
- };
-
- ctx.h[0] ^= 0x01010000 ^ ((key.len() << 8) as u64) ^ (outlen as u64);
-
- if key.len() > 0 {
- blake2b_update(&mut ctx, key);
- ctx.c = ctx.b.len();
- }
-
- ctx
-}
-
-fn blake2b_update(ctx: &mut Blake2bCtx, mut data: &[u8]) {
- assert!(!ctx.finalized, "Blake2bCtx already finalized");
-
- let mut bytes_to_copy = data.len();
- let mut space_in_buffer = ctx.b.len() - ctx.c;
-
- while bytes_to_copy > space_in_buffer {
- checked_mem_copy(data, &mut ctx.b[ctx.c .. ], space_in_buffer);
-
- ctx.t[0] = ctx.t[0].wrapping_add(ctx.b.len() as u64);
- if ctx.t[0] < (ctx.b.len() as u64) {
- ctx.t[1] += 1;
- }
- blake2b_compress(ctx, false);
- ctx.c = 0;
-
- data = &data[space_in_buffer .. ];
- bytes_to_copy -= space_in_buffer;
- space_in_buffer = ctx.b.len();
- }
-
- if bytes_to_copy > 0 {
- checked_mem_copy(data, &mut ctx.b[ctx.c .. ], bytes_to_copy);
- ctx.c += bytes_to_copy;
- }
-
- #[cfg(debug_assertions)]
- {
- // compute additional FNV hash for simpler to read debug output
- const MAGIC_PRIME: u64 = 0x00000100000001b3;
-
- for &byte in data {
- ctx.fnv_hash = (ctx.fnv_hash ^ byte as u64).wrapping_mul(MAGIC_PRIME);
- }
- }
-}
-
-fn blake2b_final(ctx: &mut Blake2bCtx)
-{
- assert!(!ctx.finalized, "Blake2bCtx already finalized");
-
- ctx.t[0] = ctx.t[0].wrapping_add(ctx.c as u64);
- if ctx.t[0] < ctx.c as u64 {
- ctx.t[1] += 1;
- }
-
- while ctx.c < 128 {
- ctx.b[ctx.c] = 0;
- ctx.c += 1;
- }
-
- blake2b_compress(ctx, true);
-
- // Modify our buffer to little-endian format as it will be read
- // as a byte array. It's OK to modify the buffer in place since
- // this is the last time this data will be accessed.
- if cfg!(target_endian = "big") {
- for word in &mut ctx.h {
- *word = word.to_le();
- }
- }
-
- ctx.finalized = true;
-}
-
-#[inline(always)]
-fn checked_mem_copy<T1, T2>(from: &[T1], to: &mut [T2], byte_count: usize) {
- let from_size = from.len() * mem::size_of::<T1>();
- let to_size = to.len() * mem::size_of::<T2>();
- assert!(from_size >= byte_count);
- assert!(to_size >= byte_count);
- let from_byte_ptr = from.as_ptr() as * const u8;
- let to_byte_ptr = to.as_mut_ptr() as * mut u8;
- unsafe {
- ::std::ptr::copy_nonoverlapping(from_byte_ptr, to_byte_ptr, byte_count);
- }
-}
-
-pub fn blake2b(out: &mut [u8], key: &[u8], data: &[u8])
-{
- let mut ctx = blake2b_new(out.len(), key);
- blake2b_update(&mut ctx, data);
- blake2b_final(&mut ctx);
- checked_mem_copy(&ctx.h, out, ctx.outlen as usize);
-}
-
-pub struct Blake2bHasher(Blake2bCtx);
-
-impl ::std::hash::Hasher for Blake2bHasher {
- fn write(&mut self, bytes: &[u8]) {
- blake2b_update(&mut self.0, bytes);
- }
-
- fn finish(&self) -> u64 {
- assert!(self.0.outlen == 8,
- "Hasher initialized with incompatible output length");
- u64::from_le(self.0.h[0])
- }
-}
-
-impl Blake2bHasher {
- pub fn new(outlen: usize, key: &[u8]) -> Blake2bHasher {
- Blake2bHasher(blake2b_new(outlen, key))
- }
-
- pub fn finalize(&mut self) -> &[u8] {
- if !self.0.finalized {
- blake2b_final(&mut self.0);
- }
- debug_assert!(mem::size_of_val(&self.0.h) >= self.0.outlen as usize);
- let raw_ptr = (&self.0.h[..]).as_ptr() as * const u8;
- unsafe {
- slice::from_raw_parts(raw_ptr, self.0.outlen as usize)
- }
- }
-}
-
-impl ::std::fmt::Debug for Blake2bHasher {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
- write!(fmt, "{:?}", self.0)
- }
-}
-
-#[cfg(test)]
-fn selftest_seq(out: &mut [u8], seed: u32)
-{
- let mut a: u32 = 0xDEAD4BADu32.wrapping_mul(seed);
- let mut b: u32 = 1;
-
- for i in 0 .. out.len() {
- let t: u32 = a.wrapping_add(b);
- a = b;
- b = t;
- out[i] = ((t >> 24) & 0xFF) as u8;
- }
-}
-
-#[test]
-fn blake2b_selftest()
-{
- use std::hash::Hasher;
-
- // grand hash of hash results
- const BLAKE2B_RES: [u8; 32] = [
- 0xC2, 0x3A, 0x78, 0x00, 0xD9, 0x81, 0x23, 0xBD,
- 0x10, 0xF5, 0x06, 0xC6, 0x1E, 0x29, 0xDA, 0x56,
- 0x03, 0xD7, 0x63, 0xB8, 0xBB, 0xAD, 0x2E, 0x73,
- 0x7F, 0x5E, 0x76, 0x5A, 0x7B, 0xCC, 0xD4, 0x75
- ];
-
- // parameter sets
- const B2B_MD_LEN: [usize; 4] = [20, 32, 48, 64];
- const B2B_IN_LEN: [usize; 6] = [0, 3, 128, 129, 255, 1024];
-
- let mut data = [0u8; 1024];
- let mut md = [0u8; 64];
- let mut key = [0u8; 64];
-
- let mut hasher = Blake2bHasher::new(32, &[]);
-
- for i in 0 .. 4 {
- let outlen = B2B_MD_LEN[i];
- for j in 0 .. 6 {
- let inlen = B2B_IN_LEN[j];
-
- selftest_seq(&mut data[.. inlen], inlen as u32); // unkeyed hash
- blake2b(&mut md[.. outlen], &[], &data[.. inlen]);
- hasher.write(&md[.. outlen]); // hash the hash
-
- selftest_seq(&mut key[0 .. outlen], outlen as u32); // keyed hash
- blake2b(&mut md[.. outlen], &key[.. outlen], &data[.. inlen]);
- hasher.write(&md[.. outlen]); // hash the hash
- }
- }
-
- // compute and compare the hash of hashes
- let md = hasher.finalize();
- for i in 0 .. 32 {
- assert_eq!(md[i], BLAKE2B_RES[i]);
- }
-}
pub mod base_n;
pub mod bitslice;
pub mod bitvec;
-pub mod blake2b;
pub mod graph;
pub mod indexed_set;
pub mod indexed_vec;
pub mod unify;
pub mod fx;
pub mod tuple_slice;
-pub mod veccell;
pub mod control_flow_graph;
pub mod flock;
pub mod sync;
+++ /dev/null
-// Copyright 2012-2014 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::cell::UnsafeCell;
-use std::mem;
-
-pub struct VecCell<T> {
- data: UnsafeCell<Vec<T>>,
-}
-
-impl<T> VecCell<T> {
- pub fn with_capacity(capacity: usize) -> VecCell<T> {
- VecCell { data: UnsafeCell::new(Vec::with_capacity(capacity)) }
- }
-
- #[inline]
- pub fn push(&self, data: T) -> usize {
- // The logic here, and in `swap` below, is that the `push`
- // method on the vector will not recursively access this
- // `VecCell`. Therefore, we can temporarily obtain mutable
- // access, secure in the knowledge that even if aliases exist
- // -- indeed, even if aliases are reachable from within the
- // vector -- they will not be used for the duration of this
- // particular fn call. (Note that we also are relying on the
- // fact that `VecCell` is not `Sync`.)
- unsafe {
- let v = self.data.get();
- (*v).push(data);
- (*v).len()
- }
- }
-
- pub fn swap(&self, mut data: Vec<T>) -> Vec<T> {
- unsafe {
- let v = self.data.get();
- mem::swap(&mut *v, &mut data);
- }
- data
- }
-}
};
let outputs = build_output_filenames(input, outdir, output, &krate.attrs, sess);
-
- // Ensure the source file isn't accidentally overwritten during compilation.
- match *input_path {
- Some(ref input_path) => {
- if outputs.contains_path(input_path) && sess.opts.will_create_output_file() {
- sess.err(&format!(
- "the input file \"{}\" would be overwritten by the generated executable",
- input_path.display()));
- return Err(CompileIncomplete::Stopped);
- }
- },
- None => {}
- }
-
let crate_name =
::rustc_trans_utils::link::find_crate_name(Some(sess), &krate.attrs, input);
-
let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
phase_2_configure_and_expand(
sess,
)?
};
- write_out_deps(sess, &outputs, &crate_name);
+ let output_paths = generated_output_paths(sess, &outputs, output.is_some(), &crate_name);
+
+ // Ensure the source file isn't accidentally overwritten during compilation.
+ if let Some(ref input_path) = *input_path {
+ if sess.opts.will_create_output_file() {
+ if output_contains_path(&output_paths, input_path) {
+ sess.err(&format!(
+ "the input file \"{}\" would be overwritten by the generated \
+ executable",
+ input_path.display()));
+ return Err(CompileIncomplete::Stopped);
+ }
+ if let Some(dir_path) = output_conflicts_with_dir(&output_paths) {
+ sess.err(&format!(
+ "the generated executable for the input file \"{}\" conflicts with the \
+ existing directory \"{}\"",
+ input_path.display(), dir_path.display()));
+ return Err(CompileIncomplete::Stopped);
+ }
+ }
+ }
+
+ write_out_deps(sess, &outputs, &output_paths);
if sess.opts.output_types.contains_key(&OutputType::DepInfo) &&
sess.opts.output_types.keys().count() == 1 {
return Ok(())
}
+ if let &Some(ref dir) = outdir {
+ if fs::create_dir_all(dir).is_err() {
+ sess.err("failed to find or create the directory specified by --out-dir");
+ return Err(CompileIncomplete::Stopped);
+ }
+ }
+
let arenas = AllArenas::new();
// Construct the HIR map
filename.to_string().replace(" ", "\\ ")
}
-fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) {
+// Returns all the paths that correspond to generated files.
+fn generated_output_paths(sess: &Session,
+ outputs: &OutputFilenames,
+ exact_name: bool,
+ crate_name: &str) -> Vec<PathBuf> {
let mut out_filenames = Vec::new();
for output_type in sess.opts.output_types.keys() {
let file = outputs.path(*output_type);
match *output_type {
- OutputType::Exe => {
- for output in sess.crate_types.borrow().iter() {
+ // If the filename has been overridden using `-o`, it will not be modified
+ // by appending `.rlib`, `.exe`, etc., so we can skip this transformation.
+ OutputType::Exe if !exact_name => {
+ for crate_type in sess.crate_types.borrow().iter() {
let p = ::rustc_trans_utils::link::filename_for_input(
sess,
- *output,
+ *crate_type,
crate_name,
outputs
);
}
}
}
+ out_filenames
+}
+// Runs `f` on every output file path and returns the first non-None result, or None if `f`
+// returns None for every file path.
+fn check_output<F, T>(output_paths: &Vec<PathBuf>, f: F) -> Option<T>
+ where F: Fn(&PathBuf) -> Option<T> {
+ for output_path in output_paths {
+ if let Some(result) = f(output_path) {
+ return Some(result);
+ }
+ }
+ None
+}
+
+pub fn output_contains_path(output_paths: &Vec<PathBuf>, input_path: &PathBuf) -> bool {
+ let input_path = input_path.canonicalize().ok();
+ if input_path.is_none() {
+ return false
+ }
+ let check = |output_path: &PathBuf| {
+ if output_path.canonicalize().ok() == input_path {
+ Some(())
+ } else { None }
+ };
+ check_output(output_paths, check).is_some()
+}
+
+pub fn output_conflicts_with_dir(output_paths: &Vec<PathBuf>) -> Option<PathBuf> {
+ let check = |output_path: &PathBuf| {
+ if output_path.is_dir() {
+ Some(output_path.clone())
+ } else { None }
+ };
+ check_output(output_paths, check)
+}
+
+fn write_out_deps(sess: &Session,
+ outputs: &OutputFilenames,
+ out_filenames: &Vec<PathBuf>) {
// Write out dependency rules to the dep-info file if requested
if !sess.opts.output_types.contains_key(&OutputType::DepInfo) {
return;
.map(|fmap| escape_dep_filename(&fmap.name))
.collect();
let mut file = fs::File::create(&deps_filename)?;
- for path in &out_filenames {
+ for path in out_filenames {
write!(file, "{}: {}\n\n", path.display(), files.join(" "))?;
}
Some(out_file.clone())
};
if *odir != None {
- sess.warn("ignoring --out-dir flag due to -o flag.");
+ sess.warn("ignoring --out-dir flag due to -o flag");
+ }
+ if !sess.opts.cg.extra_filename.is_empty() {
+ sess.warn("ignoring -C extra-filename flag due to -o flag");
}
let cur_dir = Path::new("");
Assign(_, ref value) => (value, "assigned value", false),
AssignOp(.., ref value) => (value, "assigned value", false),
InPlace(_, ref value) => (value, "emplacement value", false),
- Call(_, ref args) => {
- for arg in args {
- self.check_unused_parens_core(cx, arg, "function argument", false)
+ // either function/method call, or something this lint doesn't care about
+ ref call_or_other => {
+ let args_to_check;
+ let call_kind;
+ match *call_or_other {
+ Call(_, ref args) => {
+ call_kind = "function";
+ args_to_check = &args[..];
+ },
+ MethodCall(_, ref args) => {
+ call_kind = "method";
+ // first "argument" is self (which sometimes needs parens)
+ args_to_check = &args[1..];
+ }
+ // actual catch-all arm
+ _ => { return; }
}
- return;
- },
- MethodCall(_, ref args) => {
- for arg in &args[1..] { // first "argument" is self (which sometimes needs parens)
- self.check_unused_parens_core(cx, arg, "method argument", false)
+ // Don't lint if this is a nested macro expansion: otherwise, the lint could
+ // trigger in situations that macro authors shouldn't have to care about, e.g.,
+ // when a parenthesized token tree matched in one macro expansion is matched as
+ // an expression in another and used as a fn/method argument (Issue #47775)
+ if e.span.ctxt().outer().expn_info()
+ .map_or(false, |info| info.call_site.ctxt().outer()
+ .expn_info().is_some()) {
+ return;
+ }
+ let msg = format!("{} argument", call_kind);
+ for arg in args_to_check {
+ self.check_unused_parens_core(cx, arg, &msg, false);
}
return;
}
- _ => return,
};
self.check_unused_parens_core(cx, &value, msg, struct_lit_needs_parens);
}
for adj in cx.tables.expr_adjustments(e) {
if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind {
let msg = match m {
- hir::MutImmutable => "unnecessary allocation, use & instead",
- hir::MutMutable => "unnecessary allocation, use &mut instead"
+ adjustment::AutoBorrowMutability::Immutable =>
+ "unnecessary allocation, use & instead",
+ adjustment::AutoBorrowMutability::Mutable { .. }=>
+ "unnecessary allocation, use &mut instead"
};
cx.span_lint(UNUSED_ALLOCATION, e.span, msg);
}
"immutable",
"mutable",
) {
- (BorrowKind::Shared, lft, _, BorrowKind::Mut, _, rgt) |
- (BorrowKind::Mut, _, lft, BorrowKind::Shared, rgt, _) => self.tcx
+ (BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) |
+ (BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => self.tcx
.cannot_reborrow_already_borrowed(
span,
&desc_place,
Origin::Mir,
),
- (BorrowKind::Mut, _, _, BorrowKind::Mut, _, _) => self.tcx
+ (BorrowKind::Mut { .. }, _, _, BorrowKind::Mut { .. }, _, _) => self.tcx
.cannot_mutably_borrow_multiply(
span,
&desc_place,
Origin::Mir,
),
- (BorrowKind::Mut, _, lft, BorrowKind::Unique, _, _) => self.tcx
+ (BorrowKind::Mut { .. }, _, lft, BorrowKind::Unique, _, _) => self.tcx
.cannot_reborrow_already_uniquely_borrowed(
span,
&desc_place,
let scope_tree = borrows.0.scope_tree();
let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All).last().unwrap();
- match root_place {
- &Place::Local(local) => {
- if let Some(_) = self.storage_dead_or_drop_error_reported_l.replace(local) {
- debug!("report_does_not_live_long_enough({:?}): <suppressed>",
- (borrow, drop_span));
- return
- }
- }
- &Place::Static(ref statik) => {
- if let Some(_) = self.storage_dead_or_drop_error_reported_s
- .replace(statik.def_id)
- {
- debug!("report_does_not_live_long_enough({:?}): <suppressed>",
- (borrow, drop_span));
- return
- }
- },
- &Place::Projection(_) =>
- unreachable!("root_place is an unreachable???")
- };
-
let borrow_span = self.mir.source_info(borrow.location).span;
let proper_span = match *root_place {
Place::Local(local) => self.mir.local_decls[local].source_info.span,
_ => drop_span,
};
+ if self.access_place_error_reported.contains(&(root_place.clone(), borrow_span)) {
+ debug!("suppressing access_place error when borrow doesn't live long enough for {:?}",
+ borrow_span);
+ return;
+ }
+
+ self.access_place_error_reported.insert((root_place.clone(), borrow_span));
+
match (borrow.region, &self.describe_place(&borrow.borrowed_place)) {
(RegionKind::ReScope(_), Some(name)) => {
self.report_scoped_local_value_does_not_live_long_enough(
use rustc::infer::InferCtxt;
use rustc::ty::{self, ParamEnv, TyCtxt};
use rustc::ty::maps::Providers;
-use rustc::mir::{AssertMessage, BasicBlock, BorrowKind, Local, Location, Place};
+use rustc::mir::{AssertMessage, BasicBlock, BorrowKind, Location, Place};
use rustc::mir::{Mir, Mutability, Operand, Projection, ProjectionElem, Rvalue};
use rustc::mir::{Field, Statement, StatementKind, Terminator, TerminatorKind};
use rustc::mir::ClosureRegionRequirements;
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false,
hir::BodyOwnerKind::Fn => true,
},
- storage_dead_or_drop_error_reported_l: FxHashSet(),
- storage_dead_or_drop_error_reported_s: FxHashSet(),
+ access_place_error_reported: FxHashSet(),
reservation_error_reported: FxHashSet(),
nonlexical_regioncx: opt_regioncx.clone(),
};
/// I'm not sure this is the right approach - @eddyb could you try and
/// figure this out?
locals_are_invalidated_at_exit: bool,
- /// This field keeps track of when storage dead or drop errors are reported
- /// in order to stop duplicate error reporting and identify the conditions required
- /// for a "temporary value dropped here while still borrowed" error. See #45360.
- storage_dead_or_drop_error_reported_l: FxHashSet<Local>,
- /// Same as the above, but for statics (thread-locals)
- storage_dead_or_drop_error_reported_s: FxHashSet<DefId>,
+ /// This field keeps track of when borrow errors are reported in the access_place function
+ /// so that there is no duplicate reporting. This field cannot also be used for the conflicting
+ /// borrow errors that is handled by the `reservation_error_reported` field as the inclusion
+ /// of the `Span` type (while required to mute some errors) stops the muting of the reservation
+ /// errors.
+ access_place_error_reported: FxHashSet<(Place<'tcx>, Span)>,
/// This field keeps track of when borrow conflict errors are reported
/// for reservations, so that we don't report seemingly duplicate
/// errors for corresponding activations
match stmt.kind {
StatementKind::Assign(ref lhs, ref rhs) => {
+ self.consume_rvalue(
+ ContextKind::AssignRhs.new(location),
+ (rhs, span),
+ location,
+ flow_state,
+ );
+
self.mutate_place(
ContextKind::AssignLhs.new(location),
(lhs, span),
JustWrite,
flow_state,
);
-
- self.consume_rvalue(
- ContextKind::AssignRhs.new(location),
- (rhs, span),
- location,
- flow_state,
- );
}
StatementKind::SetDiscriminant {
ref place,
TerminatorKind::Goto { target: _ }
| TerminatorKind::Abort
| TerminatorKind::Unreachable
- | TerminatorKind::FalseEdges { .. } => {
+ | TerminatorKind::FalseEdges { real_target: _, imaginary_targets: _ }
+ | TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => {
// no data used, thus irrelevant to borrowck
}
}
}
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
+ /// Returns true if the borrow represented by `kind` is
+ /// allowed to be split into separate Reservation and
+ /// Activation phases.
+ fn allow_two_phase_borrow(&self, kind: BorrowKind) -> bool {
+ self.tcx.sess.two_phase_borrows() &&
+ (kind.allows_two_phase_borrow() ||
+ self.tcx.sess.opts.debugging_opts.two_phase_beyond_autoref)
+ }
+
/// Checks an access to the given place to see if it is allowed. Examines the set of borrows
/// that are in scope, as well as which paths have been initialized, to ensure that (a) the
/// place is initialized and (b) it is not borrowed in some way that would prevent this
if let Activation(_, borrow_index) = rw {
if self.reservation_error_reported.contains(&place_span.0) {
- debug!(
- "skipping access_place for activation of invalid reservation \
- place: {:?} borrow_index: {:?}",
- place_span.0,
- borrow_index
- );
+ debug!("skipping access_place for activation of invalid reservation \
+ place: {:?} borrow_index: {:?}", place_span.0, borrow_index);
return AccessErrorsReported {
mutability_error: false,
conflict_error: true,
}
}
+ if self.access_place_error_reported.contains(&(place_span.0.clone(), place_span.1)) {
+ debug!("access_place: suppressing error place_span=`{:?}` kind=`{:?}`",
+ place_span, kind);
+ return AccessErrorsReported {
+ mutability_error: false,
+ conflict_error: true,
+ };
+ }
+
let mutability_error =
self.check_access_permissions(place_span, rw, is_local_mutation_allowed);
let conflict_error =
self.check_access_for_conflict(context, place_span, sd, rw, flow_state);
+ if conflict_error || mutability_error {
+ debug!("access_place: logging error place_span=`{:?}` kind=`{:?}`",
+ place_span, kind);
+ self.access_place_error_reported.insert((place_span.0.clone(), place_span.1));
+ }
+
AccessErrorsReported {
mutability_error,
conflict_error,
Control::Continue
}
- (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut) => {
+ (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => {
// Reading from mere reservations of mutable-borrows is OK.
- if this.tcx.sess.two_phase_borrows() && index.is_reservation()
+ if this.allow_two_phase_borrow(borrow.kind) && index.is_reservation()
{
return Control::Continue;
}
}
(Reservation(kind), BorrowKind::Unique)
- | (Reservation(kind), BorrowKind::Mut)
+ | (Reservation(kind), BorrowKind::Mut { .. })
| (Activation(kind, _), _)
| (Write(kind), _) => {
match rw {
place_span.0
);
this.reservation_error_reported.insert(place_span.0.clone());
- }
+ },
Activation(_, activating) => {
debug!(
"observing check_place for activation of \
borrow_index: {:?}",
activating
);
- }
- Read(..) | Write(..) => {}
+ },
+ Read(..) | Write(..) => {},
}
match kind {
Rvalue::Ref(_ /*rgn*/, bk, ref place) => {
let access_kind = match bk {
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
- BorrowKind::Unique | BorrowKind::Mut => {
+ BorrowKind::Unique | BorrowKind::Mut { .. } => {
let wk = WriteKind::MutableBorrow(bk);
- if self.tcx.sess.two_phase_borrows() {
+ if self.allow_two_phase_borrow(bk) {
(Deep, Reservation(wk))
} else {
(Deep, Write(wk))
// mutable borrow before we check it.
match borrow.kind {
BorrowKind::Shared => return,
- BorrowKind::Unique | BorrowKind::Mut => {}
+ BorrowKind::Unique | BorrowKind::Mut { .. } => {}
}
self.access_place(
span_bug!(span, "&unique borrow for {:?} should not fail", place);
}
}
- Reservation(WriteKind::MutableBorrow(BorrowKind::Mut))
- | Write(WriteKind::MutableBorrow(BorrowKind::Mut)) => if let Err(place_err) =
+ Reservation(WriteKind::MutableBorrow(BorrowKind::Mut { .. }))
+ | Write(WriteKind::MutableBorrow(BorrowKind::Mut { .. })) => if let Err(place_err) =
self.is_mutable(place, is_local_mutation_allowed)
{
error_reported = true;
Activation(..) => {} // permission checks are done at Reservation point.
Read(ReadKind::Borrow(BorrowKind::Unique))
- | Read(ReadKind::Borrow(BorrowKind::Mut))
+ | Read(ReadKind::Borrow(BorrowKind::Mut { .. }))
| Read(ReadKind::Borrow(BorrowKind::Shared))
| Read(ReadKind::Copy) => {} // Access authorized
}
&substs[..]
));
}
- DefiningTy::Const(ty) => {
+ DefiningTy::Const(def_id, substs) => {
err.note(&format!(
- "defining type: {:?}",
- ty
+ "defining constant type: {:?} with substs {:#?}",
+ def_id,
+ &substs[..]
));
}
}
use rustc::mir::{BasicBlock, Location, Mir};
use rustc::mir::Local;
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
+use rustc::traits;
+use rustc::infer::InferOk;
use rustc::util::common::ErrorReported;
+use borrow_check::nll::type_check::AtLocation;
use rustc_data_structures::fx::FxHashSet;
use syntax::codemap::DUMMY_SP;
use util::liveness::LivenessResults;
location
);
- let tcx = self.cx.infcx.tcx;
- let mut types = vec![(dropped_ty, 0)];
- let mut known = FxHashSet();
- while let Some((ty, depth)) = types.pop() {
- let span = DUMMY_SP; // FIXME
- let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) {
- Ok(result) => result,
- Err(ErrorReported) => {
- continue;
- }
- };
-
- let ty::DtorckConstraint {
- outlives,
- dtorck_types,
- } = result;
-
- // All things in the `outlives` array may be touched by
- // the destructor and must be live at this point.
- for outlive in outlives {
- let cause = Cause::DropVar(dropped_local, location);
- self.push_type_live_constraint(outlive, location, cause);
- }
+ // If we end visiting the same type twice (usually due to a cycle involving
+ // associated types), we need to ensure that its region types match up with the type
+ // we added to the 'known' map the first time around. For this reason, we need
+ // our infcx to hold onto its calculated region constraints after each call
+ // to dtorck_constraint_for_ty. Otherwise, normalizing the corresponding associated
+ // type will end up instantiating the type with a new set of inference variables
+ // Since this new type will never be in 'known', we end up looping forever.
+ //
+ // For this reason, we avoid calling TypeChecker.normalize, instead doing all normalization
+ // ourselves in one large 'fully_perform_op' callback.
+ let (type_constraints, kind_constraints) = self.cx.fully_perform_op(location.at_self(),
+ |cx| {
+
+ let tcx = cx.infcx.tcx;
+ let mut selcx = traits::SelectionContext::new(cx.infcx);
+ let cause = cx.misc(cx.last_span);
+
+ let mut types = vec![(dropped_ty, 0)];
+ let mut final_obligations = Vec::new();
+ let mut type_constraints = Vec::new();
+ let mut kind_constraints = Vec::new();
- // However, there may also be some types that
- // `dtorck_constraint_for_ty` could not resolve (e.g.,
- // associated types and parameters). We need to normalize
- // associated types here and possibly recursively process.
- for ty in dtorck_types {
- let ty = self.cx.normalize(&ty, location);
- let ty = self.cx.infcx.resolve_type_and_region_vars_if_possible(&ty);
- match ty.sty {
- ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => {
- let cause = Cause::DropVar(dropped_local, location);
- self.push_type_live_constraint(ty, location, cause);
+ let mut known = FxHashSet();
+
+ while let Some((ty, depth)) = types.pop() {
+ let span = DUMMY_SP; // FIXME
+ let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) {
+ Ok(result) => result,
+ Err(ErrorReported) => {
+ continue;
}
+ };
+
+ let ty::DtorckConstraint {
+ outlives,
+ dtorck_types,
+ } = result;
+
+ // All things in the `outlives` array may be touched by
+ // the destructor and must be live at this point.
+ for outlive in outlives {
+ let cause = Cause::DropVar(dropped_local, location);
+ kind_constraints.push((outlive, location, cause));
+ }
- _ => if known.insert(ty) {
- types.push((ty, depth + 1));
- },
+ // However, there may also be some types that
+ // `dtorck_constraint_for_ty` could not resolve (e.g.,
+ // associated types and parameters). We need to normalize
+ // associated types here and possibly recursively process.
+ for ty in dtorck_types {
+ let traits::Normalized { value: ty, obligations } =
+ traits::normalize(&mut selcx, cx.param_env, cause.clone(), &ty);
+
+ final_obligations.extend(obligations);
+
+ let ty = cx.infcx.resolve_type_and_region_vars_if_possible(&ty);
+ match ty.sty {
+ ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => {
+ let cause = Cause::DropVar(dropped_local, location);
+ type_constraints.push((ty, location, cause));
+ }
+
+ _ => if known.insert(ty) {
+ types.push((ty, depth + 1));
+ },
+ }
}
}
+
+ Ok(InferOk {
+ value: (type_constraints, kind_constraints), obligations: final_obligations
+ })
+ }).unwrap();
+
+ for (ty, location, cause) in type_constraints {
+ self.push_type_live_constraint(ty, location, cause);
+ }
+
+ for (kind, location, cause) in kind_constraints {
+ self.push_type_live_constraint(kind, location, cause);
}
}
}
}
};
if let PlaceContext::Copy = context {
- let ty = place_ty.to_ty(self.tcx());
- if self.cx
- .infcx
- .type_moves_by_default(self.cx.param_env, ty, DUMMY_SP)
- {
- span_mirbug!(self, place, "attempted copy of non-Copy type ({:?})", ty);
- }
+ let tcx = self.tcx();
+ let trait_ref = ty::TraitRef {
+ def_id: tcx.lang_items().copy_trait().unwrap(),
+ substs: tcx.mk_substs_trait(place_ty.to_ty(tcx), &[]),
+ };
+
+ // In order to have a Copy operand, the type T of the value must be Copy. Note that we
+ // prove that T: Copy, rather than using the type_moves_by_default test. This is
+ // important because type_moves_by_default ignores the resulting region obligations and
+ // assumes they pass. This can result in bounds from Copy impls being unsoundly ignored
+ // (e.g., #29149). Note that we decide to use Copy before knowing whether the bounds
+ // fully apply: in effect, the rule is that if a value of some type could implement
+ // Copy, then it must.
+ self.cx.prove_trait_ref(trait_ref, location);
}
place_ty
}
| TerminatorKind::GeneratorDrop
| TerminatorKind::Unreachable
| TerminatorKind::Drop { .. }
- | TerminatorKind::FalseEdges { .. } => {
+ | TerminatorKind::FalseEdges { .. }
+ | TerminatorKind::FalseUnwind { .. } => {
// no checks needed for these
}
self.assert_iscleanup(mir, block_data, *target, is_cleanup);
}
}
+ TerminatorKind::FalseUnwind {
+ real_target,
+ unwind
+ } => {
+ self.assert_iscleanup(mir, block_data, real_target, is_cleanup);
+ if let Some(unwind) = unwind {
+ if is_cleanup {
+ span_mirbug!(self, block_data, "cleanup in cleanup block via false unwind");
+ }
+ self.assert_iscleanup(mir, block_data, unwind, true);
+ }
+ }
}
}
/// The MIR represents some form of constant. The signature then
/// is that it has no inputs and a single return value, which is
/// the value of the constant.
- Const(Ty<'tcx>),
+ Const(DefId, &'tcx Substs<'tcx>),
}
#[derive(Debug)]
/// see `DefiningTy` for details.
fn defining_ty(&self) -> DefiningTy<'tcx> {
let tcx = self.infcx.tcx;
-
let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id);
- let defining_ty = if self.mir_def_id == closure_base_def_id {
- tcx.type_of(closure_base_def_id)
- } else {
- let tables = tcx.typeck_tables_of(self.mir_def_id);
- tables.node_id_to_type(self.mir_hir_id)
- };
-
- let defining_ty = self.infcx
- .replace_free_regions_with_nll_infer_vars(FR, &defining_ty);
-
match tcx.hir.body_owner_kind(self.mir_node_id) {
- BodyOwnerKind::Fn => match defining_ty.sty {
- ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs),
- ty::TyGenerator(def_id, substs, interior) => {
- DefiningTy::Generator(def_id, substs, interior)
+ BodyOwnerKind::Fn => {
+ let defining_ty = if self.mir_def_id == closure_base_def_id {
+ tcx.type_of(closure_base_def_id)
+ } else {
+ let tables = tcx.typeck_tables_of(self.mir_def_id);
+ tables.node_id_to_type(self.mir_hir_id)
+ };
+
+ let defining_ty = self.infcx
+ .replace_free_regions_with_nll_infer_vars(FR, &defining_ty);
+
+ match defining_ty.sty {
+ ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs),
+ ty::TyGenerator(def_id, substs, interior) => {
+ DefiningTy::Generator(def_id, substs, interior)
+ }
+ ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs),
+ _ => span_bug!(
+ tcx.def_span(self.mir_def_id),
+ "expected defining type for `{:?}`: `{:?}`",
+ self.mir_def_id,
+ defining_ty
+ ),
}
- ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs),
- _ => span_bug!(
- tcx.def_span(self.mir_def_id),
- "expected defining type for `{:?}`: `{:?}`",
- self.mir_def_id,
- defining_ty
- ),
- },
- BodyOwnerKind::Const | BodyOwnerKind::Static(..) => DefiningTy::Const(defining_ty),
+ }
+
+ BodyOwnerKind::Const | BodyOwnerKind::Static(..) => {
+ assert_eq!(closure_base_def_id, self.mir_def_id);
+ let identity_substs = Substs::identity_for_item(tcx, closure_base_def_id);
+ let substs = self.infcx
+ .replace_free_regions_with_nll_infer_vars(FR, &identity_substs);
+ DefiningTy::Const(self.mir_def_id, substs)
+ }
}
}
substs.substs
}
- DefiningTy::FnDef(_, substs) => substs,
-
- // When we encounter a constant body, just return whatever
- // substitutions are in scope for that constant.
- DefiningTy::Const(_) => {
- identity_substs
- }
+ DefiningTy::FnDef(_, substs) | DefiningTy::Const(_, substs) => substs,
};
let global_mapping = iter::once((gcx.types.re_static, fr_static));
sig.inputs_and_output()
}
- // For a constant body, there are no inputs, and one
- // "output" (the type of the constant).
- DefiningTy::Const(ty) => ty::Binder::dummy(tcx.mk_type_list(iter::once(ty))),
+ DefiningTy::Const(def_id, _) => {
+ // For a constant body, there are no inputs, and one
+ // "output" (the type of the constant).
+ assert_eq!(self.mir_def_id, def_id);
+ let ty = tcx.type_of(def_id);
+ let ty = indices.fold_to_region_vids(tcx, &ty);
+ ty::Binder::dummy(tcx.mk_type_list(iter::once(ty)))
+ }
}
}
// Or:
//
// [block: If(lhs)] -false-> [else_block: If(rhs)] -true-> [true_block]
- // | | (false)
- // +----------true------------+-------------------> [false_block]
+ // | (true) | (false)
+ // [true_block] [false_block]
let (true_block, false_block, mut else_block, join_block) =
(this.cfg.start_new_block(), this.cfg.start_new_block(),
join_block.unit()
}
ExprKind::Loop { condition: opt_cond_expr, body } => {
- // [block] --> [loop_block] ~~> [loop_block_end] -1-> [exit_block]
- // ^ |
- // | 0
- // | |
- // | v
- // [body_block_end] <~~~ [body_block]
+ // [block] --> [loop_block] -/eval. cond./-> [loop_block_end] -1-> [exit_block]
+ // ^ |
+ // | 0
+ // | |
+ // | v
+ // [body_block_end] <-/eval. body/-- [body_block]
//
// If `opt_cond_expr` is `None`, then the graph is somewhat simplified:
//
- // [block] --> [loop_block / body_block ] ~~> [body_block_end] [exit_block]
- // ^ |
- // | |
- // +--------------------------+
- //
+ // [block]
+ // |
+ // [loop_block] -> [body_block] -/eval. body/-> [body_block_end]
+ // | ^ |
+ // false link | |
+ // | +-----------------------------------------+
+ // +-> [diverge_cleanup]
+ // The false link is required to make sure borrowck considers unwinds through the
+ // body, even when the exact code in the body cannot unwind
let loop_block = this.cfg.start_new_block();
let exit_block = this.cfg.start_new_block();
// always `()` anyway
this.cfg.push_assign_unit(exit_block, source_info, destination);
} else {
- body_block = loop_block;
+ body_block = this.cfg.start_new_block();
+ let diverge_cleanup = this.diverge_cleanup();
+ this.cfg.terminate(loop_block, source_info,
+ TerminatorKind::FalseUnwind {
+ real_target: body_block,
+ unwind: Some(diverge_cleanup)
+ })
}
// The “return” value of the loop body must always be an unit. We therefore
-> BlockAnd<()> {
let discriminant_place = unpack!(block = self.as_place(block, discriminant));
+ // Matching on a `discriminant_place` with an uninhabited type doesn't
+ // generate any memory reads by itself, and so if the place "expression"
+ // contains unsafe operations like raw pointer dereferences or union
+ // field projections, we wouldn't know to require an `unsafe` block
+ // around a `match` equivalent to `std::intrinsics::unreachable()`.
+ // See issue #47412 for this hole being discovered in the wild.
+ //
+ // HACK(eddyb) Work around the above issue by adding a dummy inspection
+ // of `discriminant_place`, specifically by applying `Rvalue::Discriminant`
+ // (which will work regardless of type) and storing the result in a temp.
+ let dummy_source_info = self.source_info(span);
+ let dummy_access = Rvalue::Discriminant(discriminant_place.clone());
+ let dummy_ty = dummy_access.ty(&self.local_decls, self.hir.tcx());
+ let dummy_temp = self.temp(dummy_ty, dummy_source_info.span);
+ self.cfg.push_assign(block, dummy_source_info, &dummy_temp, dummy_access);
+
let mut arm_blocks = ArmBlocks {
blocks: arms.iter()
.map(|_| self.cfg.start_new_block())
TerminatorKind::FalseEdges {
real_target: block,
imaginary_targets:
- vec![candidate.next_candidate_pre_binding_block]});
+ vec![candidate.next_candidate_pre_binding_block],
+ });
self.bind_matched_candidate(block, candidate.bindings);
TerminatorKind::FalseEdges {
real_target: otherwise,
imaginary_targets:
- vec![candidate.next_candidate_pre_binding_block] });
+ vec![candidate.next_candidate_pre_binding_block],
+ });
Some(otherwise)
} else {
self.cfg.terminate(block, candidate_source_info,
let kind = match self.kind {
mir::BorrowKind::Shared => "",
mir::BorrowKind::Unique => "uniq ",
- mir::BorrowKind::Mut => "mut ",
+ mir::BorrowKind::Mut { .. } => "mut ",
};
let region = format!("{}", self.region);
let region = if region.len() > 0 { format!("{} ", region) } else { region };
mir::TerminatorKind::Yield {..} |
mir::TerminatorKind::Goto {..} |
mir::TerminatorKind::FalseEdges {..} |
+ mir::TerminatorKind::FalseUnwind {..} |
mir::TerminatorKind::Unreachable => {}
}
}
self.propagate_bits_into_entry_set_for(in_out, changed, target);
}
}
+ mir::TerminatorKind::FalseUnwind { ref real_target, unwind } => {
+ self.propagate_bits_into_entry_set_for(in_out, changed, real_target);
+ if let Some(ref unwind) = unwind {
+ if !self.dead_unwinds.contains(&bb) {
+ self.propagate_bits_into_entry_set_for(in_out, changed, unwind);
+ }
+ }
+ }
}
}
TerminatorKind::Abort |
TerminatorKind::GeneratorDrop |
TerminatorKind::FalseEdges { .. } |
+ TerminatorKind::FalseUnwind { .. } |
TerminatorKind::Unreachable => { }
TerminatorKind::Return => {
use rustc::hir::def::{Def, CtorKind};
use rustc::middle::const_val::ConstVal;
use rustc::ty::{self, AdtKind, VariantDef, Ty};
-use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
+use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability};
use rustc::ty::cast::CastKind as TyCastKind;
use rustc::hir;
use rustc::hir::def_id::LocalDefId;
+use rustc::mir::{BorrowKind};
impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
type Output = Expr<'tcx>;
span,
kind: ExprKind::Borrow {
region: deref.region,
- borrow_kind: to_borrow_kind(deref.mutbl),
+ borrow_kind: deref.mutbl.to_borrow_kind(),
arg: expr.to_ref(),
},
};
Adjust::Borrow(AutoBorrow::Ref(r, m)) => {
ExprKind::Borrow {
region: r,
- borrow_kind: to_borrow_kind(m),
+ borrow_kind: m.to_borrow_kind(),
arg: expr.to_ref(),
}
}
span,
kind: ExprKind::Borrow {
region,
- borrow_kind: to_borrow_kind(m),
+ borrow_kind: m.to_borrow_kind(),
arg: expr.to_ref(),
},
};
- ExprKind::Cast { source: expr.to_ref() }
+ let cast_expr = Expr {
+ temp_lifetime,
+ ty: adjustment.target,
+ span,
+ kind: ExprKind::Cast { source: expr.to_ref() }
+ };
+
+ // To ensure that both implicit and explicit coercions are
+ // handled the same way, we insert an extra layer of indirection here.
+ // For explicit casts (e.g. 'foo as *const T'), the source of the 'Use'
+ // will be an ExprKind::Hair with the appropriate cast expression. Here,
+ // we make our Use source the generated Cast from the original coercion.
+ //
+ // In both cases, this outer 'Use' ensures that the inner 'Cast' is handled by
+ // as_operand, not by as_rvalue - causing the cast result to be stored in a temporary.
+ // Ordinary, this is identical to using the cast directly as an rvalue. However, if the
+ // source of the cast was previously borrowed as mutable, storing the cast in a
+ // temporary gives the source a chance to expire before the cast is used. For
+ // structs with a self-referential *mut ptr, this allows assignment to work as
+ // expected.
+ //
+ // For example, consider the type 'struct Foo { field: *mut Foo }',
+ // The method 'fn bar(&mut self) { self.field = self }'
+ // triggers a coercion from '&mut self' to '*mut self'. In order
+ // for the assignment to be valid, the implicit borrow
+ // of 'self' involved in the coercion needs to end before the local
+ // containing the '*mut T' is assigned to 'self.field' - otherwise,
+ // we end up trying to assign to 'self.field' while we have another mutable borrow
+ // active.
+ //
+ // We only need to worry about this kind of thing for coercions from refs to ptrs,
+ // since they get rid of a borrow implicitly.
+ ExprKind::Use { source: cast_expr.to_ref() }
}
Adjust::Unsize => {
ExprKind::Unsize { source: expr.to_ref() }
};
ExprKind::Borrow {
region,
- borrow_kind: to_borrow_kind(mutbl),
+ borrow_kind: mutbl.to_borrow_kind(),
arg: expr.to_ref(),
}
}
}
}
-fn to_borrow_kind(m: hir::Mutability) -> BorrowKind {
- match m {
- hir::MutMutable => BorrowKind::Mut,
- hir::MutImmutable => BorrowKind::Shared,
+trait ToBorrowKind { fn to_borrow_kind(&self) -> BorrowKind; }
+
+impl ToBorrowKind for AutoBorrowMutability {
+ fn to_borrow_kind(&self) -> BorrowKind {
+ match *self {
+ AutoBorrowMutability::Mutable { allow_two_phase_borrow } =>
+ BorrowKind::Mut { allow_two_phase_borrow },
+ AutoBorrowMutability::Immutable =>
+ BorrowKind::Shared,
+ }
+ }
+}
+
+impl ToBorrowKind for hir::Mutability {
+ fn to_borrow_kind(&self) -> BorrowKind {
+ match *self {
+ hir::MutMutable => BorrowKind::Mut { allow_two_phase_borrow: false },
+ hir::MutImmutable => BorrowKind::Shared,
+ }
}
}
let borrow_kind = match upvar_borrow.kind {
ty::BorrowKind::ImmBorrow => BorrowKind::Shared,
ty::BorrowKind::UniqueImmBorrow => BorrowKind::Unique,
- ty::BorrowKind::MutBorrow => BorrowKind::Mut,
+ ty::BorrowKind::MutBorrow => BorrowKind::Mut { allow_two_phase_borrow: false }
};
Expr {
temp_lifetime,
ecx.write_primval(dest, PrimVal::from_u128(size), dest_layout.ty)?;
}
+ "type_id" => {
+ let ty = substs.type_at(0);
+ let type_id = ecx.tcx.type_id_hash(ty) as u128;
+ ecx.write_primval(dest, PrimVal::from_u128(type_id), dest_layout.ty)?;
+ }
+
name => return Err(ConstEvalError::NeedsRfc(format!("calling intrinsic `{}`", name)).into()),
}
ReifyFnPointer => {
match self.eval_operand(operand)?.ty.sty {
ty::TyFnDef(def_id, substs) => {
+ if self.tcx.has_attr(def_id, "rustc_args_required_const") {
+ bug!("reifying a fn ptr that requires \
+ const arguments");
+ }
let instance = self.resolve(def_id, substs)?;
let fn_ptr = self.memory.create_fn_alloc(instance);
let valty = ValTy {
Resume => unimplemented!(),
Abort => unimplemented!(),
FalseEdges { .. } => bug!("should have been eliminated by `simplify_branches` mir pass"),
+ FalseUnwind { .. } => bug!("should have been eliminated by `simplify_branches` mir pass"),
Unreachable => return err!(Unreachable),
}
mir::TerminatorKind::Assert { .. } => {}
mir::TerminatorKind::GeneratorDrop |
mir::TerminatorKind::Yield { .. } |
- mir::TerminatorKind::FalseEdges { .. } => bug!(),
+ mir::TerminatorKind::FalseEdges { .. } |
+ mir::TerminatorKind::FalseUnwind { .. } => bug!(),
}
self.super_terminator_kind(block, kind, location);
{
debug!("build_clone_shim(def_id={:?})", def_id);
- let mut builder = CloneShimBuilder::new(tcx, def_id);
+ let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty);
let is_copy = !self_ty.moves_by_default(tcx, tcx.param_env(def_id), builder.span);
+ let dest = Place::Local(RETURN_PLACE);
+ let src = Place::Local(Local::new(1+0)).deref();
+
match self_ty.sty {
_ if is_copy => builder.copy_shim(),
ty::TyArray(ty, len) => {
let len = len.val.to_const_int().unwrap().to_u64().unwrap();
- builder.array_shim(ty, len)
+ builder.array_shim(dest, src, ty, len)
}
ty::TyClosure(def_id, substs) => {
builder.tuple_like_shim(
- &substs.upvar_tys(def_id, tcx).collect::<Vec<_>>(),
- AggregateKind::Closure(def_id, substs)
+ dest, src,
+ substs.upvar_tys(def_id, tcx)
)
}
- ty::TyTuple(tys, _) => builder.tuple_like_shim(&**tys, AggregateKind::Tuple),
+ ty::TyTuple(tys, _) => builder.tuple_like_shim(dest, src, tys.iter().cloned()),
_ => {
bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty)
}
}
impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
- fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Self {
- let sig = tcx.fn_sig(def_id);
+ fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ def_id: DefId,
+ self_ty: Ty<'tcx>) -> Self {
+ // we must subst the self_ty because it's
+ // otherwise going to be TySelf and we can't index
+ // or access fields of a Place of type TySelf.
+ let substs = tcx.mk_substs_trait(self_ty, &[]);
+ let sig = tcx.fn_sig(def_id).subst(tcx, substs);
let sig = tcx.erase_late_bound_regions(&sig);
let span = tcx.def_span(def_id);
})
}
+ /// Gives the index of an upcoming BasicBlock, with an offset.
+ /// offset=0 will give you the index of the next BasicBlock,
+ /// offset=1 will give the index of the next-to-next block,
+ /// offset=-1 will give you the index of the last-created block
+ fn block_index_offset(&mut self, offset: usize) -> BasicBlock {
+ BasicBlock::new(self.blocks.len() + offset)
+ }
+
fn make_statement(&self, kind: StatementKind<'tcx>) -> Statement<'tcx> {
Statement {
source_info: self.source_info(),
fn make_clone_call(
&mut self,
+ dest: Place<'tcx>,
+ src: Place<'tcx>,
ty: Ty<'tcx>,
- rcvr_field: Place<'tcx>,
next: BasicBlock,
cleanup: BasicBlock
- ) -> Place<'tcx> {
+ ) {
let tcx = self.tcx;
let substs = Substs::for_item(
})
);
- let loc = self.make_place(Mutability::Not, ty);
-
- // `let ref_loc: &ty = &rcvr_field;`
+ // `let ref_loc: &ty = &src;`
let statement = self.make_statement(
StatementKind::Assign(
ref_loc.clone(),
- Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, rcvr_field)
+ Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, src)
)
);
self.block(vec![statement], TerminatorKind::Call {
func,
args: vec![Operand::Move(ref_loc)],
- destination: Some((loc.clone(), next)),
+ destination: Some((dest, next)),
cleanup: Some(cleanup),
}, false);
-
- loc
}
fn loop_header(
}
}
- fn array_shim(&mut self, ty: Ty<'tcx>, len: u64) {
+ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len: u64) {
let tcx = self.tcx;
let span = self.span;
- let rcvr = Place::Local(Local::new(1+0)).deref();
let beg = self.local_decls.push(temp_decl(Mutability::Mut, tcx.types.usize, span));
let end = self.make_place(Mutability::Not, tcx.types.usize);
- let ret = self.make_place(Mutability::Mut, tcx.mk_array(ty, len));
// BB #0
// `let mut beg = 0;`
self.loop_header(Place::Local(beg), end, BasicBlock::new(2), BasicBlock::new(4), false);
// BB #2
- // `let cloned = Clone::clone(rcvr[beg])`;
+ // `dest[i] = Clone::clone(src[beg])`;
// Goto #3 if ok, #5 if unwinding happens.
- let rcvr_field = rcvr.clone().index(beg);
- let cloned = self.make_clone_call(ty, rcvr_field, BasicBlock::new(3), BasicBlock::new(5));
+ let dest_field = dest.clone().index(beg);
+ let src_field = src.clone().index(beg);
+ self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3),
+ BasicBlock::new(5));
// BB #3
- // `ret[beg] = cloned;`
// `beg = beg + 1;`
// `goto #1`;
- let ret_field = ret.clone().index(beg);
let statements = vec![
- self.make_statement(
- StatementKind::Assign(
- ret_field,
- Rvalue::Use(Operand::Move(cloned))
- )
- ),
self.make_statement(
StatementKind::Assign(
Place::Local(beg),
self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
// BB #4
- // `return ret;`
- let ret_statement = self.make_statement(
- StatementKind::Assign(
- Place::Local(RETURN_PLACE),
- Rvalue::Use(Operand::Move(ret.clone())),
- )
- );
- self.block(vec![ret_statement], TerminatorKind::Return, false);
+ // `return dest;`
+ self.block(vec![], TerminatorKind::Return, false);
// BB #5 (cleanup)
// `let end = beg;`
BasicBlock::new(7), BasicBlock::new(9), true);
// BB #7 (cleanup)
- // `drop(ret[beg])`;
+ // `drop(dest[beg])`;
self.block(vec![], TerminatorKind::Drop {
- location: ret.index(beg),
+ location: dest.index(beg),
target: BasicBlock::new(8),
unwind: None,
}, true);
self.block(vec![], TerminatorKind::Resume, true);
}
- fn tuple_like_shim(&mut self, tys: &[ty::Ty<'tcx>], kind: AggregateKind<'tcx>) {
- match kind {
- AggregateKind::Tuple | AggregateKind::Closure(..) => (),
- _ => bug!("only tuples and closures are accepted"),
- };
+ fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>,
+ src: Place<'tcx>, tys: I)
+ where I: Iterator<Item = ty::Ty<'tcx>> {
+ let mut previous_field = None;
+ for (i, ity) in tys.enumerate() {
+ let field = Field::new(i);
+ let src_field = src.clone().field(field, ity);
- let rcvr = Place::Local(Local::new(1+0)).deref();
+ let dest_field = dest.clone().field(field, ity);
- let mut returns = Vec::new();
- for (i, ity) in tys.iter().enumerate() {
- let rcvr_field = rcvr.clone().field(Field::new(i), *ity);
+ // #(2i + 1) is the cleanup block for the previous clone operation
+ let cleanup_block = self.block_index_offset(1);
+ // #(2i + 2) is the next cloning block
+ // (or the Return terminator if this is the last block)
+ let next_block = self.block_index_offset(2);
// BB #(2i)
- // `returns[i] = Clone::clone(&rcvr.i);`
+ // `dest.i = Clone::clone(&src.i);`
// Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens.
- returns.push(
- self.make_clone_call(
- *ity,
- rcvr_field,
- BasicBlock::new(2 * i + 2),
- BasicBlock::new(2 * i + 1),
- )
+ self.make_clone_call(
+ dest_field.clone(),
+ src_field,
+ ity,
+ next_block,
+ cleanup_block,
);
// BB #(2i + 1) (cleanup)
- if i == 0 {
- // Nothing to drop, just resume.
- self.block(vec![], TerminatorKind::Resume, true);
- } else {
+ if let Some((previous_field, previous_cleanup)) = previous_field.take() {
// Drop previous field and goto previous cleanup block.
self.block(vec![], TerminatorKind::Drop {
- location: returns[i - 1].clone(),
- target: BasicBlock::new(2 * i - 1),
+ location: previous_field,
+ target: previous_cleanup,
unwind: None,
}, true);
+ } else {
+ // Nothing to drop, just resume.
+ self.block(vec![], TerminatorKind::Resume, true);
}
+
+ previous_field = Some((dest_field, cleanup_block));
}
- // `return kind(returns[0], returns[1], ..., returns[tys.len() - 1]);`
- let ret_statement = self.make_statement(
- StatementKind::Assign(
- Place::Local(RETURN_PLACE),
- Rvalue::Aggregate(
- box kind,
- returns.into_iter().map(Operand::Move).collect()
- )
- )
- );
- self.block(vec![ret_statement], TerminatorKind::Return, false);
+ self.block(vec![], TerminatorKind::Return, false);
}
}
}),
span
));
+ let borrow_kind = BorrowKind::Mut {
+ allow_two_phase_borrow: false,
+ };
statements.push(Statement {
source_info,
kind: StatementKind::Assign(
Place::Local(ref_rcvr),
- Rvalue::Ref(tcx.types.re_erased, BorrowKind::Mut, rcvr_l)
+ Rvalue::Ref(tcx.types.re_erased, borrow_kind, rcvr_l)
)
});
Operand::Move(Place::Local(ref_rcvr))
TerminatorKind::Abort |
TerminatorKind::Return |
TerminatorKind::Unreachable |
- TerminatorKind::FalseEdges { .. } => {
+ TerminatorKind::FalseEdges { .. } |
+ TerminatorKind::FalseUnwind { .. } => {
// safe (at least as emitted during MIR construction)
}
debug!("Creating temp for return destination");
let dest = Rvalue::Ref(
self.tcx.types.re_erased,
- BorrowKind::Mut,
+ BorrowKind::Mut { allow_two_phase_borrow: false },
destination.0);
let ty = dest.ty(caller_mir, self.tcx);
callsite: &CallSite<'tcx>, caller_mir: &mut Mir<'tcx>) -> Local {
let arg = Rvalue::Ref(
self.tcx.types.re_erased,
- BorrowKind::Mut,
+ BorrowKind::Mut { allow_two_phase_borrow: false },
arg.deref());
let ty = arg.ty(caller_mir, self.tcx);
*target = self.update_target(*target);
}
}
+ TerminatorKind::FalseUnwind { real_target: _ , unwind: _ } =>
+ // see the ordering of passes in the optimized_mir query.
+ bug!("False unwinds should have been removed before inlining")
}
}
/// Borrow of a constant temporary.
Ref(Location),
- /// Array of indices found in the third argument of
- /// a call to one of the simd_shuffleN intrinsics.
- ShuffleIndices(BasicBlock)
+ /// Currently applied to function calls where the callee has the unstable
+ /// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle
+ /// intrinsic. The intrinsic requires the arguments are indeed constant and
+ /// the attribute currently provides the semantic requirement that arguments
+ /// must be constant.
+ Argument { bb: BasicBlock, index: usize },
}
struct TempCollector<'tcx> {
_ => bug!()
}
}
- Candidate::ShuffleIndices(bb) => {
+ Candidate::Argument { bb, index } => {
match self.source[bb].terminator_mut().kind {
TerminatorKind::Call { ref mut args, .. } => {
- Rvalue::Use(mem::replace(&mut args[2], new_operand))
+ Rvalue::Use(mem::replace(&mut args[index], new_operand))
}
_ => bug!()
}
}
(statement.source_info.span, dest.ty(mir, tcx).to_ty(tcx))
}
- Candidate::ShuffleIndices(bb) => {
+ Candidate::Argument { bb, index } => {
let terminator = mir[bb].terminator();
let ty = match terminator.kind {
TerminatorKind::Call { ref args, .. } => {
- args[2].ty(mir, tcx)
+ args[index].ty(mir, tcx)
}
_ => {
span_bug!(terminator.source_info.span,
- "expected simd_shuffleN call to promote");
+ "expected call argument to promote");
}
};
(terminator.source_info.span, ty)
use rustc_data_structures::bitvec::BitVector;
use rustc_data_structures::indexed_set::IdxSetBuf;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
+use rustc_data_structures::fx::FxHashSet;
use rustc::hir;
use rustc::hir::def_id::DefId;
use rustc::middle::const_val::ConstVal;
use rustc::middle::lang_items;
use syntax::abi::Abi;
use syntax::attr;
+use syntax::ast::LitKind;
use syntax::feature_gate::UnstableFeatures;
use syntax_pos::{Span, DUMMY_SP};
fn not_const(&mut self) {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
- span_err!(self.tcx.sess, self.span, E0019,
- "{} contains unimplemented expression type", self.mode);
+ let mut err = struct_span_err!(
+ self.tcx.sess,
+ self.span,
+ E0019,
+ "{} contains unimplemented expression type",
+ self.mode
+ );
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note("A function call isn't allowed in the const's initialization expression \
+ because the expression's value must be known at compile-time.");
+ err.note("Remember: you can't use a function call inside a const's initialization \
+ expression! However, you can use it anywhere else.");
+ }
+ err.emit();
}
}
fn statement_like(&mut self) {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
- span_err!(self.tcx.sess, self.span, E0016,
- "blocks in {}s are limited to items and tail expressions",
- self.mode);
+ let mut err = struct_span_err!(
+ self.tcx.sess,
+ self.span,
+ E0016,
+ "blocks in {}s are limited to items and tail expressions",
+ self.mode
+ );
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note("Blocks in constants may only contain items (such as constant, function \
+ definition, etc...) and a tail expression.");
+ err.help("To avoid it, you have to replace the non-item object.");
+ }
+ err.emit();
}
}
TerminatorKind::GeneratorDrop |
TerminatorKind::Yield { .. } |
TerminatorKind::Unreachable |
- TerminatorKind::FalseEdges { .. } => None,
+ TerminatorKind::FalseEdges { .. } |
+ TerminatorKind::FalseUnwind { .. } => None,
TerminatorKind::Return => {
// Check for unused values. This usually means
_ => {}
}
}
- Candidate::ShuffleIndices(_) => {}
+ Candidate::Argument { .. } => {}
}
}
}
if self.mode == Mode::Const || self.mode == Mode::ConstFn {
- span_err!(self.tcx.sess, self.span, E0013,
- "{}s cannot refer to statics, use \
- a constant instead", self.mode);
+ let mut err = struct_span_err!(self.tcx.sess, self.span, E0013,
+ "{}s cannot refer to statics, use \
+ a constant instead", self.mode);
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note(
+ "Static and const variables can refer to other const variables. But a \
+ const variable cannot refer to a static variable."
+ );
+ err.help(
+ "To fix this, the value can be extracted as a const and then used."
+ );
+ }
+ err.emit()
}
}
Place::Projection(ref proj) => {
if let ty::TyRawPtr(_) = base_ty.sty {
this.add(Qualif::NOT_CONST);
if this.mode != Mode::Fn {
- struct_span_err!(this.tcx.sess,
- this.span, E0396,
+ let mut err = struct_span_err!(
+ this.tcx.sess,
+ this.span,
+ E0396,
"raw pointers cannot be dereferenced in {}s",
- this.mode)
- .span_label(this.span,
- "dereference of raw pointer in constant")
- .emit();
+ this.mode
+ );
+ err.span_label(this.span,
+ "dereference of raw pointer in constant");
+ if this.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note(
+ "The value behind a raw pointer can't be determined \
+ at compile-time (or even link-time), which means it \
+ can't be used in a constant expression."
+ );
+ err.help("A possible fix is to dereference your pointer \
+ at some point in run-time.");
+ }
+ err.emit();
}
}
}
}
let ty = place.ty(self.mir, self.tcx).to_ty(self.tcx);
- if kind == BorrowKind::Mut {
+ if let BorrowKind::Mut { .. } = kind {
// In theory, any zero-sized value could be borrowed
// mutably without consequences. However, only &mut []
// is allowed right now, and only in functions.
if !allow {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
- struct_span_err!(self.tcx.sess, self.span, E0017,
- "references in {}s may only refer \
- to immutable values", self.mode)
- .span_label(self.span, format!("{}s require immutable values",
- self.mode))
- .emit();
+ let mut err = struct_span_err!(self.tcx.sess, self.span, E0017,
+ "references in {}s may only refer \
+ to immutable values", self.mode);
+ err.span_label(self.span, format!("{}s require immutable values",
+ self.mode));
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note("References in statics and constants may only refer to \
+ immutable values.\n\n\
+ Statics are shared everywhere, and if they refer to \
+ mutable data one might violate memory safety since \
+ holding multiple mutable references to shared data is \
+ not allowed.\n\n\
+ If you really want global mutable state, try using \
+ static mut or a global UnsafeCell.");
+ }
+ err.emit();
}
}
} else {
(CastTy::FnPtr, CastTy::Int(_)) => {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
- span_err!(self.tcx.sess, self.span, E0018,
- "raw pointers cannot be cast to integers in {}s",
- self.mode);
+ let mut err = struct_span_err!(
+ self.tcx.sess,
+ self.span,
+ E0018,
+ "raw pointers cannot be cast to integers in {}s",
+ self.mode
+ );
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note("\
+The value of static and constant integers must be known at compile time. You can't cast a pointer \
+to an integer because the address of a pointer can vary.
+
+For example, if you write:
+
+```
+static MY_STATIC: u32 = 42;
+static MY_STATIC_ADDR: usize = &MY_STATIC as *const _ as usize;
+static WHAT: usize = (MY_STATIC_ADDR^17) + MY_STATIC_ADDR;
+```
+
+Then `MY_STATIC_ADDR` would contain the address of `MY_STATIC`. However, the address can change \
+when the program is linked, as well as change between different executions due to ASLR, and many \
+linkers would not be able to calculate the value of `WHAT`.
+
+On the other hand, static and constant pointers can point either to a known numeric address or to \
+the address of a symbol.
+
+```
+static MY_STATIC: u32 = 42;
+static MY_STATIC_ADDR: &'static u32 = &MY_STATIC;
+const CONST_ADDR: *const u8 = 0x5f3759df as *const u8;
+```
+
+This does not pose a problem by itself because they can't be accessed directly.");
+ }
+ err.emit();
}
}
_ => {}
Rvalue::NullaryOp(NullOp::Box, _) => {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
- struct_span_err!(self.tcx.sess, self.span, E0010,
- "allocations are not allowed in {}s", self.mode)
- .span_label(self.span, format!("allocation not allowed in {}s", self.mode))
- .emit();
+ let mut err = struct_span_err!(self.tcx.sess, self.span, E0010,
+ "allocations are not allowed in {}s", self.mode);
+ err.span_label(self.span, format!("allocation not allowed in {}s", self.mode));
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note(
+ "The value of statics and constants must be known at compile time, \
+ and they live for the entire lifetime of a program. Creating a boxed \
+ value allocates memory on the heap at runtime, and therefore cannot \
+ be done at compile time."
+ );
+ }
+ err.emit();
}
}
self.visit_operand(func, location);
let fn_ty = func.ty(self.mir, self.tcx);
+ let mut callee_def_id = None;
let (mut is_shuffle, mut is_const_fn) = (false, None);
if let ty::TyFnDef(def_id, _) = fn_ty.sty {
+ callee_def_id = Some(def_id);
match self.tcx.fn_sig(def_id).abi() {
Abi::RustIntrinsic |
Abi::PlatformIntrinsic => {
assert!(!self.tcx.is_const_fn(def_id));
match &self.tcx.item_name(def_id)[..] {
- "size_of" | "min_align_of" => is_const_fn = Some(def_id),
+ "size_of" | "min_align_of" | "type_id" => is_const_fn = Some(def_id),
name if name.starts_with("simd_shuffle") => {
is_shuffle = true;
}
}
+ let constant_arguments = callee_def_id.and_then(|id| {
+ args_required_const(self.tcx, id)
+ });
for (i, arg) in args.iter().enumerate() {
self.nest(|this| {
this.visit_operand(arg, location);
- if is_shuffle && i == 2 && this.mode == Mode::Fn {
- let candidate = Candidate::ShuffleIndices(bb);
+ if this.mode != Mode::Fn {
+ return
+ }
+ let candidate = Candidate::Argument { bb, index: i };
+ if is_shuffle && i == 2 {
if this.can_promote() {
this.promotion_candidates.push(candidate);
} else {
span_err!(this.tcx.sess, this.span, E0526,
"shuffle indices are not constant");
}
+ return
+ }
+
+ let constant_arguments = match constant_arguments.as_ref() {
+ Some(s) => s,
+ None => return,
+ };
+ if !constant_arguments.contains(&i) {
+ return
+ }
+ if this.can_promote() {
+ this.promotion_candidates.push(candidate);
+ } else {
+ this.tcx.sess.span_err(this.span,
+ &format!("argument {} is required to be a constant",
+ i + 1));
}
});
}
// Avoid a generic error for other uses of arguments.
if self.qualif.intersects(Qualif::FN_ARGUMENT) {
let decl = &self.mir.local_decls[index];
- span_err!(self.tcx.sess, decl.source_info.span, E0022,
- "arguments of constant functions can only \
- be immutable by-value bindings");
+ let mut err = struct_span_err!(
+ self.tcx.sess,
+ decl.source_info.span,
+ E0022,
+ "arguments of constant functions can only be immutable by-value bindings"
+ );
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note("Constant functions are not allowed to mutate anything. Thus, \
+ binding to an argument with a mutable pattern is not allowed.");
+ err.note("Remove any mutable bindings from the argument list to fix this \
+ error. In case you need to mutate the argument, try lazily \
+ initializing a global variable instead of using a const fn, or \
+ refactoring the code to a functional style to avoid mutation if \
+ possible.");
+ }
+ err.emit();
return;
}
}
}
}
}
+
+fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option<FxHashSet<usize>> {
+ let attrs = tcx.get_attrs(def_id);
+ let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?;
+ let mut ret = FxHashSet();
+ for meta in attr.meta_item_list()? {
+ match meta.literal()?.node {
+ LitKind::Int(a, _) => { ret.insert(a as usize); }
+ _ => return None,
+ }
+ }
+ Some(ret)
+}
TerminatorKind::Goto { .. } |
TerminatorKind::Resume |
TerminatorKind::SwitchInt { .. } |
- TerminatorKind::FalseEdges { .. } => {
+ TerminatorKind::FalseEdges { .. } |
+ TerminatorKind::FalseUnwind { .. } => {
terminator.successors().iter().all(|succ| {
nop_landing_pads.contains(succ.index())
})
TerminatorKind::FalseEdges { real_target, .. } => {
TerminatorKind::Goto { target: real_target }
},
+ TerminatorKind::FalseUnwind { real_target, .. } => {
+ TerminatorKind::Goto { target: real_target }
+ },
_ => continue
};
}
let result = BasicBlockData {
statements: vec![self.assign(
&Place::Local(ref_place),
- Rvalue::Ref(tcx.types.re_erased, BorrowKind::Mut, self.place.clone())
+ Rvalue::Ref(tcx.types.re_erased,
+ BorrowKind::Mut { allow_two_phase_borrow: false },
+ self.place.clone())
)],
terminator: Some(Terminator {
kind: TerminatorKind::Call {
} else {
(Rvalue::Ref(
tcx.types.re_erased,
- BorrowKind::Mut,
+ BorrowKind::Mut { allow_two_phase_borrow: false },
self.place.clone().index(cur)),
Rvalue::BinaryOp(BinOp::Add, copy(&Place::Local(cur)), one))
};
// cur = tmp as *mut T;
// end = Offset(cur, len);
drop_block_stmts.push(self.assign(&tmp, Rvalue::Ref(
- tcx.types.re_erased, BorrowKind::Mut, self.place.clone()
+ tcx.types.re_erased,
+ BorrowKind::Mut { allow_two_phase_borrow: false },
+ self.place.clone()
)));
drop_block_stmts.push(self.assign(&cur, Rvalue::Cast(
CastKind::Misc, Operand::Move(tmp.clone()), iter_ty
Ok(Ordering::Less) |
Ok(Ordering::Equal) => {}
Ok(Ordering::Greater) => {
- struct_span_err!(self.tcx.sess, start.span, E0030,
- "lower range bound must be less than or equal to upper")
- .span_label(start.span, "lower bound larger than upper bound")
- .emit();
+ let mut err = struct_span_err!(
+ self.tcx.sess,
+ start.span,
+ E0030,
+ "lower range bound must be less than or equal to upper"
+ );
+ err.span_label(start.span, "lower bound larger than upper bound");
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note("When matching against a range, the compiler verifies that \
+ the range is non-empty. Range patterns include both \
+ end-points, so this is equivalent to requiring the start of \
+ the range to be less than or equal to the end of the range.");
+ }
+ err.emit();
}
Err(ErrorReported) => {}
}
TerminatorKind::GeneratorDrop => "TerminatorKind::GeneratorDrop",
TerminatorKind::Yield { .. } => "TerminatorKind::Yield",
TerminatorKind::FalseEdges { .. } => "TerminatorKind::FalseEdges",
+ TerminatorKind::FalseUnwind { .. } => "TerminatorKind::FalseUnwind",
}, kind);
self.super_terminator_kind(block, kind, location);
}
if names.is_empty() {
import_directive_subclass_to_string(subclass)
} else {
- (format!("{}::{}",
- names_to_string(names),
- import_directive_subclass_to_string(subclass)))
+ // Note that this code looks a little wonky, it's currently here to
+ // hopefully help debug #48116, but otherwise isn't intended to
+ // cause any problems.
+ let x = format!(
+ "{}::{}",
+ names_to_string(names),
+ import_directive_subclass_to_string(subclass),
+ );
+ assert!(!names.is_empty());
+ assert!(!x.starts_with("::"));
+ return x
}
}
}
rustc_typeck = { path = "../librustc_typeck" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
-rls-data = "0.14"
+rls-data = "0.15"
rls-span = "0.4"
# FIXME(#40527) should move rustc serialize out of tree
rustc-serialize = "0.3"
impl_items: &'l [ast::ImplItem],
) {
if let Some(impl_data) = self.save_ctxt.get_item_data(item) {
- down_cast_data!(impl_data, RelationData, item.span);
- self.dumper.dump_relation(impl_data);
+ if let super::Data::RelationData(rel, imp) = impl_data {
+ self.dumper.dump_relation(rel);
+ self.dumper.dump_impl(imp);
+ } else {
+ span_bug!(item.span, "unexpected data kind: {:?}", impl_data);
+ }
}
self.visit_ty(&typ);
if let &Some(ref trait_ref) = trait_ref {
use rustc_serialize::json::as_json;
use rls_data::{self, Analysis, CratePreludeData, Def, DefKind, Import, MacroRef, Ref, RefKind,
- Relation};
+ Relation, Impl};
use rls_data::config::Config;
use rls_span::{Column, Row};
pub fn dump_relation(&mut self, data: Relation) {
self.result.relations.push(data);
}
+
+ pub fn dump_impl(&mut self, data: Impl) {
+ self.result.impls.push(data);
+ }
}
use rustc::ty::{self, TyCtxt};
use rustc_typeck::hir_ty_to_ty;
+use std::cell::Cell;
use std::default::Default;
use std::env;
use std::fs::File;
use span_utils::SpanUtils;
use rls_data::{Def, DefKind, ExternalCrateData, GlobalCrateId, MacroRef, Ref, RefKind, Relation,
- RelationKind, SpanData};
+ RelationKind, SpanData, Impl, ImplKind};
use rls_data::config::Config;
analysis: &'l ty::CrateAnalysis,
span_utils: SpanUtils<'tcx>,
config: Config,
+ impl_counter: Cell<u32>,
}
#[derive(Debug)]
pub enum Data {
RefData(Ref),
DefData(Def),
- RelationData(Relation),
+ RelationData(Relation, Impl),
}
impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
attributes: lower_attributes(item.attrs.to_owned(), self),
}))
}
- ast::ItemKind::Impl(.., ref trait_ref, ref typ, _) => {
+ ast::ItemKind::Impl(.., ref trait_ref, ref typ, ref impls) => {
if let ast::TyKind::Path(None, ref path) = typ.node {
// Common case impl for a struct or something basic.
if generated_code(path.span) {
let sub_span = self.span_utils.sub_span_for_type_name(path.span);
filter!(self.span_utils, sub_span, typ.span, None);
+ let impl_id = self.next_impl_id();
+ let span = self.span_from_span(sub_span.unwrap());
+
let type_data = self.lookup_ref_id(typ.id);
type_data.map(|type_data| {
Data::RelationData(Relation {
- kind: RelationKind::Impl,
- span: self.span_from_span(sub_span.unwrap()),
+ kind: RelationKind::Impl {
+ id: impl_id,
+ },
+ span: span.clone(),
from: id_from_def_id(type_data),
to: trait_ref
.as_ref()
.and_then(|t| self.lookup_ref_id(t.ref_id))
.map(id_from_def_id)
.unwrap_or(null_id()),
+ },
+ Impl {
+ id: impl_id,
+ kind: match *trait_ref {
+ Some(_) => ImplKind::Direct,
+ None => ImplKind::Inherent,
+ },
+ span: span,
+ value: String::new(),
+ parent: None,
+ children: impls
+ .iter()
+ .map(|i| id_from_node_id(i.id, self))
+ .collect(),
+ docs: String::new(),
+ sig: None,
+ attributes: vec![],
})
})
} else {
field_ref: &ast::Field,
variant: &ty::VariantDef,
) -> Option<Ref> {
- let f = variant.field_named(field_ref.ident.node.name);
+ let f = variant.find_field_named(field_ref.ident.node.name)?;
// We don't really need a sub-span here, but no harm done
let sub_span = self.span_utils.span_for_last_ident(field_ref.ident.span);
filter!(self.span_utils, sub_span, field_ref.ident.span, None);
result.push_str(&val.as_str());
}
result.push('\n');
+ } else if let Some(meta_list) = attr.meta_item_list() {
+ meta_list.into_iter()
+ .filter(|it| it.check_name("include"))
+ .filter_map(|it| it.meta_item_list().map(|l| l.to_owned()))
+ .flat_map(|it| it)
+ .filter(|meta| meta.check_name("contents"))
+ .filter_map(|meta| meta.value_str())
+ .for_each(|val| {
+ result.push_str(&val.as_str());
+ result.push('\n');
+ });
}
}
}
result
}
+
+ fn next_impl_id(&self) -> u32 {
+ let next = self.impl_counter.get();
+ self.impl_counter.set(next + 1);
+ next
+ }
}
fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String {
analysis,
span_utils: SpanUtils::new(&tcx.sess),
config: find_config(config),
+ impl_counter: Cell::new(0),
};
handler.save(save_ctxt, krate, cratename)
// Remove the temporary object file and metadata if we aren't saving temps
if !sess.opts.cg.save_temps {
- if sess.opts.output_types.should_trans() {
+ if sess.opts.output_types.should_trans() &&
+ !preserve_objects_for_their_debuginfo(sess)
+ {
for obj in trans.modules.iter().filter_map(|m| m.object.as_ref()) {
remove(sess, obj);
}
out_filenames
}
+/// Returns a boolean indicating whether we should preserve the object files on
+/// the filesystem for their debug information. This is often useful with
+/// split-dwarf like schemes.
+fn preserve_objects_for_their_debuginfo(sess: &Session) -> bool {
+ // If the objects don't have debuginfo there's nothing to preserve.
+ if sess.opts.debuginfo == NoDebugInfo {
+ return false
+ }
+
+ // If we're only producing artifacts that are archives, no need to preserve
+ // the objects as they're losslessly contained inside the archives.
+ let output_linked = sess.crate_types.borrow()
+ .iter()
+ .any(|x| *x != config::CrateTypeRlib && *x != config::CrateTypeStaticlib);
+ if !output_linked {
+ return false
+ }
+
+ // If we're on OSX then the equivalent of split dwarf is turned on by
+ // default. The final executable won't actually have any debug information
+ // except it'll have pointers to elsewhere. Historically we've always run
+ // `dsymutil` to "link all the dwarf together" but this is actually sort of
+ // a bummer for incremental compilation! (the whole point of split dwarf is
+ // that you don't do this sort of dwarf link).
+ //
+ // Basically as a result this just means that if we're on OSX and we're
+ // *not* running dsymutil then the object files are the only source of truth
+ // for debug information, so we must preserve them.
+ if sess.target.target.options.is_like_osx {
+ match sess.opts.debugging_opts.run_dsymutil {
+ // dsymutil is not being run, preserve objects
+ Some(false) => return true,
+
+ // dsymutil is being run, no need to preserve the objects
+ Some(true) => return false,
+
+ // The default historical behavior was to always run dsymutil, so
+ // we're preserving that temporarily, but we're likely to switch the
+ // default soon.
+ None => return false,
+ }
+ }
+
+ false
+}
+
fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilenames) -> PathBuf {
let out_filename = outputs.single_output_file.clone()
.unwrap_or(outputs
// On macOS, debuggers need this utility to get run to do some munging of
- // the symbols
- if sess.target.target.options.is_like_osx && sess.opts.debuginfo != NoDebugInfo {
+ // the symbols. Note, though, that if the object files are being preserved
+ // for their debug information there's no need for us to run dsymutil.
+ if sess.target.target.options.is_like_osx &&
+ sess.opts.debuginfo != NoDebugInfo &&
+ !preserve_objects_for_their_debuginfo(sess)
+ {
match Command::new("dsymutil").arg(out_filename).output() {
Ok(..) => {}
Err(e) => sess.fatal(&format!("failed to run dsymutil: {}", e)),
if asm2wasm && config.emit_obj {
let assembly = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
- binaryen_assemble(cgcx, diag_handler, &assembly, &obj_out);
+ let suffix = ".wasm.map"; // FIXME use target suffix
+ let map = cgcx.output_filenames.path(OutputType::Exe)
+ .with_extension(&suffix[1..]);
+ binaryen_assemble(cgcx, diag_handler, &assembly, &obj_out, &map);
timeline.record("binaryen");
if !config.emit_asm {
fn binaryen_assemble(cgcx: &CodegenContext,
handler: &Handler,
assembly: &Path,
- object: &Path) {
+ object: &Path,
+ map: &Path) {
use rustc_binaryen::{Module, ModuleOptions};
let input = fs::read(&assembly).and_then(|contents| {
let mut options = ModuleOptions::new();
if cgcx.debuginfo != config::NoDebugInfo {
options.debuginfo(true);
+ let map_file_name = map.file_name().unwrap();
+ options.source_map_url(map_file_name.to_str().unwrap());
}
options.stack(1024 * 1024);
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
});
let err = assembled.and_then(|binary| {
- fs::write(&object, binary.data())
+ fs::write(&object, binary.data()).and_then(|()| {
+ if cgcx.debuginfo != config::NoDebugInfo {
+ fs::write(map, binary.source_map())
+ } else {
+ Ok(())
+ }
+ })
});
if let Err(e) = err {
handler.err(&format!("failed to run binaryen assembler: {}", e));
None => None,
Some(Class::Int) => {
*i += 1;
- Some(match size.bytes() {
- 1 => Reg::i8(),
- 2 => Reg::i16(),
- 3 |
- 4 => Reg::i32(),
- _ => Reg::i64()
+ Some(if size.bytes() < 8 {
+ Reg {
+ kind: RegKind::Integer,
+ size
+ }
+ } else {
+ Reg::i64()
})
}
Some(Class::Sse) => {
TerminatorKind::Unreachable |
TerminatorKind::SwitchInt { .. } |
TerminatorKind::Yield { .. } |
- TerminatorKind::FalseEdges { .. } => {
+ TerminatorKind::FalseEdges { .. } |
+ TerminatorKind::FalseUnwind { .. } => {
/* nothing to do */
}
TerminatorKind::Call { cleanup: unwind, .. } |
cleanup);
}
mir::TerminatorKind::GeneratorDrop |
- mir::TerminatorKind::Yield { .. } |
- mir::TerminatorKind::FalseEdges { .. } => bug!("generator ops in trans"),
+ mir::TerminatorKind::Yield { .. } => bug!("generator ops in trans"),
+ mir::TerminatorKind::FalseEdges { .. } |
+ mir::TerminatorKind::FalseUnwind { .. } => bug!("borrowck false edges in trans"),
}
}
self.cx.align_of(substs.type_at(0)).abi());
Ok(Const::new(llval, tcx.types.usize))
}
+ "type_id" => {
+ let llval = C_u64(self.cx,
+ self.cx.tcx.type_id_hash(substs.type_at(0)));
+ Ok(Const::new(llval, tcx.types.u64))
+ }
_ => span_bug!(span, "{:?} in constant", terminator.kind)
}
} else if let Some((op, is_checked)) = self.is_binop_lang_item(def_id) {
mir::CastKind::ReifyFnPointer => {
match operand.ty.sty {
ty::TyFnDef(def_id, substs) => {
+ if tcx.has_attr(def_id, "rustc_args_required_const") {
+ bug!("reifying a fn ptr that requires \
+ const arguments");
+ }
callee::resolve_and_get_fn(self.cx, def_id, substs)
}
_ => {
} else {
self.cx.tcx.data_layout.pointer_align
};
- if bk == mir::BorrowKind::Mut {
+ if let mir::BorrowKind::Mut { .. } = bk {
consts::addr_of_mut(self.cx, llval, align, "ref_mut")
} else {
consts::addr_of(self.cx, llval, align, "ref")
mir::CastKind::ReifyFnPointer => {
match operand.layout.ty.sty {
ty::TyFnDef(def_id, substs) => {
+ if bx.cx.tcx.has_attr(def_id, "rustc_args_required_const") {
+ bug!("reifying a fn ptr that requires \
+ const arguments");
+ }
OperandValue::Immediate(
callee::resolve_and_get_fn(bx.cx, def_id, substs))
}
end.span
};
- struct_span_err!(tcx.sess, span, E0029,
- "only char and numeric types are allowed in range patterns")
- .span_label(span, "ranges require char or numeric types")
- .note(&format!("start type: {}", self.ty_to_string(lhs_ty)))
- .note(&format!("end type: {}", self.ty_to_string(rhs_ty)))
- .emit();
+ let mut err = struct_span_err!(
+ tcx.sess,
+ span,
+ E0029,
+ "only char and numeric types are allowed in range patterns"
+ );
+ err.span_label(span, "ranges require char or numeric types");
+ err.note(&format!("start type: {}", self.ty_to_string(lhs_ty)));
+ err.note(&format!("end type: {}", self.ty_to_string(rhs_ty)));
+ if tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note(
+ "In a match expression, only numbers and characters can be matched \
+ against a range. This is because the compiler checks that the range \
+ is non-empty at compile-time, and is unable to evaluate arbitrary \
+ comparison functions. If you want to capture values of an orderable \
+ type between two end-points, you can use a guard."
+ );
+ }
+ err.emit();
return;
}
// This is "x = SomeTrait" being reduced from
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
let type_str = self.ty_to_string(expected);
- struct_span_err!(self.tcx.sess, span, E0033,
- "type `{}` cannot be dereferenced", type_str)
- .span_label(span, format!("type `{}` cannot be dereferenced", type_str))
- .emit();
+ let mut err = struct_span_err!(
+ self.tcx.sess,
+ span,
+ E0033,
+ "type `{}` cannot be dereferenced",
+ type_str
+ );
+ err.span_label(span, format!("type `{}` cannot be dereferenced", type_str));
+ if self.tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note("\
+This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \
+pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, \
+this type has no compile-time size. Therefore, all accesses to trait types must be through \
+pointers. If you encounter this error you should try to avoid dereferencing the pointer.
+
+You can read more about trait objects in the Trait Objects section of the Reference: \
+https://doc.rust-lang.org/reference/types.html#trait-objects");
+ }
+ err.emit();
return false
}
}
self.field_ty(span, f, substs)
})
.unwrap_or_else(|| {
- struct_span_err!(tcx.sess, span, E0026,
- "{} `{}` does not have a field named `{}`",
- kind_name,
- tcx.item_path_str(variant.did),
- field.name)
- .span_label(span,
- format!("{} `{}` does not have field `{}`",
- kind_name,
- tcx.item_path_str(variant.did),
- field.name))
- .emit();
+ let mut err = struct_span_err!(
+ tcx.sess,
+ span,
+ E0026,
+ "{} `{}` does not have a field named `{}`",
+ kind_name,
+ tcx.item_path_str(variant.did),
+ field.name
+ );
+ err.span_label(span,
+ format!("{} `{}` does not have field `{}`",
+ kind_name,
+ tcx.item_path_str(variant.did),
+ field.name));
+ if tcx.sess.teach(&err.get_code().unwrap()) {
+ err.note(
+ "This error indicates that a struct pattern attempted to \
+ extract a non-existent field from a struct. Struct fields \
+ are identified by the name used before the colon : so struct \
+ patterns should resemble the declaration of the struct type \
+ being matched.\n\n\
+ If you are using shorthand field patterns but want to refer \
+ to the struct field by a different name, you should rename \
+ it explicitly."
+ );
+ }
+ err.emit();
tcx.types.err
})
if variant.ctor_kind == CtorKind::Fn {
diag.note("trying to match a tuple variant with a struct variant pattern");
}
+ if tcx.sess.teach(&diag.get_code().unwrap()) {
+ diag.note(
+ "This error indicates that a pattern for a struct fails to specify a \
+ sub-pattern for every one of the struct's fields. Ensure that each field \
+ from the struct's definition is mentioned in the pattern, or use `..` to \
+ ignore unwanted fields."
+ );
+ }
diag.emit();
}
}
use hir::def_id::{DefId, LOCAL_CRATE};
use rustc::{infer, traits};
use rustc::ty::{self, TyCtxt, TypeFoldable, Ty};
-use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
+use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability};
use syntax::abi;
use syntax::symbol::Symbol;
use syntax_pos::Span;
let mut autoref = None;
if borrow {
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty {
+ let mutbl = match mt.mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // For initial two-phase borrow
+ // deployment, conservatively omit
+ // overloaded function call ops.
+ allow_two_phase_borrow: false,
+ }
+ };
autoref = Some(Adjustment {
- kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)),
+ kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)),
target: method.sig.inputs()[0]
});
}
use rustc::infer::type_variable::TypeVariableOrigin;
use rustc::lint;
use rustc::traits::{self, ObligationCause, ObligationCauseCode};
-use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
+use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability};
use rustc::ty::{self, TypeAndMut, Ty, ClosureSubsts};
use rustc::ty::fold::TypeFoldable;
use rustc::ty::error::TypeError;
ty::TyRef(r_borrow, _) => r_borrow,
_ => span_bug!(span, "expected a ref type, got {:?}", ty),
};
+ let mutbl = match mt_b.mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // Deref-coercion is a case where we deliberately
+ // disallow two-phase borrows in its initial
+ // deployment; see discussion on PR #47489.
+ allow_two_phase_borrow: false,
+ }
+ };
adjustments.push(Adjustment {
- kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mt_b.mutbl)),
+ kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)),
target: ty
});
let coercion = Coercion(self.cause.span);
let r_borrow = self.next_region_var(coercion);
+ let mutbl = match mt_b.mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ allow_two_phase_borrow: false,
+ }
+ };
Some((Adjustment {
kind: Adjust::Deref(None),
target: mt_a.ty
}, Adjustment {
- kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mt_b.mutbl)),
+ kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)),
target: self.tcx.mk_ref(r_borrow, ty::TypeAndMut {
mutbl: mt_b.mutbl,
ty: mt_a.ty
] => {
match self.node_ty(expr.hir_id).sty {
ty::TyRef(_, mt_orig) => {
+ let mutbl_adj: hir::Mutability = mutbl_adj.into();
// Reborrow that we can safely ignore, because
// the next adjustment can only be a Deref
// which will be merged into it.
use rustc::traits;
use rustc::ty::{self, Ty};
use rustc::ty::subst::Subst;
-use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, OverloadedDeref};
+use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability, OverloadedDeref};
use rustc::ty::fold::TypeFoldable;
use rustc::infer::{self, InferOk};
use syntax_pos::Span;
mutbl,
ty: target
});
+ let mutbl = match mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // Method call receivers are the primary use case
+ // for two-phase borrows.
+ allow_two_phase_borrow: true,
+ }
+ };
adjustments.push(Adjustment {
kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)),
target
if let Some(unsize_target) = pick.unsize {
target = self.tcx.mk_ref(region, ty::TypeAndMut {
- mutbl,
+ mutbl: mutbl.into(),
ty: unsize_target
});
adjustments.push(Adjustment {
for adjustment in &mut adjustments[..] {
if let Adjust::Borrow(AutoBorrow::Ref(..)) = adjustment.kind {
debug!("convert_place_op_to_mutable: converting autoref {:?}", adjustment);
+ let mutbl = match mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // For initial two-phase borrow
+ // deployment, conservatively omit
+ // overloaded operators.
+ allow_two_phase_borrow: false,
+ }
+ };
adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(region, mutbl));
adjustment.target = self.tcx.mk_ref(region, ty::TypeAndMut {
ty: source,
- mutbl
+ mutbl: mutbl.into(),
});
}
source = adjustment.target;
if reached_raw_pointer
&& !self.tcx.sess.features.borrow().arbitrary_self_types {
// this case used to be allowed by the compiler,
- // so we do a future-compat lint here
+ // so we do a future-compat lint here for the 2015 epoch
// (see https://github.com/rust-lang/rust/issues/46906)
- self.tcx.lint_node(
- lint::builtin::TYVAR_BEHIND_RAW_POINTER,
- scope_expr_id,
- span,
- &format!("the type of this value must be known in this context"));
+ if self.tcx.sess.rust_2018() {
+ span_err!(self.tcx.sess, span, E0908,
+ "the type of this value must be known \
+ to call a method on a raw pointer on it");
+ } else {
+ self.tcx.lint_node(
+ lint::builtin::TYVAR_BEHIND_RAW_POINTER,
+ scope_expr_id,
+ span,
+ &format!("the type of this value must be known in this context"));
+ }
} else {
let t = self.structurally_resolved_type(span, final_ty);
assert_eq!(t, self.tcx.types.err);
use rustc::ty::subst::{Kind, Subst, Substs};
use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode};
use rustc::ty::{self, Ty, TyCtxt, Visibility, ToPredicate};
-use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
+use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
use rustc::ty::fold::TypeFoldable;
use rustc::ty::maps::Providers;
use rustc::ty::util::{Representability, IntTypeExt};
let mut adjustments = autoderef.adjust_steps(needs);
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty {
+ let mutbl = match mt.mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // FIXME (#46747): arguably indexing is
+ // "just another kind of call"; perhaps it
+ // would be more consistent to allow
+ // two-phase borrows for .index()
+ // receivers here.
+ allow_two_phase_borrow: false,
+ }
+ };
adjustments.push(Adjustment {
- kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)),
+ kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)),
target: self.tcx.mk_ref(region, ty::TypeAndMut {
mutbl: mt.mutbl,
ty: adjusted_ty
let rcvr = &args[0];
let rcvr_t = self.check_expr_with_needs(&rcvr, needs);
// no need to check for bot/err -- callee does that
- let rcvr_t = self.structurally_resolved_type(expr.span, rcvr_t);
+ let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t);
let method = match self.lookup_method(rcvr_t,
segment,
expr.span, oprnd_t, needs) {
let method = self.register_infer_ok_obligations(ok);
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty {
+ let mutbl = match mt.mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // (It shouldn't actually matter for unary ops whether
+ // we enable two-phase borrows or not, since a unary
+ // op has no additional operands.)
+ allow_two_phase_borrow: false,
+ }
+ };
self.apply_adjustments(oprnd, vec![Adjustment {
- kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)),
+ kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)),
target: method.sig.inputs()[0]
}]);
}
}
}
+ self.check_rustc_args_require_const(def.def_id(), node_id, span);
+
debug!("instantiate_value_path: type of {:?} is {:?}",
node_id,
ty_substituted);
ty_substituted
}
+ fn check_rustc_args_require_const(&self,
+ def_id: DefId,
+ node_id: ast::NodeId,
+ span: Span) {
+ // We're only interested in functions tagged with
+ // #[rustc_args_required_const], so ignore anything that's not.
+ if !self.tcx.has_attr(def_id, "rustc_args_required_const") {
+ return
+ }
+
+ // If our calling expression is indeed the function itself, we're good!
+ // If not, generate an error that this can only be called directly.
+ match self.tcx.hir.get(self.tcx.hir.get_parent_node(node_id)) {
+ Node::NodeExpr(expr) => {
+ match expr.node {
+ hir::ExprCall(ref callee, ..) => {
+ if callee.id == node_id {
+ return
+ }
+ }
+ _ => {}
+ }
+ }
+ _ => {}
+ }
+
+ self.tcx.sess.span_err(span, "this function can only be invoked \
+ directly, not through a function pointer");
+ }
+
/// Report errors if the provided parameters are too few or too many.
fn check_path_parameter_count(&self,
span: Span,
use super::method::MethodCallee;
use rustc::ty::{self, Ty, TypeFoldable, TypeVariants};
use rustc::ty::TypeVariants::{TyStr, TyRef};
-use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
+use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability};
use rustc::infer::type_variable::TypeVariableOrigin;
use errors;
use syntax_pos::Span;
let by_ref_binop = !op.node.is_by_value();
if is_assign == IsAssign::Yes || by_ref_binop {
if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty {
+ let mutbl = match mt.mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // For initial two-phase borrow
+ // deployment, conservatively omit
+ // overloaded binary ops.
+ allow_two_phase_borrow: false,
+ }
+ };
let autoref = Adjustment {
- kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)),
+ kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)),
target: method.sig.inputs()[0]
};
self.apply_adjustments(lhs_expr, vec![autoref]);
}
if by_ref_binop {
if let ty::TyRef(region, mt) = method.sig.inputs()[1].sty {
+ let mutbl = match mt.mutbl {
+ hir::MutImmutable => AutoBorrowMutability::Immutable,
+ hir::MutMutable => AutoBorrowMutability::Mutable {
+ // For initial two-phase borrow
+ // deployment, conservatively omit
+ // overloaded binary ops.
+ allow_two_phase_borrow: false,
+ }
+ };
let autoref = Adjustment {
- kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)),
+ kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)),
target: method.sig.inputs()[1]
};
// HACK(eddyb) Bypass checks due to reborrows being in
match *autoref {
adjustment::AutoBorrow::Ref(r, m) => {
self.link_region(expr.span, r,
- ty::BorrowKind::from_mutbl(m), expr_cmt);
+ ty::BorrowKind::from_mutbl(m.into()), expr_cmt);
}
adjustment::AutoBorrow::RawPtr(m) => {
}
}
-fn ensure_no_ty_param_bounds(tcx: TyCtxt,
- span: Span,
- generics: &hir::Generics,
- thing: &'static str) {
+fn ensure_no_param_bounds(tcx: TyCtxt,
+ span: Span,
+ generics: &hir::Generics,
+ thing: &'static str) {
let mut warn = false;
for ty_param in generics.ty_params() {
- for bound in ty_param.bounds.iter() {
- match *bound {
- hir::TraitTyParamBound(..) => {
- warn = true;
- }
- hir::RegionTyParamBound(..) => { }
- }
+ if !ty_param.bounds.is_empty() {
+ warn = true;
}
}
- for predicate in generics.where_clause.predicates.iter() {
- match *predicate {
- hir::WherePredicate::BoundPredicate(..) => {
- warn = true;
- }
- hir::WherePredicate::RegionPredicate(..) => { }
- hir::WherePredicate::EqPredicate(..) => { }
+ for lft_param in generics.lifetimes() {
+ if !lft_param.bounds.is_empty() {
+ warn = true;
}
}
+ if !generics.where_clause.predicates.is_empty() {
+ warn = true;
+ }
+
if warn {
// According to accepted RFC #XXX, we should
// eventually accept these, but it will not be
// part of this PR. Still, convert to warning to
// make bootstrapping easier.
span_warn!(tcx.sess, span, E0122,
- "trait bounds are not (yet) enforced \
- in {} definitions",
+ "generic bounds are ignored in {}",
thing);
}
}
}
},
hir::ItemTy(_, ref generics) => {
- ensure_no_ty_param_bounds(tcx, it.span, generics, "type");
+ ensure_no_param_bounds(tcx, it.span, generics, "type aliases");
tcx.generics_of(def_id);
tcx.type_of(def_id);
tcx.predicates_of(def_id);
the alignment of the zero-sized type is less than or equal to the data field's
alignment.
"##,
+
+
+E0908: r##"
+A method was called on a raw pointer whose inner type wasn't completely known.
+
+For example, you may have done something like:
+
+```compile_fail
+# #![deny(warnings)]
+let foo = &1;
+let bar = foo as *const _;
+if bar.is_null() {
+ // ...
+}
+```
+
+Here, the type of `bar` isn't known; it could be a pointer to anything. Instead,
+specify a type for the pointer (preferably something that makes sense for the
+thing you're pointing to):
+
+```
+let foo = &1;
+let bar = foo as *const i32;
+if bar.is_null() {
+ // ...
+}
+```
+
+Even though `is_null()` exists as a method on any raw pointer, Rust shows this
+error because Rust allows for `self` to have arbitrary types (behind the
+arbitrary_self_types feature flag).
+
+This means that someone can specify such a function:
+
+```ignore (cannot-doctest-feature-doesnt-exist-yet)
+impl Foo {
+ fn is_null(self: *const Self) -> bool {
+ // do something else
+ }
+}
+```
+
+and now when you call `.is_null()` on a raw pointer to `Foo`, there's ambiguity.
+
+Given that we don't know what type the pointer is, and there's potential
+ambiguity for some types, we disallow calling methods on raw pointers when
+the type is unknown.
+"##,
+
}
register_diagnostics! {
if UnstableFeatures::from_environment().is_nightly_build() {
let dox = attrs.collapsed_doc_value().unwrap_or_else(String::new);
for link in markdown_links(&dox, cx.render_type) {
+ // bail early for real links
+ if link.contains('/') {
+ continue;
+ }
let (def, fragment) = {
let mut kind = PathKind::Unknown;
let path_str = if let Some(prefix) =
let def_id = cx.tcx.hir.body_owner_def_id(n);
let param_env = cx.tcx.param_env(def_id);
let substs = Substs::identity_for_item(cx.tcx, def_id);
- let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap();
+ let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap_or_else(|_| {
+ cx.tcx.mk_const(ty::Const {
+ val: ConstVal::Unevaluated(def_id, substs),
+ ty: cx.tcx.types.usize
+ })
+ });
let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val {
n.to_string()
} else if let ConstVal::Unevaluated(def_id, _) = n.val {
let mut n = cx.tcx.lift(&n).unwrap();
if let ConstVal::Unevaluated(def_id, substs) = n.val {
let param_env = cx.tcx.param_env(def_id);
- n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap()
+ if let Ok(new_n) = cx.tcx.const_eval(param_env.and((def_id, substs))) {
+ n = new_n;
+ }
};
let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val {
n.to_string()
}
PP::Parenthesized { ref mut output, .. } => {
assert!(output.is_none());
- *output = Some(rhs.clone());
+ if *rhs != clean::Type::Tuple(Vec::new()) {
+ *output = Some(rhs.clone());
+ }
}
};
true
// 2 for "In Return Types"
var currentTab = 0;
+ var themesWidth = null;
+
function hasClass(elem, className) {
if (elem && className && elem.className) {
var elemClass = elem.className;
sidebar.appendChild(div);
}
}
- document.getElementsByTagName("body")[0].style.marginTop = '45px';
- var themePicker = document.getElementById("theme-picker");
- if (themePicker) {
- themePicker.style.position = "fixed";
+ var themePicker = document.getElementsByClassName("theme-picker");
+ if (themePicker && themePicker.length > 0) {
+ themePicker[0].style.display = "none";
}
}
filler.remove();
}
document.getElementsByTagName("body")[0].style.marginTop = '';
- var themePicker = document.getElementById("theme-picker");
- if (themePicker) {
- themePicker.style.position = "absolute";
+ var themePicker = document.getElementsByClassName("theme-picker");
+ if (themePicker && themePicker.length > 0) {
+ themePicker[0].style.display = null;
}
}
display: block;
border-bottom: 1px solid;
border-right: 1px solid;
+ height: 45px;
}
.sidebar-elems {
}
nav.sub {
- margin: 0 auto;
+ width: calc(100% - 32px);
+ float: right;
}
.content {
margin-left: 0px;
}
+ #main {
+ margin-top: 45px;
+ padding: 0;
+ }
+
.content .in-band {
width: 100%;
}
.show-it {
display: block;
+ width: 246px;
+ }
+
+ .show-it > .block.items {
+ margin: 8px 0;
+ }
+
+ .show-it > .block.items > ul {
+ margin: 0;
+ }
+
+ .show-it > .block.items > ul > li {
+ text-align: center;
+ margin: 2px 0;
+ }
+
+ .show-it > .block.items > ul > li > a {
+ font-size: 21px;
}
/* Because of ios, we need to actually have a full height sidebar title so the
@media (max-width: 700px) {
.theme-picker {
- left: 109px;
- top: 7px;
+ left: 10px;
+ top: 54px;
z-index: 1;
}
}
}
.content .highlighted a, .content .highlighted span { color: #eee !important; }
.content .highlighted.trait { background-color: #013191; }
+.content .highlighted.mod,
+.content .highlighted.externcrate { background-color: #afc6e4; }
.content .highlighted.mod { background-color: #803a1b; }
.content .highlighted.externcrate { background-color: #396bac; }
.content .highlighted.enum { background-color: #5b4e68; }
.content .highlighted.struct { background-color: #194e9f; }
+.content .highlighted.union { background-color: #b7bd49; }
.content .highlighted.fn,
.content .highlighted.method,
.content .highlighted.tymethod { background-color: #4950ed; }
.content .highlighted.primitive { background-color: #00708a; }
.content span.enum, .content a.enum, .block a.current.enum { color: #82b089; }
-.content span.struct, .content a.struct, .block a.current.struct { color: #ff794d; }
+.content span.struct, .content a.struct, .block a.current.struct { color: #2dbfb8; }
.content span.type, .content a.type, .block a.current.type { color: #ff7f00; }
.content span.foreigntype, .content a.foreigntype, .block a.current.foreigntype { color: #dd7de8; }
.content span.macro, .content a.macro, .block a.current.macro { color: #09bd00; }
@media (max-width: 700px) {
#theme-picker {
- background: #353535;
+ background: #f0f0f0;
}
}
.content .highlighted.primitive { background-color: #9aecff; }
.content span.enum, .content a.enum, .block a.current.enum { color: #508157; }
-.content span.struct, .content a.struct, .block a.current.struct { color: #df3600; }
+.content span.struct, .content a.struct, .block a.current.struct { color: #ad448e; }
.content span.type, .content a.type, .block a.current.type { color: #ba5d00; }
.content span.foreigntype, .content a.foreigntype, .block a.current.foreigntype { color: #cd00e2; }
.content span.macro, .content a.macro, .block a.current.macro { color: #068000; }
pub mod visit_ast;
pub mod visit_lib;
pub mod test;
+pub mod theme;
use clean::AttributesExt;
"additional themes which will be added to the generated docs",
"FILES")
}),
+ unstable("theme-checker", |o| {
+ o.optmulti("", "theme-checker",
+ "check if given theme is valid",
+ "FILES")
+ }),
]
}
return 0;
}
+ let to_check = matches.opt_strs("theme-checker");
+ if !to_check.is_empty() {
+ let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css"));
+ let mut errors = 0;
+
+ println!("rustdoc: [theme-checker] Starting tests!");
+ for theme_file in to_check.iter() {
+ print!(" - Checking \"{}\"...", theme_file);
+ let (success, differences) = theme::test_theme_against(theme_file, &paths);
+ if !differences.is_empty() || !success {
+ println!(" FAILED");
+ errors += 1;
+ if !differences.is_empty() {
+ println!("{}", differences.join("\n"));
+ }
+ } else {
+ println!(" OK");
+ }
+ }
+ if errors != 0 {
+ return 1;
+ }
+ return 0;
+ }
+
if matches.free.is_empty() {
print_error("missing file operand");
return 1;
}
let mut themes = Vec::new();
- for theme in matches.opt_strs("themes").iter().map(|s| PathBuf::from(&s)) {
- if !theme.is_file() {
- eprintln!("rustdoc: option --themes arguments must all be files");
- return 1;
+ if matches.opt_present("themes") {
+ let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css"));
+
+ for (theme_file, theme_s) in matches.opt_strs("themes")
+ .iter()
+ .map(|s| (PathBuf::from(&s), s.to_owned())) {
+ if !theme_file.is_file() {
+ println!("rustdoc: option --themes arguments must all be files");
+ return 1;
+ }
+ let (success, ret) = theme::test_theme_against(&theme_file, &paths);
+ if !success || !ret.is_empty() {
+ println!("rustdoc: invalid theme: \"{}\"", theme_s);
+ println!(" Check what's wrong with the \"theme-checker\" option");
+ return 1;
+ }
+ themes.push(theme_file);
}
- themes.push(theme);
}
let external_html = match ExternalHtml::load(
--- /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.
+
+use std::collections::HashSet;
+use std::fs::File;
+use std::hash::{Hash, Hasher};
+use std::io::Read;
+use std::path::Path;
+
+macro_rules! try_something {
+ ($e:expr, $out:expr) => ({
+ match $e {
+ Ok(c) => c,
+ Err(e) => {
+ eprintln!("rustdoc: got an error: {}", e);
+ return $out;
+ }
+ }
+ })
+}
+
+#[derive(Debug, Clone, Eq)]
+pub struct CssPath {
+ pub name: String,
+ pub children: HashSet<CssPath>,
+}
+
+// This PartialEq implementation IS NOT COMMUTATIVE!!!
+//
+// The order is very important: the second object must have all first's rules.
+// However, the first doesn't require to have all second's rules.
+impl PartialEq for CssPath {
+ fn eq(&self, other: &CssPath) -> bool {
+ if self.name != other.name {
+ false
+ } else {
+ for child in &self.children {
+ if !other.children.iter().any(|c| child == c) {
+ return false;
+ }
+ }
+ true
+ }
+ }
+}
+
+impl Hash for CssPath {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.name.hash(state);
+ for x in &self.children {
+ x.hash(state);
+ }
+ }
+}
+
+impl CssPath {
+ fn new(name: String) -> CssPath {
+ CssPath {
+ name,
+ children: HashSet::new(),
+ }
+ }
+}
+
+/// All variants contain the position they occur.
+#[derive(Debug, Clone, Copy)]
+enum Events {
+ StartLineComment(usize),
+ StartComment(usize),
+ EndComment(usize),
+ InBlock(usize),
+ OutBlock(usize),
+}
+
+impl Events {
+ fn get_pos(&self) -> usize {
+ match *self {
+ Events::StartLineComment(p) |
+ Events::StartComment(p) |
+ Events::EndComment(p) |
+ Events::InBlock(p) |
+ Events::OutBlock(p) => p,
+ }
+ }
+
+ fn is_comment(&self) -> bool {
+ match *self {
+ Events::StartLineComment(_) |
+ Events::StartComment(_) |
+ Events::EndComment(_) => true,
+ _ => false,
+ }
+ }
+}
+
+fn previous_is_line_comment(events: &[Events]) -> bool {
+ if let Some(&Events::StartLineComment(_)) = events.last() {
+ true
+ } else {
+ false
+ }
+}
+
+fn is_line_comment(pos: usize, v: &[u8], events: &[Events]) -> bool {
+ if let Some(&Events::StartComment(_)) = events.last() {
+ return false;
+ }
+ pos + 1 < v.len() && v[pos + 1] == b'/'
+}
+
+fn load_css_events(v: &[u8]) -> Vec<Events> {
+ let mut pos = 0;
+ let mut events = Vec::with_capacity(100);
+
+ while pos < v.len() - 1 {
+ match v[pos] {
+ b'/' if pos + 1 < v.len() && v[pos + 1] == b'*' => {
+ events.push(Events::StartComment(pos));
+ pos += 1;
+ }
+ b'/' if is_line_comment(pos, v, &events) => {
+ events.push(Events::StartLineComment(pos));
+ pos += 1;
+ }
+ b'\n' if previous_is_line_comment(&events) => {
+ events.push(Events::EndComment(pos));
+ }
+ b'*' if pos + 1 < v.len() && v[pos + 1] == b'/' => {
+ events.push(Events::EndComment(pos + 2));
+ pos += 1;
+ }
+ b'{' if !previous_is_line_comment(&events) => {
+ if let Some(&Events::StartComment(_)) = events.last() {
+ pos += 1;
+ continue
+ }
+ events.push(Events::InBlock(pos + 1));
+ }
+ b'}' if !previous_is_line_comment(&events) => {
+ if let Some(&Events::StartComment(_)) = events.last() {
+ pos += 1;
+ continue
+ }
+ events.push(Events::OutBlock(pos + 1));
+ }
+ _ => {}
+ }
+ pos += 1;
+ }
+ events
+}
+
+fn get_useful_next(events: &[Events], pos: &mut usize) -> Option<Events> {
+ while *pos < events.len() {
+ if !events[*pos].is_comment() {
+ return Some(events[*pos]);
+ }
+ *pos += 1;
+ }
+ None
+}
+
+fn get_previous_positions(events: &[Events], mut pos: usize) -> Vec<usize> {
+ let mut ret = Vec::with_capacity(3);
+
+ ret.push(events[pos].get_pos());
+ if pos > 0 {
+ pos -= 1;
+ }
+ loop {
+ if pos < 1 || !events[pos].is_comment() {
+ let x = events[pos].get_pos();
+ if *ret.last().unwrap() != x {
+ ret.push(x);
+ } else {
+ ret.push(0);
+ }
+ break
+ }
+ ret.push(events[pos].get_pos());
+ pos -= 1;
+ }
+ if ret.len() & 1 != 0 && events[pos].is_comment() {
+ ret.push(0);
+ }
+ ret.iter().rev().cloned().collect()
+}
+
+fn build_rule(v: &[u8], positions: &[usize]) -> String {
+ positions.chunks(2)
+ .map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or(""))
+ .collect::<String>()
+ .trim()
+ .replace("\n", " ")
+ .replace("/", "")
+ .replace("\t", " ")
+ .replace("{", "")
+ .replace("}", "")
+ .split(" ")
+ .filter(|s| s.len() > 0)
+ .collect::<Vec<&str>>()
+ .join(" ")
+}
+
+fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet<CssPath> {
+ let mut paths = Vec::with_capacity(50);
+
+ while *pos < events.len() {
+ if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) {
+ *pos += 1;
+ break
+ }
+ if let Some(Events::InBlock(_)) = get_useful_next(events, pos) {
+ paths.push(CssPath::new(build_rule(v, &get_previous_positions(events, *pos))));
+ *pos += 1;
+ }
+ while let Some(Events::InBlock(_)) = get_useful_next(events, pos) {
+ if let Some(ref mut path) = paths.last_mut() {
+ for entry in inner(v, events, pos).iter() {
+ path.children.insert(entry.clone());
+ }
+ }
+ }
+ if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) {
+ *pos += 1;
+ }
+ }
+ paths.iter().cloned().collect()
+}
+
+pub fn load_css_paths(v: &[u8]) -> CssPath {
+ let events = load_css_events(v);
+ let mut pos = 0;
+
+ let mut parent = CssPath::new("parent".to_owned());
+ parent.children = inner(v, &events, &mut pos);
+ parent
+}
+
+pub fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec<String>) {
+ if against.name != other.name {
+ return
+ } else {
+ for child in &against.children {
+ let mut found = false;
+ let mut found_working = false;
+ let mut tmp = Vec::new();
+
+ for other_child in &other.children {
+ if child.name == other_child.name {
+ if child != other_child {
+ get_differences(child, other_child, &mut tmp);
+ } else {
+ found_working = true;
+ }
+ found = true;
+ break
+ }
+ }
+ if found == false {
+ v.push(format!(" Missing \"{}\" rule", child.name));
+ } else if found_working == false {
+ v.extend(tmp.iter().cloned());
+ }
+ }
+ }
+}
+
+pub fn test_theme_against<P: AsRef<Path>>(f: &P, against: &CssPath) -> (bool, Vec<String>) {
+ let mut file = try_something!(File::open(f), (false, Vec::new()));
+ let mut data = Vec::with_capacity(1000);
+
+ try_something!(file.read_to_end(&mut data), (false, Vec::new()));
+ let paths = load_css_paths(&data);
+ let mut ret = Vec::new();
+ get_differences(against, &paths, &mut ret);
+ (true, ret)
+}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+
+ #[test]
+ fn test_comments_in_rules() {
+ let text = r#"
+rule a {}
+
+rule b, c
+// a line comment
+{}
+
+rule d
+// another line comment
+e {}
+
+rule f/* a multine
+
+comment*/{}
+
+rule g/* another multine
+
+comment*/h
+
+i {}
+
+rule j/*commeeeeent
+
+you like things like "{}" in there? :)
+*/
+end {}"#;
+
+ let against = r#"
+rule a {}
+
+rule b, c {}
+
+rule d e {}
+
+rule f {}
+
+rule gh i {}
+
+rule j end {}
+"#;
+
+ let mut ret = Vec::new();
+ get_differences(&load_css_paths(against.as_bytes()),
+ &load_css_paths(text.as_bytes()),
+ &mut ret);
+ assert!(ret.is_empty());
+ }
+
+ #[test]
+ fn test_text() {
+ let text = r#"
+a
+/* sdfs
+*/ b
+c // sdf
+d {}
+"#;
+ let paths = load_css_paths(text.as_bytes());
+ assert!(paths.children.contains(&CssPath::new("a b c d".to_owned())));
+ }
+
+ #[test]
+ fn test_comparison() {
+ let x = r#"
+a {
+ b {
+ c {}
+ }
+}
+"#;
+
+ let y = r#"
+a {
+ b {}
+}
+"#;
+
+ let against = load_css_paths(y.as_bytes());
+ let other = load_css_paths(x.as_bytes());
+
+ let mut ret = Vec::new();
+ get_differences(&against, &other, &mut ret);
+ assert!(ret.is_empty());
+ get_differences(&other, &against, &mut ret);
+ assert_eq!(ret, vec![" Missing \"c\" rule".to_owned()]);
+ }
+}
/// The returned slice will **not** contain the trailing nul terminator that this C
/// string has.
///
- /// > **Note**: This method is currently implemented as a 0-cost cast, but
- /// > it is planned to alter its definition in the future to perform the
- /// > length calculation whenever this method is called.
+ /// > **Note**: This method is currently implemented as a constant-time
+ /// > cast, but it is planned to alter its definition in the future to
+ /// > perform the length calculation whenever this method is called.
///
/// # Examples
///
/// it will return an error with details of where UTF-8 validation failed.
///
/// > **Note**: This method is currently implemented to check for validity
- /// > after a 0-cost cast, but it is planned to alter its definition in the
- /// > future to perform the length calculation in addition to the UTF-8
- /// > check whenever this method is called.
+ /// > after a constant-time cast, but it is planned to alter its definition
+ /// > in the future to perform the length calculation in addition to the
+ /// > UTF-8 check whenever this method is called.
///
/// [`&str`]: ../primitive.str.html
///
/// with the result.
///
/// > **Note**: This method is currently implemented to check for validity
- /// > after a 0-cost cast, but it is planned to alter its definition in the
- /// > future to perform the length calculation in addition to the UTF-8
- /// > check whenever this method is called.
+ /// > after a constant-time cast, but it is planned to alter its definition
+ /// > in the future to perform the length calculation in addition to the
+ /// > UTF-8 check whenever this method is called.
///
/// [`Cow`]: ../borrow/enum.Cow.html
/// [`Borrowed`]: ../borrow/enum.Cow.html#variant.Borrowed
self.inner.file_attr().map(Metadata)
}
- /// Creates a new independently owned handle to the underlying file.
- ///
- /// The returned `File` is a reference to the same state that this object
- /// references. Both handles will read and write with the same cursor
- /// position.
+ /// Create a new `File` instance that shares the same underlying file handle
+ /// as the existing `File` instance. Reads, writes, and seeks will affect
+ /// both `File` instances simultaneously.
///
/// # Examples
///
+ /// Create two handles for a file named `foo.txt`:
+ ///
/// ```no_run
/// use std::fs::File;
///
/// # fn foo() -> std::io::Result<()> {
- /// let mut f = File::open("foo.txt")?;
- /// let file_copy = f.try_clone()?;
+ /// let mut file = File::open("foo.txt")?;
+ /// let file_copy = file.try_clone()?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ ///
+ /// Assuming there’s a file named `foo.txt` with contents `abcdef\n`, create
+ /// two handles, seek one of them, and read the remaining bytes from the
+ /// other handle:
+ ///
+ /// ```no_run
+ /// use std::fs::File;
+ /// use std::io::SeekFrom;
+ /// use std::io::prelude::*;
+ ///
+ /// # fn foo() -> std::io::Result<()> {
+ /// let mut file = File::open("foo.txt")?;
+ /// let mut file_copy = file.try_clone()?;
+ ///
+ /// file.seek(SeekFrom::Start(3))?;
+ ///
+ /// let mut contents = vec![];
+ /// file_copy.read_to_end(&mut contents)?;
+ /// assert_eq!(contents, b"def\n");
/// # Ok(())
/// # }
/// ```
self.0.accessed().map(FromInner::from_inner)
}
- /// Returns the creation time listed in the this metadata.
+ /// Returns the creation time listed in this metadata.
///
/// The returned value corresponds to the `birthtime` field of `stat` on
/// Unix platforms and the `ftCreationTime` field on Windows platforms.
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(exact_size_is_empty)]
+#![feature(external_doc)]
#![feature(fs_read_write)]
#![feature(fixed_size_array)]
#![feature(float_from_str_radix)]
+++ /dev/null
-// Copyright 2015 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.
-
-//! Raw OS-specific types for the current platform/architecture
-
-#![stable(feature = "raw_os", since = "1.1.0")]
-
-use fmt;
-
-#[cfg(any(all(target_os = "linux", any(target_arch = "aarch64",
- target_arch = "arm",
- target_arch = "powerpc",
- target_arch = "powerpc64",
- target_arch = "s390x")),
- all(target_os = "android", any(target_arch = "aarch64",
- target_arch = "arm")),
- all(target_os = "l4re", target_arch = "x86_64"),
- all(target_os = "openbsd", target_arch = "aarch64"),
- all(target_os = "fuchsia", target_arch = "aarch64")))]
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
-#[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
- target_arch = "arm",
- target_arch = "powerpc",
- target_arch = "powerpc64",
- target_arch = "s390x")),
- all(target_os = "android", any(target_arch = "aarch64",
- target_arch = "arm")),
- all(target_os = "l4re", target_arch = "x86_64"),
- all(target_os = "openbsd", target_arch = "aarch64"),
- all(target_os = "fuchsia", target_arch = "aarch64"))))]
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_short = i16;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ushort = u16;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_int = i32;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_uint = u32;
-#[cfg(any(target_pointer_width = "32", windows))]
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i32;
-#[cfg(any(target_pointer_width = "32", windows))]
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u32;
-#[cfg(all(target_pointer_width = "64", not(windows)))]
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i64;
-#[cfg(all(target_pointer_width = "64", not(windows)))]
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u64;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_longlong = i64;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulonglong = u64;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_float = f32;
-#[stable(feature = "raw_os", since = "1.1.0")] pub type c_double = f64;
-
-/// Type used to construct void pointers for use with C.
-///
-/// This type is only useful as a pointer target. Do not use it as a
-/// return type for FFI functions which have the `void` return type in
-/// C. Use the unit type `()` or omit the return type instead.
-// NB: For LLVM to recognize the void pointer type and by extension
-// functions like malloc(), we need to have it represented as i8* in
-// LLVM bitcode. The enum used here ensures this and prevents misuse
-// of the "raw" type by only having private variants.. We need two
-// variants, because the compiler complains about the repr attribute
-// otherwise.
-#[repr(u8)]
-#[stable(feature = "raw_os", since = "1.1.0")]
-pub enum c_void {
- #[unstable(feature = "c_void_variant", reason = "should not have to exist",
- issue = "0")]
- #[doc(hidden)] __variant1,
- #[unstable(feature = "c_void_variant", reason = "should not have to exist",
- issue = "0")]
- #[doc(hidden)] __variant2,
-}
-
-#[stable(feature = "std_debug", since = "1.16.0")]
-impl fmt::Debug for c_void {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.pad("c_void")
- }
-}
-
-#[cfg(test)]
-#[allow(unused_imports)]
-mod tests {
- use any::TypeId;
- use libc;
- use mem;
-
- macro_rules! ok {
- ($($t:ident)*) => {$(
- assert!(TypeId::of::<libc::$t>() == TypeId::of::<raw::$t>(),
- "{} is wrong", stringify!($t));
- )*}
- }
-
- #[test]
- fn same() {
- use os::raw;
- ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
- c_longlong c_ulonglong c_float c_double);
- }
-}
--- /dev/null
+Equivalent to C's `char` type.
+
+[C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. This type will always be either [`i8`] or [`u8`], as the type is defined as being one byte long.
+
+C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with the character `'\0'`. See [`CStr`] for more information.
+
+[C's `char` type]: https://en.wikipedia.org/wiki/C_data_types#Basic_types
+[Rust's `char` type]: ../../primitive.char.html
+[`CStr`]: ../../ffi/struct.CStr.html
+[`i8`]: ../../primitive.i8.html
+[`u8`]: ../../primitive.u8.html
--- /dev/null
+Equivalent to C's `double` type.
+
+This type will almost always be [`f64`], which is guaranteed to be an [IEEE-754 double-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`], and it may be `f32` or something entirely different from the IEEE-754 standard.
+
+[IEEE-754 double-precision float]: https://en.wikipedia.org/wiki/IEEE_754
+[`float`]: type.c_float.html
+[`f64`]: ../../primitive.f64.html
--- /dev/null
+Equivalent to C's `float` type.
+
+This type will almost always be [`f32`], which is guaranteed to be an [IEEE-754 single-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number, and it may have less precision than `f32` or not follow the IEEE-754 standard at all.
+
+[IEEE-754 single-precision float]: https://en.wikipedia.org/wiki/IEEE_754
+[`f32`]: ../../primitive.f32.html
--- /dev/null
+Equivalent to C's `signed int` (`int`) type.
+
+This type will almost always be [`i32`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer that is at least the size of a [`short`]; some systems define it as an [`i16`], for example.
+
+[`short`]: type.c_short.html
+[`i32`]: ../../primitive.i32.html
+[`i16`]: ../../primitive.i16.html
--- /dev/null
+Equivalent to C's `signed long` (`long`) type.
+
+This type will always be [`i32`] or [`i64`]. Most notably, many Linux-based systems assume an `i64`, but Windows assumes `i32`. The C standard technically only requires that this type be a signed integer that is at least 32 bits and at least the size of an [`int`], although in practice, no system would have a `long` that is neither an `i32` nor `i64`.
+
+[`int`]: type.c_int.html
+[`i32`]: ../../primitive.i32.html
+[`i64`]: ../../primitive.i64.html
--- /dev/null
+Equivalent to C's `signed long long` (`long long`) type.
+
+This type will almost always be [`i64`], but may differ on some systems. The C standard technically only requires that this type be a signed integer that is at least 64 bits and at least the size of a [`long`], although in practice, no system would have a `long long` that is not an `i64`, as most systems do not have a standardised [`i128`] type.
+
+[`long`]: type.c_int.html
+[`i64`]: ../../primitive.i64.html
+[`i128`]: ../../primitive.i128.html
--- /dev/null
+// Copyright 2015 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.
+
+//! Platform-specific types, as defined by C.
+//!
+//! Code that interacts via FFI will almost certainly be using the
+//! base types provided by C, which aren't nearly as nicely defined
+//! as Rust's primitive types. This module provides types which will
+//! match those defined by C, so that code that interacts with C will
+//! refer to the correct types.
+
+#![stable(feature = "raw_os", since = "1.1.0")]
+
+use fmt;
+
+#[doc(include = "os/raw/char.md")]
+#[cfg(any(all(target_os = "linux", any(target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ target_arch = "s390x")),
+ all(target_os = "android", any(target_arch = "aarch64",
+ target_arch = "arm")),
+ all(target_os = "l4re", target_arch = "x86_64"),
+ all(target_os = "openbsd", target_arch = "aarch64"),
+ all(target_os = "fuchsia", target_arch = "aarch64")))]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
+#[doc(include = "os/raw/char.md")]
+#[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ target_arch = "s390x")),
+ all(target_os = "android", any(target_arch = "aarch64",
+ target_arch = "arm")),
+ all(target_os = "l4re", target_arch = "x86_64"),
+ all(target_os = "openbsd", target_arch = "aarch64"),
+ all(target_os = "fuchsia", target_arch = "aarch64"))))]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
+#[doc(include = "os/raw/schar.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;
+#[doc(include = "os/raw/uchar.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8;
+#[doc(include = "os/raw/short.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_short = i16;
+#[doc(include = "os/raw/ushort.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ushort = u16;
+#[doc(include = "os/raw/int.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_int = i32;
+#[doc(include = "os/raw/uint.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_uint = u32;
+#[doc(include = "os/raw/long.md")]
+#[cfg(any(target_pointer_width = "32", windows))]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i32;
+#[doc(include = "os/raw/ulong.md")]
+#[cfg(any(target_pointer_width = "32", windows))]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u32;
+#[doc(include = "os/raw/long.md")]
+#[cfg(all(target_pointer_width = "64", not(windows)))]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i64;
+#[doc(include = "os/raw/ulong.md")]
+#[cfg(all(target_pointer_width = "64", not(windows)))]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u64;
+#[doc(include = "os/raw/longlong.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_longlong = i64;
+#[doc(include = "os/raw/ulonglong.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulonglong = u64;
+#[doc(include = "os/raw/float.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_float = f32;
+#[doc(include = "os/raw/double.md")]
+#[stable(feature = "raw_os", since = "1.1.0")] pub type c_double = f64;
+
+/// Equivalent to C's `void` type when used as a [pointer].
+///
+/// In essence, `*const c_void` is equivalent to C's `const void*`
+/// and `*mut c_void` is equivalent to C's `void*`. That said, this is
+/// *not* the same as C's `void` return type, which is Rust's `()` type.
+///
+/// Ideally, this type would be equivalent to [`!`], but currently it may
+/// be more ideal to use `c_void` for FFI purposes.
+///
+/// [`!`]: ../../primitive.never.html
+/// [pointer]: ../../primitive.pointer.html
+// NB: For LLVM to recognize the void pointer type and by extension
+// functions like malloc(), we need to have it represented as i8* in
+// LLVM bitcode. The enum used here ensures this and prevents misuse
+// of the "raw" type by only having private variants.. We need two
+// variants, because the compiler complains about the repr attribute
+// otherwise.
+#[repr(u8)]
+#[stable(feature = "raw_os", since = "1.1.0")]
+pub enum c_void {
+ #[unstable(feature = "c_void_variant", reason = "should not have to exist",
+ issue = "0")]
+ #[doc(hidden)] __variant1,
+ #[unstable(feature = "c_void_variant", reason = "should not have to exist",
+ issue = "0")]
+ #[doc(hidden)] __variant2,
+}
+
+#[stable(feature = "std_debug", since = "1.16.0")]
+impl fmt::Debug for c_void {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.pad("c_void")
+ }
+}
+
+#[cfg(test)]
+#[allow(unused_imports)]
+mod tests {
+ use any::TypeId;
+ use libc;
+ use mem;
+
+ macro_rules! ok {
+ ($($t:ident)*) => {$(
+ assert!(TypeId::of::<libc::$t>() == TypeId::of::<raw::$t>(),
+ "{} is wrong", stringify!($t));
+ )*}
+ }
+
+ #[test]
+ fn same() {
+ use os::raw;
+ ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
+ c_longlong c_ulonglong c_float c_double);
+ }
+}
--- /dev/null
+Equivalent to C's `signed char` type.
+
+This type will always be [`i8`], but is included for completeness. It is defined as being a signed integer the same size as a C [`char`].
+
+[`char`]: type.c_char.html
+[`i8`]: ../../primitive.i8.html
--- /dev/null
+Equivalent to C's `signed short` (`short`) type.
+
+This type will almost always be [`i16`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer with at least 16 bits; some systems may define it as `i32`, for example.
+
+[`char`]: type.c_char.html
+[`i16`]: ../../primitive.i16.html
--- /dev/null
+Equivalent to C's `unsigned char` type.
+
+This type will always be [`u8`], but is included for completeness. It is defined as being an unsigned integer the same size as a C [`char`].
+
+[`char`]: type.c_char.html
+[`u8`]: ../../primitive.u8.html
--- /dev/null
+Equivalent to C's `unsigned int` type.
+
+This type will almost always be [`u32`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as an [`int`]; some systems define it as a [`u16`], for example.
+
+[`int`]: type.c_int.html
+[`u32`]: ../../primitive.u32.html
+[`u16`]: ../../primitive.u16.html
--- /dev/null
+Equivalent to C's `unsigned long` type.
+
+This type will always be [`u32`] or [`u64`]. Most notably, many Linux-based systems assume an `u64`, but Windows assumes `u32`. The C standard technically only requires that this type be an unsigned integer with the size of a [`long`], although in practice, no system would have a `ulong` that is neither a `u32` nor `u64`.
+
+[`long`]: type.c_long.html
+[`u32`]: ../../primitive.u32.html
+[`u64`]: ../../primitive.u64.html
--- /dev/null
+Equivalent to C's `unsigned long long` type.
+
+This type will almost always be [`u64`], but may differ on some systems. The C standard technically only requires that this type be an unsigned integer with the size of a [`long long`], although in practice, no system would have a `long long` that is not a `u64`, as most systems do not have a standardised [`u128`] type.
+
+[`long long`]: type.c_longlong.html
+[`u64`]: ../../primitive.u64.html
+[`u128`]: ../../primitive.u128.html
--- /dev/null
+Equivalent to C's `unsigned short` type.
+
+This type will almost always be [`u16`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as a [`short`].
+
+[`short`]: type.c_short.html
+[`u16`]: ../../primitive.u16.html
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for *mut T {}
#[unstable(feature = "ptr_internals", issue = "0")]
impl<T: UnwindSafe + ?Sized> UnwindSafe for Unique<T> {}
-#[stable(feature = "nonnull", since = "1.24.0")]
+#[stable(feature = "nonnull", since = "1.25.0")]
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for NonNull<T> {}
#[stable(feature = "catch_unwind", since = "1.9.0")]
impl<T: ?Sized> UnwindSafe for Mutex<T> {}
#[cfg_attr(test, allow(dead_code))]
pub mod guard {
- pub unsafe fn current() -> Option<usize> {
+ pub type Guard = !;
+ pub unsafe fn current() -> Option<Guard> {
None
}
- pub unsafe fn init() -> Option<usize> {
+ pub unsafe fn init() -> Option<Guard> {
None
}
}
}
pub mod guard {
- pub unsafe fn current() -> Option<usize> { None }
- pub unsafe fn init() -> Option<usize> { None }
+ pub type Guard = !;
+ pub unsafe fn current() -> Option<Guard> { None }
+ pub unsafe fn init() -> Option<Guard> { None }
}
use sys_common::thread_info;
- // This is initialized in init() and only read from after
- static mut PAGE_SIZE: usize = 0;
-
#[cfg(any(target_os = "linux", target_os = "android"))]
unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize {
#[repr(C)]
_data: *mut libc::c_void) {
use sys_common::util::report_overflow;
- let guard = thread_info::stack_guard().unwrap_or(0);
+ let guard = thread_info::stack_guard().unwrap_or(0..0);
let addr = siginfo_si_addr(info);
// If the faulting address is within the guard page, then we print a
// message saying so and abort.
- if guard != 0 && guard - PAGE_SIZE <= addr && addr < guard {
+ if guard.start <= addr && addr < guard.end {
report_overflow();
rtabort!("stack overflow");
} else {
static mut MAIN_ALTSTACK: *mut libc::c_void = ptr::null_mut();
pub unsafe fn init() {
- PAGE_SIZE = ::sys::os::page_size();
-
let mut action: sigaction = mem::zeroed();
action.sa_flags = SA_SIGINFO | SA_ONSTACK;
action.sa_sigaction = signal_handler as sighandler_t;
not(target_os = "solaris")))]
#[cfg_attr(test, allow(dead_code))]
pub mod guard {
- pub unsafe fn current() -> Option<usize> { None }
- pub unsafe fn init() -> Option<usize> { None }
+ use ops::Range;
+ pub type Guard = Range<usize>;
+ pub unsafe fn current() -> Option<Guard> { None }
+ pub unsafe fn init() -> Option<Guard> { None }
}
use libc;
use libc::mmap;
use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED};
+ use ops::Range;
use sys::os;
- #[cfg(any(target_os = "macos",
- target_os = "bitrig",
- target_os = "openbsd",
- target_os = "solaris"))]
+ // This is initialized in init() and only read from after
+ static mut PAGE_SIZE: usize = 0;
+
+ pub type Guard = Range<usize>;
+
+ #[cfg(target_os = "solaris")]
+ unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
+ let mut current_stack: libc::stack_t = ::mem::zeroed();
+ assert_eq!(libc::stack_getbounds(&mut current_stack), 0);
+ Some(current_stack.ss_sp)
+ }
+
+ #[cfg(target_os = "macos")]
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
- current().map(|s| s as *mut libc::c_void)
+ let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize -
+ libc::pthread_get_stacksize_np(libc::pthread_self());
+ Some(stackaddr as *mut libc::c_void)
+ }
+
+ #[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
+ unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
+ let mut current_stack: libc::stack_t = ::mem::zeroed();
+ assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(),
+ &mut current_stack), 0);
+
+ let extra = if cfg!(target_os = "bitrig") {3} else {1} * PAGE_SIZE;
+ let stackaddr = if libc::pthread_main_np() == 1 {
+ // main thread
+ current_stack.ss_sp as usize - current_stack.ss_size + extra
+ } else {
+ // new thread
+ current_stack.ss_sp as usize - current_stack.ss_size
+ };
+ Some(stackaddr as *mut libc::c_void)
}
#[cfg(any(target_os = "android", target_os = "freebsd",
ret
}
- pub unsafe fn init() -> Option<usize> {
- let psize = os::page_size();
+ pub unsafe fn init() -> Option<Guard> {
+ PAGE_SIZE = os::page_size();
+
let mut stackaddr = get_stack_start()?;
// Ensure stackaddr is page aligned! A parent process might
// stackaddr < stackaddr + stacksize, so if stackaddr is not
// page-aligned, calculate the fix such that stackaddr <
// new_page_aligned_stackaddr < stackaddr + stacksize
- let remainder = (stackaddr as usize) % psize;
+ let remainder = (stackaddr as usize) % PAGE_SIZE;
if remainder != 0 {
- stackaddr = ((stackaddr as usize) + psize - remainder)
+ stackaddr = ((stackaddr as usize) + PAGE_SIZE - remainder)
as *mut libc::c_void;
}
// Instead, we'll just note where we expect rlimit to start
// faulting, so our handler can report "stack overflow", and
// trust that the kernel's own stack guard will work.
- Some(stackaddr as usize)
+ let stackaddr = stackaddr as usize;
+ Some(stackaddr - PAGE_SIZE..stackaddr)
} else {
// Reallocate the last page of the stack.
// This ensures SIGBUS will be raised on
// stack overflow.
- let result = mmap(stackaddr, psize, PROT_NONE,
+ let result = mmap(stackaddr, PAGE_SIZE, PROT_NONE,
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
if result != stackaddr || result == MAP_FAILED {
panic!("failed to allocate a guard page");
}
+ let guardaddr = stackaddr as usize;
let offset = if cfg!(target_os = "freebsd") {
2
} else {
1
};
- Some(stackaddr as usize + offset * psize)
+ Some(guardaddr..guardaddr + offset * PAGE_SIZE)
}
}
- #[cfg(target_os = "solaris")]
- pub unsafe fn current() -> Option<usize> {
- let mut current_stack: libc::stack_t = ::mem::zeroed();
- assert_eq!(libc::stack_getbounds(&mut current_stack), 0);
- Some(current_stack.ss_sp as usize)
- }
-
- #[cfg(target_os = "macos")]
- pub unsafe fn current() -> Option<usize> {
- Some(libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize -
- libc::pthread_get_stacksize_np(libc::pthread_self()))
- }
-
- #[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
- pub unsafe fn current() -> Option<usize> {
- let mut current_stack: libc::stack_t = ::mem::zeroed();
- assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(),
- &mut current_stack), 0);
-
- let extra = if cfg!(target_os = "bitrig") {3} else {1} * os::page_size();
- Some(if libc::pthread_main_np() == 1 {
- // main thread
- current_stack.ss_sp as usize - current_stack.ss_size + extra
- } else {
- // new thread
- current_stack.ss_sp as usize - current_stack.ss_size
- })
+ #[cfg(any(target_os = "macos",
+ target_os = "bitrig",
+ target_os = "openbsd",
+ target_os = "solaris"))]
+ pub unsafe fn current() -> Option<Guard> {
+ let stackaddr = get_stack_start()? as usize;
+ Some(stackaddr - PAGE_SIZE..stackaddr)
}
#[cfg(any(target_os = "android", target_os = "freebsd",
target_os = "linux", target_os = "netbsd", target_os = "l4re"))]
- pub unsafe fn current() -> Option<usize> {
+ pub unsafe fn current() -> Option<Guard> {
let mut ret = None;
let mut attr: libc::pthread_attr_t = ::mem::zeroed();
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
&mut size), 0);
+ let stackaddr = stackaddr as usize;
ret = if cfg!(target_os = "freebsd") {
- Some(stackaddr as usize - guardsize)
+ // FIXME does freebsd really fault *below* the guard addr?
+ let guardaddr = stackaddr - guardsize;
+ Some(guardaddr - PAGE_SIZE..guardaddr)
} else if cfg!(target_os = "netbsd") {
- Some(stackaddr as usize)
+ Some(stackaddr - guardsize..stackaddr)
+ } else if cfg!(all(target_os = "linux", target_env = "gnu")) {
+ // glibc used to include the guard area within the stack, as noted in the BUGS
+ // section of `man pthread_attr_getguardsize`. This has been corrected starting
+ // with glibc 2.27, and in some distro backports, so the guard is now placed at the
+ // end (below) the stack. There's no easy way for us to know which we have at
+ // runtime, so we'll just match any fault in the range right above or below the
+ // stack base to call that fault a stack overflow.
+ Some(stackaddr - guardsize..stackaddr + guardsize)
} else {
- Some(stackaddr as usize + guardsize)
+ Some(stackaddr..stackaddr + guardsize)
};
}
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
}
pub mod guard {
- pub unsafe fn current() -> Option<usize> { None }
- pub unsafe fn init() -> Option<usize> { None }
+ pub type Guard = !;
+ pub unsafe fn current() -> Option<Guard> { None }
+ pub unsafe fn init() -> Option<Guard> { None }
}
#[cfg_attr(test, allow(dead_code))]
pub mod guard {
- pub unsafe fn current() -> Option<usize> { None }
- pub unsafe fn init() -> Option<usize> { None }
+ pub type Guard = !;
+ pub unsafe fn current() -> Option<Guard> { None }
+ pub unsafe fn init() -> Option<Guard> { None }
}
#![allow(dead_code)] // stack_guard isn't used right now on all platforms
use cell::RefCell;
+use sys::thread::guard::Guard;
use thread::Thread;
struct ThreadInfo {
- stack_guard: Option<usize>,
+ stack_guard: Option<Guard>,
thread: Thread,
}
ThreadInfo::with(|info| info.thread.clone())
}
-pub fn stack_guard() -> Option<usize> {
- ThreadInfo::with(|info| info.stack_guard).and_then(|o| o)
+pub fn stack_guard() -> Option<Guard> {
+ ThreadInfo::with(|info| info.stack_guard.clone()).and_then(|o| o)
}
-pub fn set(stack_guard: Option<usize>, thread: Thread) {
+pub fn set(stack_guard: Option<Guard>, thread: Thread) {
THREAD_INFO.with(|c| assert!(c.borrow().is_none()));
THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{
stack_guard,
pub pats: Vec<P<Pat>>,
pub guard: Option<P<Expr>>,
pub body: P<Expr>,
- pub beginning_vert: Option<Span>, // For RFC 1925 feature gate
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pats,
guard: None,
body: expr,
- beginning_vert: None,
}
}
match_hi: usize,
// Specifically used if we are matching a repetition. If we aren't both should be `None`.
+ /// The KleeneOp of this sequence if we are in a repetition.
+ seq_op: Option<quoted::KleeneOp>,
/// The separator if we are in a repetition
sep: Option<Token>,
/// The "parent" matcher position if we are in a repetition. That is, the matcher position just
stack: vec![],
// Haven't descended into any sequences, so both of these are `None`.
+ seq_op: None,
sep: None,
up: None,
})
}
}
// We don't need a separator. Move the "dot" back to the beginning of the matcher
- // and try to match again.
- else {
+ // and try to match again UNLESS we are only allowed to have _one_ repetition.
+ else if item.seq_op != Some(quoted::KleeneOp::ZeroOrOne) {
item.match_cur = item.match_lo;
item.idx = 0;
cur_items.push(item);
match item.top_elts.get_tt(idx) {
// Need to descend into a sequence
TokenTree::Sequence(sp, seq) => {
- if seq.op == quoted::KleeneOp::ZeroOrMore {
- // Examine the case where there are 0 matches of this sequence
+ // Examine the case where there are 0 matches of this sequence
+ if seq.op == quoted::KleeneOp::ZeroOrMore
+ || seq.op == quoted::KleeneOp::ZeroOrOne
+ {
let mut new_item = item.clone();
new_item.match_cur += seq.num_captures;
new_item.idx += 1;
cur_items.push(new_item);
}
- // Examine the case where there is at least one match of this sequence
let matches = create_matches(item.matches.len());
cur_items.push(Box::new(MatcherPos {
stack: vec![],
sep: seq.separator.clone(),
+ seq_op: Some(seq.op),
idx: 0,
matches,
match_lo: item.match_cur,
s.iter().map(|m| {
if let MatchedNonterminal(ref nt) = *m {
if let NtTT(ref tt) = **nt {
- let tt = quoted::parse(tt.clone().into(), true, sess).pop().unwrap();
+ let tt = quoted::parse(tt.clone().into(), true, sess, features, &def.attrs)
+ .pop().unwrap();
valid &= check_lhs_nt_follows(sess, features, &def.attrs, &tt);
return tt;
}
s.iter().map(|m| {
if let MatchedNonterminal(ref nt) = *m {
if let NtTT(ref tt) = **nt {
- return quoted::parse(tt.clone().into(), false, sess).pop().unwrap();
+ return quoted::parse(tt.clone().into(), false, sess, features, &def.attrs)
+ .pop().unwrap();
}
}
sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs")
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use ast;
+use {ast, attr};
use ext::tt::macro_parser;
+use feature_gate::{self, emit_feature_err, Features, GateIssue};
use parse::{token, ParseSess};
use print::pprust;
use symbol::keywords;
use syntax_pos::{BytePos, Span, DUMMY_SP};
use tokenstream;
+use std::cell::RefCell;
+use std::iter::Peekable;
use std::rc::Rc;
/// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note
ZeroOrMore,
/// Kleene plus (`+`) for one or more repetitions
OneOrMore,
+ ZeroOrOne,
}
/// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, and `$(...)`
/// `ident` are "matchers". They are not present in the body of a macro rule -- just in the
/// pattern, so we pass a parameter to indicate whether to expect them or not.
/// - `sess`: the parsing session. Any errors will be emitted to this session.
+/// - `features`, `attrs`: language feature flags and attributes so that we know whether to use
+/// unstable features or not.
///
/// # Returns
///
input: tokenstream::TokenStream,
expect_matchers: bool,
sess: &ParseSess,
+ features: &RefCell<Features>,
+ attrs: &[ast::Attribute],
) -> Vec<TokenTree> {
// Will contain the final collection of `self::TokenTree`
let mut result = Vec::new();
// For each token tree in `input`, parse the token into a `self::TokenTree`, consuming
// additional trees if need be.
- let mut trees = input.trees();
+ let mut trees = input.trees().peekable();
while let Some(tree) = trees.next() {
- let tree = parse_tree(tree, &mut trees, expect_matchers, sess);
-
// Given the parsed tree, if there is a metavar and we are expecting matchers, actually
// parse out the matcher (i.e. in `$id:ident` this would parse the `:` and `ident`).
+ let tree = parse_tree(tree, &mut trees, expect_matchers, sess, features, attrs);
match tree {
TokenTree::MetaVar(start_sp, ident) if expect_matchers => {
let span = match trees.next() {
/// converting `tree`
/// - `expect_matchers`: same as for `parse` (see above).
/// - `sess`: the parsing session. Any errors will be emitted to this session.
+/// - `features`, `attrs`: language feature flags and attributes so that we know whether to use
+/// unstable features or not.
fn parse_tree<I>(
tree: tokenstream::TokenTree,
- trees: &mut I,
+ trees: &mut Peekable<I>,
expect_matchers: bool,
sess: &ParseSess,
+ features: &RefCell<Features>,
+ attrs: &[ast::Attribute],
) -> TokenTree
where
I: Iterator<Item = tokenstream::TokenTree>,
sess.span_diagnostic.span_err(span, &msg);
}
// Parse the contents of the sequence itself
- let sequence = parse(delimited.tts.into(), expect_matchers, sess);
+ let sequence = parse(delimited.tts.into(), expect_matchers, sess, features, attrs);
// Get the Kleene operator and optional separator
- let (separator, op) = parse_sep_and_kleene_op(trees, span, sess);
+ let (separator, op) = parse_sep_and_kleene_op(trees, span, sess, features, attrs);
// Count the number of captured "names" (i.e. named metavars)
let name_captures = macro_parser::count_names(&sequence);
TokenTree::Sequence(
span,
Rc::new(Delimited {
delim: delimited.delim,
- tts: parse(delimited.tts.into(), expect_matchers, sess),
+ tts: parse(delimited.tts.into(), expect_matchers, sess, features, attrs),
}),
),
}
}
+/// Takes a token and returns `Some(KleeneOp)` if the token is `+` `*` or `?`. Otherwise, return
+/// `None`.
+fn kleene_op(token: &token::Token) -> Option<KleeneOp> {
+ match *token {
+ token::BinOp(token::Star) => Some(KleeneOp::ZeroOrMore),
+ token::BinOp(token::Plus) => Some(KleeneOp::OneOrMore),
+ token::Question => Some(KleeneOp::ZeroOrOne),
+ _ => None,
+ }
+}
+
+/// Parse the next token tree of the input looking for a KleeneOp. Returns
+///
+/// - Ok(Ok(op)) if the next token tree is a KleeneOp
+/// - Ok(Err(tok, span)) if the next token tree is a token but not a KleeneOp
+/// - Err(span) if the next token tree is not a token
+fn parse_kleene_op<I>(
+ input: &mut I,
+ span: Span,
+) -> Result<Result<KleeneOp, (token::Token, Span)>, Span>
+where
+ I: Iterator<Item = tokenstream::TokenTree>,
+{
+ match input.next() {
+ Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) {
+ Some(op) => Ok(Ok(op)),
+ None => Ok(Err((tok, span))),
+ },
+ tree => Err(tree.as_ref()
+ .map(tokenstream::TokenTree::span)
+ .unwrap_or(span)),
+ }
+}
+
/// Attempt to parse a single Kleene star, possibly with a separator.
///
/// For example, in a pattern such as `$(a),*`, `a` is the pattern to be repeated, `,` is the
/// operator and separator, then a tuple with `(separator, KleeneOp)` is returned. Otherwise, an
/// error with the appropriate span is emitted to `sess` and a dummy value is returned.
fn parse_sep_and_kleene_op<I>(
- input: &mut I,
+ input: &mut Peekable<I>,
span: Span,
sess: &ParseSess,
+ features: &RefCell<Features>,
+ attrs: &[ast::Attribute],
) -> (Option<token::Token>, KleeneOp)
where
I: Iterator<Item = tokenstream::TokenTree>,
{
- fn kleene_op(token: &token::Token) -> Option<KleeneOp> {
- match *token {
- token::BinOp(token::Star) => Some(KleeneOp::ZeroOrMore),
- token::BinOp(token::Plus) => Some(KleeneOp::OneOrMore),
- _ => None,
+ // We basically look at two token trees here, denoted as #1 and #2 below
+ let span = match parse_kleene_op(input, span) {
+ // #1 is a `+` or `*` KleeneOp
+ //
+ // `?` is ambiguous: it could be a separator or a Kleene::ZeroOrOne, so we need to look
+ // ahead one more token to be sure.
+ Ok(Ok(op)) if op != KleeneOp::ZeroOrOne => return (None, op),
+
+ // #1 is `?` token, but it could be a Kleene::ZeroOrOne without a separator or it could
+ // be a `?` separator followed by any Kleene operator. We need to look ahead 1 token to
+ // find out which.
+ Ok(Ok(op)) => {
+ assert_eq!(op, KleeneOp::ZeroOrOne);
+
+ // Lookahead at #2. If it is a KleenOp, then #1 is a separator.
+ let is_1_sep = if let Some(&tokenstream::TokenTree::Token(_, ref tok2)) = input.peek() {
+ kleene_op(tok2).is_some()
+ } else {
+ false
+ };
+
+ if is_1_sep {
+ // #1 is a separator and #2 should be a KleepeOp::*
+ // (N.B. We need to advance the input iterator.)
+ match parse_kleene_op(input, span) {
+ // #2 is a KleeneOp (this is the only valid option) :)
+ Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => {
+ if !features.borrow().macro_at_most_once_rep
+ && !attr::contains_name(attrs, "allow_internal_unstable")
+ {
+ let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
+ emit_feature_err(
+ sess,
+ "macro_at_most_once_rep",
+ span,
+ GateIssue::Language,
+ explain,
+ );
+ }
+ return (Some(token::Question), op);
+ }
+ Ok(Ok(op)) => return (Some(token::Question), op),
+
+ // #2 is a random token (this is an error) :(
+ Ok(Err((_, span))) => span,
+
+ // #2 is not even a token at all :(
+ Err(span) => span,
+ }
+ } else {
+ if !features.borrow().macro_at_most_once_rep
+ && !attr::contains_name(attrs, "allow_internal_unstable")
+ {
+ let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
+ emit_feature_err(
+ sess,
+ "macro_at_most_once_rep",
+ span,
+ GateIssue::Language,
+ explain,
+ );
+ }
+
+ // #2 is a random tree and #1 is KleeneOp::ZeroOrOne
+ return (None, op);
+ }
}
- }
- // We attempt to look at the next two token trees in `input`. I will call the first #1 and the
- // second #2. If #1 and #2 don't match a valid KleeneOp with/without separator, that is an
- // error, and we should emit an error on the most specific span possible.
- let span = match input.next() {
- // #1 is a token
- Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) {
- // #1 is a KleeneOp with no separator
- Some(op) => return (None, op),
-
- // #1 is not a KleeneOp, but may be a separator... need to look at #2
- None => match input.next() {
- // #2 is a token
- Some(tokenstream::TokenTree::Token(span, tok2)) => match kleene_op(&tok2) {
- // #2 is a KleeneOp, so #1 must be a separator
- Some(op) => return (Some(tok), op),
-
- // #2 is not a KleeneOp... error
- None => span,
- },
-
- // #2 is not a token at all... error
- tree => tree.as_ref()
- .map(tokenstream::TokenTree::span)
- .unwrap_or(span),
- },
+ // #1 is a separator followed by #2, a KleeneOp
+ Ok(Err((tok, span))) => match parse_kleene_op(input, span) {
+ // #2 is a KleeneOp :D
+ Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => {
+ if !features.borrow().macro_at_most_once_rep
+ && !attr::contains_name(attrs, "allow_internal_unstable")
+ {
+ let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
+ emit_feature_err(
+ sess,
+ "macro_at_most_once_rep",
+ span,
+ GateIssue::Language,
+ explain,
+ );
+ }
+ return (Some(tok), op);
+ }
+ Ok(Ok(op)) => return (Some(tok), op),
+
+ // #2 is a random token :(
+ Ok(Err((_, span))) => span,
+
+ // #2 is not a token at all :(
+ Err(span) => span,
},
- // #1 is not a token at all... error
- tree => tree.as_ref()
- .map(tokenstream::TokenTree::span)
- .unwrap_or(span),
+ // #1 is not a token
+ Err(span) => span,
};
- // Error...
- sess.span_diagnostic.span_err(span, "expected `*` or `+`");
+ if !features.borrow().macro_at_most_once_rep
+ && !attr::contains_name(attrs, "allow_internal_unstable")
+ {
+ sess.span_diagnostic
+ .span_err(span, "expected one of: `*`, `+`, or `?`");
+ } else {
+ sess.span_diagnostic.span_err(span, "expected `*` or `+`");
+ }
(None, KleeneOp::ZeroOrMore)
}
// allow `#[must_use]` on functions and comparison operators (RFC 1940)
(active, fn_must_use, "1.21.0", Some(43302)),
- // allow '|' at beginning of match arms (RFC 1925)
- (active, match_beginning_vert, "1.21.0", Some(44101)),
-
// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
(active, non_exhaustive, "1.22.0", Some(44109)),
// In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`)
(active, in_band_lifetimes, "1.23.0", Some(44524)),
- // Nested groups in `use` (RFC 2128)
- (active, use_nested_groups, "1.23.0", Some(44494)),
-
// generic associated types (RFC 1598)
(active, generic_associated_types, "1.23.0", Some(44265)),
// Allows `#[repr(transparent)]` attribute on newtype structs
(active, repr_transparent, "1.25.0", Some(43036)),
+
+ // Use `?` as the Kleene "at most one" operator
+ (active, macro_at_most_once_rep, "1.25.0", Some(48075)),
);
declare_features! (
(accepted, abi_sysv64, "1.24.0", Some(36167)),
// Allows `repr(align(16))` struct attribute (RFC 1358)
(accepted, repr_align, "1.24.0", Some(33626)),
+ // allow '|' at beginning of match arms (RFC 1925)
+ (accepted, match_beginning_vert, "1.25.0", Some(44101)),
+ // Nested groups in `use` (RFC 2128)
+ (accepted, use_nested_groups, "1.25.0", Some(44494)),
);
// If you change this, please modify src/doc/unstable-book as well. You must
"wasm_import_memory attribute is currently unstable",
cfg_fn!(wasm_import_memory))),
+ ("rustc_args_required_const", Whitelisted, Gated(Stability::Unstable,
+ "rustc_attrs",
+ "never will be stable",
+ cfg_fn!(rustc_attrs))),
+
// Crate level attributes
("crate_name", CrateLevel, Ungated),
("crate_type", CrateLevel, Ungated),
pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str =
"Unsized tuple coercion is not stable enough for use and is subject to change";
+pub const EXPLAIN_MACRO_AT_MOST_ONCE_REP: &'static str =
+ "Using the `?` macro Kleene operator for \"at most one\" repetition is unstable";
+
struct PostExpansionVisitor<'a> {
context: &'a Context<'a>,
}
}
fn visit_arm(&mut self, arm: &'a ast::Arm) {
- if let Some(span) = arm.beginning_vert {
- gate_feature_post!(&self, match_beginning_vert,
- span,
- "Use of a '|' at the beginning of a match arm is experimental")
- }
visit::walk_arm(self, arm)
}
visit::walk_path(self, path);
}
- fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, nested: bool) {
- if nested {
- match use_tree.kind {
- ast::UseTreeKind::Simple(_) => {
- if use_tree.prefix.segments.len() != 1 {
- gate_feature_post!(&self, use_nested_groups, use_tree.span,
- "paths in `use` groups are experimental");
- }
- }
- ast::UseTreeKind::Glob => {
- gate_feature_post!(&self, use_nested_groups, use_tree.span,
- "glob imports in `use` groups are experimental");
- }
- ast::UseTreeKind::Nested(_) => {
- gate_feature_post!(&self, use_nested_groups, use_tree.span,
- "nested groups in `use` are experimental");
- }
- }
- }
-
- visit::walk_use_tree(self, use_tree, id);
- }
-
fn visit_vis(&mut self, vis: &'a ast::Visibility) {
if let ast::Visibility::Crate(span, ast::CrateSugar::JustCrate) = *vis {
gate_feature_post!(&self, crate_visibility_modifier, span,
fold_attrs(attrs.into(), fld).into()
}
-pub fn noop_fold_arm<T: Folder>(Arm {attrs, pats, guard, body, beginning_vert}: Arm,
+pub fn noop_fold_arm<T: Folder>(Arm {attrs, pats, guard, body}: Arm,
fld: &mut T) -> Arm {
Arm {
attrs: fold_attrs(attrs, fld),
pats: pats.move_map(|x| fld.fold_pat(x)),
guard: guard.map(|x| fld.fold_expr(x)),
body: fld.fold_expr(body),
- beginning_vert,
}
}
})
}
+ fn expected_ident_found(&self) -> DiagnosticBuilder<'a> {
+ let mut err = self.struct_span_err(self.span,
+ &format!("expected identifier, found {}",
+ self.this_token_descr()));
+ if let Some(token_descr) = self.token_descr() {
+ err.span_label(self.span, format!("expected identifier, found {}", token_descr));
+ } else {
+ err.span_label(self.span, "expected identifier");
+ }
+ err
+ }
+
pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
self.parse_ident_common(true)
}
match self.token {
token::Ident(i) => {
if self.token.is_reserved_ident() {
- let mut err = self.struct_span_err(self.span,
- &format!("expected identifier, found {}",
- self.this_token_descr()));
- if let Some(token_descr) = self.token_descr() {
- err.span_label(self.span, format!("expected identifier, found {}",
- token_descr));
- } else {
- err.span_label(self.span, "expected identifier");
- }
+ let mut err = self.expected_ident_found();
if recover {
err.emit();
} else {
Err(if self.prev_token_kind == PrevTokenKind::DocComment {
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
} else {
- let mut err = self.fatal(&format!("expected identifier, found `{}`",
- self.this_token_to_string()));
- if let Some(token_descr) = self.token_descr() {
- err.span_label(self.span, format!("expected identifier, found {}",
- token_descr));
- } else {
- err.span_label(self.span, "expected identifier");
- }
+ let mut err = self.expected_ident_found();
if self.token == token::Underscore {
err.note("`_` is a wildcard pattern, not an identifier");
}
let attrs = self.parse_outer_attributes()?;
// Allow a '|' before the pats (RFC 1925)
- let beginning_vert = if self.eat(&token::BinOp(token::Or)) {
- Some(self.prev_span)
- } else {
- None
- };
+ self.eat(&token::BinOp(token::Or));
let pats = self.parse_pats()?;
let guard = if self.eat_keyword(keywords::If) {
Some(self.parse_expr()?)
pats,
guard,
body: expr,
- beginning_vert,
})
}
}
}
+ // If there are no outputs, the inline assembly is executed just for its side effects,
+ // so ensure that it is volatile
+ if outputs.is_empty() {
+ volatile = true;
+ }
+
MacEager::expr(P(ast::Expr {
id: ast::DUMMY_NODE_ID,
node: ast::ExprKind::InlineAsm(P(ast::InlineAsm {
use std::thread;
use std::time::{Instant, Duration};
use std::borrow::Cow;
+use std::process;
const TEST_WARN_TIMEOUT_S: u64 = 60;
const QUIET_MODE_MAX_COLUMN: usize = 100; // insert a '\n' after 100 tests in quiet mode
pub fn test_main(args: &[String], tests: Vec<TestDescAndFn>, options: Options) {
let mut opts = match parse_opts(args) {
Some(Ok(o)) => o,
- Some(Err(msg)) => panic!("{:?}", msg),
+ Some(Err(msg)) => {
+ eprintln!("error: {}", msg);
+ process::exit(101);
+ },
None => return,
};
+
opts.options = options;
if opts.list {
if let Err(e) = list_tests_console(&opts, tests) {
- panic!("io error when listing tests: {:?}", e);
+ eprintln!("error: io error when listing tests: {:?}", e);
+ process::exit(101);
}
} else {
match run_tests_console(&opts, tests) {
Ok(true) => {}
- Ok(false) => std::process::exit(101),
- Err(e) => panic!("io error when running tests: {:?}", e),
+ Ok(false) => process::exit(101),
+ Err(e) => {
+ eprintln!("error: io error when listing tests: {:?}", e);
+ process::exit(101);
+ },
}
}
}
-Subproject commit bc344d5bc23c61ff9baf82d268a0edf199933cc3
+Subproject commit 9f81beaf32608fbe1fe0f2a82f974e800e9d8c62
if (isSet(Flags & LLVMRustDIFlags::FlagRValueReference)) {
Result |= DINode::DIFlags::FlagRValueReference;
}
+#if LLVM_VERSION_LE(4, 0)
if (isSet(Flags & LLVMRustDIFlags::FlagExternalTypeRef)) {
Result |= DINode::DIFlags::FlagExternalTypeRef;
}
+#endif
if (isSet(Flags & LLVMRustDIFlags::FlagIntroducedVirtual)) {
Result |= DINode::DIFlags::FlagIntroducedVirtual;
}
# If this file is modified, then llvm will be (optionally) cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
-2018-01-25
+2018-02-09
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// only-x86_64
+
+// compile-flags: -C no-prepopulate-passes
+
+#![crate_type = "lib"]
+
+pub struct S24 {
+ a: i8,
+ b: i8,
+ c: i8,
+}
+
+pub struct S48 {
+ a: i16,
+ b: i16,
+ c: i8,
+}
+
+// CHECK: i24 @struct_24_bits(i24
+#[no_mangle]
+pub extern "sysv64" fn struct_24_bits(a: S24) -> S24 {
+ a
+}
+
+// CHECK: i48 @struct_48_bits(i48
+#[no_mangle]
+pub extern "sysv64" fn struct_48_bits(a: S48) -> S48 {
+ a
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags: -O
+
+// ignore-asmjs
+
+#![feature(asm)]
+#![crate_type = "lib"]
+
+// Check that inline assembly expressions without any outputs
+// are marked as having side effects / being volatile
+
+// CHECK-LABEL: @assembly
+#[no_mangle]
+pub fn assembly() {
+ unsafe { asm!("") }
+// CHECK: tail call void asm sideeffect "", {{.*}}
+}
--- /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.
+
+// compile-flags: -O
+// ignore-tidy-linelength
+
+#![crate_type = "lib"]
+
+use std::iter;
+
+// CHECK-LABEL: @repeat_take_collect
+#[no_mangle]
+pub fn repeat_take_collect() -> Vec<u8> {
+// CHECK: call void @llvm.memset.p0i8
+ iter::repeat(42).take(100000).collect()
+}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// only-x86_64
+
+// compile-flags: -C no-prepopulate-passes
+
+#![crate_type="lib"]
+#![feature(repr_transparent)]
+
+#[repr(C)]
+pub struct Rgb8 { r: u8, g: u8, b: u8 }
+
+#[repr(transparent)]
+pub struct Rgb8Wrap(Rgb8);
+
+// CHECK: i24 @test_Rgb8Wrap(i24)
+#[no_mangle]
+pub extern "sysv64" fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} }
+
+#[repr(C)]
+pub union FloatBits {
+ float: f32,
+ bits: u32,
+}
+
+#[repr(transparent)]
+pub struct SmallUnion(FloatBits);
+
+// CHECK: i32 @test_SmallUnion(i32)
+#[no_mangle]
+pub extern "sysv64" fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} }
pub extern fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} }
-// The rest of this file tests newtypes around small aggregates on an ABI where small aggregates are
-// packed into one register. This is ABI-dependent, so instead we focus on one ABI and supply a
-// dummy definition for other ABIs to keep FileCheck happy.
+// All that remains to be tested are aggregates. They are tested in separate files called repr-
+// transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR
+// function signatures vary so much that it's not reasonably possible to cover all of them with a
+// single CHECK line.
//
-// Bigger aggregates are tested in separate files called repr-transparent-aggregate-*.rs because
-// there, the expected LLVM IR function signatures vary so much that it's not reasonably possible to
-// cover all of them with a single CHECK line. Instead we group ABIs by the general "shape" of the
-// signature and have a separate test file for each bin.
-//
-// PS: You may be wondering why we don't just compare the return types and argument types for
-// equality with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on
-// newtypes containing aggregates. This is OK on all ABIs we support, but because LLVM has not
-// gotten rid of pointee types yet, the IR function signature will be syntactically different (%Foo*
-// vs %FooWrapper*).
-
-#[repr(C)]
-pub struct Rgb8 { r: u8, g: u8, b: u8 }
-
-#[repr(transparent)]
-pub struct Rgb8Wrap(Rgb8);
-
-// NB: closing parenthesis is missing because sometimes the argument has a name and sometimes not
-// CHECK: define i32 @test_Rgb8Wrap(i32
-#[no_mangle]
-#[cfg(all(target_arch="x86_64", target_os="linux"))]
-pub extern fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} }
-
-#[cfg(not(all(target_arch="x86_64", target_os="linux")))]
-#[no_mangle]
-pub extern fn test_Rgb8Wrap(_: u32) -> u32 { loop {} }
-
-// Same as with the small struct above: ABI-dependent, we only test the interesting case
-// (ABIs that pack the aggregate into a scalar) and stub it out on other ABIs
-
-#[repr(C)]
-pub union FloatBits {
- float: f32,
- bits: u32,
-}
-
-#[repr(transparent)]
-pub struct SmallUnion(FloatBits);
-
-// NB: closing parenthesis is missing because sometimes the argument has a name and sometimes not
-// CHECK: define i32 @test_SmallUnion(i32
-#[no_mangle]
-#[cfg(all(target_arch="x86_64", target_os="linux"))]
-pub extern fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} }
-
-#[cfg(not(all(target_arch="x86_64", target_os="linux")))]
-#[no_mangle]
-pub extern fn test_SmallUnion(_: u32) -> u32 { loop {} }
+// You may be wondering why we don't just compare the return types and argument types for equality
+// with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on newtypes
+// containing aggregates. This is OK on all ABIs we support, but because LLVM has not gotten rid of
+// pointee types yet, the IR function signature will be syntactically different (%Foo* vs
+// %FooWrapper*).
// ignore-wasm
// ignore-emscripten
// ignore-windows
-// no-system-llvm
+// min-system-llvm-version 5.0
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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(unreachable_patterns)]
-
-fn main() {
- let foo = Some(1);
- match foo {
- Some(_) => {/* ... */}
- None => {/* ... */}
- _ => {/* ... */} //~ ERROR unreachable pattern
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = Some(1);
-
- match x { } //~ ERROR E0004
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum Terminator {
- HastaLaVistaBaby,
- TalkToMyHand,
-}
-
-fn main() {
- let x = Terminator::HastaLaVistaBaby;
-
- match x { //~ ERROR E0004
- Terminator::TalkToMyHand => {}
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = Some(1);
- let Some(y) = x; //~ ERROR E0005
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = Some("s".to_string());
- match x {
- op_string @ Some(s) => {},
- //~^ ERROR E0007
- //~| ERROR E0303
- None => {},
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- match Some("hi".to_string()) {
- Some(s) if s.len() == 0 => {},
- //~^ ERROR E0008
- _ => {},
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- struct X { x: (), }
- let x = Some((X { x: () }, X { x: () }));
- match x {
- Some((y, ref z)) => {},
- //~^ ERROR E0009
- None => panic!()
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(box_syntax)]
-#![allow(warnings)]
-
-const CON : Box<i32> = box 0; //~ ERROR E0010
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-static X: i32 = 1;
-const C: i32 = 2;
-
-const CR: &'static mut i32 = &mut C; //~ ERROR E0017
-static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
- //~| ERROR cannot borrow
-static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum Fruit {
- Apple(String, String),
- Pear(u32),
-}
-
-
-fn main() {
- let x = Fruit::Apple(String::new(), String::new());
- match x {
- Fruit::Apple(a) => {}, //~ ERROR E0023
- Fruit::Apple(a, b, c) => {}, //~ ERROR E0023
- Fruit::Pear(1, 2) => {}, //~ ERROR E0023
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- a: u8,
- b: u8,
-}
-
-fn main() {
- let x = Foo { a:1, b:2 };
- let Foo { a: x, a: y, b: 0 } = x;
- //~^ ERROR field `a` bound multiple times in the pattern
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Thing {
- x: u32,
- y: u32
-}
-
-fn main() {
- let thing = Thing { x: 0, y: 0 };
- match thing {
- Thing { x, y, z } => {}
- //~^ ERROR struct `Thing` does not have a field named `z` [E0026]
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Dog {
- name: String,
- age: u32,
-}
-
-fn main() {
- let d = Dog { name: "Rusty".to_string(), age: 8 };
-
- match d {
- Dog { age: x } => {}
- //~^ ERROR pattern does not mention field `name`
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let s = "hoho";
-
- match s {
- "hello" ... "world" => {}
- //~^ ERROR only char and numeric types are allowed in range patterns
- //~| ERROR non-reference pattern used to match a reference
- _ => {}
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-
-fn main() {
- match 5u32 {
- 1000 ... 5 => {}
- //~^ ERROR lower range bound must be less than or equal to upper
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait SomeTrait {
- fn foo();
-}
-
-fn main() {
- let trait_obj: &SomeTrait = SomeTrait;
- //~^ ERROR expected value, found trait `SomeTrait`
- //~| ERROR E0038
- //~| method `foo` has no receiver
-
- let &invalid = trait_obj;
- //~^ ERROR E0033
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Test;
-
-trait Trait1 {
- fn foo();
-}
-
-trait Trait2 {
- fn foo();
-}
-
-impl Trait1 for Test {
- fn foo() {}
-}
-
-impl Trait2 for Test {
- fn foo() {}
-}
-
-fn main() {
- Test::foo() //~ ERROR multiple applicable items in scope
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Trait {
- fn foo(&self) -> Self;
-}
-
-fn call_foo(x: Box<Trait>) {
- //~^ ERROR E0038
- let y = x.foo();
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- x: i32,
-}
-
-impl Drop for Foo {
- fn drop(&mut self) {
- println!("kaboom");
- }
-}
-
-fn main() {
- let mut x = Foo { x: -7 };
- x.drop();
- //~^ ERROR E0040
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-extern { fn some_func<T>(x: T); } //~ ERROR E0044
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn foo<T: Default>(x: T) -> Self;
-}
-
-struct Bar;
-
-impl Foo for Bar {
- fn foo(x: bool) -> Self { Bar } //~ ERROR E0049
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn foo(&self, x: u8) -> bool;
- fn bar(&self, x: u8, y: u8, z: u8);
- fn less(&self);
-}
-
-struct Bar;
-
-impl Foo for Bar {
- fn foo(&self) -> bool { true } //~ ERROR E0050
- fn bar(&self) { } //~ ERROR E0050
- fn less(&self, x: u8, y: u8, z: u8) { } //~ ERROR E0050
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = 5;
- let x_is_nonzero = x as bool; //~ ERROR E0054
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![recursion_limit="2"]
-struct Foo;
-
-impl Foo {
- fn foo(&self) {}
-}
-
-fn main() {
- let foo = Foo;
- let ref_foo = &&Foo;
- ref_foo.foo();
- //~^ ERROR E0055
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let f = |x| x * 3;
- let a = f(); //~ ERROR E0057
- let b = f(4);
- let c = f(2, 3); //~ ERROR E0057
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(unboxed_closures)]
-
-fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) } //~ ERROR E0059
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-extern "C" {
- fn printf(_: *const u8, ...) -> u32;
-}
-
-fn main() {
- unsafe { printf(); }
- //~^ ERROR E0060
- //~| expected at least 1 parameter
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn f(a: u16, b: &str) {}
-
-fn f2(a: u16) {}
-
-fn main() {
- f(0);
- //~^ ERROR E0061
- //~| expected 2 parameters
-
- f2();
- //~^ ERROR E0061
- //~| expected 1 parameter
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- x: i32
-}
-
-fn main() {
- let x = Foo {
- x: 0,
- x: 0,
- //~^ ERROR E0062
- };
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// ignore-tidy-linelength
-
-struct SingleFoo {
- x: i32
-}
-
-struct PluralFoo {
- x: i32,
- y: i32,
- z: i32
-}
-
-struct TruncatedFoo {
- a: i32,
- b: i32,
- x: i32,
- y: i32,
- z: i32
-}
-
-struct TruncatedPluralFoo {
- a: i32,
- b: i32,
- c: i32,
- x: i32,
- y: i32,
- z: i32
-}
-
-
-fn main() {
- let w = SingleFoo { };
- //~^ ERROR missing field `x` in initializer of `SingleFoo`
- let x = PluralFoo {x: 1};
- //~^ ERROR missing fields `y`, `z` in initializer of `PluralFoo`
- let y = TruncatedFoo{x:1};
- //~^ missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo`
- let z = TruncatedPluralFoo{x:1};
- //~^ ERROR missing fields `a`, `b`, `c` and 2 other fields in initializer of `TruncatedPluralFoo`
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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::collections::LinkedList;
-
-fn main() {
- LinkedList::new() += 1; //~ ERROR E0368
- //~^ ERROR E0067
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo() -> u8 {
- return;
- //~^ ERROR `return;` in a function whose return type is not `()`
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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 SOME_CONST : i32 = 12;
-
-fn some_other_func() {}
-
-fn some_function() {
- SOME_CONST = 14; //~ ERROR E0070
- 1 = 3; //~ ERROR E0070
- some_other_func() = 4; //~ ERROR E0070
- //~^ ERROR E0308
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum Foo {}
-type FooAlias = Foo;
-
-fn main() {
- let u = FooAlias { value: 0 };
- //~^ ERROR expected struct, variant or union type, found enum `Foo` [E0071]
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-
-#[repr(simd)]
-struct Bad; //~ ERROR E0075
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-
-#[repr(simd)]
-struct Bad(u16, u32, u32);
-//~^ ERROR E0076
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-
-#[repr(simd)]
-struct Bad(String); //~ ERROR E0077
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum Enum {
- X = (1 << 500), //~ ERROR E0080
- //~| WARNING shift left with overflow
- Y = (1 / 0) //~ ERROR E0080
- //~| WARNING divide by zero
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum Enum {
- P = 3,
- X = 3,
- //~^ ERROR discriminant value `3isize` already exists
- Y = 5
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[repr(i32)] //~ ERROR: E0084
-enum Foo {}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo() {}
-fn bar<T>() {}
-
-fn main() {
- foo::<f64>(); //~ ERROR expected at most 0 type parameters, found 1 type parameter [E0087]
-
- bar::<f64, u64>(); //~ ERROR expected at most 1 type parameter, found 2 type parameters [E0087]
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn f() {}
-fn g<'a>() -> &'a u8 { loop {} }
-
-fn main() {
- f::<'static>(); //~ ERROR E0088
- g::<'static, 'static>(); //~ ERROR E0088
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo<T, U>() {}
-
-fn main() {
- foo::<f64>(); //~ ERROR expected 2 type parameters, found 1 type parameter [E0089]
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo<'a: 'b, 'b: 'a>() {}
-
-fn main() {
- foo::<'static>(); //~ ERROR expected 2 lifetime parameters, found 1 lifetime parameter [E0090]
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-type Foo<T> = u32; //~ ERROR E0091
-type Foo2<A, B> = Box<A>; //~ ERROR E0091
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(intrinsics)]
-extern "rust-intrinsic" {
- fn atomic_foo(); //~ ERROR E0092
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(intrinsics)]
-extern "rust-intrinsic" {
- fn foo();
- //~^ ERROR E0093
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(intrinsics)]
-extern "rust-intrinsic" {
- fn size_of<T, U>() -> usize; //~ ERROR E0094
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- x: &bool,
- //~^ ERROR E0106
-}
-enum Bar {
- A(u8),
- B(&bool),
- //~^ ERROR E0106
-}
-type MyStr = &str;
- //~^ ERROR E0106
-
-struct Baz<'a>(&'a str);
-struct Buzz<'a, 'b>(&'a str, &'b str);
-
-struct Quux {
- baz: Baz,
- //~^ ERROR E0106
- //~| expected lifetime parameter
- buzz: Buzz,
- //~^ ERROR E0106
- //~| expected 2 lifetime parameters
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo<'a>(&'a str);
-struct Buzz<'a, 'b>(&'a str, &'b str);
-
-enum Bar {
- A,
- B,
- C,
-}
-
-struct Baz<'a, 'b, 'c> {
- buzz: Buzz<'a>,
- //~^ ERROR E0107
- //~| expected 2 lifetime parameters
- bar: Bar<'a>,
- //~^ ERROR E0107
- //~| unexpected lifetime parameter
- foo2: Foo<'a, 'b, 'c>,
- //~^ ERROR E0107
- //~| 2 unexpected lifetime parameters
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-type X = u32<i32>; //~ ERROR E0109
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-type X = u32<'static>; //~ ERROR E0110
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-impl Vec<u8> {}
-//~^ ERROR E0116
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-impl Drop for u32 {} //~ ERROR E0117
-//~| ERROR the Drop trait may only be implemented on structures
-//~| implementing Drop requires a struct
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-impl (u8, u8) { //~ ERROR E0118
- fn get_state(&self) -> String {
- String::new()
- }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait MyTrait {
- fn get(&self) -> usize;
-}
-
-impl<T> MyTrait for T {
- fn get(&self) -> usize { 0 }
-}
-
-struct Foo {
- value: usize
-}
-
-impl MyTrait for Foo { //~ ERROR E0119
- fn get(&self) -> usize { self.value }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait MyTrait { fn foo() {} }
-
-impl Drop for MyTrait {
- //~^ ERROR E0120
- fn drop(&mut self) {}
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo() -> _ { 5 } //~ ERROR E0121
-
-static BAR: _ = "test"; //~ ERROR E0121
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- field1: i32,
- field1: i32,
- //~^ ERROR field `field1` is already declared [E0124]
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo<T=U, U=()> { //~ ERROR E0128
- field1: T,
- field2: U,
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-extern {
- fn foo((a, b): (u32, u32));
- //~^ ERROR E0130
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main<T>() {
- //~^ ERROR E0131
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(start)]
-
-#[start]
-fn f< T >() {} //~ ERROR E0132
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-unsafe fn f() { return; }
-
-fn main() {
- f();
- //~^ ERROR E0133
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(main)]
-
-#[main]
-fn foo() {}
-
-#[main]
-fn f() {}
-//~^ ERROR E0137
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(start)]
-
-#[start]
-fn foo(argc: isize, argv: *const *const u8) -> isize { 0 }
-
-#[start]
-fn f(argc: isize, argv: *const *const u8) -> isize { 0 }
-//~^ ERROR E0138
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(lang_items)]
-
-#[lang = "panic_fmt"]
-struct Foo; //~ ERROR E0152
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(box_syntax)]
-
-fn main() {
- let _x: Box<str> = box *"hello"; //~ ERROR E0161
- //~^ ERROR E0507
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Irrefutable(i32);
-
-fn main() {
- let irr = Irrefutable(0);
- if let Irrefutable(x) = irr { //~ ERROR E0162
- println!("{}", x);
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-
-enum Foo {}
-
-impl Foo {
- const B: u8 = 0;
-}
-
-fn bar(foo: Foo) -> u32 {
- match foo {
- Foo::B(i) => i, //~ ERROR E0164
- }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Irrefutable(i32);
-
-fn main() {
- let irr = Irrefutable(0);
- while let Irrefutable(x) = irr { //~ ERROR E0165
- //~| irrefutable pattern
- // ...
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[derive(Copy)] //~ ERROR E0184
-struct Foo;
-
-impl Drop for Foo {
- fn drop(&mut self) {
- }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn foo();
- //~^ NOTE trait method declared without `&self`
-}
-
-struct Bar;
-
-impl Foo for Bar {
- fn foo(&self) {}
- //~^ ERROR E0185
- //~| NOTE `&self` used in impl
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn foo(&self); //~ `&self` used in trait
-}
-
-struct Bar;
-
-impl Foo for Bar {
- fn foo() {} //~ ERROR E0186
- //~^ expected `&self` in impl
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Trait {
- type Bar;
-}
-
-type Foo = Trait; //~ ERROR E0191
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(optin_builtin_traits)]
-
-trait Trait {
- type Bar;
-}
-
-struct Foo;
-
-impl !Trait for Foo { } //~ ERROR E0192
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo<T> {
- fn do_something(&self) -> T;
- fn do_something_else<T: Clone>(&self, bar: T);
- //~^ ERROR E0194
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Trait {
- fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
- //~^ NOTE lifetimes in impl do not match this method in trait
-}
-
-struct Foo;
-
-impl Trait for Foo {
- fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195
- //~^ NOTE lifetimes do not match method in trait
- }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo;
-
-unsafe impl Foo { } //~ ERROR E0197
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(optin_builtin_traits)]
-
-struct Foo;
-
-unsafe impl !Send for Foo { } //~ ERROR E0198
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(optin_builtin_traits)]
-
-struct Foo;
-
-trait Bar { }
-unsafe impl Bar for Foo { } //~ ERROR implementing the trait `Bar` is not unsafe [E0199]
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo;
-
-unsafe trait Bar { }
-
-impl Bar for Foo { } //~ ERROR E0200
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo(u8);
-
-impl Foo {
- fn bar(&self) -> bool { self.0 > 5 }
- fn bar() {} //~ ERROR E0201
-}
-
-trait Baz {
- type Quux;
- fn baz(&self) -> bool;
-}
-
-impl Baz for Foo {
- type Quux = u32;
-
- fn baz(&self) -> bool { true }
- fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201
- type Quux = u32; //~ ERROR E0201
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-type Foo = i32;
-
-impl Copy for Foo { }
-//~^ ERROR the trait `Copy` may not be implemented for this type
-//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
-
-#[derive(Copy, Clone)]
-struct Bar;
-
-impl Copy for &'static Bar { }
-//~^ ERROR the trait `Copy` may not be implemented for this type
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo;
-
-impl<T: Default> Foo { //~ ERROR E0207
- fn get(&self) -> T {
- <T as Default>::default()
- }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let v: Vec(&str) = vec!["foo"];
- //~^ ERROR E0214
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Trait {
- type Bar;
-}
-
-type Foo = Trait<F=i32>; //~ ERROR E0220
- //~| ERROR E0191
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait T1 {}
-trait T2 {}
-
-trait Foo {
- type A: T1;
-}
-
-trait Bar : Foo {
- type A: T2;
- fn do_something() {
- let _: Self::A;
- //~^ ERROR E0221
- }
-}
-
-trait T3 {}
-
-trait My : std::str::FromStr {
- type Err: T3;
- fn test() {
- let _: Self::Err;
- //~^ ERROR E0221
- }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait MyTrait { type X; }
-
-fn main() {
- let foo: MyTrait::X;
- //~^ ERROR ambiguous associated type
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let _: Box<std::io::Read + std::io::Write>;
- //~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-pub trait Foo {
- type A;
- fn boo(&self) -> <Self as Foo>::A;
-}
-
-struct Bar;
-
-impl Foo for isize {
- type A = usize;
- fn boo(&self) -> usize { 42 }
-}
-
-fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
-//~^ ERROR associated type bindings are not allowed here [E0229]
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(on_unimplemented)]
-
-#[rustc_on_unimplemented]
-//~^ ERROR E0232
-trait Bar {}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo<T> { x: T }
-struct Bar { x: Foo }
- //~^ ERROR wrong number of type arguments: expected 1, found 0 [E0243]
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo { x: bool }
-struct Bar<S, T> { x: Foo<S, T> }
- //~^ ERROR wrong number of type arguments: expected 0, found 2 [E0244]
-
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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 foo::baz;
-use bar::baz; //~ ERROR E0252
-
-mod foo {
- pub struct baz;
-}
-
-mod bar {
- pub mod baz {}
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod foo {
- pub trait MyTrait {
- fn do_something();
- }
-}
-
-use foo::MyTrait::do_something;
- //~^ ERROR E0253
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(alloc)]
-#![allow(unused_extern_crates)]
-
-extern crate alloc;
-
-mod foo {
- pub trait alloc {
- fn do_something();
- }
-}
-
-use foo::alloc;
-//~^ ERROR E0254
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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 bar::foo;
-
-fn foo() {} //~ ERROR E0255
-
-mod bar {
- pub fn foo() {}
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(alloc, libc)]
-#![allow(unused_extern_crates)]
-
-extern crate alloc;
-
-extern crate libc as alloc;
-//~^ ERROR E0259
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(alloc)]
-#![allow(unused_extern_crates)]
-
-extern crate alloc;
-
-mod alloc {
-//~^ ERROR the name `alloc` is defined multiple times [E0260]
- pub trait MyTrait {
- fn do_something();
- }
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo(x: &'a str) { } //~ ERROR E0261
- //~| undeclared lifetime
-
-struct Foo {
- x: &'a str, //~ ERROR E0261
- //~| undeclared lifetime
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo<'static>(x: &'static str) { } //~ ERROR E0262
- //~| 'static is a reserved lifetime name
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) {
- //~^ ERROR E0263
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(lang_items)]
-
-extern "C" {
- #[lang = "cake"]
- fn cake(); //~ ERROR E0264
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let w = || { break; }; //~ ERROR E0267
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- break; //~ ERROR E0268
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Trait { type AssociatedType; }
-
-fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
- println!("in foo");
-}
-
-impl Trait for i8 { type AssociatedType = &'static str; }
-
-fn main() {
- foo(3_i8); //~ ERROR E0271
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {}
-
-struct Bar<T>(T);
-
-impl<T> Foo for T where Bar<T>: Foo {} //~ ERROR E0275
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn foo<T>(x: T);
-}
-
-impl Foo for bool {
- fn foo<T>(x: T) where T: Copy {} //~ ERROR E0276
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- bar: Bar
-}
-
-struct Bar {
- baz: Baz
-}
-
-struct Baz {
- x: *const u8
-}
-
-fn is_send<T: Send>() { }
-
-fn main() {
- is_send::<Foo>();
- //~^ ERROR the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo`
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// ignore-cloudabi no std::path
-
-use std::path::Path;
-
-trait Foo {
- fn bar(&self);
-}
-
-fn some_func<T: Foo>(foo: T) {
- foo.bar();
-}
-
-fn f(p: Path) { }
-//~^ ERROR the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path`
-
-fn main() {
- some_func(5i32);
- //~^ ERROR the trait bound `i32: Foo` is not satisfied
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = "hello".chars().rev().collect(); //~ ERROR E0282
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Generator {
- fn create() -> u32;
-}
-
-struct Impl;
-
-impl Generator for Impl {
- fn create() -> u32 { 1 }
-}
-
-struct AnotherImpl;
-
-impl Generator for AnotherImpl {
- fn create() -> u32 { 2 }
-}
-
-fn main() {
- let cont: u32 = Generator::create(); //~ ERROR E0283
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![recursion_limit] //~ ERROR E0296
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let xs : Vec<Option<i32>> = vec![Some(1), None];
-
- for Some(x) in xs {}
- //~^ ERROR E0005
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- match Some(()) {
- None => { },
- option if option.take().is_none() => {}, //~ ERROR E0301
- Some(_) => { }
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- match Some(()) {
- None => { },
- option if { option = None; false } => { }, //~ ERROR E0302
- Some(_) => { }
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- match Some("hi".to_string()) {
- ref op_string_ref @ Some(s) => {},
- //~^ ERROR pattern bindings are not allowed after an `@` [E0303]
- //~| ERROR E0009
- None => {},
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = 1u8;
- match x {
- 0u8...3i8 => (), //~ ERROR E0308
- _ => ()
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(intrinsics)]
-
-extern "rust-intrinsic" {
- fn size_of<T>(); //~ ERROR E0308
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod foo {
- pub const X: u32 = 1;
-}
-
-pub use foo as foo2;
-//~^ ERROR `foo` is private, and cannot be re-exported [E0365]
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![allow(dead_code)]
-
-#[deny(overflowing_literals)]
-#[repr(i64)]
-enum Foo {
- X = 0x7fffffffffffffff,
- Y, //~ ERROR E0370
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(coerce_unsized)]
-use std::ops::CoerceUnsized;
-
-struct Foo<T: ?Sized> {
- a: i32,
-}
-
-impl<T, U> CoerceUnsized<Foo<U>> for Foo<T> //~ ERROR E0374
- where T: CoerceUnsized<U> {}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// ignore-tidy-linelength
-
-#![feature(coerce_unsized)]
-use std::ops::CoerceUnsized;
-
-struct Foo<T: ?Sized, U: ?Sized> {
- a: i32,
- b: T,
- c: U,
-}
-
-impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
-//~^ ERROR E0375
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(coerce_unsized)]
-use std::ops::CoerceUnsized;
-
-struct Foo<T: ?Sized> {
- a: T,
-}
-
-impl<T, U> CoerceUnsized<U> for Foo<T> {} //~ ERROR E0376
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-static X: i32 = 1;
-const C: i32 = 2;
-
-const CR: &'static mut i32 = &mut C; //~ ERROR E0017
-static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
- //~| ERROR cannot borrow
-static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct FancyNum {
- num: u8,
-}
-
-fn main() {
- let mut fancy = FancyNum{ num: 5 };
- let fancy_ref = &(&mut fancy);
- fancy_ref.num = 6; //~ ERROR E0389
- println!("{}", fancy_ref.num);
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- x: i32
-}
-
-impl *mut Foo {} //~ ERROR E0390
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum Foo<T> { Bar } //~ ERROR E0392
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait A<T=Self> {}
-
-fn together_we_will_rule_the_galaxy(son: &A) {}
-//~^ ERROR E0393
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![allow(warnings)]
-
-static A: u32 = 0;
-static B: u32 = A;
-//~^ ERROR E0394
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-static FOO: i32 = 42;
-static BAR: i32 = 42;
-
-static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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 REG_ADDR: *const u8 = 0x5f3759df as *const u8;
-
-const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo<T>(x: T) {
- fn bar(y: T) { //~ ERROR E0401
- }
- bar(x);
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo<T, T>(s: T, u: T) {} //~ ERROR E0403
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo;
-struct Bar;
-
-impl Foo for Bar {} //~ ERROR E0404
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo;
-
-impl SomeTrait for Foo {} //~ ERROR E0405
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn a();
-}
-
-struct Bar;
-
-impl Foo for Bar {
- fn a() {}
- fn b() {}
- //~^ ERROR E0407
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = Some(0);
-
- match x {
- Some(y) | None => {} //~ ERROR variable `y` is not bound in all patterns
- _ => ()
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- <Self>::foo; //~ ERROR E0411
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-impl Something {} //~ ERROR E0412
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo(f: i32, f: i32) {} //~ ERROR E0415
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- match (1, 2) {
- (x, x) => {} //~ ERROR E0416
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main () {
- struct Foo { a: bool };
-
- let f = Foo(); //~ ERROR E0423
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo;
-
-impl Foo {
- fn bar(self) {}
-
- fn foo() {
- self.bar(); //~ ERROR E0424
- }
-}
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn bar() {
- elf; //~ ERROR E0425
- }
-}
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main () {
- loop {
- break 'a;
- //~^ ERROR E0426
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Bar; //~ previous definition of the type `Bar` here
-struct Bar; //~ ERROR E0428
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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::fmt::self; //~ ERROR E0429
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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::fmt::{self, self}; //~ ERROR E0430
- //~^ ERROR E0252
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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 {self}; //~ ERROR E0431
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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 something::Foo; //~ ERROR E0432
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main () {
- let map = HashMap::new(); //~ ERROR E0433
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn foo() {
- let y = 5;
- fn bar() -> u32 {
- y //~ ERROR E0434
- }
-}
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main () {
- let foo = 42u32;
- let _: [u8; foo]; //~ ERROR E0435
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {}
-
-impl Foo for i32 {
- type Bar = bool; //~ ERROR E0437
-}
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-
-trait Bar {}
-
-impl Bar for i32 {
- const BAR: bool = true; //~ ERROR E0438
-}
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(platform_intrinsics)]
-
-extern "platform-intrinsic" {
- fn simd_shuffle<A,B>(a: A, b: A, c: [u32; 8]) -> B; //~ ERROR E0439
-}
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-#![feature(platform_intrinsics)]
-
-#[repr(simd)]
-struct f64x2(f64, f64);
-
-extern "platform-intrinsic" {
- fn x86_mm_movemask_pd<T>(x: f64x2) -> i32; //~ ERROR E0440
-}
-
-fn main () {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-#![feature(platform_intrinsics)]
-
-#[repr(simd)]
-struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
-
-extern "platform-intrinsic" {
- fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-#![feature(platform_intrinsics)]
-
-#[repr(simd)]
-struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
- i8, i8, i8, i8, i8, i8, i8, i8);
-#[repr(simd)]
-struct i32x4(i32, i32, i32, i32);
-#[repr(simd)]
-struct i64x2(i64, i64);
-
-extern "platform-intrinsic" {
- fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
- //~^ ERROR E0442
- //~| ERROR E0442
- //~| ERROR E0442
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-#![feature(platform_intrinsics)]
-
-#[repr(simd)]
-struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
-#[repr(simd)]
-struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64);
-
-extern "platform-intrinsic" {
- fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(repr_simd)]
-#![feature(platform_intrinsics)]
-
-#[repr(simd)]
-struct f64x2(f64, f64);
-
-extern "platform-intrinsic" {
- fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Foo {
- fn dummy(&self) { }
-}
-
-pub trait Bar : Foo {}
-//~^ ERROR private trait `Foo` in public interface [E0445]
-//~| NOTE can't leak private trait
-pub struct Bar2<T: Foo>(pub T);
-//~^ ERROR private trait `Foo` in public interface [E0445]
-//~| NOTE can't leak private trait
-pub fn foo<T: Foo> (t: T) {}
-//~^ ERROR private trait `Foo` in public interface [E0445]
-//~| NOTE can't leak private trait
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod Foo {
- struct Bar(u32);
-
- pub fn bar() -> Bar { //~ ERROR E0446
- Bar(0)
- }
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Bar;
-
-trait Foo {
- fn foo();
-}
-
-pub impl Bar {} //~ ERROR E0449
-
-pub impl Foo for Bar { //~ ERROR E0449
- pub fn foo() {} //~ ERROR E0449
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod Bar {
- pub struct Foo {
- pub a: isize,
- b: isize,
- }
-
- pub struct FooTuple (
- pub isize,
- isize,
- );
-}
-
-fn pat_match(foo: Bar::Foo) {
- let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451
-}
-
-fn main() {
- let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![allow(foo = "")] //~ ERROR E0452
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![forbid(non_snake_case)]
-
-#[allow(non_snake_case)]
-//~^ ERROR allow(non_snake_case) overruled by outer forbid(non_snake_case)
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[link(name = "")] extern {}
-//~^ ERROR E0454
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458
- //~| ERROR E0459
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[link(kind = "dylib")] extern {} //~ ERROR E0459
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(plugin)]
-#![plugin(cookie_monster)]
-//~^ ERROR E0463
-extern crate cake_is_a_lie;
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-trait Wedding<'t>: 't { }
-
-struct Prince<'kiss, 'SnowWhite> {
- child: Box<Wedding<'kiss> + 'SnowWhite>, //~ ERROR E0478
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
-
-const A: AtomicUsize = ATOMIC_USIZE_INIT;
-static B: &'static AtomicUsize = &A; //~ ERROR E0492
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- a: u32
-}
-
-static S : Foo = Foo { a : 0 };
-static A : &'static u32 = &S.a; //~ ERROR E0494
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo<'a> {
- a: &'a i32,
-}
-
-impl<'a> Foo<'a> {
- fn f<'a>(x: &'a i32) { //~ ERROR E0496
- }
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let mut i = 0;
- let mut x = &mut i;
- let mut a = &mut i; //~ ERROR E0499
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn bar(x: &mut i32) {}
-fn foo(a: &mut i32) {
- let ref y = a;
- bar(a); //~ ERROR E0502
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let mut value = 3;
- let _borrow = &mut value;
- let _sum = value + 1; //~ ERROR E0503
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct FancyNum {
- num: u8,
-}
-
-fn main() {
- let fancy_num = FancyNum { num: 5 };
- let fancy_ref = &fancy_num;
-
- let x = move || {
- println!("child function: {}", fancy_num.num); //~ ERROR E0504
- };
-
- x();
- println!("main function: {}", fancy_ref.num);
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Value {}
-
-fn eat(val: Value) {}
-
-fn main() {
- let x = Value{};
- {
- let _ref_to_val: &Value = &x;
- eat(x); //~ ERROR E0505
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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::cell::RefCell;
-
-struct TheDarkKnight;
-
-impl TheDarkKnight {
- fn nothing_is_true(self) {}
-}
-
-fn main() {
- let x = RefCell::new(TheDarkKnight);
-
- x.borrow().nothing_is_true(); //~ ERROR E0507
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct FancyNum {
- num: usize
-}
-
-struct DropStruct {
- fancy: FancyNum
-}
-
-impl Drop for DropStruct {
- fn drop(&mut self) {
- }
-}
-
-fn main() {
- let drop_struct = DropStruct{fancy: FancyNum{num: 5}};
- let fancy_field = drop_struct.fancy; //~ ERROR E0509
- println!("Fancy: {}", fancy_field.num);
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(platform_intrinsics)]
-
-extern "platform-intrinsic" {
- fn simd_add<T>(a: T, b: T) -> T;
-}
-
-fn main() {
- unsafe { simd_add(0, 1); } //~ ERROR E0511
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn takes_u8(_: u8) {}
-
-fn main() {
- unsafe { takes_u8(::std::mem::transmute(0u16)); } //~ ERROR E0512
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x: typeof(92) = 92; //~ ERROR E0516
- //~| reserved keyword
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[repr(C)] //~ ERROR: E0517
-type Foo = u8;
-
-#[repr(packed)] //~ ERROR: E0517
-enum Foo2 {Bar, Baz}
-
-#[repr(u8)] //~ ERROR: E0517
-struct Foo3 {bar: bool, baz: bool}
-
-#[repr(C)] //~ ERROR: E0517
-impl Foo3 {
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[inline(always)] //~ ERROR: E0518
-struct Foo;
-
-#[inline(never)] //~ ERROR: E0518
-impl Foo {
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(specialization)]
-
-trait SpaceLlama {
- fn fly(&self);
-}
-
-impl<T> SpaceLlama for T {
- default fn fly(&self) {}
-}
-
-impl<T: Clone> SpaceLlama for T {
- fn fly(&self) {}
-}
-
-impl SpaceLlama for i32 {
- default fn fly(&self) {}
- //~^ ERROR E0520
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(lang_items)]
-
-#[lang = "cookie"]
-fn cookie() -> ! {
-//~^^ ERROR definition of an unknown language item: `cookie` [E0522]
- loop {}
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(slice_patterns)]
-
-fn main() {
- let r = &[1, 2, 3, 4];
- match r {
- &[a, b] => {
- //~^ ERROR E0527
- println!("a={}, b={}", a, b);
- }
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(slice_patterns)]
-
-fn main() {
- let r = &[1, 2];
- match r {
- &[a, b, c, rest..] => {
- //~^ ERROR E0528
- }
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(slice_patterns)]
-
-fn main() {
- let r: f32 = 1.0;
- match r {
- [a, b] => {
- //~^ ERROR E0529
- }
- }
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- static TEST: i32 = 0;
-
- let r: (i32, i32) = (0, 0);
- match r {
- TEST => {} //~ ERROR E0530
- }
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let value = 1;
-
- match SomeStruct(value) {
- StructConst1(_) => { },
- //~^ ERROR expected tuple struct/variant, found constant `StructConst1`
- _ => { },
- }
-
- struct SomeStruct(u8);
-
- const StructConst1 : SomeStruct = SomeStruct(1);
- const StructConst2 : SomeStruct = SomeStruct(2);
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[inline()] //~ ERROR E0534
-pub fn something() {}
-
-fn main() {
- something();
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[export_name]
-//~^ ERROR E0558
-
-pub fn something() {}
-
-fn main() {}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum Field {
- Fool { x: u32 },
-}
-
-fn main() {
- let s = Field::Fool { joke: 0 };
- //~^ ERROR E0559
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Simba {
- mother: u32,
-}
-
-fn main() {
- let s = Simba { mother: 1, father: 0 };
- //~^ ERROR E0560
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(attr_literals)]
-
-// deprecated doesn't currently support literals
-#[deprecated("since")] //~ ERROR E0565
-fn f() { }
-
-fn main() { }
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![feature(attr_literals)]
-
-// repr currently doesn't support literals
-#[repr("C")] //~ ERROR E0565
-struct A { }
-
-fn main() { }
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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 FOO: u32 = return 0; //~ ERROR E0572
-
-fn main() {}
+++ /dev/null
-// Copyright 2014 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.
-
-// This test was derived from the wasm and parsell crates. They
-// stopped compiling when #32330 is fixed.
-
-#![allow(dead_code, unused_variables)]
-
-use std::str::Chars;
-
-pub trait HasOutput<Ch, Str> {
- type Output;
-}
-
-#[derive(Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Debug)]
-pub enum Token<'a> {
- Begin(&'a str)
-}
-
-fn mk_unexpected_char_err<'a>() -> Option<&'a i32> {
- unimplemented!()
-}
-
-fn foo<'a>(data: &mut Chars<'a>) {
- bar(mk_unexpected_char_err)
-}
-
-fn bar<F>(t: F)
- // No type can satisfy this requirement, since `'a` does not
- // appear in any of the input types:
- where F: for<'a> Fn() -> Option<&'a i32>
- //~^ ERROR E0582
-{
-}
-
-fn baz<F>(t: F)
- // No type can satisfy this requirement, since `'a` does not
- // appear in any of the input types:
- where F: for<'a> Iterator<Item=&'a i32>
- //~^ ERROR E0582
-{
-}
-
-fn main() {
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- /// Hello! I'm useless...
- //~^ ERROR E0585
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
- let x = &tmp[1..=]; //~ ERROR E0586
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo<'a> {
- x: Option<&'a u32>,
-}
-
-fn main() {
- let mut x = Foo { x: None };
- let y = 0;
- x.x = Some(&y);
- //~^ `y` does not live long enough [E0597]
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo;
-
-fn main() {
- || if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- !"a"; //~ ERROR E0600
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// compile-flags:-D bogus
-
-// error-pattern:E0602
-// error-pattern:requested on the command line with `-D bogus`
-
-fn main() {}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod SomeModule {
- const PRIVATE: u32 = 0x_a_bad_1dea_u32;
-}
-
-fn main() {
- SomeModule::PRIVATE; //~ ERROR E0603
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- 1u32 as char; //~ ERROR E0604
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = 0u8;
- x as Vec<u8>; //~ ERROR E0605
-
- let v = 0 as *const u8;
- v as &u8; //~ ERROR E0605
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- &0u8 as u8; //~ ERROR E0606
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let v = 0 as *const u8;
- v as *const [u8]; //~ ERROR E0607
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- 0u8[2]; //~ ERROR E0608
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- x: u32,
-}
-struct Bar;
-
-fn main() {
- let x = Foo { x: 0 };
- let _ = x.foo; //~ ERROR E0609
-
- let y = Bar;
- y.1; //~ ERROR E0609
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x = 0;
- let _ = x.foo; //~ ERROR E0610
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod a {
- pub struct Foo(u32);
-
- impl Foo {
- pub fn new() -> Foo { Foo(0) }
- }
-}
-
-fn main() {
- let y = a::Foo::new();
- y.0; //~ ERROR E0611
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo(u32);
-
-fn main() {
- let y = Foo(0);
- y.1; //~ ERROR E0612
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let y = 0u32;
- *y; //~ ERROR E0614
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-struct Foo {
- x: u32,
-}
-
-impl Foo {
- fn method(&self) {}
-}
-
-fn main() {
- let f = Foo { x: 0 };
- f.method; //~ ERROR E0615
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod a {
- pub struct Foo {
- x: u32,
- }
-
- impl Foo {
- pub fn new() -> Foo { Foo { x: 0 } }
- }
-}
-
-fn main() {
- let f = a::Foo::new();
- f.x; //~ ERROR E0616
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// ignore-tidy-linelength
-
-extern {
- fn printf(c: *const i8, ...);
-}
-
-fn main() {
- unsafe {
- printf(::std::ptr::null(), 0f32);
- //~^ ERROR can't pass `f32` to variadic function
- //~| HELP cast the value to `c_double`
- printf(::std::ptr::null(), 0i8);
- //~^ ERROR can't pass `i8` to variadic function
- //~| HELP cast the value to `c_int`
- printf(::std::ptr::null(), 0i16);
- //~^ ERROR can't pass `i16` to variadic function
- //~| HELP cast the value to `c_int`
- printf(::std::ptr::null(), 0u8);
- //~^ ERROR can't pass `u8` to variadic function
- //~| HELP cast the value to `c_uint`
- printf(::std::ptr::null(), 0u16);
- //~^ ERROR can't pass `u16` to variadic function
- //~| HELP cast the value to `c_uint`
- printf(::std::ptr::null(), printf);
- //~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
- //~| HELP cast the value to `unsafe extern "C" fn(*const i8, ...)`
- }
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-enum X {
- Entry,
-}
-
-fn main() {
- X::Entry();
- //~^ ERROR expected function, found enum variant `X::Entry` [E0618]
- let x = 0i32;
- x();
- //~^ ERROR expected function, found `i32` [E0618]
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let x;
-
- match x {
- (..) => {} //~ ERROR E0619
- _ => {}
- }
-}
-
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn main() {
- let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620
-}
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// Test that we give the generic E0495 when one of the free regions is
-// bound in a closure (rather than suggesting a change to the signature
-// of the closure, which is not specified in `foo` but rather in `invoke`).
-
-// FIXME - This might be better as a UI test, but the finer details
-// of the error seem to vary on different machines.
-fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32
-where F: FnOnce(&'a i32, &i32) -> &'a i32
-{
- let y = 22;
- f(x, &y)
-}
-
-fn foo<'a>(x: &'a i32) {
- invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2015 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.
-
-#![feature(intrinsics)]
-extern "rust-intrinsic" {
- pub static breakpoint : unsafe extern "rust-intrinsic" fn();
- //~^ ERROR intrinsic must be a function [E0622]
-}
-fn main() { unsafe { breakpoint(); } }
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-mod inner {
- pub struct Foo;
-
- impl Foo {
- fn method(&self) {}
- }
-}
-
-fn main() {
- let foo = inner::Foo;
- foo.method(); //~ ERROR method `method` is private [E0624]
-}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-#![feature(underscore_lifetimes)]
-
-struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_`
-fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_`
-
-struct Bar<'a>(&'a u8);
-impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_`
- fn bar() {}
-}
-
-fn main() {}
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-#![allow(warnings)]
-#![feature(conservative_impl_trait, nested_impl_trait)]
-
-trait Id<T> {}
-trait Lt<'a> {}
-
-impl<'a> Lt<'a> for () {}
-impl<T> Id<T> for T {}
-
-fn free_fn_capture_hrtb_in_impl_trait()
- -> impl for<'a> Id<impl Lt<'a>>
- //~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level [E0657]
-{
- ()
-}
-
-struct Foo;
-impl Foo {
- fn impl_fn_capture_hrtb_in_impl_trait()
- -> impl for<'a> Id<impl Lt<'a>>
- //~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level
- {
- ()
- }
-}
-
-fn main() {}
+++ /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.
-
-fn main() {
- let _ = ::std::u128::MAX; //~ ERROR E0658
-}
+++ /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.
-
-mod moon {
- pub fn foo() {}
-}
-
-mod earth {
- pub fn foo() {}
-}
-
-mod collider {
- pub use moon::*;
- pub use earth::*;
-}
-
-fn main() {
- collider::foo(); //~ ERROR E0659
-}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(use_nested_groups)]
#![allow(unused_imports)]
mod foo {}
{
let mut e = Baz::X(2);
let _e0 = e.x();
- match e {
+ match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed
Baz::X(value) => value
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
{
let mut e = Box::new(Baz::X(3));
let _e0 = e.x();
- match *e {
+ match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed
Baz::X(value) => value
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
{
let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let _v = &mut v;
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[x, _, .., _, _] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[_, x, .., _, _] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[_, _, .., x, _] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[_, _, .., _, x] => println!("{}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
{
let mut v = &[1, 2, 3, 4, 5];
let _v = &mut v;
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[x..] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[_, x..] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[x.., _] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
_ => panic!("other case"),
}
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[_, x.., _] => println!("{:?}", x),
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
let mut e = E::A(3);
let _e = &mut e;
- match e {
+ match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed
E::A(ref ax) =>
//[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable
//[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable
struct S { x: F, y: (u32, u32), };
let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) };
let _s = &mut s;
- match s {
+ match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed
S { y: (ref y0, _), .. } =>
//[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable
//[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable
println!("y0: {:?}", y0),
_ => panic!("other case"),
}
- match s {
+ match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed
S { x: F { y: ref x0, .. }, .. } =>
//[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable
//[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable
struct F {x: u32, y: u32};
let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}];
let _v = &mut v;
- match v {
+ match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed
&[_, F {x: ref xf, ..}] => println!("{}", xf),
//[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable
// No errors in AST
fn match_enum() {
let mut foo = Foo::B;
let p = &mut foo;
- let _ = match foo {
+ let _ = match foo { //[mir]~ ERROR [E0503]
Foo::B => 1, //[mir]~ ERROR [E0503]
_ => 2,
Foo::A(x) => x //[ast]~ ERROR [E0503]
fn main() {
let mut x = 1;
let _x = &mut x;
- let _ = match x {
+ let _ = match x { //[mir]~ ERROR [E0503]
x => x + 1, //[ast]~ ERROR [E0503]
//[mir]~^ ERROR [E0503]
y => y + 2, //[ast]~ ERROR [E0503]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// revisions: lxl nll
-//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
-//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
+// ignore-tidy-linelength
+
+// revisions: lxl_beyond nll_beyond nll_target
+
+//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref
+//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll
+//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
// This is an important corner case pointed out by Niko: one is
// allowed to initiate a shared borrow during a reservation, but it
//
// FIXME: for clarity, diagnostics for these cases might be better off
// if they specifically said "cannot activate mutable borrow of `x`"
+//
+// The convention for the listed revisions: "lxl" means lexical
+// lifetimes (which can be easier to reason about). "nll" means
+// non-lexical lifetimes. "nll_target" means the initial conservative
+// two-phase borrows that only applies to autoref-introduced borrows.
+// "nll_beyond" means the generalization of two-phase borrows to all
+// `&mut`-borrows (doing so makes it easier to write code for specific
+// corner cases).
#![allow(dead_code)]
let mut x = 3;
let y = &mut x;
{ let z = &x; read(z); }
+ //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
*y += 1;
}
let mut x = 3;
let y = &mut x;
let z = &x;
+ //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
*y += 1;
- //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
- //[nll]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
+ //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
+ //[nll_beyond]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
+ //[nll_target]~^^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
read(z);
}
let mut x = 3;
let y = &mut x;
let z = &x;
+ //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
read(z);
*y += 1;
- //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
- // (okay with nll today)
+ //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
+ // (okay with (generalized) nll today)
}
fn should_also_eventually_be_ok_with_nll() {
let mut x = 3;
let y = &mut x;
let _z = &x;
+ //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
*y += 1;
- //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
+ //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
+ // (okay with (generalized) nll today)
}
fn main() { }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// revisions: lxl nll
-//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
-//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
+// ignore-tidy-linelength
+
+// revisions: lxl_beyond nll_beyond nll_target
+//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref
+//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref -Z nll
+//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
// This is the second counter-example from Niko's blog post
// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/
// It is "artificial". It is meant to illustrate directly that we
// should allow an aliasing access during reservation, but *not* while
// the mutable borrow is active.
+//
+// The convention for the listed revisions: "lxl" means lexical
+// lifetimes (which can be easier to reason about). "nll" means
+// non-lexical lifetimes. "nll_target" means the initial conservative
+// two-phase borrows that only applies to autoref-introduced borrows.
+// "nll_beyond" means the generalization of two-phase borrows to all
+// `&mut`-borrows (doing so makes it easier to write code for specific
+// corner cases).
fn main() {
/*0*/ let mut i = 0;
/*1*/ let p = &mut i; // (reservation of `i` starts here)
/*2*/ let j = i; // OK: `i` is only reserved here
+ //[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503]
/*3*/ *p += 1; // (mutable borrow of `i` starts here, since `p` is used)
- /*4*/ let k = i; //[lxl]~ ERROR cannot use `i` because it was mutably borrowed [E0503]
- //[nll]~^ ERROR cannot use `i` because it was mutably borrowed [E0503]
+ /*4*/ let k = i; //[lxl_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503]
+ //[nll_beyond]~^ ERROR cannot use `i` because it was mutably borrowed [E0503]
+ //[nll_target]~^^ ERROR cannot use `i` because it was mutably borrowed [E0503]
/*5*/ *p += 1;
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// revisions: lxl nll g2p
+//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
+//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
+//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll -Z two-phase-beyond-autoref
+
+// This is a test checking that when we limit two-phase borrows to
+// method receivers, we do not let other kinds of auto-ref to leak
+// through.
+//
+// The g2p revision illustrates the "undesirable" behavior you would
+// otherwise observe without limiting the phasing to autoref on method
+// receivers (namely, in many cases demonstrated below, the error
+// would not arise).
+
+// (If we revise the compiler or this test so that the g2p revision
+// passes, turn the `rustc_attrs` feature back on and tag the `fn
+// main` with `#[rustc_error]` so that this remains a valid
+// compile-fail test.)
+//
+// #![feature(rustc_attrs)]
+
+use std::ops::{Index, IndexMut};
+use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
+use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};
+
+// This is case outlined by Niko that we want to ensure we reject
+// (at least initially).
+
+fn foo(x: &mut u32, y: u32) {
+ *x += y;
+}
+
+fn deref_coercion(x: &mut u32) {
+ foo(x, *x);
+ //[lxl]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503]
+ //[nll]~^^ ERROR cannot use `*x` because it was mutably borrowed [E0503]
+}
+
+// While adding a flag to adjustments (indicating whether they
+// should support two-phase borrows, here are the cases I
+// encountered:
+//
+// - [x] Resolving overloaded_call_traits (call, call_mut, call_once)
+// - [x] deref_coercion (shown above)
+// - [x] coerce_unsized e.g. `&[T; n]`, `&mut [T; n] -> &[T]`,
+// `&mut [T; n] -> &mut [T]`, `&Concrete -> &Trait`
+// - [x] Method Call Receivers (the case we want to support!)
+// - [x] ExprIndex and ExprUnary Deref; only need to handle coerce_index_op
+// - [x] overloaded_binops
+
+fn overloaded_call_traits() {
+ // Regarding overloaded call traits, note that there is no
+ // scenario where adding two-phase borrows should "fix" these
+ // cases, because either we will resolve both invocations to
+ // `call_mut` (in which case the inner call requires a mutable
+ // borrow which will conflict with the outer reservation), or we
+ // will resolve both to `call` (which will just work, regardless
+ // of two-phase borrow support), or we will resolve both to
+ // `call_once` (in which case the inner call requires moving the
+ // receiver, invalidating the outer call).
+
+ fn twice_ten_sm<F: FnMut(i32) -> i32>(f: &mut F) {
+ f(f(10));
+ //[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time
+ //[lxl]~| ERROR cannot borrow `*f` as mutable more than once at a time
+ //[nll]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time
+ //[nll]~| ERROR cannot borrow `*f` as mutable more than once at a time
+ //[g2p]~^^^^^ ERROR cannot borrow `*f` as mutable more than once at a time
+ }
+ fn twice_ten_si<F: Fn(i32) -> i32>(f: &mut F) {
+ f(f(10));
+ }
+ fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
+ f(f(10));
+ //[lxl]~^ ERROR use of moved value: `*f`
+ //[nll]~^^ ERROR use of moved value: `*f`
+ //[g2p]~^^^ ERROR use of moved value: `*f`
+ }
+
+ fn twice_ten_om(f: &mut FnMut(i32) -> i32) {
+ f(f(10));
+ //[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time
+ //[lxl]~| ERROR cannot borrow `*f` as mutable more than once at a time
+ //[nll]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time
+ //[nll]~| ERROR cannot borrow `*f` as mutable more than once at a time
+ //[g2p]~^^^^^ ERROR cannot borrow `*f` as mutable more than once at a time
+ }
+ fn twice_ten_oi(f: &mut Fn(i32) -> i32) {
+ f(f(10));
+ }
+ fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) {
+ f(f(10));
+ //[lxl]~^ ERROR cannot move a value of type
+ //[lxl]~^^ ERROR cannot move a value of type
+ //[lxl]~^^^ ERROR use of moved value: `*f`
+ //[nll]~^^^^ ERROR cannot move a value of type
+ //[nll]~^^^^^ ERROR cannot move a value of type
+ //[nll]~^^^^^^ ERROR cannot move a value of type
+ //[nll]~^^^^^^^ ERROR cannot move a value of type
+ //[nll]~^^^^^^^^ ERROR use of moved value: `*f`
+ //[g2p]~^^^^^^^^^ ERROR cannot move a value of type
+ //[g2p]~^^^^^^^^^^ ERROR cannot move a value of type
+ //[g2p]~^^^^^^^^^^^ ERROR cannot move a value of type
+ //[g2p]~^^^^^^^^^^^^ ERROR cannot move a value of type
+ //[g2p]~^^^^^^^^^^^^^ ERROR use of moved value: `*f`
+ }
+
+ twice_ten_sm(&mut |x| x + 1);
+ twice_ten_si(&mut |x| x + 1);
+ twice_ten_so(Box::new(|x| x + 1));
+ twice_ten_om(&mut |x| x + 1);
+ twice_ten_oi(&mut |x| x + 1);
+ twice_ten_oo(Box::new(|x| x + 1));
+}
+
+trait TwoMethods {
+ fn m(&mut self, x: i32) -> i32 { x + 1 }
+ fn i(&self, x: i32) -> i32 { x + 1 }
+}
+
+struct T;
+
+impl TwoMethods for T { }
+
+struct S;
+
+impl S {
+ fn m(&mut self, x: i32) -> i32 { x + 1 }
+ fn i(&self, x: i32) -> i32 { x + 1 }
+}
+
+impl TwoMethods for [i32; 3] { }
+
+fn double_access<X: Copy>(m: &mut [X], s: &[X]) {
+ m[0] = s[1];
+}
+
+fn coerce_unsized() {
+ let mut a = [1, 2, 3];
+
+ // This is not okay.
+ double_access(&mut a, &a);
+ //[lxl]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
+ //[nll]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
+ //[g2p]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
+
+ // But this is okay.
+ a.m(a.i(10));
+}
+
+struct I(i32);
+
+impl Index<i32> for I {
+ type Output = i32;
+ fn index(&self, _: i32) -> &i32 {
+ &self.0
+ }
+}
+
+impl IndexMut<i32> for I {
+ fn index_mut(&mut self, _: i32) -> &mut i32 {
+ &mut self.0
+ }
+}
+
+fn coerce_index_op() {
+ let mut i = I(10);
+ i[i[3]] = 4;
+ //[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
+ //[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
+
+ i[3] = i[4];
+
+ i[i[3]] = i[4];
+ //[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
+ //[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
+}
+
+struct A(i32);
+
+macro_rules! trivial_binop {
+ ($Trait:ident, $m:ident) => {
+ impl $Trait<i32> for A { fn $m(&mut self, rhs: i32) { self.0 = rhs; } }
+ }
+}
+
+trivial_binop!(AddAssign, add_assign);
+trivial_binop!(SubAssign, sub_assign);
+trivial_binop!(MulAssign, mul_assign);
+trivial_binop!(DivAssign, div_assign);
+trivial_binop!(RemAssign, rem_assign);
+trivial_binop!(BitAndAssign, bitand_assign);
+trivial_binop!(BitOrAssign, bitor_assign);
+trivial_binop!(BitXorAssign, bitxor_assign);
+trivial_binop!(ShlAssign, shl_assign);
+trivial_binop!(ShrAssign, shr_assign);
+
+fn overloaded_binops() {
+ let mut a = A(10);
+ a += a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a -= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a *= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a /= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a &= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a |= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a ^= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a <<= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+ a >>= a.0;
+ //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed
+ //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed
+}
+
+fn main() {
+
+ // As a reminder, this is the basic case we want to ensure we handle.
+ let mut v = vec![1, 2, 3];
+ v.push(v.len());
+
+ // (as a rule, pnkfelix does not like to write tests with dead code.)
+
+ deref_coercion(&mut 5);
+ overloaded_call_traits();
+
+
+ let mut s = S;
+ s.m(s.i(10));
+
+ let mut t = T;
+ t.m(t.i(10));
+
+ coerce_unsized();
+ coerce_index_op();
+ overloaded_binops();
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// revisions: lxl nll
-//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows
-//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
+// ignore-tidy-linelength
+
+// revisions: lxl_beyond nll_beyond nll_target
+
+//[lxl_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref
+//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll
+//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll
// This is a corner case that the current implementation is (probably)
// treating more conservatively than is necessary. But it also does
// So this test is just making a note of the current behavior, with
// the caveat that in the future, the rules may be loosened, at which
// point this test might be thrown out.
+//
+// The convention for the listed revisions: "lxl" means lexical
+// lifetimes (which can be easier to reason about). "nll" means
+// non-lexical lifetimes. "nll_target" means the initial conservative
+// two-phase borrows that only applies to autoref-introduced borrows.
+// "nll_beyond" means the generalization of two-phase borrows to all
+// `&mut`-borrows (doing so makes it easier to write code for specific
+// corner cases).
+//
+// FIXME: in "nll_target", we currently see the same error reported
+// twice. This is injected by `-Z two-phase-borrows`; not sure why as
+// of yet.
fn main() {
let mut vec = vec![0, 1];
// with the shared borrow. But in the current implementation,
// its an error.
delay = &mut vec;
- //[lxl]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
- //[nll]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
+ //[lxl_beyond]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
+ //[nll_beyond]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
+ //[nll_target]~^^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
+ //[nll_target]~| ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable
shared[0];
}
: [u32; (i8::MAX as i8 + 1u8) as usize]
//~^ ERROR mismatched types
//~| expected i8, found u8
- //~| ERROR the trait bound `i8: std::ops::Add<u8>` is not satisfied
+ //~| ERROR cannot add `u8` to `i8`
= [0; (i8::MAX as usize) + 1];
--- /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::any::TypeId;
+
+struct A;
+
+fn main() {
+ const A_ID: TypeId = TypeId::of::<A>();
+ //~^ ERROR `std::any::TypeId::of` is not yet stable as a const fn
+}
#![feature(unsized_tuple_coercion)]
type Fat<T: ?Sized> = (isize, &'static str, T);
-//~^ WARNING trait bounds are not (yet) enforced
+//~^ WARNING bounds are ignored
#[derive(PartialEq,Eq)]
struct Bar;
--- /dev/null
+// Copyright 2012 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.
+
+// ignore-tidy-linelength
+// compile-flags: -Zepoch=2015 -Zunstable-options
+
+// tests that epochs work with the tyvar warning-turned-error
+
+#[deny(warnings)]
+fn main() {
+ let x = 0;
+ let y = &x as *const _;
+ let _ = y.is_null();
+ //~^ error: the type of this value must be known in this context [tyvar_behind_raw_pointer]
+ //~^^ warning: this was previously accepted
+}
--- /dev/null
+// Copyright 2012 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.
+
+// ignore-tidy-linelength
+// compile-flags: -Zepoch=2018 -Zunstable-options
+
+// tests that epochs work with the tyvar warning-turned-error
+
+#[deny(warnings)]
+fn main() {
+ let x = 0;
+ let y = &x as *const _;
+ let _ = y.is_null();
+ //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0908]
+}
#![allow(unused_macros)]
macro_rules! assign {
- (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected `*` or `+`
+ (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected one of: `*`, `+`, or `?`
$($a)* = $($b)*
}
}
--- /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.
+
+static TAB: [&mut [u8]; 0] = [];
+
+pub unsafe fn test() {
+ TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389]
+}
+
+pub fn main() {}
--- /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.
+
+#![feature(const_fn)]
+#![feature(core_intrinsics)]
+
+use std::intrinsics;
+
+struct Foo {
+ bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
+ //~^ ERROR unsupported cyclic reference between types/traits detected
+ x: usize,
+}
+
+fn main() {}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// Issue 46036: [NLL] false edges on infinite loops
+// Infinite loops should create false edges to the cleanup block.
+#![feature(nll)]
+
+struct Foo { x: &'static u32 }
+
+fn foo() {
+ let a = 3;
+ let foo = Foo { x: &a }; //~ ERROR E0597
+ loop { }
+}
+
+fn main() { }
fn main() {
write(&buf);
- buf[0]=2; //[mir]~ ERROR E0594
+ buf[0]=2; //[ast]~ ERROR E0389
+ //[mir]~^ ERROR E0594
}
--- /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.
+
+#[derive(Copy, Clone)]
+enum Void {}
+
+// Tests that we detect unsafe places (specifically, union fields and
+// raw pointer dereferences), even when they're matched on while having
+// an uninhabited type (equivalent to `std::intrinsics::unreachable()`).
+
+fn union_field() {
+ union Union { unit: (), void: Void }
+ let u = Union { unit: () };
+ match u.void {}
+ //~^ ERROR access to union field requires unsafe function or block
+}
+
+fn raw_ptr_deref() {
+ let ptr = std::ptr::null::<Void>();
+ match *ptr {}
+ //~^ ERROR dereference of raw pointer requires unsafe function or block
+}
+
+fn main() {}
--- /dev/null
+// Copyright 2012 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.
+
+// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`.
+// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the
+// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to
+// exercise that logic in the macro parser.
+//
+// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but
+// included for consistency with `+` and `*`.
+//
+// This test focuses on error cases.
+
+#![feature(macro_at_most_once_rep)]
+
+macro_rules! foo {
+ ($(a)?) => {}
+}
+
+macro_rules! baz {
+ ($(a),?) => {} // comma separator is meaningless for `?`
+}
+
+macro_rules! barplus {
+ ($(a)?+) => {}
+}
+
+macro_rules! barstar {
+ ($(a)?*) => {}
+}
+
+pub fn main() {
+ foo!(a?a?a); //~ ERROR no rules expected the token `?`
+ foo!(a?a); //~ ERROR no rules expected the token `?`
+ foo!(a?); //~ ERROR no rules expected the token `?`
+ baz!(a?a?a); //~ ERROR no rules expected the token `?`
+ baz!(a?a); //~ ERROR no rules expected the token `?`
+ baz!(a?); //~ ERROR no rules expected the token `?`
+ baz!(a,); //~ ERROR unexpected end of macro invocation
+ baz!(a?a?a,); //~ ERROR no rules expected the token `?`
+ baz!(a?a,); //~ ERROR no rules expected the token `?`
+ baz!(a?,); //~ ERROR no rules expected the token `?`
+ barplus!(); //~ ERROR unexpected end of macro invocation
+ barplus!(a?); //~ ERROR unexpected end of macro invocation
+ barstar!(a?); //~ ERROR unexpected end of macro invocation
+}
--- /dev/null
+// Copyright 2012 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.
+
+// Test that the 'static bound from the Copy impl is respected. Regression test for #29149.
+
+#![feature(nll)]
+
+#[derive(Clone)] struct Foo<'a>(&'a u32);
+impl Copy for Foo<'static> {}
+
+fn main() {
+ let s = 2;
+ let a = Foo(&s); //~ ERROR `s` does not live long enough [E0597]
+ drop(a);
+ drop(a);
+}
let mut x = 22;
let wrapper = Wrap { w: &mut x };
x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506]
- //[mir]~^ ERROR cannot assign to `x` because it is borrowed [E0506]
- //[mir]~^^ ERROR cannot use `x` because it was mutably borrowed [E0503]
+ //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503]
*wrapper.w += 1;
}
pub trait PubTr {}
pub type Alias<T: PrivTr> = T; //~ ERROR private trait `traits::PrivTr` in public interface
- //~^ WARN trait bounds are not (yet) enforced in type definitions
+ //~^ WARN bounds are ignored in type aliases
//~| WARNING hard error
pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface
//~^ WARNING hard error
--- /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.
+
+#![feature(attr_literals, rustc_attrs, const_fn)]
+
+#[rustc_args_required_const(0)]
+fn foo(_a: i32) {
+}
+
+#[rustc_args_required_const(1)]
+fn bar(_a: i32, _b: i32) {
+}
+
+const A: i32 = 3;
+
+const fn baz() -> i32 {
+ 3
+}
+
+fn main() {
+ foo(2);
+ foo(2 + 3);
+ foo(baz());
+ let a = 4;
+ foo(A);
+ foo(a); //~ ERROR: argument 1 is required to be a constant
+ bar(a, 3);
+ bar(a, a); //~ ERROR: argument 2 is required to be a constant
+}
--- /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.
+
+#![feature(attr_literals, rustc_attrs, const_fn)]
+
+#[rustc_args_required_const(0)]
+fn foo(_a: i32) {
+}
+
+fn main() {
+ let a = foo; //~ ERROR: this function can only be invoked directly
+ a(2);
+}
fn main() {
<i32 as Add<u32>>::add(1, 2);
- //~^ ERROR `i32: std::ops::Add<u32>` is not satisfied
+ //~^ ERROR cannot add `u32` to `i32`
<i32 as Add<i32>>::add(1u32, 2);
//~^ ERROR mismatched types
<i32 as Add<i32>>::add(1, 2u32);
}
#[cfg(not(cfail1))]
-#[rustc_clean(cfg="cfail2", except="HirBody, TypeckTables")]
+#[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")]
#[rustc_clean(cfg="cfail3")]
pub fn change_continue_label() {
let mut _x = 0;
// goto -> bb1;
// }
// bb1: {
+// falseUnwind -> [real: bb2, cleanup: bb3];
+// }
+// bb2: {
// StorageLive(_2);
// _2 = const true;
// StorageLive(_3);
// _3 = &'23_1rs _2;
// StorageLive(_5);
// _5 = _2;
-// switchInt(move _5) -> [0u8: bb3, otherwise: bb2];
+// switchInt(move _5) -> [0u8: bb5, otherwise: bb4];
// }
-// bb2: {
+// bb3: {
+// ...
+// }
+// bb4: {
// _0 = ();
// StorageDead(_5);
// EndRegion('23_1rs);
// StorageDead(_2);
// return;
// }
-// bb3: {
+// bb5: {
// _4 = ();
// StorageDead(_5);
// StorageLive(_7);
// goto -> bb1;
// }
// bb1: {
+// falseUnwind -> [real: bb2, cleanup: bb3];
+// }
+// bb2: {
// _1 = const true;
// StorageLive(_3);
// _3 = &'26_1rs _1;
// StorageLive(_5);
// _5 = _1;
-// switchInt(move _5) -> [0u8: bb3, otherwise: bb2];
+// switchInt(move _5) -> [0u8: bb5, otherwise: bb4];
// }
-// bb2: {
+// bb3: {
+// ...
+// }
+// bb4: {
// _0 = ();
// StorageDead(_5);
// EndRegion('26_1rs);
// StorageDead(_1);
// return;
// }
-// bb3: {
+// bb5: {
// _4 = ();
// StorageDead(_5);
// StorageLive(_7);
// _1 = const false;
// StorageLive(_2);
// _2 = const 3i32;
-// StorageLive(_4);
-// goto -> bb1;
+// falseUnwind -> [real: bb2, cleanup: bb1];
// }
-//
// bb1: {
+// ...
+// }
+// bb2: {
+// StorageLive(_4);
+// goto -> bb3;
+// }
+// bb3: {
+// falseUnwind -> [real: bb4, cleanup: bb1];
+// }
+// bb4: {
// StorageLive(_7);
// _7 = _1;
-// switchInt(move _7) -> [0u8: bb3, otherwise: bb2];
+// switchInt(move _7) -> [0u8: bb6, otherwise: bb5];
// }
-// bb2: {
+// bb5: {
// _0 = ();
// StorageDead(_7);
// EndRegion('33_0rs);
// StorageDead(_1);
// return;
// }
-// bb3: {
+// bb6: {
// _4 = &'33_0rs _2;
// _6 = ();
// StorageDead(_7);
// _1 = const true;
// _3 = ();
-// goto -> bb1;
+// goto -> bb3;
// }
// }
// END rustc.main.SimplifyCfg-qualify-consts.after.mir
// goto -> bb1;
// }
// bb1: {
+// falseUnwind -> [real: bb2, cleanup: bb3];
+// }
+// bb2: {
// StorageLive(_2);
// StorageLive(_3);
// StorageLive(_4);
// _4 = std::option::Option<&'35_0rs S<'35_0rs>>::None;
-// _3 = const <std::cell::Cell<T>>::new(move _4) -> [return: bb3, unwind: bb2];
+// _3 = const <std::cell::Cell<T>>::new(move _4) -> [return: bb4, unwind: bb3];
// }
-// bb2: {
+// bb3: {
// resume;
// }
-// bb3: {
+// bb4: {
// StorageDead(_4);
// _2 = S<'35_0rs> { r: move _3 };
// StorageDead(_3);
// _8 = &'35_0rs (*_9);
// _7 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(move _8,);
// StorageDead(_8);
-// _5 = const <std::cell::Cell<T>>::set(move _6, move _7) -> [return: bb4, unwind: bb2];
+// _5 = const <std::cell::Cell<T>>::set(move _6, move _7) -> [return: bb5, unwind: bb3];
// }
-// bb4: {
+// bb5: {
// EndRegion('16s);
// StorageDead(_7);
// StorageDead(_6);
// StorageDead(_9);
// StorageLive(_11);
-// _11 = const query() -> [return: bb5, unwind: bb2];
-// }
-// bb5: {
-// switchInt(move _11) -> [0u8: bb7, otherwise: bb6];
+// _11 = const query() -> [return: bb6, unwind: bb3];
// }
// bb6: {
+// switchInt(move _11) -> [0u8: bb8, otherwise: bb7];
+// }
+// bb7: {
// _0 = ();
// StorageDead(_11);
// EndRegion('35_0rs);
// StorageDead(_2);
// return;
// }
-// bb7: {
+// bb8: {
// _10 = ();
// StorageDead(_11);
// StorageLive(_14);
// _16 = &'35_0rs (*_17);
// _15 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(move _16,);
// StorageDead(_16);
-// _13 = const <std::cell::Cell<T>>::set(move _14, move _15) -> [return: bb8, unwind: bb2];
+// _13 = const <std::cell::Cell<T>>::set(move _14, move _15) -> [return: bb9, unwind: bb3];
// }
-// bb8: {
+// bb9: {
// EndRegion('33s);
// StorageDead(_15);
// StorageDead(_14);
// bb0: {
// StorageLive(_1);
// _1 = const false;
-// goto -> bb1;
+// goto -> bb2;
// }
-//
// bb1: {
+// resume;
+// }
+// bb2: {
+// falseUnwind -> [real: bb3, cleanup: bb1];
+// }
+// bb3: {
// StorageLive(_4);
// _4 = _1;
-// switchInt(move _4) -> [0u8: bb3, otherwise: bb2];
+// switchInt(move _4) -> [0u8: bb5, otherwise: bb4];
// }
-//
-// bb2: {
+// bb4: {
// _0 = ();
// StorageDead(_4);
// StorageDead(_1);
// return;
// }
-//
-// bb3: {
+// bb5: {
// _3 = ();
// StorageDead(_4);
// _1 = const true;
// _2 = ();
-// goto -> bb1;
+// goto -> bb2;
// }
// END rustc.main.SimplifyCfg-initial.after.mir
--- /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.
+
+// compile-flags: -Z identify_regions -Z emit-end-regions
+
+// Tests to make sure we correctly generate falseUnwind edges in loops
+
+fn main() {
+ // Exit early at runtime. Since only care about the generated MIR
+ // and not the runtime behavior (which is exercised by other tests)
+ // we just bail early. Without this the test just loops infinitely.
+ if true {
+ return;
+ }
+ loop {
+ let x = 1;
+ continue;
+ }
+}
+
+// END RUST SOURCE
+// START rustc.main.SimplifyCfg-qualify-consts.after.mir
+// ...
+// bb1: { // The cleanup block
+// resume;
+// }
+// ...
+// bb3: { // Entry into the loop
+// _1 = ();
+// goto -> bb4;
+// }
+// bb4: { // The loop_block
+// falseUnwind -> [real: bb5, cleanup: bb1];
+// }
+// bb5: { // The loop body (body_block)
+// StorageLive(_5);
+// _5 = const 1i32;
+// StorageDead(_5);
+// goto -> bb4;
+// }
+// ...
+// END rustc.main.SimplifyCfg-qualify-consts.after.mir
// bb0: {
// ...
// _2 = std::option::Option<i32>::Some(const 42i32,);
-// _5 = discriminant(_2);
-// switchInt(move _5) -> [0isize: bb6, 1isize: bb4, otherwise: bb8];
+// _3 = discriminant(_2);
+// _6 = discriminant(_2);
+// switchInt(move _6) -> [0isize: bb6, 1isize: bb4, otherwise: bb8];
// }
// bb1: {
// resume;
// }
// bb2: { // arm1
-// StorageLive(_7);
-// _7 = _3;
-// _1 = (const 1i32, move _7);
-// StorageDead(_7);
+// StorageLive(_8);
+// _8 = _4;
+// _1 = (const 1i32, move _8);
+// StorageDead(_8);
// goto -> bb13;
// }
// bb3: { // binding3(empty) and arm3
// unreachable;
// }
// bb9: { // binding1 and guard
-// StorageLive(_3);
-// _3 = ((_2 as Some).0: i32);
-// StorageLive(_6);
-// _6 = const guard() -> [return: bb10, unwind: bb1];
+// StorageLive(_4);
+// _4 = ((_2 as Some).0: i32);
+// StorageLive(_7);
+// _7 = const guard() -> [return: bb10, unwind: bb1];
// }
// bb10: { // end of guard
-// switchInt(move _6) -> [0u8: bb11, otherwise: bb2];
+// switchInt(move _7) -> [0u8: bb11, otherwise: bb2];
// }
// bb11: { // to pre_binding2
// falseEdges -> [real: bb5, imaginary: bb5];
// }
// bb12: { // bindingNoLandingPads.before.mir2 and arm2
-// StorageLive(_4);
-// _4 = ((_2 as Some).0: i32);
-// StorageLive(_8);
-// _8 = _4;
-// _1 = (const 2i32, move _8);
-// StorageDead(_8);
+// StorageLive(_5);
+// _5 = ((_2 as Some).0: i32);
+// StorageLive(_9);
+// _9 = _5;
+// _1 = (const 2i32, move _9);
+// StorageDead(_9);
// goto -> bb13;
// }
// bb13: {
// bb0: {
// ...
// _2 = std::option::Option<i32>::Some(const 42i32,);
-// _5 = discriminant(_2);
-// switchInt(move _5) -> [0isize: bb5, 1isize: bb4, otherwise: bb8];
+// _3 = discriminant(_2);
+// _6 = discriminant(_2);
+// switchInt(move _6) -> [0isize: bb5, 1isize: bb4, otherwise: bb8];
// }
// bb1: {
// resume;
// }
// bb2: { // arm1
-// StorageLive(_7);
-// _7 = _3;
-// _1 = (const 1i32, move _7);
-// StorageDead(_7);
+// StorageLive(_8);
+// _8 = _4;
+// _1 = (const 1i32, move _8);
+// StorageDead(_8);
// goto -> bb13;
// }
// bb3: { // binding3(empty) and arm3
// unreachable;
// }
// bb9: { // binding1 and guard
-// StorageLive(_3);
-// _3 = ((_2 as Some).0: i32);
-// StorageLive(_6);
-// _6 = const guard() -> [return: bb10, unwind: bb1];
+// StorageLive(_4);
+// _4 = ((_2 as Some).0: i32);
+// StorageLive(_7);
+// _7 = const guard() -> [return: bb10, unwind: bb1];
// }
// bb10: { // end of guard
-// switchInt(move _6) -> [0u8: bb11, otherwise: bb2];
+// switchInt(move _7) -> [0u8: bb11, otherwise: bb2];
// }
// bb11: { // to pre_binding2
// falseEdges -> [real: bb6, imaginary: bb5];
// }
// bb12: { // binding2 and arm2
-// StorageLive(_4);
-// _4 = ((_2 as Some).0: i32);
-// StorageLive(_8);
-// _8 = _4;
-// _1 = (const 2i32, move _8);
-// StorageDead(_8);
+// StorageLive(_5);
+// _5 = ((_2 as Some).0: i32);
+// StorageLive(_9);
+// _9 = _5;
+// _1 = (const 2i32, move _9);
+// StorageDead(_9);
// goto -> bb13;
// }
// bb13: {
// bb0: {
// ...
// _2 = std::option::Option<i32>::Some(const 1i32,);
-// _7 = discriminant(_2);
-// switchInt(move _7) -> [1isize: bb4, otherwise: bb5];
+// _3 = discriminant(_2);
+// _8 = discriminant(_2);
+// switchInt(move _8) -> [1isize: bb4, otherwise: bb5];
// }
// bb1: {
// resume;
// unreachable;
// }
// bb9: { // binding1: Some(w) if guard()
-// StorageLive(_3);
-// _3 = ((_2 as Some).0: i32);
-// StorageLive(_8);
-// _8 = const guard() -> [return: bb10, unwind: bb1];
+// StorageLive(_4);
+// _4 = ((_2 as Some).0: i32);
+// StorageLive(_9);
+// _9 = const guard() -> [return: bb10, unwind: bb1];
// }
// bb10: { //end of guard
-// switchInt(move _8) -> [0u8: bb11, otherwise: bb2];
+// switchInt(move _9) -> [0u8: bb11, otherwise: bb2];
// }
// bb11: { // to pre_binding2
// falseEdges -> [real: bb5, imaginary: bb5];
// }
// bb12: { // binding2 & arm2
-// StorageLive(_4);
-// _4 = _2;
+// StorageLive(_5);
+// _5 = _2;
// _1 = const 2i32;
// goto -> bb17;
// }
// bb13: { // binding3: Some(y) if guard2(y)
-// StorageLive(_5);
-// _5 = ((_2 as Some).0: i32);
-// StorageLive(_10);
+// StorageLive(_6);
+// _6 = ((_2 as Some).0: i32);
// StorageLive(_11);
-// _11 = _5;
-// _10 = const guard2(move _11) -> [return: bb14, unwind: bb1];
+// StorageLive(_12);
+// _12 = _6;
+// _11 = const guard2(move _12) -> [return: bb14, unwind: bb1];
// }
// bb14: { // end of guard2
-// StorageDead(_11);
-// switchInt(move _10) -> [0u8: bb15, otherwise: bb3];
+// StorageDead(_12);
+// switchInt(move _11) -> [0u8: bb15, otherwise: bb3];
// }
// bb15: { // to pre_binding4
// falseEdges -> [real: bb7, imaginary: bb7];
// }
// bb16: { // binding4 & arm4
-// StorageLive(_6);
-// _6 = _2;
+// StorageLive(_7);
+// _7 = _2;
// _1 = const 4i32;
// goto -> bb17;
// }
// END RUST SOURCE
// START rustc.main.nll.0.mir
-// | Live variables on entry to bb2: []
-// bb2: {
-// | Live variables on entry to bb2[0]: []
+// | Live variables on entry to bb3: []
+// bb3: {
+// | Live variables on entry to bb3[0]: []
// _1 = const 55usize;
-// | Live variables on entry to bb2[1]: [_1]
+// | Live variables on entry to bb3[1]: [_1]
// StorageLive(_3);
-// | Live variables on entry to bb2[2]: [_1]
+// | Live variables on entry to bb3[2]: [_1]
// StorageLive(_4);
-// | Live variables on entry to bb2[3]: [_1]
+// | Live variables on entry to bb3[3]: [_1]
// _4 = _1;
-// | Live variables on entry to bb2[4]: [_4]
-// _3 = const use_x(move _4) -> [return: bb3, unwind: bb1];
+// | Live variables on entry to bb3[4]: [_4]
+// _3 = const use_x(move _4) -> [return: bb4, unwind: bb1];
// }
// END rustc.main.nll.0.mir
// Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]);
// StorageLive(_3);
// StorageLive(_4);
+// StorageLive(_5);
// Validate(Suspend(ReScope(Node(ItemLocalId(9)))), [(*_2): i32]);
-// _4 = &ReErased mut (*_2);
-// Validate(Acquire, [(*_4): i32/ReScope(Node(ItemLocalId(9)))]);
-// _3 = move _4 as *mut i32 (Misc);
+// _5 = &ReErased mut (*_2);
+// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(9)))]);
+// _4 = move _5 as *mut i32 (Misc);
+// _3 = move _4;
// EndRegion(ReScope(Node(ItemLocalId(9))));
// StorageDead(_4);
+// StorageDead(_5);
// Validate(Release, [_0: bool, _3: *mut i32]);
// _0 = const write_42(move _3) -> bb1;
// }
macro_rules! foo {
{ $+ } => { //~ ERROR expected identifier, found `+`
//~^ ERROR missing fragment specifier
- $(x)(y) //~ ERROR expected `*` or `+`
+ $(x)(y) //~ ERROR expected one of: `*`, `+`, or `?`
}
}
--- /dev/null
+-include ../tools.mk
+
+all:
+ cp foo.rs $(TMPDIR)/foo.rs
+ mkdir $(TMPDIR)/foo
+ $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \
+ | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\""
--- /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.
+
+fn main() {}
all:
cp foo.rs $(TMPDIR)/foo
- $(RUSTC) $(TMPDIR)/foo 2>&1 \
+ $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \
| $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable"
+ cp bar.rs $(TMPDIR)/bar.rlib
+ $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \
+ | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable"
$(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1
cp foo.rs $(TMPDIR)/foo.rs
$(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
--- /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.
+
+#![crate_type = "lib"]
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// 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.
//
static EXTERN_FOO: u8;
fn extern_foo(a: u8, b: i32) -> String;
}
+
+struct Rls699 {
+ f: u32,
+}
+
+fn new(f: u32) -> Rls699 {
+ Rls699 { fs }
+}
--- /dev/null
+Extra docs for this struct.
#![feature(box_syntax)]
#![feature(rustc_private)]
#![feature(associated_type_defaults)]
+#![feature(external_doc)]
extern crate graphviz;
// A simple rust project
trait Foo {
type Bar = FrameBuffer;
}
+
+#[doc(include="extra-docs.md")]
+struct StructWithDocs;
extern crate rustc;
extern crate rustc_plugin;
+use syntax::feature_gate::Features;
use syntax::parse::token::{NtExpr, NtPat};
use syntax::ast::{Ident, Pat};
use syntax::tokenstream::{TokenTree};
use syntax_pos::Span;
use rustc_plugin::Registry;
+use std::cell::RefCell;
+
fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree])
-> Box<MacResult + 'static> {
let mbe_matcher = quote_tokens!(cx, $$matched:expr, $$($$pat:pat)|+);
- let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(), true, cx.parse_sess);
+ let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(),
+ true,
+ cx.parse_sess,
+ &RefCell::new(Features::new()),
+ &[]);
let map = match TokenTree::parse(cx, &mbe_matcher, args.iter().cloned().collect()) {
Success(map) => map,
Failure(_, tok) => {
// Unfortunately, LLVM has no "disable" option for this, so we have to set
// "enable" to 0 instead.
-// compile-flags:-g -Cllvm-args=-enable-tail-merge=0
+// compile-flags:-g -Cllvm-args=-enable-tail-merge=0 -Cllvm-args=-opt-bisect-limit=0
// ignore-pretty issue #37195
// ignore-cloudabi spawning processes is not supported
// ignore-emscripten spawning processes is not supported
+// note that above `-opt-bisect-limit=0` is used to basically disable
+// optimizations
+
use std::env;
#[path = "backtrace-debuginfo-aux.rs"] mod aux;
inner_inlined(&mut counter, main_pos, pos!());
}
-fn check_trace(output: &str, error: &str) {
+fn check_trace(output: &str, error: &str) -> Result<(), String> {
// reverse the position list so we can start with the last item (which was the first line)
let mut remaining: Vec<&str> = output.lines().map(|s| s.trim()).rev().collect();
- assert!(error.contains("stack backtrace"), "no backtrace in the error: {}", error);
+ if !error.contains("stack backtrace") {
+ return Err(format!("no backtrace found in stderr:\n{}", error))
+ }
for line in error.lines() {
if !remaining.is_empty() && line.contains(remaining.last().unwrap()) {
remaining.pop();
}
}
- assert!(remaining.is_empty(),
- "trace does not match position list: {}\n---\n{}", error, output);
+ if !remaining.is_empty() {
+ return Err(format!("trace does not match position list\n\
+ still need to find {:?}\n\n\
+ --- stdout\n{}\n\
+ --- stderr\n{}",
+ remaining, output, error))
+ }
+ Ok(())
}
fn run_test(me: &str) {
use std::process::Command;
let mut i = 0;
+ let mut errors = Vec::new();
loop {
let out = Command::new(me)
.env("RUST_BACKTRACE", "full")
assert!(output.contains("done."), "bad output for successful run: {}", output);
break;
} else {
- check_trace(output, error);
+ if let Err(e) = check_trace(output, error) {
+ errors.push(e);
+ }
}
i += 1;
}
+ if errors.len() > 0 {
+ for error in errors {
+ println!("---------------------------------------");
+ println!("{}", error);
+ }
+
+ panic!("found some errors");
+ }
}
#[inline(never)]
--- /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.
+
+#![feature(core_intrinsics)]
+#![feature(const_type_id)]
+
+use std::any::TypeId;
+
+struct A;
+
+static ID_ISIZE: TypeId = TypeId::of::<isize>();
+
+pub fn main() {
+ assert_eq!(ID_ISIZE, TypeId::of::<isize>());
+
+ // sanity test of TypeId
+ const T: (TypeId, TypeId, TypeId) = (TypeId::of::<usize>(),
+ TypeId::of::<&'static str>(),
+ TypeId::of::<A>());
+ let (d, e, f) = (TypeId::of::<usize>(), TypeId::of::<&'static str>(),
+ TypeId::of::<A>());
+
+ assert!(T.0 != T.1);
+ assert!(T.0 != T.2);
+ assert!(T.1 != T.2);
+
+ assert_eq!(T.0, d);
+ assert_eq!(T.1, e);
+ assert_eq!(T.2, f);
+
+ // Check fn pointer against collisions
+ const F: (TypeId, TypeId) = (TypeId::of::<fn(fn(A) -> A) -> A>(),
+ TypeId::of::<fn(fn() -> A, A) -> A>());
+
+ assert!(F.0 != F.1);
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(use_nested_groups)]
#![allow(unused_import)]
use {{}, {}};
--- /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.
+//
+// Tests that automatic coercions from &mut T to *mut T
+// allow borrows of T to expire immediately - essentially, that
+// they work identically to 'foo as *mut T'
+#![feature(nll)]
+
+struct SelfReference {
+ self_reference: *mut SelfReference,
+}
+
+impl SelfReference {
+ fn set_self_ref(&mut self) {
+ self.self_reference = self;
+ }
+}
+
+fn main() {}
--- /dev/null
+// Copyright 2012 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.
+
+// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`.
+// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the
+// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to
+// exercise that logic in the macro parser.
+//
+// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but
+// included for consistency with `+` and `*`.
+//
+// This test focuses on non-error cases and making sure the correct number of repetitions happen.
+
+#![feature(macro_at_most_once_rep)]
+
+macro_rules! foo {
+ ($($a:ident)? ; $num:expr) => { {
+ let mut x = 0;
+
+ $(
+ x += $a;
+ )?
+
+ assert_eq!(x, $num);
+ } }
+}
+
+macro_rules! baz {
+ ($($a:ident),? ; $num:expr) => { { // comma separator is meaningless for `?`
+ let mut x = 0;
+
+ $(
+ x += $a;
+ )?
+
+ assert_eq!(x, $num);
+ } }
+}
+
+macro_rules! barplus {
+ ($($a:ident)?+ ; $num:expr) => { {
+ let mut x = 0;
+
+ $(
+ x += $a;
+ )+
+
+ assert_eq!(x, $num);
+ } }
+}
+
+macro_rules! barstar {
+ ($($a:ident)?* ; $num:expr) => { {
+ let mut x = 0;
+
+ $(
+ x += $a;
+ )*
+
+ assert_eq!(x, $num);
+ } }
+}
+
+pub fn main() {
+ let a = 1;
+
+ // accept 0 or 1 repetitions
+ foo!( ; 0);
+ foo!(a ; 1);
+ baz!( ; 0);
+ baz!(a ; 1);
+
+ // Make sure using ? as a separator works as before
+ barplus!(a ; 1);
+ barplus!(a?a ; 2);
+ barplus!(a?a?a ; 3);
+ barstar!( ; 0);
+ barstar!(a ; 1);
+ barstar!(a?a ; 2);
+ barstar!(a?a?a ; 3);
+}
--- /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.
+
+enum Foo {
+ A,
+ B,
+ C,
+ D,
+ E,
+}
+use Foo::*;
+
+fn main() {
+ for foo in &[A, B, C, D, E] {
+ match *foo {
+ | A => println!("A"),
+ | B | C if 1 < 2 => println!("BC!"),
+ | _ => {},
+ }
+ }
+}
--- /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.
+
+#![feature(nll)]
+
+pub struct DescriptorSet<'a> {
+ pub slots: Vec<AttachInfo<'a, Resources>>
+}
+
+pub trait ResourcesTrait<'r>: Sized {
+ type DescriptorSet: 'r;
+}
+
+pub struct Resources;
+
+impl<'a> ResourcesTrait<'a> for Resources {
+ type DescriptorSet = DescriptorSet<'a>;
+}
+
+pub enum AttachInfo<'a, R: ResourcesTrait<'a>> {
+ NextDescriptorSet(Box<R::DescriptorSet>)
+}
+
+fn main() {
+ let _x = DescriptorSet {slots: Vec::new()};
+}
// ignore-emscripten no processes
// ignore-musl FIXME #31506
// ignore-pretty
-// no-system-llvm
+// min-system-llvm-version 5.0
// compile-flags: -C lto
// no-prefer-dynamic
// ignore-cloudabi no processes
// ignore-emscripten no processes
// ignore-musl FIXME #31506
-// no-system-llvm
+// min-system-llvm-version 5.0
use std::mem;
use std::process::Command;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(use_nested_groups)]
-
mod a {
pub enum B {}
--- /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.
+
+pub fn f2<F: FnMut(u32) + Clone>(f: F) {}
+
+pub fn f3<F: FnMut(u64) -> () + Clone>(f: F) {}
--- /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.
+
+// Just check if we don't get an ICE for the _S type.
+
+#![feature(const_size_of)]
+
+use std::cell::Cell;
+use std::mem;
+
+pub struct S {
+ s: Cell<usize>
+}
+
+pub type _S = [usize; 0 - (mem::size_of::<S>() != 4) as usize];
--- /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.
+
+// This should not ICE
+pub fn test() {
+ macro_rules! foo {
+ () => ()
+ }
+}
--- /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.
+
+// aux-build:unit-return.rs
+
+#![crate_name = "foo"]
+
+extern crate unit_return;
+
+// @has 'foo/fn.f0.html' '//*[@class="rust fn"]' 'F: FnMut(u8) + Clone'
+pub fn f0<F: FnMut(u8) + Clone>(f: F) {}
+
+// @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone'
+pub fn f1<F: FnMut(u16) -> () + Clone>(f: F) {}
+
+// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone'
+pub use unit_return::f2;
+
+// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone'
+pub use unit_return::f3;
//~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]
//~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]
//~| ERROR use of moved value: `maybe` (Mir) [E0382]
+ //~| ERROR use of moved value: `maybe` (Mir) [E0382]
//~| ERROR use of moved value: `maybe.0` (Mir) [E0382]
}
}
|
= note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
+error[E0382]: use of moved value: `maybe` (Mir)
+ --> $DIR/issue-41962.rs:17:9
+ |
+17 | if let Some(thing) = maybe {
+ | ^ ----- value moved here
+ | _________|
+ | |
+18 | | //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]
+19 | | //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]
+20 | | //~| ERROR use of moved value: `maybe` (Mir) [E0382]
+21 | | //~| ERROR use of moved value: `maybe` (Mir) [E0382]
+22 | | //~| ERROR use of moved value: `maybe.0` (Mir) [E0382]
+23 | | }
+ | |_________^ value used here after move
+ |
+ = note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait
+
error[E0382]: use of moved value: `maybe` (Mir)
--> $DIR/issue-41962.rs:17:16
|
|
= note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
-error: aborting due to 4 previous errors
+error: aborting due to 5 previous errors
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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(unreachable_patterns)]
+
+fn main() {
+ let foo = Some(1);
+ match foo {
+ Some(_) => {/* ... */}
+ None => {/* ... */}
+ _ => {/* ... */} //~ ERROR unreachable pattern
+ }
+}
--- /dev/null
+error: unreachable pattern
+ --> $DIR/E0001.rs:18:9
+ |
+18 | _ => {/* ... */} //~ ERROR unreachable pattern
+ | ^
+ |
+note: lint level defined here
+ --> $DIR/E0001.rs:11:9
+ |
+11 | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = Some(1);
+
+ match x { } //~ ERROR E0004
+}
--- /dev/null
+error[E0004]: non-exhaustive patterns: type std::option::Option<i32> is non-empty
+ --> $DIR/E0004-2.rs:14:11
+ |
+14 | match x { } //~ ERROR E0004
+ | ^
+ |
+help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
+ --> $DIR/E0004-2.rs:14:11
+ |
+14 | match x { } //~ ERROR E0004
+ | ^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum Terminator {
+ HastaLaVistaBaby,
+ TalkToMyHand,
+}
+
+fn main() {
+ let x = Terminator::HastaLaVistaBaby;
+
+ match x { //~ ERROR E0004
+ Terminator::TalkToMyHand => {}
+ }
+}
--- /dev/null
+error[E0004]: non-exhaustive patterns: `HastaLaVistaBaby` not covered
+ --> $DIR/E0004.rs:19:11
+ |
+19 | match x { //~ ERROR E0004
+ | ^ pattern `HastaLaVistaBaby` not covered
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = Some(1);
+ let Some(y) = x; //~ ERROR E0005
+}
--- /dev/null
+error[E0005]: refutable pattern in local binding: `None` not covered
+ --> $DIR/E0005.rs:13:9
+ |
+13 | let Some(y) = x; //~ ERROR E0005
+ | ^^^^^^^ pattern `None` not covered
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = Some("s".to_string());
+ match x {
+ op_string @ Some(s) => {},
+ //~^ ERROR E0007
+ //~| ERROR E0303
+ None => {},
+ }
+}
--- /dev/null
+error[E0007]: cannot bind by-move with sub-bindings
+ --> $DIR/E0007.rs:14:9
+ |
+14 | op_string @ Some(s) => {},
+ | ^^^^^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it
+
+error[E0303]: pattern bindings are not allowed after an `@`
+ --> $DIR/E0007.rs:14:26
+ |
+14 | op_string @ Some(s) => {},
+ | ^ not allowed after `@`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ match Some("hi".to_string()) {
+ Some(s) if s.len() == 0 => {},
+ //~^ ERROR E0008
+ _ => {},
+ }
+}
--- /dev/null
+error[E0008]: cannot bind by-move into a pattern guard
+ --> $DIR/E0008.rs:13:14
+ |
+13 | Some(s) if s.len() == 0 => {},
+ | ^ moves value into pattern guard
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ struct X { x: (), }
+ let x = Some((X { x: () }, X { x: () }));
+ match x {
+ Some((y, ref z)) => {},
+ //~^ ERROR E0009
+ None => panic!()
+ }
+}
--- /dev/null
+error[E0009]: cannot bind by-move and by-ref in the same pattern
+ --> $DIR/E0009.rs:15:15
+ |
+15 | Some((y, ref z)) => {},
+ | ^ ----- both by-ref and by-move used
+ | |
+ | by-move pattern here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags: -Z teach
+
+#![feature(box_syntax)]
+#![allow(warnings)]
+
+const CON : Box<i32> = box 0; //~ ERROR E0010
+
+fn main() {}
--- /dev/null
+error[E0010]: allocations are not allowed in constants
+ --> $DIR/E0010-teach.rs:16:24
+ |
+16 | const CON : Box<i32> = box 0; //~ ERROR E0010
+ | ^^^^^ allocation not allowed in constants
+ |
+ = note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time.
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(box_syntax)]
+#![allow(warnings)]
+
+const CON : Box<i32> = box 0; //~ ERROR E0010
+
+fn main() {}
--- /dev/null
+error[E0010]: allocations are not allowed in constants
+ --> $DIR/E0010.rs:14:24
+ |
+14 | const CON : Box<i32> = box 0; //~ ERROR E0010
+ | ^^^^^ allocation not allowed in constants
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+static X: i32 = 1;
+const C: i32 = 2;
+
+const CR: &'static mut i32 = &mut C; //~ ERROR E0017
+static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+ //~| ERROR cannot borrow
+static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
+fn main() {}
--- /dev/null
+error[E0017]: references in constants may only refer to immutable values
+ --> $DIR/E0017.rs:14:30
+ |
+14 | const CR: &'static mut i32 = &mut C; //~ ERROR E0017
+ | ^^^^^^ constants require immutable values
+
+error[E0017]: references in statics may only refer to immutable values
+ --> $DIR/E0017.rs:15:39
+ |
+15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+ | ^^^^^^ statics require immutable values
+
+error[E0596]: cannot borrow immutable static item as mutable
+ --> $DIR/E0017.rs:15:44
+ |
+15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+ | ^
+
+error[E0017]: references in statics may only refer to immutable values
+ --> $DIR/E0017.rs:17:38
+ |
+17 | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
+ | ^^^^^^ statics require immutable values
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum Fruit {
+ Apple(String, String),
+ Pear(u32),
+}
+
+
+fn main() {
+ let x = Fruit::Apple(String::new(), String::new());
+ match x {
+ Fruit::Apple(a) => {}, //~ ERROR E0023
+ Fruit::Apple(a, b, c) => {}, //~ ERROR E0023
+ Fruit::Pear(1, 2) => {}, //~ ERROR E0023
+ }
+}
--- /dev/null
+error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
+ --> $DIR/E0023.rs:20:9
+ |
+20 | Fruit::Apple(a) => {}, //~ ERROR E0023
+ | ^^^^^^^^^^^^^^^ expected 2 fields, found 1
+
+error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
+ --> $DIR/E0023.rs:21:9
+ |
+21 | Fruit::Apple(a, b, c) => {}, //~ ERROR E0023
+ | ^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 3
+
+error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field
+ --> $DIR/E0023.rs:22:9
+ |
+22 | Fruit::Pear(1, 2) => {}, //~ ERROR E0023
+ | ^^^^^^^^^^^^^^^^^ expected 1 field, found 2
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ a: u8,
+ b: u8,
+}
+
+fn main() {
+ let x = Foo { a:1, b:2 };
+ let Foo { a: x, a: y, b: 0 } = x;
+ //~^ ERROR field `a` bound multiple times in the pattern
+}
--- /dev/null
+error[E0025]: field `a` bound multiple times in the pattern
+ --> $DIR/E0025.rs:18:21
+ |
+18 | let Foo { a: x, a: y, b: 0 } = x;
+ | ---- ^^^^ multiple uses of `a` in pattern
+ | |
+ | first use of `a`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags: -Z teach
+
+struct Thing {
+ x: u32,
+ y: u32
+}
+
+fn main() {
+ let thing = Thing { x: 0, y: 0 };
+ match thing {
+ Thing { x, y, z } => {}
+ //~^ ERROR struct `Thing` does not have a field named `z` [E0026]
+ }
+}
--- /dev/null
+error[E0026]: struct `Thing` does not have a field named `z`
+ --> $DIR/E0026-teach.rs:21:23
+ |
+21 | Thing { x, y, z } => {}
+ | ^ struct `Thing` does not have field `z`
+ |
+ = note: This error indicates that a struct pattern attempted to extract a non-existent field from a struct. Struct fields are identified by the name used before the colon : so struct patterns should resemble the declaration of the struct type being matched.
+
+ If you are using shorthand field patterns but want to refer to the struct field by a different name, you should rename it explicitly.
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Thing {
+ x: u32,
+ y: u32
+}
+
+fn main() {
+ let thing = Thing { x: 0, y: 0 };
+ match thing {
+ Thing { x, y, z } => {}
+ //~^ ERROR struct `Thing` does not have a field named `z` [E0026]
+ }
+}
--- /dev/null
+error[E0026]: struct `Thing` does not have a field named `z`
+ --> $DIR/E0026.rs:19:23
+ |
+19 | Thing { x, y, z } => {}
+ | ^ struct `Thing` does not have field `z`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags: -Z teach
+
+struct Dog {
+ name: String,
+ age: u32,
+}
+
+fn main() {
+ let d = Dog { name: "Rusty".to_string(), age: 8 };
+
+ match d {
+ Dog { age: x } => {}
+ //~^ ERROR pattern does not mention field `name`
+ }
+}
--- /dev/null
+error[E0027]: pattern does not mention field `name`
+ --> $DIR/E0027-teach.rs:22:9
+ |
+22 | Dog { age: x } => {}
+ | ^^^^^^^^^^^^^^ missing field `name`
+ |
+ = note: This error indicates that a pattern for a struct fails to specify a sub-pattern for every one of the struct's fields. Ensure that each field from the struct's definition is mentioned in the pattern, or use `..` to ignore unwanted fields.
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Dog {
+ name: String,
+ age: u32,
+}
+
+fn main() {
+ let d = Dog { name: "Rusty".to_string(), age: 8 };
+
+ match d {
+ Dog { age: x } => {}
+ //~^ ERROR pattern does not mention field `name`
+ }
+}
--- /dev/null
+error[E0027]: pattern does not mention field `name`
+ --> $DIR/E0027.rs:20:9
+ |
+20 | Dog { age: x } => {}
+ | ^^^^^^^^^^^^^^ missing field `name`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags: -Z teach
+
+fn main() {
+ let s = "hoho";
+
+ match s {
+ "hello" ... "world" => {}
+ //~^ ERROR only char and numeric types are allowed in range patterns
+ //~| ERROR non-reference pattern used to match a reference
+ _ => {}
+ }
+}
--- /dev/null
+error[E0658]: non-reference pattern used to match a reference (see issue #42640)
+ --> $DIR/E0029-teach.rs:17:9
+ |
+17 | "hello" ... "world" => {}
+ | ^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&"hello" ... "world"`
+ |
+ = help: add #![feature(match_default_bindings)] to the crate attributes to enable
+
+error[E0029]: only char and numeric types are allowed in range patterns
+ --> $DIR/E0029-teach.rs:17:9
+ |
+17 | "hello" ... "world" => {}
+ | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types
+ |
+ = note: start type: &'static str
+ = note: end type: &'static str
+ = note: In a match expression, only numbers and characters can be matched against a range. This is because the compiler checks that the range is non-empty at compile-time, and is unable to evaluate arbitrary comparison functions. If you want to capture values of an orderable type between two end-points, you can use a guard.
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let s = "hoho";
+
+ match s {
+ "hello" ... "world" => {}
+ //~^ ERROR only char and numeric types are allowed in range patterns
+ //~| ERROR non-reference pattern used to match a reference
+ _ => {}
+ }
+}
--- /dev/null
+error[E0658]: non-reference pattern used to match a reference (see issue #42640)
+ --> $DIR/E0029.rs:15:9
+ |
+15 | "hello" ... "world" => {}
+ | ^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&"hello" ... "world"`
+ |
+ = help: add #![feature(match_default_bindings)] to the crate attributes to enable
+
+error[E0029]: only char and numeric types are allowed in range patterns
+ --> $DIR/E0029.rs:15:9
+ |
+15 | "hello" ... "world" => {}
+ | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types
+ |
+ = note: start type: &'static str
+ = note: end type: &'static str
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags: -Z teach
+
+fn main() {
+ match 5u32 {
+ 1000 ... 5 => {}
+ //~^ ERROR lower range bound must be less than or equal to upper
+ }
+}
--- /dev/null
+error[E0030]: lower range bound must be less than or equal to upper
+ --> $DIR/E0030-teach.rs:15:9
+ |
+15 | 1000 ... 5 => {}
+ | ^^^^ lower bound larger than upper bound
+ |
+ = note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range.
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+
+fn main() {
+ match 5u32 {
+ 1000 ... 5 => {}
+ //~^ ERROR lower range bound must be less than or equal to upper
+ }
+}
--- /dev/null
+error[E0030]: lower range bound must be less than or equal to upper
+ --> $DIR/E0030.rs:14:9
+ |
+14 | 1000 ... 5 => {}
+ | ^^^^ lower bound larger than upper bound
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags: -Z teach
+
+trait SomeTrait {
+ fn foo();
+}
+
+fn main() {
+ let trait_obj: &SomeTrait = SomeTrait;
+ //~^ ERROR expected value, found trait `SomeTrait`
+ //~| ERROR E0038
+ //~| method `foo` has no receiver
+
+ let &invalid = trait_obj;
+ //~^ ERROR E0033
+}
--- /dev/null
+error[E0423]: expected value, found trait `SomeTrait`
+ --> $DIR/E0033-teach.rs:18:33
+ |
+18 | let trait_obj: &SomeTrait = SomeTrait;
+ | ^^^^^^^^^ not a value
+
+error[E0038]: the trait `SomeTrait` cannot be made into an object
+ --> $DIR/E0033-teach.rs:18:20
+ |
+18 | let trait_obj: &SomeTrait = SomeTrait;
+ | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
+ |
+ = note: method `foo` has no receiver
+
+error[E0033]: type `&SomeTrait` cannot be dereferenced
+ --> $DIR/E0033-teach.rs:23:9
+ |
+23 | let &invalid = trait_obj;
+ | ^^^^^^^^ type `&SomeTrait` cannot be dereferenced
+ |
+ = note: This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, this type has no compile-time size. Therefore, all accesses to trait types must be through pointers. If you encounter this error you should try to avoid dereferencing the pointer.
+
+ You can read more about trait objects in the Trait Objects section of the Reference: https://doc.rust-lang.org/reference/types.html#trait-objects
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait SomeTrait {
+ fn foo();
+}
+
+fn main() {
+ let trait_obj: &SomeTrait = SomeTrait;
+ //~^ ERROR expected value, found trait `SomeTrait`
+ //~| ERROR E0038
+ //~| method `foo` has no receiver
+
+ let &invalid = trait_obj;
+ //~^ ERROR E0033
+}
--- /dev/null
+error[E0423]: expected value, found trait `SomeTrait`
+ --> $DIR/E0033.rs:16:33
+ |
+16 | let trait_obj: &SomeTrait = SomeTrait;
+ | ^^^^^^^^^ not a value
+
+error[E0038]: the trait `SomeTrait` cannot be made into an object
+ --> $DIR/E0033.rs:16:20
+ |
+16 | let trait_obj: &SomeTrait = SomeTrait;
+ | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
+ |
+ = note: method `foo` has no receiver
+
+error[E0033]: type `&SomeTrait` cannot be dereferenced
+ --> $DIR/E0033.rs:21:9
+ |
+21 | let &invalid = trait_obj;
+ | ^^^^^^^^ type `&SomeTrait` cannot be dereferenced
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Test;
+
+trait Trait1 {
+ fn foo();
+}
+
+trait Trait2 {
+ fn foo();
+}
+
+impl Trait1 for Test {
+ fn foo() {}
+}
+
+impl Trait2 for Test {
+ fn foo() {}
+}
+
+fn main() {
+ Test::foo() //~ ERROR multiple applicable items in scope
+}
--- /dev/null
+error[E0034]: multiple applicable items in scope
+ --> $DIR/E0034.rs:30:5
+ |
+30 | Test::foo() //~ ERROR multiple applicable items in scope
+ | ^^^^^^^^^ multiple `foo` found
+ |
+note: candidate #1 is defined in an impl of the trait `Trait1` for the type `Test`
+ --> $DIR/E0034.rs:22:5
+ |
+22 | fn foo() {}
+ | ^^^^^^^^
+note: candidate #2 is defined in an impl of the trait `Trait2` for the type `Test`
+ --> $DIR/E0034.rs:26:5
+ |
+26 | fn foo() {}
+ | ^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Trait {
+ fn foo(&self) -> Self;
+}
+
+fn call_foo(x: Box<Trait>) {
+ //~^ ERROR E0038
+ let y = x.foo();
+}
+
+fn main() {
+}
--- /dev/null
+error[E0038]: the trait `Trait` cannot be made into an object
+ --> $DIR/E0038.rs:15:1
+ |
+15 | fn call_foo(x: Box<Trait>) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object
+ |
+ = note: method `foo` references the `Self` type in its arguments or return type
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ x: i32,
+}
+
+impl Drop for Foo {
+ fn drop(&mut self) {
+ println!("kaboom");
+ }
+}
+
+fn main() {
+ let mut x = Foo { x: -7 };
+ x.drop();
+ //~^ ERROR E0040
+}
--- /dev/null
+error[E0040]: explicit use of destructor method
+ --> $DIR/E0040.rs:23:7
+ |
+23 | x.drop();
+ | ^^^^ explicit destructor calls not allowed
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+extern { fn some_func<T>(x: T); } //~ ERROR E0044
+
+fn main() {
+}
--- /dev/null
+error[E0044]: foreign items may not have type parameters
+ --> $DIR/E0044.rs:11:10
+ |
+11 | extern { fn some_func<T>(x: T); } //~ ERROR E0044
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: consider using specialization instead of type parameters
+ --> $DIR/E0044.rs:11:10
+ |
+11 | extern { fn some_func<T>(x: T); } //~ ERROR E0044
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045
+
+fn main() {
+}
--- /dev/null
+error[E0045]: variadic function must have C or cdecl calling convention
+ --> $DIR/E0045.rs:11:17
+ |
+11 | extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045
+ | ^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn foo<T: Default>(x: T) -> Self;
+}
+
+struct Bar;
+
+impl Foo for Bar {
+ fn foo(x: bool) -> Self { Bar } //~ ERROR E0049
+}
+
+fn main() {
+}
--- /dev/null
+error[E0049]: method `foo` has 0 type parameters but its trait declaration has 1 type parameter
+ --> $DIR/E0049.rs:18:5
+ |
+12 | fn foo<T: Default>(x: T) -> Self;
+ | --------------------------------- expected 1 type parameter
+...
+18 | fn foo(x: bool) -> Self { Bar } //~ ERROR E0049
+ | ^^^^^^^^^^^^^^^^^^^^^^^ found 0 type parameters
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn foo(&self, x: u8) -> bool;
+ fn bar(&self, x: u8, y: u8, z: u8);
+ fn less(&self);
+}
+
+struct Bar;
+
+impl Foo for Bar {
+ fn foo(&self) -> bool { true } //~ ERROR E0050
+ fn bar(&self) { } //~ ERROR E0050
+ fn less(&self, x: u8, y: u8, z: u8) { } //~ ERROR E0050
+}
+
+fn main() {
+}
--- /dev/null
+error[E0050]: method `foo` has 1 parameter but the declaration in trait `Foo::foo` has 2
+ --> $DIR/E0050.rs:20:12
+ |
+12 | fn foo(&self, x: u8) -> bool;
+ | -- trait requires 2 parameters
+...
+20 | fn foo(&self) -> bool { true } //~ ERROR E0050
+ | ^^^^^ expected 2 parameters, found 1
+
+error[E0050]: method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 4
+ --> $DIR/E0050.rs:21:12
+ |
+13 | fn bar(&self, x: u8, y: u8, z: u8);
+ | -- trait requires 4 parameters
+...
+21 | fn bar(&self) { } //~ ERROR E0050
+ | ^^^^^ expected 4 parameters, found 1
+
+error[E0050]: method `less` has 4 parameters but the declaration in trait `Foo::less` has 1
+ --> $DIR/E0050.rs:22:37
+ |
+14 | fn less(&self);
+ | ----- trait requires 1 parameter
+...
+22 | fn less(&self, x: u8, y: u8, z: u8) { } //~ ERROR E0050
+ | ^^ expected 1 parameter, found 4
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = 5;
+ let x_is_nonzero = x as bool; //~ ERROR E0054
+}
--- /dev/null
+error[E0054]: cannot cast as `bool`
+ --> $DIR/E0054.rs:13:24
+ |
+13 | let x_is_nonzero = x as bool; //~ ERROR E0054
+ | ^^^^^^^^^ unsupported cast
+ |
+ = help: compare with zero instead
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![recursion_limit="2"]
+struct Foo;
+
+impl Foo {
+ fn foo(&self) {}
+}
+
+fn main() {
+ let foo = Foo;
+ let ref_foo = &&Foo;
+ ref_foo.foo();
+ //~^ ERROR E0055
+}
--- /dev/null
+error[E0055]: reached the recursion limit while auto-dereferencing Foo
+ --> $DIR/E0055.rs:21:13
+ |
+21 | ref_foo.foo();
+ | ^^^ deref recursion limit reached
+ |
+ = help: consider adding a `#![recursion_limit="4"]` attribute to your crate
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let f = |x| x * 3;
+ let a = f(); //~ ERROR E0057
+ let b = f(4);
+ let c = f(2, 3); //~ ERROR E0057
+}
--- /dev/null
+error[E0057]: this function takes 1 parameter but 0 parameters were supplied
+ --> $DIR/E0057.rs:13:13
+ |
+13 | let a = f(); //~ ERROR E0057
+ | ^^^ expected 1 parameter
+
+error[E0057]: this function takes 1 parameter but 2 parameters were supplied
+ --> $DIR/E0057.rs:15:13
+ |
+15 | let c = f(2, 3); //~ ERROR E0057
+ | ^^^^^^^ expected 1 parameter
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(unboxed_closures)]
+
+fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) } //~ ERROR E0059
+
+fn main() {
+}
--- /dev/null
+error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit
+ --> $DIR/E0059.rs:13:41
+ |
+13 | fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) } //~ ERROR E0059
+ | ^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+extern "C" {
+ fn printf(_: *const u8, ...) -> u32;
+}
+
+fn main() {
+ unsafe { printf(); }
+ //~^ ERROR E0060
+ //~| expected at least 1 parameter
+}
--- /dev/null
+error[E0060]: this function takes at least 1 parameter but 0 parameters were supplied
+ --> $DIR/E0060.rs:16:14
+ |
+12 | fn printf(_: *const u8, ...) -> u32;
+ | ------------------------------------ defined here
+...
+16 | unsafe { printf(); }
+ | ^^^^^^^^ expected at least 1 parameter
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn f(a: u16, b: &str) {}
+
+fn f2(a: u16) {}
+
+fn main() {
+ f(0);
+ //~^ ERROR E0061
+ //~| expected 2 parameters
+
+ f2();
+ //~^ ERROR E0061
+ //~| expected 1 parameter
+}
--- /dev/null
+error[E0061]: this function takes 2 parameters but 1 parameter was supplied
+ --> $DIR/E0061.rs:16:5
+ |
+11 | fn f(a: u16, b: &str) {}
+ | --------------------- defined here
+...
+16 | f(0);
+ | ^^^^ expected 2 parameters
+
+error[E0061]: this function takes 1 parameter but 0 parameters were supplied
+ --> $DIR/E0061.rs:20:5
+ |
+13 | fn f2(a: u16) {}
+ | ------------- defined here
+...
+20 | f2();
+ | ^^^^ expected 1 parameter
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ x: i32
+}
+
+fn main() {
+ let x = Foo {
+ x: 0,
+ x: 0,
+ //~^ ERROR E0062
+ };
+}
--- /dev/null
+error[E0062]: field `x` specified more than once
+ --> $DIR/E0062.rs:18:9
+ |
+17 | x: 0,
+ | ---- first use of `x`
+18 | x: 0,
+ | ^^ used more than once
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// ignore-tidy-linelength
+
+struct SingleFoo {
+ x: i32
+}
+
+struct PluralFoo {
+ x: i32,
+ y: i32,
+ z: i32
+}
+
+struct TruncatedFoo {
+ a: i32,
+ b: i32,
+ x: i32,
+ y: i32,
+ z: i32
+}
+
+struct TruncatedPluralFoo {
+ a: i32,
+ b: i32,
+ c: i32,
+ x: i32,
+ y: i32,
+ z: i32
+}
+
+
+fn main() {
+ let w = SingleFoo { };
+ //~^ ERROR missing field `x` in initializer of `SingleFoo`
+ let x = PluralFoo {x: 1};
+ //~^ ERROR missing fields `y`, `z` in initializer of `PluralFoo`
+ let y = TruncatedFoo{x:1};
+ //~^ missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo`
+ let z = TruncatedPluralFoo{x:1};
+ //~^ ERROR missing fields `a`, `b`, `c` and 2 other fields in initializer of `TruncatedPluralFoo`
+}
--- /dev/null
+error[E0063]: missing field `x` in initializer of `SingleFoo`
+ --> $DIR/E0063.rs:42:13
+ |
+42 | let w = SingleFoo { };
+ | ^^^^^^^^^ missing `x`
+
+error[E0063]: missing fields `y`, `z` in initializer of `PluralFoo`
+ --> $DIR/E0063.rs:44:13
+ |
+44 | let x = PluralFoo {x: 1};
+ | ^^^^^^^^^ missing `y`, `z`
+
+error[E0063]: missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo`
+ --> $DIR/E0063.rs:46:13
+ |
+46 | let y = TruncatedFoo{x:1};
+ | ^^^^^^^^^^^^ missing `a`, `b`, `y` and 1 other field
+
+error[E0063]: missing fields `a`, `b`, `c` and 2 other fields in initializer of `TruncatedPluralFoo`
+ --> $DIR/E0063.rs:48:13
+ |
+48 | let z = TruncatedPluralFoo{x:1};
+ | ^^^^^^^^^^^^^^^^^^ missing `a`, `b`, `c` and 2 other fields
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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::collections::LinkedList;
+
+fn main() {
+ LinkedList::new() += 1; //~ ERROR E0368
+ //~^ ERROR E0067
+}
--- /dev/null
+error[E0368]: binary assignment operation `+=` cannot be applied to type `std::collections::LinkedList<_>`
+ --> $DIR/E0067.rs:14:5
+ |
+14 | LinkedList::new() += 1; //~ ERROR E0368
+ | -----------------^^^^^
+ | |
+ | cannot use `+=` on type `std::collections::LinkedList<_>`
+
+error[E0067]: invalid left-hand side expression
+ --> $DIR/E0067.rs:14:5
+ |
+14 | LinkedList::new() += 1; //~ ERROR E0368
+ | ^^^^^^^^^^^^^^^^^ invalid expression for left-hand side
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo() -> u8 {
+ return;
+ //~^ ERROR `return;` in a function whose return type is not `()`
+}
+
+fn main() {
+}
--- /dev/null
+error[E0069]: `return;` in a function whose return type is not `()`
+ --> $DIR/E0069.rs:12:5
+ |
+12 | return;
+ | ^^^^^^ return type is not ()
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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 SOME_CONST : i32 = 12;
+
+fn some_other_func() {}
+
+fn some_function() {
+ SOME_CONST = 14; //~ ERROR E0070
+ 1 = 3; //~ ERROR E0070
+ some_other_func() = 4; //~ ERROR E0070
+ //~^ ERROR E0308
+}
+
+fn main() {
+}
--- /dev/null
+error[E0070]: invalid left-hand side expression
+ --> $DIR/E0070.rs:16:5
+ |
+16 | SOME_CONST = 14; //~ ERROR E0070
+ | ^^^^^^^^^^^^^^^ left-hand of expression not valid
+
+error[E0070]: invalid left-hand side expression
+ --> $DIR/E0070.rs:17:5
+ |
+17 | 1 = 3; //~ ERROR E0070
+ | ^^^^^ left-hand of expression not valid
+
+error[E0308]: mismatched types
+ --> $DIR/E0070.rs:18:25
+ |
+18 | some_other_func() = 4; //~ ERROR E0070
+ | ^ expected (), found integral variable
+ |
+ = note: expected type `()`
+ found type `{integer}`
+
+error[E0070]: invalid left-hand side expression
+ --> $DIR/E0070.rs:18:5
+ |
+18 | some_other_func() = 4; //~ ERROR E0070
+ | ^^^^^^^^^^^^^^^^^^^^^ left-hand of expression not valid
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum Foo {}
+type FooAlias = Foo;
+
+fn main() {
+ let u = FooAlias { value: 0 };
+ //~^ ERROR expected struct, variant or union type, found enum `Foo` [E0071]
+}
--- /dev/null
+error[E0071]: expected struct, variant or union type, found enum `Foo`
+ --> $DIR/E0071.rs:15:13
+ |
+15 | let u = FooAlias { value: 0 };
+ | ^^^^^^^^ not a struct
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+
+#[repr(simd)]
+struct Bad; //~ ERROR E0075
+
+fn main() {
+}
--- /dev/null
+error[E0075]: SIMD vector cannot be empty
+ --> $DIR/E0075.rs:14:1
+ |
+14 | struct Bad; //~ ERROR E0075
+ | ^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+
+#[repr(simd)]
+struct Bad(u16, u32, u32);
+//~^ ERROR E0076
+
+fn main() {
+}
--- /dev/null
+error[E0076]: SIMD vector should be homogeneous
+ --> $DIR/E0076.rs:14:1
+ |
+14 | struct Bad(u16, u32, u32);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+
+#[repr(simd)]
+struct Bad(String); //~ ERROR E0077
+
+fn main() {
+}
--- /dev/null
+error[E0077]: SIMD vector element type should be machine type
+ --> $DIR/E0077.rs:14:1
+ |
+14 | struct Bad(String); //~ ERROR E0077
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum Enum {
+ X = (1 << 500), //~ ERROR E0080
+ //~| WARNING shift left with overflow
+ Y = (1 / 0) //~ ERROR E0080
+ //~| WARNING divide by zero
+}
+
+fn main() {
+}
--- /dev/null
+warning: constant evaluation error: attempt to shift left with overflow
+ --> $DIR/E0080.rs:12:9
+ |
+12 | X = (1 << 500), //~ ERROR E0080
+ | ^^^^^^^^^^
+ |
+ = note: #[warn(const_err)] on by default
+
+error[E0080]: constant evaluation error
+ --> $DIR/E0080.rs:12:9
+ |
+12 | X = (1 << 500), //~ ERROR E0080
+ | ^^^^^^^^^^ attempt to shift left with overflow
+
+warning: constant evaluation error: attempt to divide by zero
+ --> $DIR/E0080.rs:14:9
+ |
+14 | Y = (1 / 0) //~ ERROR E0080
+ | ^^^^^^^
+
+error[E0080]: constant evaluation error
+ --> $DIR/E0080.rs:14:9
+ |
+14 | Y = (1 / 0) //~ ERROR E0080
+ | ^^^^^^^ attempt to divide by zero
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum Enum {
+ P = 3,
+ X = 3,
+ //~^ ERROR discriminant value `3isize` already exists
+ Y = 5
+}
+
+fn main() {
+}
--- /dev/null
+error[E0081]: discriminant value `3isize` already exists
+ --> $DIR/E0081.rs:13:9
+ |
+12 | P = 3,
+ | - first use of `3isize`
+13 | X = 3,
+ | ^ enum already has `3isize`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[repr(i32)] //~ ERROR: E0084
+enum Foo {}
+
+fn main() {
+}
--- /dev/null
+error[E0084]: unsupported representation for zero-variant enum
+ --> $DIR/E0084.rs:11:1
+ |
+11 | #[repr(i32)] //~ ERROR: E0084
+ | ^^^^^^^^^^^^
+12 | enum Foo {}
+ | ----------- zero-variant enum
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo() {}
+fn bar<T>() {}
+
+fn main() {
+ foo::<f64>(); //~ ERROR expected at most 0 type parameters, found 1 type parameter [E0087]
+
+ bar::<f64, u64>(); //~ ERROR expected at most 1 type parameter, found 2 type parameters [E0087]
+}
--- /dev/null
+error[E0087]: too many type parameters provided: expected at most 0 type parameters, found 1 type parameter
+ --> $DIR/E0087.rs:15:11
+ |
+15 | foo::<f64>(); //~ ERROR expected at most 0 type parameters, found 1 type parameter [E0087]
+ | ^^^ expected 0 type parameters
+
+error[E0087]: too many type parameters provided: expected at most 1 type parameter, found 2 type parameters
+ --> $DIR/E0087.rs:17:16
+ |
+17 | bar::<f64, u64>(); //~ ERROR expected at most 1 type parameter, found 2 type parameters [E0087]
+ | ^^^ expected 1 type parameter
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn f() {}
+fn g<'a>() -> &'a u8 { loop {} }
+
+fn main() {
+ f::<'static>(); //~ ERROR E0088
+ g::<'static, 'static>(); //~ ERROR E0088
+}
--- /dev/null
+error[E0088]: too many lifetime parameters provided: expected at most 0 lifetime parameters, found 1 lifetime parameter
+ --> $DIR/E0088.rs:15:9
+ |
+15 | f::<'static>(); //~ ERROR E0088
+ | ^^^^^^^ expected 0 lifetime parameters
+
+error[E0088]: too many lifetime parameters provided: expected at most 1 lifetime parameter, found 2 lifetime parameters
+ --> $DIR/E0088.rs:16:18
+ |
+16 | g::<'static, 'static>(); //~ ERROR E0088
+ | ^^^^^^^ expected 1 lifetime parameter
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo<T, U>() {}
+
+fn main() {
+ foo::<f64>(); //~ ERROR expected 2 type parameters, found 1 type parameter [E0089]
+}
--- /dev/null
+error[E0089]: too few type parameters provided: expected 2 type parameters, found 1 type parameter
+ --> $DIR/E0089.rs:14:5
+ |
+14 | foo::<f64>(); //~ ERROR expected 2 type parameters, found 1 type parameter [E0089]
+ | ^^^^^^^^^^ expected 2 type parameters
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo<'a: 'b, 'b: 'a>() {}
+
+fn main() {
+ foo::<'static>(); //~ ERROR expected 2 lifetime parameters, found 1 lifetime parameter [E0090]
+}
--- /dev/null
+error[E0090]: too few lifetime parameters provided: expected 2 lifetime parameters, found 1 lifetime parameter
+ --> $DIR/E0090.rs:14:5
+ |
+14 | foo::<'static>(); //~ ERROR expected 2 lifetime parameters, found 1 lifetime parameter [E0090]
+ | ^^^^^^^^^^^^^^ expected 2 lifetime parameters
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+type Foo<T> = u32; //~ ERROR E0091
+type Foo2<A, B> = Box<A>; //~ ERROR E0091
+
+fn main() {
+}
--- /dev/null
+error[E0091]: type parameter `T` is unused
+ --> $DIR/E0091.rs:11:10
+ |
+11 | type Foo<T> = u32; //~ ERROR E0091
+ | ^ unused type parameter
+
+error[E0091]: type parameter `B` is unused
+ --> $DIR/E0091.rs:12:14
+ |
+12 | type Foo2<A, B> = Box<A>; //~ ERROR E0091
+ | ^ unused type parameter
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(intrinsics)]
+extern "rust-intrinsic" {
+ fn atomic_foo(); //~ ERROR E0092
+}
+
+fn main() {
+}
--- /dev/null
+error[E0092]: unrecognized atomic operation function: `foo`
+ --> $DIR/E0092.rs:13:5
+ |
+13 | fn atomic_foo(); //~ ERROR E0092
+ | ^^^^^^^^^^^^^^^^ unrecognized atomic operation
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(intrinsics)]
+extern "rust-intrinsic" {
+ fn foo();
+ //~^ ERROR E0093
+}
+
+fn main() {
+}
--- /dev/null
+error[E0093]: unrecognized intrinsic function: `foo`
+ --> $DIR/E0093.rs:13:5
+ |
+13 | fn foo();
+ | ^^^^^^^^^ unrecognized intrinsic
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(intrinsics)]
+extern "rust-intrinsic" {
+ fn size_of<T, U>() -> usize; //~ ERROR E0094
+}
+
+fn main() {
+}
--- /dev/null
+error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1
+ --> $DIR/E0094.rs:13:15
+ |
+13 | fn size_of<T, U>() -> usize; //~ ERROR E0094
+ | ^^^^^^ expected 1 type parameter
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ x: &bool,
+ //~^ ERROR E0106
+}
+enum Bar {
+ A(u8),
+ B(&bool),
+ //~^ ERROR E0106
+}
+type MyStr = &str;
+ //~^ ERROR E0106
+
+struct Baz<'a>(&'a str);
+struct Buzz<'a, 'b>(&'a str, &'b str);
+
+struct Quux {
+ baz: Baz,
+ //~^ ERROR E0106
+ //~| expected lifetime parameter
+ buzz: Buzz,
+ //~^ ERROR E0106
+ //~| expected 2 lifetime parameters
+}
+
+fn main() {
+}
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/E0106.rs:12:8
+ |
+12 | x: &bool,
+ | ^ expected lifetime parameter
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/E0106.rs:17:7
+ |
+17 | B(&bool),
+ | ^ expected lifetime parameter
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/E0106.rs:20:14
+ |
+20 | type MyStr = &str;
+ | ^ expected lifetime parameter
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/E0106.rs:27:10
+ |
+27 | baz: Baz,
+ | ^^^ expected lifetime parameter
+
+error[E0106]: missing lifetime specifiers
+ --> $DIR/E0106.rs:30:11
+ |
+30 | buzz: Buzz,
+ | ^^^^ expected 2 lifetime parameters
+
+error: aborting due to 5 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo<'a>(&'a str);
+struct Buzz<'a, 'b>(&'a str, &'b str);
+
+enum Bar {
+ A,
+ B,
+ C,
+}
+
+struct Baz<'a, 'b, 'c> {
+ buzz: Buzz<'a>,
+ //~^ ERROR E0107
+ //~| expected 2 lifetime parameters
+ bar: Bar<'a>,
+ //~^ ERROR E0107
+ //~| unexpected lifetime parameter
+ foo2: Foo<'a, 'b, 'c>,
+ //~^ ERROR E0107
+ //~| 2 unexpected lifetime parameters
+}
+
+fn main() {
+}
--- /dev/null
+error[E0107]: wrong number of lifetime parameters: expected 2, found 1
+ --> $DIR/E0107.rs:21:11
+ |
+21 | buzz: Buzz<'a>,
+ | ^^^^^^^^ expected 2 lifetime parameters
+
+error[E0107]: wrong number of lifetime parameters: expected 0, found 1
+ --> $DIR/E0107.rs:24:10
+ |
+24 | bar: Bar<'a>,
+ | ^^^^^^^ unexpected lifetime parameter
+
+error[E0107]: wrong number of lifetime parameters: expected 1, found 3
+ --> $DIR/E0107.rs:27:11
+ |
+27 | foo2: Foo<'a, 'b, 'c>,
+ | ^^^^^^^^^^^^^^^ 2 unexpected lifetime parameters
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+type X = u32<i32>; //~ ERROR E0109
+
+fn main() {
+}
--- /dev/null
+error[E0109]: type parameters are not allowed on this type
+ --> $DIR/E0109.rs:11:14
+ |
+11 | type X = u32<i32>; //~ ERROR E0109
+ | ^^^ type parameter not allowed
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+type X = u32<'static>; //~ ERROR E0110
+
+fn main() {
+}
--- /dev/null
+error[E0110]: lifetime parameters are not allowed on this type
+ --> $DIR/E0110.rs:11:14
+ |
+11 | type X = u32<'static>; //~ ERROR E0110
+ | ^^^^^^^ lifetime parameter not allowed on this type
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+impl Vec<u8> {}
+//~^ ERROR E0116
+
+fn main() {
+}
--- /dev/null
+error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
+ --> $DIR/E0116.rs:11:1
+ |
+11 | impl Vec<u8> {}
+ | ^^^^^^^^^^^^^^^ impl for type defined outside of crate.
+ |
+ = note: define and implement a trait or new type instead
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+impl Drop for u32 {} //~ ERROR E0117
+//~| ERROR the Drop trait may only be implemented on structures
+//~| implementing Drop requires a struct
+
+fn main() {
+}
--- /dev/null
+error[E0120]: the Drop trait may only be implemented on structures
+ --> $DIR/E0117.rs:11:15
+ |
+11 | impl Drop for u32 {} //~ ERROR E0117
+ | ^^^ implementing Drop requires a struct
+
+error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
+ --> $DIR/E0117.rs:11:1
+ |
+11 | impl Drop for u32 {} //~ ERROR E0117
+ | ^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
+ |
+ = note: the impl does not reference any types defined in this crate
+ = note: define and implement a trait or new type instead
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+impl (u8, u8) { //~ ERROR E0118
+ fn get_state(&self) -> String {
+ String::new()
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0118]: no base type found for inherent implementation
+ --> $DIR/E0118.rs:11:6
+ |
+11 | impl (u8, u8) { //~ ERROR E0118
+ | ^^^^^^^^ impl requires a base type
+ |
+ = note: either implement a trait on it or create a newtype to wrap it instead
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait MyTrait {
+ fn get(&self) -> usize;
+}
+
+impl<T> MyTrait for T {
+ fn get(&self) -> usize { 0 }
+}
+
+struct Foo {
+ value: usize
+}
+
+impl MyTrait for Foo { //~ ERROR E0119
+ fn get(&self) -> usize { self.value }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0119]: conflicting implementations of trait `MyTrait` for type `Foo`:
+ --> $DIR/E0119.rs:23:1
+ |
+15 | impl<T> MyTrait for T {
+ | --------------------- first implementation here
+...
+23 | impl MyTrait for Foo { //~ ERROR E0119
+ | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait MyTrait { fn foo() {} }
+
+impl Drop for MyTrait {
+ //~^ ERROR E0120
+ fn drop(&mut self) {}
+}
+
+fn main() {
+}
--- /dev/null
+error[E0120]: the Drop trait may only be implemented on structures
+ --> $DIR/E0120.rs:13:15
+ |
+13 | impl Drop for MyTrait {
+ | ^^^^^^^ implementing Drop requires a struct
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo() -> _ { 5 } //~ ERROR E0121
+
+static BAR: _ = "test"; //~ ERROR E0121
+
+fn main() {
+}
--- /dev/null
+error[E0121]: the type placeholder `_` is not allowed within types on item signatures
+ --> $DIR/E0121.rs:11:13
+ |
+11 | fn foo() -> _ { 5 } //~ ERROR E0121
+ | ^ not allowed in type signatures
+
+error[E0121]: the type placeholder `_` is not allowed within types on item signatures
+ --> $DIR/E0121.rs:13:13
+ |
+13 | static BAR: _ = "test"; //~ ERROR E0121
+ | ^ not allowed in type signatures
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ field1: i32,
+ field1: i32,
+ //~^ ERROR field `field1` is already declared [E0124]
+}
+
+fn main() {
+}
--- /dev/null
+error[E0124]: field `field1` is already declared
+ --> $DIR/E0124.rs:13:5
+ |
+12 | field1: i32,
+ | ----------- `field1` first declared here
+13 | field1: i32,
+ | ^^^^^^^^^^^ field already declared
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo<T=U, U=()> { //~ ERROR E0128
+ field1: T,
+ field2: U,
+}
+
+fn main() {
+}
--- /dev/null
+error[E0128]: type parameters with a default cannot use forward declared identifiers
+ --> $DIR/E0128.rs:11:14
+ |
+11 | struct Foo<T=U, U=()> { //~ ERROR E0128
+ | ^ defaulted type parameters cannot be forward declared
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+extern {
+ fn foo((a, b): (u32, u32));
+ //~^ ERROR E0130
+}
+
+fn main() {
+}
--- /dev/null
+error[E0130]: patterns aren't allowed in foreign function declarations
+ --> $DIR/E0130.rs:12:12
+ |
+12 | fn foo((a, b): (u32, u32));
+ | ^^^^^^ pattern not allowed in foreign function
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main<T>() {
+ //~^ ERROR E0131
+}
--- /dev/null
+error[E0131]: main function is not allowed to have type parameters
+ --> $DIR/E0131.rs:11:8
+ |
+11 | fn main<T>() {
+ | ^^^ main cannot have type parameters
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(start)]
+
+#[start]
+fn f< T >() {} //~ ERROR E0132
+
+fn main() {
+}
--- /dev/null
+error[E0132]: start function is not allowed to have type parameters
+ --> $DIR/E0132.rs:14:5
+ |
+14 | fn f< T >() {} //~ ERROR E0132
+ | ^^^^^ start function cannot have type parameters
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+unsafe fn f() { return; }
+
+fn main() {
+ f();
+ //~^ ERROR E0133
+}
--- /dev/null
+error[E0133]: call to unsafe function requires unsafe function or block
+ --> $DIR/E0133.rs:14:5
+ |
+14 | f();
+ | ^^^ call to unsafe function
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(main)]
+
+#[main]
+fn foo() {}
+
+#[main]
+fn f() {}
+//~^ ERROR E0137
--- /dev/null
+error[E0137]: multiple functions with a #[main] attribute
+ --> $DIR/E0137.rs:17:1
+ |
+14 | fn foo() {}
+ | ----------- first #[main] function
+...
+17 | fn f() {}
+ | ^^^^^^^^^ additional #[main] function
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(start)]
+
+#[start]
+fn foo(argc: isize, argv: *const *const u8) -> isize { 0 }
+
+#[start]
+fn f(argc: isize, argv: *const *const u8) -> isize { 0 }
+//~^ ERROR E0138
--- /dev/null
+error[E0138]: multiple 'start' functions
+ --> $DIR/E0138.rs:17:1
+ |
+14 | fn foo(argc: isize, argv: *const *const u8) -> isize { 0 }
+ | ---------------------------------------------------------- previous `start` function here
+...
+17 | fn f(argc: isize, argv: *const *const u8) -> isize { 0 }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ multiple `start` functions
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(lang_items)]
+
+#[lang = "panic_fmt"]
+struct Foo; //~ ERROR E0152
+
+fn main() {
+}
--- /dev/null
+error[E0152]: duplicate lang item found: `panic_fmt`.
+ --> $DIR/E0152.rs:14:1
+ |
+14 | struct Foo; //~ ERROR E0152
+ | ^^^^^^^^^^^
+ |
+ = note: first defined in crate `std`.
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(box_syntax)]
+
+fn main() {
+ let _x: Box<str> = box *"hello"; //~ ERROR E0161
+ //~^ ERROR E0507
+}
--- /dev/null
+error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
+ --> $DIR/E0161.rs:14:28
+ |
+14 | let _x: Box<str> = box *"hello"; //~ ERROR E0161
+ | ^^^^^^^^
+
+error[E0507]: cannot move out of borrowed content
+ --> $DIR/E0161.rs:14:28
+ |
+14 | let _x: Box<str> = box *"hello"; //~ ERROR E0161
+ | ^^^^^^^^ cannot move out of borrowed content
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Irrefutable(i32);
+
+fn main() {
+ let irr = Irrefutable(0);
+ if let Irrefutable(x) = irr { //~ ERROR E0162
+ println!("{}", x);
+ }
+}
--- /dev/null
+error[E0162]: irrefutable if-let pattern
+ --> $DIR/E0162.rs:15:12
+ |
+15 | if let Irrefutable(x) = irr { //~ ERROR E0162
+ | ^^^^^^^^^^^^^^ irrefutable pattern
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+
+enum Foo {}
+
+impl Foo {
+ const B: u8 = 0;
+}
+
+fn bar(foo: Foo) -> u32 {
+ match foo {
+ Foo::B(i) => i, //~ ERROR E0164
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0164]: expected tuple struct/variant, found associated constant `<Foo>::B`
+ --> $DIR/E0164.rs:20:9
+ |
+20 | Foo::B(i) => i, //~ ERROR E0164
+ | ^^^^^^^^^ not a tuple variant or struct
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Irrefutable(i32);
+
+fn main() {
+ let irr = Irrefutable(0);
+ while let Irrefutable(x) = irr { //~ ERROR E0165
+ //~| irrefutable pattern
+ // ...
+ }
+}
--- /dev/null
+error[E0165]: irrefutable while-let pattern
+ --> $DIR/E0165.rs:15:15
+ |
+15 | while let Irrefutable(x) = irr { //~ ERROR E0165
+ | ^^^^^^^^^^^^^^ irrefutable pattern
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[derive(Copy)] //~ ERROR E0184
+struct Foo;
+
+impl Drop for Foo {
+ fn drop(&mut self) {
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor
+ --> $DIR/E0184.rs:11:10
+ |
+11 | #[derive(Copy)] //~ ERROR E0184
+ | ^^^^ Copy not allowed on types with destructors
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn foo();
+ //~^ NOTE trait method declared without `&self`
+}
+
+struct Bar;
+
+impl Foo for Bar {
+ fn foo(&self) {}
+ //~^ ERROR E0185
+ //~| NOTE `&self` used in impl
+}
+
+fn main() {
+}
--- /dev/null
+error[E0185]: method `foo` has a `&self` declaration in the impl, but not in the trait
+ --> $DIR/E0185.rs:19:5
+ |
+12 | fn foo();
+ | --------- trait method declared without `&self`
+...
+19 | fn foo(&self) {}
+ | ^^^^^^^^^^^^^ `&self` used in impl
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn foo(&self); //~ `&self` used in trait
+}
+
+struct Bar;
+
+impl Foo for Bar {
+ fn foo() {} //~ ERROR E0186
+ //~^ expected `&self` in impl
+}
+
+fn main() {
+}
--- /dev/null
+error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
+ --> $DIR/E0186.rs:18:5
+ |
+12 | fn foo(&self); //~ `&self` used in trait
+ | -------------- `&self` used in trait
+...
+18 | fn foo() {} //~ ERROR E0186
+ | ^^^^^^^^ expected `&self` in impl
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Trait {
+ type Bar;
+}
+
+type Foo = Trait; //~ ERROR E0191
+
+fn main() {
+}
--- /dev/null
+error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified
+ --> $DIR/E0191.rs:15:12
+ |
+15 | type Foo = Trait; //~ ERROR E0191
+ | ^^^^^ missing associated type `Bar` value
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(optin_builtin_traits)]
+
+trait Trait {
+ type Bar;
+}
+
+struct Foo;
+
+impl !Trait for Foo { } //~ ERROR E0192
+
+fn main() {
+}
--- /dev/null
+error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
+ --> $DIR/E0192.rs:19:1
+ |
+19 | impl !Trait for Foo { } //~ ERROR E0192
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo<T> {
+ fn do_something(&self) -> T;
+ fn do_something_else<T: Clone>(&self, bar: T);
+ //~^ ERROR E0194
+}
+
+fn main() {
+}
--- /dev/null
+error[E0194]: type parameter `T` shadows another type parameter of the same name
+ --> $DIR/E0194.rs:13:26
+ |
+11 | trait Foo<T> {
+ | - first `T` declared here
+12 | fn do_something(&self) -> T;
+13 | fn do_something_else<T: Clone>(&self, bar: T);
+ | ^ shadows another type parameter
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Trait {
+ fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
+ //~^ NOTE lifetimes in impl do not match this method in trait
+}
+
+struct Foo;
+
+impl Trait for Foo {
+ fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195
+ //~^ NOTE lifetimes do not match method in trait
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0195]: lifetime parameters or bounds on method `bar` do not match the trait declaration
+ --> $DIR/E0195.rs:19:5
+ |
+12 | fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
+ | ----------------------------------------- lifetimes in impl do not match this method in trait
+...
+19 | fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo;
+
+unsafe impl Foo { } //~ ERROR E0197
+
+fn main() {
+}
--- /dev/null
+error[E0197]: inherent impls cannot be unsafe
+ --> $DIR/E0197.rs:13:1
+ |
+13 | unsafe impl Foo { } //~ ERROR E0197
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(optin_builtin_traits)]
+
+struct Foo;
+
+unsafe impl !Send for Foo { } //~ ERROR E0198
+
+fn main() {
+}
--- /dev/null
+error[E0198]: negative impls cannot be unsafe
+ --> $DIR/E0198.rs:15:1
+ |
+15 | unsafe impl !Send for Foo { } //~ ERROR E0198
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(optin_builtin_traits)]
+
+struct Foo;
+
+trait Bar { }
+unsafe impl Bar for Foo { } //~ ERROR implementing the trait `Bar` is not unsafe [E0199]
+
+fn main() {
+}
--- /dev/null
+error[E0199]: implementing the trait `Bar` is not unsafe
+ --> $DIR/E0199.rs:16:1
+ |
+16 | unsafe impl Bar for Foo { } //~ ERROR implementing the trait `Bar` is not unsafe [E0199]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo;
+
+unsafe trait Bar { }
+
+impl Bar for Foo { } //~ ERROR E0200
+
+fn main() {
+}
--- /dev/null
+error[E0200]: the trait `Bar` requires an `unsafe impl` declaration
+ --> $DIR/E0200.rs:15:1
+ |
+15 | impl Bar for Foo { } //~ ERROR E0200
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo(u8);
+
+impl Foo {
+ fn bar(&self) -> bool { self.0 > 5 }
+ fn bar() {} //~ ERROR E0201
+}
+
+trait Baz {
+ type Quux;
+ fn baz(&self) -> bool;
+}
+
+impl Baz for Foo {
+ type Quux = u32;
+
+ fn baz(&self) -> bool { true }
+ fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201
+ type Quux = u32; //~ ERROR E0201
+}
+
+fn main() {
+}
--- /dev/null
+error[E0201]: duplicate definitions with name `bar`:
+ --> $DIR/E0201.rs:15:5
+ |
+14 | fn bar(&self) -> bool { self.0 > 5 }
+ | ------------------------------------ previous definition of `bar` here
+15 | fn bar() {} //~ ERROR E0201
+ | ^^^^^^^^^^^ duplicate definition
+
+error[E0201]: duplicate definitions with name `baz`:
+ --> $DIR/E0201.rs:27:5
+ |
+26 | fn baz(&self) -> bool { true }
+ | ------------------------------ previous definition of `baz` here
+27 | fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition
+
+error[E0201]: duplicate definitions with name `Quux`:
+ --> $DIR/E0201.rs:28:5
+ |
+24 | type Quux = u32;
+ | ---------------- previous definition of `Quux` here
+...
+28 | type Quux = u32; //~ ERROR E0201
+ | ^^^^^^^^^^^^^^^^ duplicate definition
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+type Foo = i32;
+
+impl Copy for Foo { }
+//~^ ERROR the trait `Copy` may not be implemented for this type
+//~| ERROR only traits defined in the current crate can be implemented for arbitrary types
+
+#[derive(Copy, Clone)]
+struct Bar;
+
+impl Copy for &'static Bar { }
+//~^ ERROR the trait `Copy` may not be implemented for this type
+
+fn main() {
+}
--- /dev/null
+error[E0206]: the trait `Copy` may not be implemented for this type
+ --> $DIR/E0206.rs:13:15
+ |
+13 | impl Copy for Foo { }
+ | ^^^ type is not a structure or enumeration
+
+error[E0206]: the trait `Copy` may not be implemented for this type
+ --> $DIR/E0206.rs:20:15
+ |
+20 | impl Copy for &'static Bar { }
+ | ^^^^^^^^^^^^ type is not a structure or enumeration
+
+error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
+ --> $DIR/E0206.rs:13:1
+ |
+13 | impl Copy for Foo { }
+ | ^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
+ |
+ = note: the impl does not reference any types defined in this crate
+ = note: define and implement a trait or new type instead
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo;
+
+impl<T: Default> Foo { //~ ERROR E0207
+ fn get(&self) -> T {
+ <T as Default>::default()
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/E0207.rs:13:6
+ |
+13 | impl<T: Default> Foo { //~ ERROR E0207
+ | ^ unconstrained type parameter
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let v: Vec(&str) = vec!["foo"];
+ //~^ ERROR E0214
+}
--- /dev/null
+error[E0214]: parenthesized parameters may only be used with a trait
+ --> $DIR/E0214.rs:12:15
+ |
+12 | let v: Vec(&str) = vec!["foo"];
+ | ^^^^^^ only traits may use parentheses
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Trait {
+ type Bar;
+}
+
+type Foo = Trait<F=i32>; //~ ERROR E0220
+ //~| ERROR E0191
+fn main() {
+}
--- /dev/null
+error[E0220]: associated type `F` not found for `Trait`
+ --> $DIR/E0220.rs:15:18
+ |
+15 | type Foo = Trait<F=i32>; //~ ERROR E0220
+ | ^^^^^ associated type `F` not found
+
+error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified
+ --> $DIR/E0220.rs:15:12
+ |
+15 | type Foo = Trait<F=i32>; //~ ERROR E0220
+ | ^^^^^^^^^^^^ missing associated type `Bar` value
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait T1 {}
+trait T2 {}
+
+trait Foo {
+ type A: T1;
+}
+
+trait Bar : Foo {
+ type A: T2;
+ fn do_something() {
+ let _: Self::A;
+ //~^ ERROR E0221
+ }
+}
+
+trait T3 {}
+
+trait My : std::str::FromStr {
+ type Err: T3;
+ fn test() {
+ let _: Self::Err;
+ //~^ ERROR E0221
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0221]: ambiguous associated type `A` in bounds of `Self`
+ --> $DIR/E0221.rs:21:16
+ |
+15 | type A: T1;
+ | ----------- ambiguous `A` from `Foo`
+...
+19 | type A: T2;
+ | ----------- ambiguous `A` from `Bar`
+20 | fn do_something() {
+21 | let _: Self::A;
+ | ^^^^^^^ ambiguous associated type `A`
+
+error[E0221]: ambiguous associated type `Err` in bounds of `Self`
+ --> $DIR/E0221.rs:31:16
+ |
+29 | type Err: T3;
+ | ------------- ambiguous `Err` from `My`
+30 | fn test() {
+31 | let _: Self::Err;
+ | ^^^^^^^^^ ambiguous associated type `Err`
+ |
+note: associated type `Self` could derive from `std::str::FromStr`
+ --> $DIR/E0221.rs:31:16
+ |
+31 | let _: Self::Err;
+ | ^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait MyTrait { type X; }
+
+fn main() {
+ let foo: MyTrait::X;
+ //~^ ERROR ambiguous associated type
+}
--- /dev/null
+error[E0223]: ambiguous associated type
+ --> $DIR/E0223.rs:14:14
+ |
+14 | let foo: MyTrait::X;
+ | ^^^^^^^^^^ ambiguous associated type
+ |
+ = note: specify the type using the syntax `<Type as MyTrait>::X`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let _: Box<std::io::Read + std::io::Write>;
+ //~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+}
--- /dev/null
+error[E0225]: only auto traits can be used as additional traits in a trait object
+ --> $DIR/E0225.rs:12:32
+ |
+12 | let _: Box<std::io::Read + std::io::Write>;
+ | ^^^^^^^^^^^^^^ non-auto additional trait
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+pub trait Foo {
+ type A;
+ fn boo(&self) -> <Self as Foo>::A;
+}
+
+struct Bar;
+
+impl Foo for isize {
+ type A = usize;
+ fn boo(&self) -> usize { 42 }
+}
+
+fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
+//~^ ERROR associated type bindings are not allowed here [E0229]
+
+fn main() {
+}
--- /dev/null
+error[E0229]: associated type bindings are not allowed here
+ --> $DIR/E0229.rs:23:25
+ |
+23 | fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
+ | ^^^^^ associated type not allowed here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(on_unimplemented)]
+
+#[rustc_on_unimplemented]
+//~^ ERROR E0232
+trait Bar {}
+
+fn main() {
+}
--- /dev/null
+error[E0232]: `#[rustc_on_unimplemented]` requires a value
+ --> $DIR/E0232.rs:13:1
+ |
+13 | #[rustc_on_unimplemented]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ value required here
+ |
+ = note: eg `#[rustc_on_unimplemented = "foo"]`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo<T> { x: T }
+struct Bar { x: Foo }
+ //~^ ERROR wrong number of type arguments: expected 1, found 0 [E0243]
+
+fn main() {
+}
--- /dev/null
+error[E0243]: wrong number of type arguments: expected 1, found 0
+ --> $DIR/E0243.rs:12:17
+ |
+12 | struct Bar { x: Foo }
+ | ^^^ expected 1 type argument
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo { x: bool }
+struct Bar<S, T> { x: Foo<S, T> }
+ //~^ ERROR wrong number of type arguments: expected 0, found 2 [E0244]
+
+
+fn main() {
+}
--- /dev/null
+error[E0244]: wrong number of type arguments: expected 0, found 2
+ --> $DIR/E0244.rs:12:23
+ |
+12 | struct Bar<S, T> { x: Foo<S, T> }
+ | ^^^^^^^^^ expected no type arguments
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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 foo::baz;
+use bar::baz; //~ ERROR E0252
+
+mod foo {
+ pub struct baz;
+}
+
+mod bar {
+ pub mod baz {}
+}
+
+fn main() {
+}
--- /dev/null
+error[E0252]: the name `baz` is defined multiple times
+ --> $DIR/E0252.rs:12:5
+ |
+11 | use foo::baz;
+ | -------- previous import of the type `baz` here
+12 | use bar::baz; //~ ERROR E0252
+ | ^^^^^^^^ `baz` reimported here
+ |
+ = note: `baz` must be defined only once in the type namespace of this module
+help: You can use `as` to change the binding name of the import
+ |
+12 | use bar::baz as other_baz; //~ ERROR E0252
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod foo {
+ pub trait MyTrait {
+ fn do_something();
+ }
+}
+
+use foo::MyTrait::do_something;
+ //~^ ERROR E0253
+
+fn main() {}
--- /dev/null
+error[E0253]: `do_something` is not directly importable
+ --> $DIR/E0253.rs:17:5
+ |
+17 | use foo::MyTrait::do_something;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(alloc)]
+#![allow(unused_extern_crates)]
+
+extern crate alloc;
+
+mod foo {
+ pub trait alloc {
+ fn do_something();
+ }
+}
+
+use foo::alloc;
+//~^ ERROR E0254
+
+fn main() {}
--- /dev/null
+error[E0254]: the name `alloc` is defined multiple times
+ --> $DIR/E0254.rs:22:5
+ |
+14 | extern crate alloc;
+ | ------------------- previous import of the extern crate `alloc` here
+...
+22 | use foo::alloc;
+ | ^^^^^^^^^^ `alloc` reimported here
+ |
+ = note: `alloc` must be defined only once in the type namespace of this module
+help: You can use `as` to change the binding name of the import
+ |
+22 | use foo::alloc as other_alloc;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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 bar::foo;
+
+fn foo() {} //~ ERROR E0255
+
+mod bar {
+ pub fn foo() {}
+}
+
+fn main() {}
--- /dev/null
+error[E0255]: the name `foo` is defined multiple times
+ --> $DIR/E0255.rs:13:1
+ |
+11 | use bar::foo;
+ | -------- previous import of the value `foo` here
+12 |
+13 | fn foo() {} //~ ERROR E0255
+ | ^^^^^^^^ `foo` redefined here
+ |
+ = note: `foo` must be defined only once in the value namespace of this module
+help: You can use `as` to change the binding name of the import
+ |
+11 | use bar::foo as other_foo;
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(alloc, libc)]
+#![allow(unused_extern_crates)]
+
+extern crate alloc;
+
+extern crate libc as alloc;
+//~^ ERROR E0259
+
+fn main() {}
--- /dev/null
+error[E0259]: the name `alloc` is defined multiple times
+ --> $DIR/E0259.rs:16:1
+ |
+14 | extern crate alloc;
+ | ------------------- previous import of the extern crate `alloc` here
+15 |
+16 | extern crate libc as alloc;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | `alloc` reimported here
+ | You can use `as` to change the binding name of the import
+ |
+ = note: `alloc` must be defined only once in the type namespace of this module
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(alloc)]
+#![allow(unused_extern_crates)]
+
+extern crate alloc;
+
+mod alloc {
+//~^ ERROR the name `alloc` is defined multiple times [E0260]
+ pub trait MyTrait {
+ fn do_something();
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0260]: the name `alloc` is defined multiple times
+ --> $DIR/E0260.rs:16:1
+ |
+14 | extern crate alloc;
+ | ------------------- previous import of the extern crate `alloc` here
+15 |
+16 | mod alloc {
+ | ^^^^^^^^^ `alloc` redefined here
+ |
+ = note: `alloc` must be defined only once in the type namespace of this module
+help: You can use `as` to change the binding name of the import
+ |
+14 | extern crate alloc as other_alloc;
+ |
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo(x: &'a str) { } //~ ERROR E0261
+ //~| undeclared lifetime
+
+struct Foo {
+ x: &'a str, //~ ERROR E0261
+ //~| undeclared lifetime
+}
+
+fn main() {}
--- /dev/null
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/E0261.rs:11:12
+ |
+11 | fn foo(x: &'a str) { } //~ ERROR E0261
+ | ^^ undeclared lifetime
+
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/E0261.rs:15:9
+ |
+15 | x: &'a str, //~ ERROR E0261
+ | ^^ undeclared lifetime
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo<'static>(x: &'static str) { } //~ ERROR E0262
+ //~| 'static is a reserved lifetime name
+
+fn main() {}
--- /dev/null
+error[E0262]: invalid lifetime parameter name: `'static`
+ --> $DIR/E0262.rs:11:8
+ |
+11 | fn foo<'static>(x: &'static str) { } //~ ERROR E0262
+ | ^^^^^^^ 'static is a reserved lifetime name
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) {
+ //~^ ERROR E0263
+}
+
+fn main() {}
--- /dev/null
+error[E0263]: lifetime name `'a` declared twice in the same scope
+ --> $DIR/E0263.rs:11:16
+ |
+11 | fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) {
+ | -- ^^ declared twice
+ | |
+ | previous declaration here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(lang_items)]
+
+extern "C" {
+ #[lang = "cake"]
+ fn cake(); //~ ERROR E0264
+}
+
+fn main() {}
--- /dev/null
+error[E0264]: unknown external lang item: `cake`
+ --> $DIR/E0264.rs:15:5
+ |
+15 | fn cake(); //~ ERROR E0264
+ | ^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let w = || { break; }; //~ ERROR E0267
+}
--- /dev/null
+error[E0267]: `break` inside of a closure
+ --> $DIR/E0267.rs:12:18
+ |
+12 | let w = || { break; }; //~ ERROR E0267
+ | ^^^^^ cannot break inside of a closure
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ break; //~ ERROR E0268
+}
--- /dev/null
+error[E0268]: `break` outside of loop
+ --> $DIR/E0268.rs:12:5
+ |
+12 | break; //~ ERROR E0268
+ | ^^^^^ cannot break outside of a loop
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Trait { type AssociatedType; }
+
+fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
+ println!("in foo");
+}
+
+impl Trait for i8 { type AssociatedType = &'static str; }
+
+fn main() {
+ foo(3_i8); //~ ERROR E0271
+}
--- /dev/null
+error[E0271]: type mismatch resolving `<i8 as Trait>::AssociatedType == u32`
+ --> $DIR/E0271.rs:20:5
+ |
+20 | foo(3_i8); //~ ERROR E0271
+ | ^^^ expected reference, found u32
+ |
+ = note: expected type `&'static str`
+ found type `u32`
+note: required by `foo`
+ --> $DIR/E0271.rs:13:1
+ |
+13 | fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {}
+
+struct Bar<T>(T);
+
+impl<T> Foo for T where Bar<T>: Foo {} //~ ERROR E0275
+
+fn main() {
+}
--- /dev/null
+error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: std::marker::Sized`
+ --> $DIR/E0275.rs:15:1
+ |
+15 | impl<T> Foo for T where Bar<T>: Foo {} //~ ERROR E0275
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: consider adding a `#![recursion_limit="128"]` attribute to your crate
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<Bar<T>>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<Bar<T>>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<Bar<T>>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<Bar<T>>`
+ = note: required because of the requirements on the impl of `Foo` for `Bar<T>`
+note: required by `Foo`
+ --> $DIR/E0275.rs:11:1
+ |
+11 | trait Foo {}
+ | ^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn foo<T>(x: T);
+}
+
+impl Foo for bool {
+ fn foo<T>(x: T) where T: Copy {} //~ ERROR E0276
+}
+
+fn main() {
+}
--- /dev/null
+error[E0276]: impl has stricter requirements than trait
+ --> $DIR/E0276.rs:16:5
+ |
+12 | fn foo<T>(x: T);
+ | ---------------- definition of `foo` from trait
+...
+16 | fn foo<T>(x: T) where T: Copy {} //~ ERROR E0276
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::marker::Copy`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ bar: Bar
+}
+
+struct Bar {
+ baz: Baz
+}
+
+struct Baz {
+ x: *const u8
+}
+
+fn is_send<T: Send>() { }
+
+fn main() {
+ is_send::<Foo>();
+ //~^ ERROR the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo`
+}
--- /dev/null
+error[E0277]: the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo`
+ --> $DIR/E0277-2.rs:26:5
+ |
+26 | is_send::<Foo>();
+ | ^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely
+ |
+ = help: within `Foo`, the trait `std::marker::Send` is not implemented for `*const u8`
+ = note: required because it appears within the type `Baz`
+ = note: required because it appears within the type `Bar`
+ = note: required because it appears within the type `Foo`
+note: required by `is_send`
+ --> $DIR/E0277-2.rs:23:1
+ |
+23 | fn is_send<T: Send>() { }
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// ignore-cloudabi no std::path
+
+use std::path::Path;
+
+trait Foo {
+ fn bar(&self);
+}
+
+fn some_func<T: Foo>(foo: T) {
+ foo.bar();
+}
+
+fn f(p: Path) { }
+//~^ ERROR the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path`
+
+fn main() {
+ some_func(5i32);
+ //~^ ERROR the trait bound `i32: Foo` is not satisfied
+}
--- /dev/null
+error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path`
+ --> $DIR/E0277.rs:23:6
+ |
+23 | fn f(p: Path) { }
+ | ^ `[u8]` does not have a constant size known at compile-time
+ |
+ = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]`
+ = note: required because it appears within the type `std::path::Path`
+ = note: all local variables must have a statically known size
+
+error[E0277]: the trait bound `i32: Foo` is not satisfied
+ --> $DIR/E0277.rs:27:5
+ |
+27 | some_func(5i32);
+ | ^^^^^^^^^ the trait `Foo` is not implemented for `i32`
+ |
+note: required by `some_func`
+ --> $DIR/E0277.rs:19:1
+ |
+19 | fn some_func<T: Foo>(foo: T) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = "hello".chars().rev().collect(); //~ ERROR E0282
+}
--- /dev/null
+error[E0282]: type annotations needed
+ --> $DIR/E0282.rs:12:9
+ |
+12 | let x = "hello".chars().rev().collect(); //~ ERROR E0282
+ | ^
+ | |
+ | cannot infer type for `_`
+ | consider giving `x` a type
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Generator {
+ fn create() -> u32;
+}
+
+struct Impl;
+
+impl Generator for Impl {
+ fn create() -> u32 { 1 }
+}
+
+struct AnotherImpl;
+
+impl Generator for AnotherImpl {
+ fn create() -> u32 { 2 }
+}
+
+fn main() {
+ let cont: u32 = Generator::create(); //~ ERROR E0283
+}
--- /dev/null
+error[E0283]: type annotations required: cannot resolve `_: Generator`
+ --> $DIR/E0283.rs:28:21
+ |
+28 | let cont: u32 = Generator::create(); //~ ERROR E0283
+ | ^^^^^^^^^^^^^^^^^
+ |
+note: required by `Generator::create`
+ --> $DIR/E0283.rs:12:5
+ |
+12 | fn create() -> u32;
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![recursion_limit] //~ ERROR E0296
+
+fn main() {}
--- /dev/null
+error[E0296]: malformed recursion limit attribute, expected #![recursion_limit="N"]
+ --> $DIR/E0296.rs:11:1
+ |
+11 | #![recursion_limit] //~ ERROR E0296
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let xs : Vec<Option<i32>> = vec![Some(1), None];
+
+ for Some(x) in xs {}
+ //~^ ERROR E0005
+}
--- /dev/null
+error[E0005]: refutable pattern in `for` loop binding: `None` not covered
+ --> $DIR/E0297.rs:14:9
+ |
+14 | for Some(x) in xs {}
+ | ^^^^^^^ pattern `None` not covered
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ match Some(()) {
+ None => { },
+ option if option.take().is_none() => {}, //~ ERROR E0301
+ Some(_) => { }
+ }
+}
--- /dev/null
+error[E0301]: cannot mutably borrow in a pattern guard
+ --> $DIR/E0301.rs:14:19
+ |
+14 | option if option.take().is_none() => {}, //~ ERROR E0301
+ | ^^^^^^ borrowed mutably in pattern guard
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ match Some(()) {
+ None => { },
+ option if { option = None; false } => { }, //~ ERROR E0302
+ Some(_) => { }
+ }
+}
--- /dev/null
+error[E0302]: cannot assign in a pattern guard
+ --> $DIR/E0302.rs:14:21
+ |
+14 | option if { option = None; false } => { }, //~ ERROR E0302
+ | ^^^^^^^^^^^^^ assignment in pattern guard
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ match Some("hi".to_string()) {
+ ref op_string_ref @ Some(s) => {},
+ //~^ ERROR pattern bindings are not allowed after an `@` [E0303]
+ //~| ERROR E0009
+ None => {},
+ }
+}
--- /dev/null
+error[E0009]: cannot bind by-move and by-ref in the same pattern
+ --> $DIR/E0303.rs:13:34
+ |
+13 | ref op_string_ref @ Some(s) => {},
+ | -------------------------^-
+ | | |
+ | | by-move pattern here
+ | both by-ref and by-move used
+
+error[E0303]: pattern bindings are not allowed after an `@`
+ --> $DIR/E0303.rs:13:34
+ |
+13 | ref op_string_ref @ Some(s) => {},
+ | ^ not allowed after `@`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = 1u8;
+ match x {
+ 0u8...3i8 => (), //~ ERROR E0308
+ _ => ()
+ }
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/E0308-4.rs:14:9
+ |
+14 | 0u8...3i8 => (), //~ ERROR E0308
+ | ^^^^^^^^^ expected u8, found i8
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(intrinsics)]
+
+extern "rust-intrinsic" {
+ fn size_of<T>(); //~ ERROR E0308
+}
+
+fn main() {
+}
--- /dev/null
+error[E0308]: intrinsic has wrong type
+ --> $DIR/E0308.rs:14:5
+ |
+14 | fn size_of<T>(); //~ ERROR E0308
+ | ^^^^^^^^^^^^^^^^ expected (), found usize
+ |
+ = note: expected type `unsafe extern "rust-intrinsic" fn()`
+ found type `unsafe extern "rust-intrinsic" fn() -> usize`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod foo {
+ pub const X: u32 = 1;
+}
+
+pub use foo as foo2;
+//~^ ERROR `foo` is private, and cannot be re-exported [E0365]
+
+fn main() {}
--- /dev/null
+error[E0365]: `foo` is private, and cannot be re-exported
+ --> $DIR/E0365.rs:15:9
+ |
+15 | pub use foo as foo2;
+ | ^^^^^^^^^^^ re-export of private `foo`
+ |
+ = note: consider declaring type or module `foo` with `pub`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![allow(dead_code)]
+
+#[deny(overflowing_literals)]
+#[repr(i64)]
+enum Foo {
+ X = 0x7fffffffffffffff,
+ Y, //~ ERROR E0370
+}
+
+fn main() {}
--- /dev/null
+error[E0370]: enum discriminant overflowed
+ --> $DIR/E0370.rs:17:5
+ |
+17 | Y, //~ ERROR E0370
+ | ^ overflowed on value after 9223372036854775807i64
+ |
+ = note: explicitly set `Y = -9223372036854775808i64` if that is desired outcome
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(coerce_unsized)]
+use std::ops::CoerceUnsized;
+
+struct Foo<T: ?Sized> {
+ a: i32,
+}
+
+impl<T, U> CoerceUnsized<Foo<U>> for Foo<T> //~ ERROR E0374
+ where T: CoerceUnsized<U> {}
+
+fn main() {}
--- /dev/null
+error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced, none found
+ --> $DIR/E0374.rs:18:1
+ |
+18 | / impl<T, U> CoerceUnsized<Foo<U>> for Foo<T> //~ ERROR E0374
+19 | | where T: CoerceUnsized<U> {}
+ | |________________________________^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// ignore-tidy-linelength
+
+#![feature(coerce_unsized)]
+use std::ops::CoerceUnsized;
+
+struct Foo<T: ?Sized, U: ?Sized> {
+ a: i32,
+ b: T,
+ c: U,
+}
+
+impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
+//~^ ERROR E0375
+
+fn main() {}
--- /dev/null
+error[E0375]: implementing the trait `CoerceUnsized` requires multiple coercions
+ --> $DIR/E0375.rs:22:12
+ |
+22 | impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions
+ |
+ = note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced
+ = note: currently, 2 fields need coercions: b (T to U), c (U to T)
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(coerce_unsized)]
+use std::ops::CoerceUnsized;
+
+struct Foo<T: ?Sized> {
+ a: T,
+}
+
+impl<T, U> CoerceUnsized<U> for Foo<T> {} //~ ERROR E0376
+
+fn main() {}
--- /dev/null
+error[E0376]: the trait `CoerceUnsized` may only be implemented for a coercion between structures
+ --> $DIR/E0376.rs:18:1
+ |
+18 | impl<T, U> CoerceUnsized<U> for Foo<T> {} //~ ERROR E0376
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+static X: i32 = 1;
+const C: i32 = 2;
+
+const CR: &'static mut i32 = &mut C; //~ ERROR E0017
+static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+ //~| ERROR cannot borrow
+static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
+
+fn main() {}
--- /dev/null
+error[E0017]: references in constants may only refer to immutable values
+ --> $DIR/E0388.rs:14:30
+ |
+14 | const CR: &'static mut i32 = &mut C; //~ ERROR E0017
+ | ^^^^^^ constants require immutable values
+
+error[E0017]: references in statics may only refer to immutable values
+ --> $DIR/E0388.rs:15:39
+ |
+15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+ | ^^^^^^ statics require immutable values
+
+error[E0596]: cannot borrow immutable static item as mutable
+ --> $DIR/E0388.rs:15:44
+ |
+15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
+ | ^
+
+error[E0017]: references in statics may only refer to immutable values
+ --> $DIR/E0388.rs:17:38
+ |
+17 | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
+ | ^^^^^^ statics require immutable values
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct FancyNum {
+ num: u8,
+}
+
+fn main() {
+ let mut fancy = FancyNum{ num: 5 };
+ let fancy_ref = &(&mut fancy);
+ fancy_ref.num = 6; //~ ERROR E0389
+ println!("{}", fancy_ref.num);
+}
--- /dev/null
+error[E0389]: cannot assign to data in a `&` reference
+ --> $DIR/E0389.rs:18:5
+ |
+18 | fancy_ref.num = 6; //~ ERROR E0389
+ | ^^^^^^^^^^^^^^^^^ assignment into an immutable reference
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ x: i32
+}
+
+impl *mut Foo {} //~ ERROR E0390
+
+fn main() {
+}
--- /dev/null
+error[E0390]: only a single inherent implementation marked with `#[lang = "mut_ptr"]` is allowed for the `*mut T` primitive
+ --> $DIR/E0390.rs:15:1
+ |
+15 | impl *mut Foo {} //~ ERROR E0390
+ | ^^^^^^^^^^^^^^^^
+ |
+help: consider using a trait to implement these methods
+ --> $DIR/E0390.rs:15:1
+ |
+15 | impl *mut Foo {} //~ ERROR E0390
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum Foo<T> { Bar } //~ ERROR E0392
+
+fn main() {
+}
--- /dev/null
+error[E0392]: parameter `T` is never used
+ --> $DIR/E0392.rs:11:10
+ |
+11 | enum Foo<T> { Bar } //~ ERROR E0392
+ | ^ unused type parameter
+ |
+ = help: consider removing `T` or using a marker such as `std::marker::PhantomData`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait A<T=Self> {}
+
+fn together_we_will_rule_the_galaxy(son: &A) {}
+//~^ ERROR E0393
+
+fn main() {
+}
--- /dev/null
+error[E0393]: the type parameter `T` must be explicitly specified
+ --> $DIR/E0393.rs:13:43
+ |
+13 | fn together_we_will_rule_the_galaxy(son: &A) {}
+ | ^ missing reference to `T`
+ |
+ = note: because of the default `Self` reference, type parameters must be specified on object types
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![allow(warnings)]
+
+static A: u32 = 0;
+static B: u32 = A;
+//~^ ERROR E0394
+
+fn main() {
+}
--- /dev/null
+error[E0394]: cannot refer to other statics by value, use the address-of operator or a constant instead
+ --> $DIR/E0394.rs:14:17
+ |
+14 | static B: u32 = A;
+ | ^ referring to another static by value
+ |
+ = note: use the address-of operator or a constant instead
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+static FOO: i32 = 42;
+static BAR: i32 = 42;
+
+static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395
+fn main() {
+}
--- /dev/null
+error[E0395]: raw pointers cannot be compared in statics
+ --> $DIR/E0395.rs:14:22
+ |
+14 | static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comparing raw pointers in static
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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 REG_ADDR: *const u8 = 0x5f3759df as *const u8;
+
+const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396
+
+fn main() {
+}
--- /dev/null
+error[E0396]: raw pointers cannot be dereferenced in constants
+ --> $DIR/E0396.rs:13:28
+ |
+13 | const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396
+ | ^^^^^^^^^ dereference of raw pointer in constant
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo<T>(x: T) {
+ fn bar(y: T) { //~ ERROR E0401
+ }
+ bar(x);
+}
+
+fn main() {
+}
--- /dev/null
+error[E0401]: can't use type parameters from outer function; try using a local type parameter instead
+ --> $DIR/E0401.rs:12:15
+ |
+12 | fn bar(y: T) { //~ ERROR E0401
+ | ^ use of type variable from outer function
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo<T, T>(s: T, u: T) {} //~ ERROR E0403
+
+fn main() {
+}
--- /dev/null
+error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+ --> $DIR/E0403.rs:11:11
+ |
+11 | fn foo<T, T>(s: T, u: T) {} //~ ERROR E0403
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo;
+struct Bar;
+
+impl Foo for Bar {} //~ ERROR E0404
+
+fn main() {
+}
--- /dev/null
+error[E0404]: expected trait, found struct `Foo`
+ --> $DIR/E0404.rs:14:6
+ |
+14 | impl Foo for Bar {} //~ ERROR E0404
+ | ^^^ not a trait
+
+error: cannot continue compilation due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo;
+
+impl SomeTrait for Foo {} //~ ERROR E0405
+
+fn main() {
+}
--- /dev/null
+error[E0405]: cannot find trait `SomeTrait` in this scope
+ --> $DIR/E0405.rs:13:6
+ |
+13 | impl SomeTrait for Foo {} //~ ERROR E0405
+ | ^^^^^^^^^ not found in this scope
+
+error: cannot continue compilation due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn a();
+}
+
+struct Bar;
+
+impl Foo for Bar {
+ fn a() {}
+ fn b() {}
+ //~^ ERROR E0407
+}
+
+fn main() {
+}
--- /dev/null
+error[E0407]: method `b` is not a member of trait `Foo`
+ --> $DIR/E0407.rs:19:5
+ |
+19 | fn b() {}
+ | ^^^^^^^^^ not a member of trait `Foo`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = Some(0);
+
+ match x {
+ Some(y) | None => {} //~ ERROR variable `y` is not bound in all patterns
+ _ => ()
+ }
+}
--- /dev/null
+error[E0408]: variable `y` is not bound in all patterns
+ --> $DIR/E0408.rs:15:19
+ |
+15 | Some(y) | None => {} //~ ERROR variable `y` is not bound in all patterns
+ | - ^^^^ pattern doesn't bind `y`
+ | |
+ | variable not in all patterns
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ <Self>::foo; //~ ERROR E0411
+}
--- /dev/null
+error[E0411]: cannot find type `Self` in this scope
+ --> $DIR/E0411.rs:12:6
+ |
+12 | <Self>::foo; //~ ERROR E0411
+ | ^^^^ `Self` is only available in traits and impls
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+impl Something {} //~ ERROR E0412
+
+fn main() {
+}
--- /dev/null
+error[E0412]: cannot find type `Something` in this scope
+ --> $DIR/E0412.rs:11:6
+ |
+11 | impl Something {} //~ ERROR E0412
+ | ^^^^^^^^^ not found in this scope
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo(f: i32, f: i32) {} //~ ERROR E0415
+
+fn main() {
+}
--- /dev/null
+error[E0415]: identifier `f` is bound more than once in this parameter list
+ --> $DIR/E0415.rs:11:16
+ |
+11 | fn foo(f: i32, f: i32) {} //~ ERROR E0415
+ | ^ used as parameter more than once
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ match (1, 2) {
+ (x, x) => {} //~ ERROR E0416
+ }
+}
--- /dev/null
+error[E0416]: identifier `x` is bound more than once in the same pattern
+ --> $DIR/E0416.rs:13:13
+ |
+13 | (x, x) => {} //~ ERROR E0416
+ | ^ used in a pattern more than once
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main () {
+ struct Foo { a: bool };
+
+ let f = Foo(); //~ ERROR E0423
+}
--- /dev/null
+error[E0423]: expected function, found struct `Foo`
+ --> $DIR/E0423.rs:14:13
+ |
+14 | let f = Foo(); //~ ERROR E0423
+ | ^^^ did you mean `Foo { /* fields */ }`?
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo;
+
+impl Foo {
+ fn bar(self) {}
+
+ fn foo() {
+ self.bar(); //~ ERROR E0424
+ }
+}
+
+fn main () {
+}
--- /dev/null
+error[E0424]: expected value, found module `self`
+ --> $DIR/E0424.rs:17:9
+ |
+17 | self.bar(); //~ ERROR E0424
+ | ^^^^ `self` value is only available in methods with `self` parameter
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn bar() {
+ elf; //~ ERROR E0425
+ }
+}
+
+fn main () {
+}
--- /dev/null
+error[E0425]: cannot find value `elf` in this scope
+ --> $DIR/E0425.rs:13:9
+ |
+13 | elf; //~ ERROR E0425
+ | ^^^ not found in this scope
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main () {
+ loop {
+ break 'a;
+ //~^ ERROR E0426
+ }
+}
--- /dev/null
+error[E0426]: use of undeclared label `'a`
+ --> $DIR/E0426.rs:13:15
+ |
+13 | break 'a;
+ | ^^ undeclared label `'a`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Bar; //~ previous definition of the type `Bar` here
+struct Bar; //~ ERROR E0428
+
+fn main () {
+}
--- /dev/null
+error[E0428]: the name `Bar` is defined multiple times
+ --> $DIR/E0428.rs:12:1
+ |
+11 | struct Bar; //~ previous definition of the type `Bar` here
+ | ----------- previous definition of the type `Bar` here
+12 | struct Bar; //~ ERROR E0428
+ | ^^^^^^^^^^^ `Bar` redefined here
+ |
+ = note: `Bar` must be defined only once in the type namespace of this module
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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::fmt::self; //~ ERROR E0429
+
+fn main () {
+}
--- /dev/null
+error[E0429]: `self` imports are only allowed within a { } list
+ --> $DIR/E0429.rs:11:5
+ |
+11 | use std::fmt::self; //~ ERROR E0429
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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::fmt::{self, self}; //~ ERROR E0430
+ //~^ ERROR E0252
+
+fn main () {
+}
--- /dev/null
+error[E0430]: `self` import can only appear once in an import list
+ --> $DIR/E0430.rs:11:16
+ |
+11 | use std::fmt::{self, self}; //~ ERROR E0430
+ | ^^^^ ---- another `self` import appears here
+ | |
+ | can only appear once in an import list
+
+error[E0252]: the name `fmt` is defined multiple times
+ --> $DIR/E0430.rs:11:22
+ |
+11 | use std::fmt::{self, self}; //~ ERROR E0430
+ | ---- ^^^^ `fmt` reimported here
+ | |
+ | previous import of the module `fmt` here
+ |
+ = note: `fmt` must be defined only once in the type namespace of this module
+help: You can use `as` to change the binding name of the import
+ |
+11 | use std::fmt::{self, self as other_fmt}; //~ ERROR E0430
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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 {self}; //~ ERROR E0431
+
+fn main () {
+}
--- /dev/null
+error[E0431]: `self` import can only appear in an import list with a non-empty prefix
+ --> $DIR/E0431.rs:11:6
+ |
+11 | use {self}; //~ ERROR E0431
+ | ^^^^ can only appear in an import list with a non-empty prefix
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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 something::Foo; //~ ERROR E0432
+
+fn main () {
+}
--- /dev/null
+error[E0432]: unresolved import `something`
+ --> $DIR/E0432.rs:11:5
+ |
+11 | use something::Foo; //~ ERROR E0432
+ | ^^^^^^^^^ Maybe a missing `extern crate something;`?
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main () {
+ let map = HashMap::new(); //~ ERROR E0433
+}
--- /dev/null
+error[E0433]: failed to resolve. Use of undeclared type or module `HashMap`
+ --> $DIR/E0433.rs:12:15
+ |
+12 | let map = HashMap::new(); //~ ERROR E0433
+ | ^^^^^^^ Use of undeclared type or module `HashMap`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn foo() {
+ let y = 5;
+ fn bar() -> u32 {
+ y //~ ERROR E0434
+ }
+}
+
+fn main () {
+}
--- /dev/null
+error[E0434]: can't capture dynamic environment in a fn item
+ --> $DIR/E0434.rs:14:9
+ |
+14 | y //~ ERROR E0434
+ | ^
+ |
+ = help: use the `|| { ... }` closure form instead
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main () {
+ let foo = 42u32;
+ let _: [u8; foo]; //~ ERROR E0435
+}
--- /dev/null
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/E0435.rs:13:17
+ |
+13 | let _: [u8; foo]; //~ ERROR E0435
+ | ^^^ non-constant value
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {}
+
+impl Foo for i32 {
+ type Bar = bool; //~ ERROR E0437
+}
+
+fn main () {
+}
--- /dev/null
+error[E0437]: type `Bar` is not a member of trait `Foo`
+ --> $DIR/E0437.rs:14:5
+ |
+14 | type Bar = bool; //~ ERROR E0437
+ | ^^^^^^^^^^^^^^^^ not a member of trait `Foo`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+
+trait Bar {}
+
+impl Bar for i32 {
+ const BAR: bool = true; //~ ERROR E0438
+}
+
+fn main () {
+}
--- /dev/null
+error[E0438]: const `BAR` is not a member of trait `Bar`
+ --> $DIR/E0438.rs:15:5
+ |
+15 | const BAR: bool = true; //~ ERROR E0438
+ | ^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Bar`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(platform_intrinsics)]
+
+extern "platform-intrinsic" {
+ fn simd_shuffle<A,B>(a: A, b: A, c: [u32; 8]) -> B; //~ ERROR E0439
+}
+
+fn main () {
+}
--- /dev/null
+error[E0439]: invalid `simd_shuffle`, needs length: `simd_shuffle`
+ --> $DIR/E0439.rs:14:5
+ |
+14 | fn simd_shuffle<A,B>(a: A, b: A, c: [u32; 8]) -> B; //~ ERROR E0439
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct f64x2(f64, f64);
+
+extern "platform-intrinsic" {
+ fn x86_mm_movemask_pd<T>(x: f64x2) -> i32; //~ ERROR E0440
+}
+
+fn main () {
+}
--- /dev/null
+error[E0440]: platform-specific intrinsic has wrong number of type parameters: found 1, expected 0
+ --> $DIR/E0440.rs:18:5
+ |
+18 | fn x86_mm_movemask_pd<T>(x: f64x2) -> i32; //~ ERROR E0440
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
+
+extern "platform-intrinsic" {
+ fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441
+}
+
+fn main() {}
--- /dev/null
+error[E0441]: unrecognized platform-specific intrinsic function: `x86_mm_adds_ep16`
+ --> $DIR/E0441.rs:18:5
+ |
+18 | fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
+ i8, i8, i8, i8, i8, i8, i8, i8);
+#[repr(simd)]
+struct i32x4(i32, i32, i32, i32);
+#[repr(simd)]
+struct i64x2(i64, i64);
+
+extern "platform-intrinsic" {
+ fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
+ //~^ ERROR E0442
+ //~| ERROR E0442
+ //~| ERROR E0442
+}
+
+fn main() {}
--- /dev/null
+error[E0442]: intrinsic argument 1 has wrong type: found vector with length 16, expected length 8
+ --> $DIR/E0442.rs:23:5
+ |
+23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0442]: intrinsic argument 2 has wrong type: found vector with length 4, expected length 8
+ --> $DIR/E0442.rs:23:5
+ |
+23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0442]: intrinsic return value has wrong type: found vector with length 2, expected length 8
+ --> $DIR/E0442.rs:23:5
+ |
+23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
+#[repr(simd)]
+struct i64x8(i64, i64, i64, i64, i64, i64, i64, i64);
+
+extern "platform-intrinsic" {
+ fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443
+}
+
+fn main() {}
--- /dev/null
+error[E0443]: intrinsic return value has wrong type: found `i64x8`, expected `i16x8` which was used for this vector type previously in this signature
+ --> $DIR/E0443.rs:20:5
+ |
+20 | fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
+#[repr(simd)]
+struct f64x2(f64, f64);
+
+extern "platform-intrinsic" {
+ fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
+}
+
+fn main() {}
--- /dev/null
+error[E0444]: platform-specific intrinsic has invalid number of arguments: found 3, expected 1
+ --> $DIR/E0444.rs:18:5
+ |
+18 | fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo {
+ fn dummy(&self) { }
+}
+
+pub trait Bar : Foo {}
+//~^ ERROR private trait `Foo` in public interface [E0445]
+//~| NOTE can't leak private trait
+pub struct Bar2<T: Foo>(pub T);
+//~^ ERROR private trait `Foo` in public interface [E0445]
+//~| NOTE can't leak private trait
+pub fn foo<T: Foo> (t: T) {}
+//~^ ERROR private trait `Foo` in public interface [E0445]
+//~| NOTE can't leak private trait
+
+fn main() {}
--- /dev/null
+error[E0445]: private trait `Foo` in public interface
+ --> $DIR/E0445.rs:15:1
+ |
+15 | pub trait Bar : Foo {}
+ | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+
+error[E0445]: private trait `Foo` in public interface
+ --> $DIR/E0445.rs:18:1
+ |
+18 | pub struct Bar2<T: Foo>(pub T);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+
+error[E0445]: private trait `Foo` in public interface
+ --> $DIR/E0445.rs:21:1
+ |
+21 | pub fn foo<T: Foo> (t: T) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod Foo {
+ struct Bar(u32);
+
+ pub fn bar() -> Bar { //~ ERROR E0446
+ Bar(0)
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0446]: private type `Foo::Bar` in public interface
+ --> $DIR/E0446.rs:14:5
+ |
+14 | / pub fn bar() -> Bar { //~ ERROR E0446
+15 | | Bar(0)
+16 | | }
+ | |_____^ can't leak private type
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Bar;
+
+trait Foo {
+ fn foo();
+}
+
+pub impl Bar {} //~ ERROR E0449
+
+pub impl Foo for Bar { //~ ERROR E0449
+ pub fn foo() {} //~ ERROR E0449
+}
+
+fn main() {
+}
--- /dev/null
+error[E0449]: unnecessary visibility qualifier
+ --> $DIR/E0449.rs:17:1
+ |
+17 | pub impl Bar {} //~ ERROR E0449
+ | ^^^^^^^^^^^^^^^ `pub` not needed here
+ |
+ = note: place qualifiers on individual impl items instead
+
+error[E0449]: unnecessary visibility qualifier
+ --> $DIR/E0449.rs:19:1
+ |
+19 | / pub impl Foo for Bar { //~ ERROR E0449
+20 | | pub fn foo() {} //~ ERROR E0449
+21 | | }
+ | |_^ `pub` not needed here
+
+error[E0449]: unnecessary visibility qualifier
+ --> $DIR/E0449.rs:20:5
+ |
+20 | pub fn foo() {} //~ ERROR E0449
+ | ^^^^^^^^^^^^^^^ `pub` not needed here
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod Bar {
+ pub struct Foo {
+ pub a: isize,
+ b: isize,
+ }
+
+ pub struct FooTuple (
+ pub isize,
+ isize,
+ );
+}
+
+fn pat_match(foo: Bar::Foo) {
+ let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451
+}
+
+fn main() {
+ let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
+}
--- /dev/null
+error[E0451]: field `b` of struct `Bar::Foo` is private
+ --> $DIR/E0451.rs:24:23
+ |
+24 | let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451
+ | ^^^ field `b` is private
+
+error[E0451]: field `b` of struct `Bar::Foo` is private
+ --> $DIR/E0451.rs:28:29
+ |
+28 | let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451
+ | ^^^^ field `b` is private
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![allow(foo = "")] //~ ERROR E0452
+
+fn main() {
+}
--- /dev/null
+error[E0452]: malformed lint attribute
+ --> $DIR/E0452.rs:11:10
+ |
+11 | #![allow(foo = "")] //~ ERROR E0452
+ | ^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![forbid(non_snake_case)]
+
+#[allow(non_snake_case)]
+//~^ ERROR allow(non_snake_case) overruled by outer forbid(non_snake_case)
+fn main() {
+}
--- /dev/null
+error[E0453]: allow(non_snake_case) overruled by outer forbid(non_snake_case)
+ --> $DIR/E0453.rs:13:9
+ |
+11 | #![forbid(non_snake_case)]
+ | -------------- `forbid` level set here
+12 |
+13 | #[allow(non_snake_case)]
+ | ^^^^^^^^^^^^^^ overruled by previous forbid
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[link(name = "")] extern {}
+//~^ ERROR E0454
+
+fn main() {
+}
--- /dev/null
+error[E0454]: #[link(name = "")] given with empty name
+ --> $DIR/E0454.rs:11:1
+ |
+11 | #[link(name = "")] extern {}
+ | ^^^^^^^^^^^^^^^^^^ empty name given
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458
+ //~| ERROR E0459
+
+fn main() {
+}
--- /dev/null
+error[E0458]: unknown kind: `wonderful_unicorn`
+ --> $DIR/E0458.rs:11:1
+ |
+11 | #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown kind
+
+error[E0459]: #[link(...)] specified without `name = "foo"`
+ --> $DIR/E0458.rs:11:1
+ |
+11 | #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[link(kind = "dylib")] extern {} //~ ERROR E0459
+
+fn main() {
+}
--- /dev/null
+error[E0459]: #[link(...)] specified without `name = "foo"`
+ --> $DIR/E0459.rs:11:1
+ |
+11 | #[link(kind = "dylib")] extern {} //~ ERROR E0459
+ | ^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(plugin)]
+#![plugin(cookie_monster)]
+//~^ ERROR E0463
+extern crate cake_is_a_lie;
+
+fn main() {
+}
--- /dev/null
+error[E0463]: can't find crate for `cookie_monster`
+ --> $DIR/E0463.rs:12:11
+ |
+12 | #![plugin(cookie_monster)]
+ | ^^^^^^^^^^^^^^ can't find crate
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Wedding<'t>: 't { }
+
+struct Prince<'kiss, 'SnowWhite> {
+ child: Box<Wedding<'kiss> + 'SnowWhite>, //~ ERROR E0478
+}
+
+fn main() {
+}
--- /dev/null
+error[E0478]: lifetime bound not satisfied
+ --> $DIR/E0478.rs:14:5
+ |
+14 | child: Box<Wedding<'kiss> + 'SnowWhite>, //~ ERROR E0478
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: lifetime parameter instantiated with the lifetime 'SnowWhite as defined on the struct at 13:1
+ --> $DIR/E0478.rs:13:1
+ |
+13 | struct Prince<'kiss, 'SnowWhite> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: but lifetime parameter must outlive the lifetime 'kiss as defined on the struct at 13:1
+ --> $DIR/E0478.rs:13:1
+ |
+13 | struct Prince<'kiss, 'SnowWhite> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
+
+const A: AtomicUsize = ATOMIC_USIZE_INIT;
+static B: &'static AtomicUsize = &A; //~ ERROR E0492
+
+fn main() {
+}
--- /dev/null
+error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
+ --> $DIR/E0492.rs:14:34
+ |
+14 | static B: &'static AtomicUsize = &A; //~ ERROR E0492
+ | ^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ a: u32
+}
+
+static S : Foo = Foo { a : 0 };
+static A : &'static u32 = &S.a; //~ ERROR E0494
+
+fn main() {
+}
--- /dev/null
+error[E0494]: cannot refer to the interior of another static, use a constant instead
+ --> $DIR/E0494.rs:16:27
+ |
+16 | static A : &'static u32 = &S.a; //~ ERROR E0494
+ | ^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo<'a> {
+ a: &'a i32,
+}
+
+impl<'a> Foo<'a> {
+ fn f<'a>(x: &'a i32) { //~ ERROR E0496
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope
+ --> $DIR/E0496.rs:16:10
+ |
+15 | impl<'a> Foo<'a> {
+ | -- first declared here
+16 | fn f<'a>(x: &'a i32) { //~ ERROR E0496
+ | ^^ lifetime 'a already in scope
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let mut i = 0;
+ let mut x = &mut i;
+ let mut a = &mut i; //~ ERROR E0499
+}
--- /dev/null
+error[E0499]: cannot borrow `i` as mutable more than once at a time
+ --> $DIR/E0499.rs:14:22
+ |
+13 | let mut x = &mut i;
+ | - first mutable borrow occurs here
+14 | let mut a = &mut i; //~ ERROR E0499
+ | ^ second mutable borrow occurs here
+15 | }
+ | - first borrow ends here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn bar(x: &mut i32) {}
+fn foo(a: &mut i32) {
+ let ref y = a;
+ bar(a); //~ ERROR E0502
+}
+
+fn main() {
+}
--- /dev/null
+error[E0502]: cannot borrow `*a` as mutable because `a` is also borrowed as immutable
+ --> $DIR/E0502.rs:14:9
+ |
+13 | let ref y = a;
+ | ----- immutable borrow occurs here
+14 | bar(a); //~ ERROR E0502
+ | ^ mutable borrow occurs here
+15 | }
+ | - immutable borrow ends here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let mut value = 3;
+ let _borrow = &mut value;
+ let _sum = value + 1; //~ ERROR E0503
+}
--- /dev/null
+error[E0503]: cannot use `value` because it was mutably borrowed
+ --> $DIR/E0503.rs:14:16
+ |
+13 | let _borrow = &mut value;
+ | ----- borrow of `value` occurs here
+14 | let _sum = value + 1; //~ ERROR E0503
+ | ^^^^^ use of borrowed `value`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct FancyNum {
+ num: u8,
+}
+
+fn main() {
+ let fancy_num = FancyNum { num: 5 };
+ let fancy_ref = &fancy_num;
+
+ let x = move || {
+ println!("child function: {}", fancy_num.num); //~ ERROR E0504
+ };
+
+ x();
+ println!("main function: {}", fancy_ref.num);
+}
--- /dev/null
+error[E0504]: cannot move `fancy_num` into closure because it is borrowed
+ --> $DIR/E0504.rs:20:40
+ |
+17 | let fancy_ref = &fancy_num;
+ | --------- borrow of `fancy_num` occurs here
+...
+20 | println!("child function: {}", fancy_num.num); //~ ERROR E0504
+ | ^^^^^^^^^ move into closure occurs here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Value {}
+
+fn eat(val: Value) {}
+
+fn main() {
+ let x = Value{};
+ {
+ let _ref_to_val: &Value = &x;
+ eat(x); //~ ERROR E0505
+ }
+}
--- /dev/null
+error[E0505]: cannot move out of `x` because it is borrowed
+ --> $DIR/E0505.rs:19:13
+ |
+18 | let _ref_to_val: &Value = &x;
+ | - borrow of `x` occurs here
+19 | eat(x); //~ ERROR E0505
+ | ^ move out of `x` occurs here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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::cell::RefCell;
+
+struct TheDarkKnight;
+
+impl TheDarkKnight {
+ fn nothing_is_true(self) {}
+}
+
+fn main() {
+ let x = RefCell::new(TheDarkKnight);
+
+ x.borrow().nothing_is_true(); //~ ERROR E0507
+}
--- /dev/null
+error[E0507]: cannot move out of borrowed content
+ --> $DIR/E0507.rs:22:5
+ |
+22 | x.borrow().nothing_is_true(); //~ ERROR E0507
+ | ^^^^^^^^^^ cannot move out of borrowed content
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct FancyNum {
+ num: usize
+}
+
+struct DropStruct {
+ fancy: FancyNum
+}
+
+impl Drop for DropStruct {
+ fn drop(&mut self) {
+ }
+}
+
+fn main() {
+ let drop_struct = DropStruct{fancy: FancyNum{num: 5}};
+ let fancy_field = drop_struct.fancy; //~ ERROR E0509
+ println!("Fancy: {}", fancy_field.num);
+}
--- /dev/null
+error[E0509]: cannot move out of type `DropStruct`, which implements the `Drop` trait
+ --> $DIR/E0509.rs:26:23
+ |
+26 | let fancy_field = drop_struct.fancy; //~ ERROR E0509
+ | ^^^^^^^^^^^^^^^^^
+ | |
+ | cannot move out of here
+ | help: consider using a reference instead: `&drop_struct.fancy`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(platform_intrinsics)]
+
+extern "platform-intrinsic" {
+ fn simd_add<T>(a: T, b: T) -> T;
+}
+
+fn main() {
+ unsafe { simd_add(0, 1); } //~ ERROR E0511
+}
--- /dev/null
+error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32`
+ --> $DIR/E0511.rs:18:14
+ |
+18 | unsafe { simd_add(0, 1); } //~ ERROR E0511
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn takes_u8(_: u8) {}
+
+fn main() {
+ unsafe { takes_u8(::std::mem::transmute(0u16)); } //~ ERROR E0512
+}
--- /dev/null
+error[E0512]: transmute called with types of different sizes
+ --> $DIR/E0512.rs:14:23
+ |
+14 | unsafe { takes_u8(::std::mem::transmute(0u16)); } //~ ERROR E0512
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: source type: u16 (16 bits)
+ = note: target type: u8 (8 bits)
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x: typeof(92) = 92; //~ ERROR E0516
+ //~| reserved keyword
+}
--- /dev/null
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+ --> $DIR/E0516.rs:12:12
+ |
+12 | let x: typeof(92) = 92; //~ ERROR E0516
+ | ^^^^^^^^^^ reserved keyword
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[repr(C)] //~ ERROR: E0517
+type Foo = u8;
+
+#[repr(packed)] //~ ERROR: E0517
+enum Foo2 {Bar, Baz}
+
+#[repr(u8)] //~ ERROR: E0517
+struct Foo3 {bar: bool, baz: bool}
+
+#[repr(C)] //~ ERROR: E0517
+impl Foo3 {
+}
+
+fn main() {
+}
--- /dev/null
+error[E0517]: attribute should be applied to struct, enum or union
+ --> $DIR/E0517.rs:11:8
+ |
+11 | #[repr(C)] //~ ERROR: E0517
+ | ^
+12 | type Foo = u8;
+ | -------------- not a struct, enum or union
+
+error[E0517]: attribute should be applied to struct or union
+ --> $DIR/E0517.rs:14:8
+ |
+14 | #[repr(packed)] //~ ERROR: E0517
+ | ^^^^^^
+15 | enum Foo2 {Bar, Baz}
+ | -------------------- not a struct or union
+
+error[E0517]: attribute should be applied to enum
+ --> $DIR/E0517.rs:17:8
+ |
+17 | #[repr(u8)] //~ ERROR: E0517
+ | ^^
+18 | struct Foo3 {bar: bool, baz: bool}
+ | ---------------------------------- not an enum
+
+error[E0517]: attribute should be applied to struct, enum or union
+ --> $DIR/E0517.rs:20:8
+ |
+20 | #[repr(C)] //~ ERROR: E0517
+ | ^
+21 | / impl Foo3 {
+22 | | }
+ | |_- not a struct, enum or union
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[inline(always)] //~ ERROR: E0518
+struct Foo;
+
+#[inline(never)] //~ ERROR: E0518
+impl Foo {
+}
+
+fn main() {
+}
--- /dev/null
+error[E0518]: attribute should be applied to function
+ --> $DIR/E0518.rs:11:1
+ |
+11 | #[inline(always)] //~ ERROR: E0518
+ | ^^^^^^^^^^^^^^^^^
+12 | struct Foo;
+ | ----------- not a function
+
+error[E0518]: attribute should be applied to function
+ --> $DIR/E0518.rs:14:1
+ |
+14 | #[inline(never)] //~ ERROR: E0518
+ | ^^^^^^^^^^^^^^^^
+15 | / impl Foo {
+16 | | }
+ | |_- not a function
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(specialization)]
+
+trait SpaceLlama {
+ fn fly(&self);
+}
+
+impl<T> SpaceLlama for T {
+ default fn fly(&self) {}
+}
+
+impl<T: Clone> SpaceLlama for T {
+ fn fly(&self) {}
+}
+
+impl SpaceLlama for i32 {
+ default fn fly(&self) {}
+ //~^ ERROR E0520
+}
+
+fn main() {
+}
--- /dev/null
+error[E0520]: `fly` specializes an item from a parent `impl`, but that item is not marked `default`
+ --> $DIR/E0520.rs:26:5
+ |
+21 | / impl<T: Clone> SpaceLlama for T {
+22 | | fn fly(&self) {}
+23 | | }
+ | |_- parent `impl` is here
+...
+26 | default fn fly(&self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `fly`
+ |
+ = note: to specialize, `fly` in the parent `impl` must be marked `default`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(lang_items)]
+
+#[lang = "cookie"]
+fn cookie() -> ! {
+//~^^ ERROR definition of an unknown language item: `cookie` [E0522]
+ loop {}
+}
--- /dev/null
+error[E0601]: main function not found
+
+error[E0522]: definition of an unknown language item: `cookie`
+ --> $DIR/E0522.rs:13:1
+ |
+13 | #[lang = "cookie"]
+ | ^^^^^^^^^^^^^^^^^^ definition of unknown language item `cookie`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(slice_patterns)]
+
+fn main() {
+ let r = &[1, 2, 3, 4];
+ match r {
+ &[a, b] => {
+ //~^ ERROR E0527
+ println!("a={}, b={}", a, b);
+ }
+ }
+}
--- /dev/null
+error[E0527]: pattern requires 2 elements but array has 4
+ --> $DIR/E0527.rs:16:10
+ |
+16 | &[a, b] => {
+ | ^^^^^^ expected 4 elements
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(slice_patterns)]
+
+fn main() {
+ let r = &[1, 2];
+ match r {
+ &[a, b, c, rest..] => {
+ //~^ ERROR E0528
+ }
+ }
+}
--- /dev/null
+error[E0528]: pattern requires at least 3 elements but array has 2
+ --> $DIR/E0528.rs:16:10
+ |
+16 | &[a, b, c, rest..] => {
+ | ^^^^^^^^^^^^^^^^^ pattern cannot match array of 2 elements
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(slice_patterns)]
+
+fn main() {
+ let r: f32 = 1.0;
+ match r {
+ [a, b] => {
+ //~^ ERROR E0529
+ }
+ }
+}
--- /dev/null
+error[E0529]: expected an array or slice, found `f32`
+ --> $DIR/E0529.rs:16:9
+ |
+16 | [a, b] => {
+ | ^^^^^^ pattern cannot match with input type `f32`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ static TEST: i32 = 0;
+
+ let r: (i32, i32) = (0, 0);
+ match r {
+ TEST => {} //~ ERROR E0530
+ }
+}
--- /dev/null
+error[E0530]: match bindings cannot shadow statics
+ --> $DIR/E0530.rs:16:9
+ |
+12 | static TEST: i32 = 0;
+ | --------------------- a static `TEST` is defined here
+...
+16 | TEST => {} //~ ERROR E0530
+ | ^^^^ cannot be named the same as a static
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let value = 1;
+
+ match SomeStruct(value) {
+ StructConst1(_) => { },
+ //~^ ERROR expected tuple struct/variant, found constant `StructConst1`
+ _ => { },
+ }
+
+ struct SomeStruct(u8);
+
+ const StructConst1 : SomeStruct = SomeStruct(1);
+ const StructConst2 : SomeStruct = SomeStruct(2);
+}
--- /dev/null
+error[E0532]: expected tuple struct/variant, found constant `StructConst1`
+ --> $DIR/E0532.rs:15:9
+ |
+15 | StructConst1(_) => { },
+ | ^^^^^^^^^^^^ not a tuple struct/variant
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[inline()] //~ ERROR E0534
+pub fn something() {}
+
+fn main() {
+ something();
+}
--- /dev/null
+error[E0534]: expected one argument
+ --> $DIR/E0534.rs:11:1
+ |
+11 | #[inline()] //~ ERROR E0534
+ | ^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#[export_name]
+//~^ ERROR E0558
+
+pub fn something() {}
+
+fn main() {}
--- /dev/null
+error[E0558]: export_name attribute has invalid format
+ --> $DIR/E0558.rs:11:1
+ |
+11 | #[export_name]
+ | ^^^^^^^^^^^^^^ did you mean #[export_name="*"]?
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum Field {
+ Fool { x: u32 },
+}
+
+fn main() {
+ let s = Field::Fool { joke: 0 };
+ //~^ ERROR E0559
+}
--- /dev/null
+error[E0559]: variant `Field::Fool` has no field named `joke`
+ --> $DIR/E0559.rs:16:27
+ |
+16 | let s = Field::Fool { joke: 0 };
+ | ^^^^^ `Field::Fool` does not have this field
+ |
+ = note: available fields are: `x`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Simba {
+ mother: u32,
+}
+
+fn main() {
+ let s = Simba { mother: 1, father: 0 };
+ //~^ ERROR E0560
+}
--- /dev/null
+error[E0560]: struct `Simba` has no field named `father`
+ --> $DIR/E0560.rs:16:32
+ |
+16 | let s = Simba { mother: 1, father: 0 };
+ | ^^^^^^^ `Simba` does not have this field
+ |
+ = note: available fields are: `mother`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(attr_literals)]
+
+// deprecated doesn't currently support literals
+#[deprecated("since")] //~ ERROR E0565
+fn f() { }
+
+fn main() { }
--- /dev/null
+error[E0565]: unsupported literal
+ --> $DIR/E0565-1.rs:14:14
+ |
+14 | #[deprecated("since")] //~ ERROR E0565
+ | ^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(attr_literals)]
+
+// repr currently doesn't support literals
+#[repr("C")] //~ ERROR E0565
+struct A { }
+
+fn main() { }
--- /dev/null
+error[E0565]: unsupported literal
+ --> $DIR/E0565.rs:14:8
+ |
+14 | #[repr("C")] //~ ERROR E0565
+ | ^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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 FOO: u32 = return 0; //~ ERROR E0572
+
+fn main() {}
--- /dev/null
+error[E0572]: return statement outside of function body
+ --> $DIR/E0572.rs:11:18
+ |
+11 | const FOO: u32 = return 0; //~ ERROR E0572
+ | ^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2014 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.
+
+// This test was derived from the wasm and parsell crates. They
+// stopped compiling when #32330 is fixed.
+
+#![allow(dead_code, unused_variables)]
+
+use std::str::Chars;
+
+pub trait HasOutput<Ch, Str> {
+ type Output;
+}
+
+#[derive(Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Debug)]
+pub enum Token<'a> {
+ Begin(&'a str)
+}
+
+fn mk_unexpected_char_err<'a>() -> Option<&'a i32> {
+ unimplemented!()
+}
+
+fn foo<'a>(data: &mut Chars<'a>) {
+ bar(mk_unexpected_char_err)
+}
+
+fn bar<F>(t: F)
+ // No type can satisfy this requirement, since `'a` does not
+ // appear in any of the input types:
+ where F: for<'a> Fn() -> Option<&'a i32>
+ //~^ ERROR E0582
+{
+}
+
+fn baz<F>(t: F)
+ // No type can satisfy this requirement, since `'a` does not
+ // appear in any of the input types:
+ where F: for<'a> Iterator<Item=&'a i32>
+ //~^ ERROR E0582
+{
+}
+
+fn main() {
+}
--- /dev/null
+error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types
+ --> $DIR/E0582.rs:38:30
+ |
+38 | where F: for<'a> Fn() -> Option<&'a i32>
+ | ^^^^^^^^^^^^^^^
+
+error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types
+ --> $DIR/E0582.rs:46:31
+ |
+46 | where F: for<'a> Iterator<Item=&'a i32>
+ | ^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ /// Hello! I'm useless...
+ //~^ ERROR E0585
+}
--- /dev/null
+error[E0585]: found a documentation comment that doesn't document anything
+ --> $DIR/E0585.rs:12:5
+ |
+12 | /// Hello! I'm useless...
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: doc comments must come before what they document, maybe a comment was intended with `//`?
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
+ let x = &tmp[1..=]; //~ ERROR E0586
+}
--- /dev/null
+error[E0586]: inclusive range with no end
+ --> $DIR/E0586.rs:13:22
+ |
+13 | let x = &tmp[1..=]; //~ ERROR E0586
+ | ^
+ |
+ = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo<'a> {
+ x: Option<&'a u32>,
+}
+
+fn main() {
+ let mut x = Foo { x: None };
+ let y = 0;
+ x.x = Some(&y);
+ //~^ `y` does not live long enough [E0597]
+}
--- /dev/null
+error[E0597]: `y` does not live long enough
+ --> $DIR/E0597.rs:18:17
+ |
+18 | x.x = Some(&y);
+ | ^ borrowed value does not live long enough
+19 | //~^ `y` does not live long enough [E0597]
+20 | }
+ | - `y` dropped here while still borrowed
+ |
+ = note: values in a scope are dropped in the opposite order they are created
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo;
+
+fn main() {
+ || if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599
+}
--- /dev/null
+error[E0599]: no associated item named `NotEvenReal` found for type `Foo` in the current scope
+ --> $DIR/E0599.rs:14:15
+ |
+11 | struct Foo;
+ | ----------- associated item `NotEvenReal` not found for this
+...
+14 | || if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599
+ | ^^^^^^^^^^^^^^^^^^ associated item not found in `Foo`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ !"a"; //~ ERROR E0600
+}
--- /dev/null
+error[E0600]: cannot apply unary operator `!` to type `&'static str`
+ --> $DIR/E0600.rs:12:5
+ |
+12 | !"a"; //~ ERROR E0600
+ | ^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// compile-flags:-D bogus
+
+// error-pattern:E0602
+// error-pattern:requested on the command line with `-D bogus`
+
+fn main() {}
--- /dev/null
+error[E0602]: unknown lint: `bogus`
+ |
+ = note: requested on the command line with `-D bogus`
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod SomeModule {
+ const PRIVATE: u32 = 0x_a_bad_1dea_u32;
+}
+
+fn main() {
+ SomeModule::PRIVATE; //~ ERROR E0603
+}
--- /dev/null
+error[E0603]: constant `PRIVATE` is private
+ --> $DIR/E0603.rs:16:5
+ |
+16 | SomeModule::PRIVATE; //~ ERROR E0603
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ 1u32 as char; //~ ERROR E0604
+}
--- /dev/null
+error[E0604]: only `u8` can be cast as `char`, not `u32`
+ --> $DIR/E0604.rs:12:5
+ |
+12 | 1u32 as char; //~ ERROR E0604
+ | ^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = 0u8;
+ x as Vec<u8>; //~ ERROR E0605
+
+ let v = 0 as *const u8;
+ v as &u8; //~ ERROR E0605
+}
--- /dev/null
+error[E0605]: non-primitive cast: `u8` as `std::vec::Vec<u8>`
+ --> $DIR/E0605.rs:13:5
+ |
+13 | x as Vec<u8>; //~ ERROR E0605
+ | ^^^^^^^^^^^^
+ |
+ = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
+
+error[E0605]: non-primitive cast: `*const u8` as `&u8`
+ --> $DIR/E0605.rs:16:5
+ |
+16 | v as &u8; //~ ERROR E0605
+ | ^^^^^^^^
+ |
+ = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ &0u8 as u8; //~ ERROR E0606
+}
--- /dev/null
+error[E0606]: casting `&u8` as `u8` is invalid
+ --> $DIR/E0606.rs:12:5
+ |
+12 | &0u8 as u8; //~ ERROR E0606
+ | ^^^^^^^^^^ cannot cast `&u8` as `u8`
+ |
+help: did you mean `*&0u8`?
+ --> $DIR/E0606.rs:12:5
+ |
+12 | &0u8 as u8; //~ ERROR E0606
+ | ^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let v = 0 as *const u8;
+ v as *const [u8]; //~ ERROR E0607
+}
--- /dev/null
+error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
+ --> $DIR/E0607.rs:13:5
+ |
+13 | v as *const [u8]; //~ ERROR E0607
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ 0u8[2]; //~ ERROR E0608
+}
--- /dev/null
+error[E0608]: cannot index into a value of type `u8`
+ --> $DIR/E0608.rs:12:5
+ |
+12 | 0u8[2]; //~ ERROR E0608
+ | ^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ x: u32,
+}
+struct Bar;
+
+fn main() {
+ let x = Foo { x: 0 };
+ let _ = x.foo; //~ ERROR E0609
+
+ let y = Bar;
+ y.1; //~ ERROR E0609
+}
--- /dev/null
+error[E0609]: no field `foo` on type `Foo`
+ --> $DIR/E0609.rs:18:15
+ |
+18 | let _ = x.foo; //~ ERROR E0609
+ | ^^^ unknown field
+ |
+ = note: available fields are: `x`
+
+error[E0609]: no field `1` on type `Bar`
+ --> $DIR/E0609.rs:21:5
+ |
+21 | y.1; //~ ERROR E0609
+ | ^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x = 0;
+ let _ = x.foo; //~ ERROR E0610
+}
--- /dev/null
+error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
+ --> $DIR/E0610.rs:13:15
+ |
+13 | let _ = x.foo; //~ ERROR E0610
+ | ^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod a {
+ pub struct Foo(u32);
+
+ impl Foo {
+ pub fn new() -> Foo { Foo(0) }
+ }
+}
+
+fn main() {
+ let y = a::Foo::new();
+ y.0; //~ ERROR E0611
+}
--- /dev/null
+error[E0611]: field `0` of tuple-struct `a::Foo` is private
+ --> $DIR/E0611.rs:21:4
+ |
+21 | y.0; //~ ERROR E0611
+ | ^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo(u32);
+
+fn main() {
+ let y = Foo(0);
+ y.1; //~ ERROR E0612
+}
--- /dev/null
+error[E0612]: attempted out-of-bounds tuple index `1` on type `Foo`
+ --> $DIR/E0612.rs:15:4
+ |
+15 | y.1; //~ ERROR E0612
+ | ^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let y = 0u32;
+ *y; //~ ERROR E0614
+}
--- /dev/null
+error[E0614]: type `u32` cannot be dereferenced
+ --> $DIR/E0614.rs:13:5
+ |
+13 | *y; //~ ERROR E0614
+ | ^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct Foo {
+ x: u32,
+}
+
+impl Foo {
+ fn method(&self) {}
+}
+
+fn main() {
+ let f = Foo { x: 0 };
+ f.method; //~ ERROR E0615
+}
--- /dev/null
+error[E0615]: attempted to take value of method `method` on type `Foo`
+ --> $DIR/E0615.rs:21:7
+ |
+21 | f.method; //~ ERROR E0615
+ | ^^^^^^
+ |
+ = help: maybe a `()` to call it is missing?
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod a {
+ pub struct Foo {
+ x: u32,
+ }
+
+ impl Foo {
+ pub fn new() -> Foo { Foo { x: 0 } }
+ }
+}
+
+fn main() {
+ let f = a::Foo::new();
+ f.x; //~ ERROR E0616
+}
--- /dev/null
+error[E0616]: field `x` of struct `a::Foo` is private
+ --> $DIR/E0616.rs:23:5
+ |
+23 | f.x; //~ ERROR E0616
+ | ^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// ignore-tidy-linelength
+
+extern {
+ fn printf(c: *const i8, ...);
+}
+
+fn main() {
+ unsafe {
+ printf(::std::ptr::null(), 0f32);
+ //~^ ERROR can't pass `f32` to variadic function
+ //~| HELP cast the value to `c_double`
+ printf(::std::ptr::null(), 0i8);
+ //~^ ERROR can't pass `i8` to variadic function
+ //~| HELP cast the value to `c_int`
+ printf(::std::ptr::null(), 0i16);
+ //~^ ERROR can't pass `i16` to variadic function
+ //~| HELP cast the value to `c_int`
+ printf(::std::ptr::null(), 0u8);
+ //~^ ERROR can't pass `u8` to variadic function
+ //~| HELP cast the value to `c_uint`
+ printf(::std::ptr::null(), 0u16);
+ //~^ ERROR can't pass `u16` to variadic function
+ //~| HELP cast the value to `c_uint`
+ printf(::std::ptr::null(), printf);
+ //~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
+ //~| HELP cast the value to `unsafe extern "C" fn(*const i8, ...)`
+ }
+}
--- /dev/null
+error[E0617]: can't pass `f32` to variadic function
+ --> $DIR/E0617.rs:19:36
+ |
+19 | printf(::std::ptr::null(), 0f32);
+ | ^^^^ help: cast the value to `c_double`: `0f32 as c_double`
+
+error[E0617]: can't pass `i8` to variadic function
+ --> $DIR/E0617.rs:22:36
+ |
+22 | printf(::std::ptr::null(), 0i8);
+ | ^^^ help: cast the value to `c_int`: `0i8 as c_int`
+
+error[E0617]: can't pass `i16` to variadic function
+ --> $DIR/E0617.rs:25:36
+ |
+25 | printf(::std::ptr::null(), 0i16);
+ | ^^^^ help: cast the value to `c_int`: `0i16 as c_int`
+
+error[E0617]: can't pass `u8` to variadic function
+ --> $DIR/E0617.rs:28:36
+ |
+28 | printf(::std::ptr::null(), 0u8);
+ | ^^^ help: cast the value to `c_uint`: `0u8 as c_uint`
+
+error[E0617]: can't pass `u16` to variadic function
+ --> $DIR/E0617.rs:31:36
+ |
+31 | printf(::std::ptr::null(), 0u16);
+ | ^^^^ help: cast the value to `c_uint`: `0u16 as c_uint`
+
+error[E0617]: can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
+ --> $DIR/E0617.rs:34:36
+ |
+34 | printf(::std::ptr::null(), printf);
+ | ^^^^^^
+help: cast the value to `unsafe extern "C" fn(*const i8, ...)`
+ |
+34 | printf(::std::ptr::null(), printf as unsafe extern "C" fn(*const i8, ...));
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 6 previous errors
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+enum X {
+ Entry,
+}
+
+fn main() {
+ X::Entry();
+ //~^ ERROR expected function, found enum variant `X::Entry` [E0618]
+ let x = 0i32;
+ x();
+ //~^ ERROR expected function, found `i32` [E0618]
+}
--- /dev/null
+error[E0618]: expected function, found enum variant `X::Entry`
+ --> $DIR/E0618.rs:16:5
+ |
+12 | Entry,
+ | ----- `X::Entry` defined here
+...
+16 | X::Entry();
+ | ^^^^^^^^^^ not a function
+help: `X::Entry` is a unit variant, you need to write it without the parenthesis
+ |
+16 | X::Entry;
+ | ^^^^^^^^
+
+error[E0618]: expected function, found `i32`
+ --> $DIR/E0618.rs:19:5
+ |
+18 | let x = 0i32;
+ | - `i32` defined here
+19 | x();
+ | ^^^ not a function
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let x;
+
+ match x {
+ (..) => {} //~ ERROR E0619
+ _ => {}
+ }
+}
+
--- /dev/null
+error[E0619]: the type of this value must be known in this context
+ --> $DIR/E0619.rs:15:9
+ |
+15 | (..) => {} //~ ERROR E0619
+ | ^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+fn main() {
+ let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620
+}
--- /dev/null
+error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]`
+ --> $DIR/E0620.rs:12:16
+ |
+12 | let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: consider using an implicit coercion to `&[usize]` instead
+ --> $DIR/E0620.rs:12:16
+ |
+12 | let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// Test that we give the generic E0495 when one of the free regions is
+// bound in a closure (rather than suggesting a change to the signature
+// of the closure, which is not specified in `foo` but rather in `invoke`).
+
+// FIXME - This might be better as a UI test, but the finer details
+// of the error seem to vary on different machines.
+fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32
+where F: FnOnce(&'a i32, &i32) -> &'a i32
+{
+ let y = 22;
+ f(x, &y)
+}
+
+fn foo<'a>(x: &'a i32) {
+ invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
+}
+
+fn main() {}
--- /dev/null
+error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
+ --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5
+ |
+25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
+ | ^^^^^^
+ |
+note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 25:16...
+ --> $DIR/E0621-does-not-trigger-for-closures.rs:25:16
+ |
+25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...so that reference does not outlive borrowed content
+ --> $DIR/E0621-does-not-trigger-for-closures.rs:25:45
+ |
+25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
+ | ^
+note: but, the lifetime must be valid for the call at 25:5...
+ --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5
+ |
+25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...so type `&i32` of expression is valid during the expression
+ --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5
+ |
+25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2015 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.
+
+#![feature(intrinsics)]
+extern "rust-intrinsic" {
+ pub static breakpoint : unsafe extern "rust-intrinsic" fn();
+ //~^ ERROR intrinsic must be a function [E0622]
+}
+fn main() { unsafe { breakpoint(); } }
--- /dev/null
+error[E0622]: intrinsic must be a function
+ --> $DIR/E0622.rs:13:5
+ |
+13 | pub static breakpoint : unsafe extern "rust-intrinsic" fn();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected a function
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+mod inner {
+ pub struct Foo;
+
+ impl Foo {
+ fn method(&self) {}
+ }
+}
+
+fn main() {
+ let foo = inner::Foo;
+ foo.method(); //~ ERROR method `method` is private [E0624]
+}
--- /dev/null
+error[E0624]: method `method` is private
+ --> $DIR/E0624.rs:21:9
+ |
+21 | foo.method(); //~ ERROR method `method` is private [E0624]
+ | ^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+#![feature(underscore_lifetimes)]
+
+struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_`
+fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_`
+
+struct Bar<'a>(&'a u8);
+impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_`
+ fn bar() {}
+}
+
+fn main() {}
--- /dev/null
+error[E0637]: invalid lifetime bound name: `'_`
+ --> $DIR/E0637.rs:12:16
+ |
+12 | struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_`
+ | ^^ `'_` is a reserved lifetime name
+
+error[E0637]: invalid lifetime bound name: `'_`
+ --> $DIR/E0637.rs:13:12
+ |
+13 | fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_`
+ | ^^ `'_` is a reserved lifetime name
+
+error[E0637]: invalid lifetime bound name: `'_`
+ --> $DIR/E0637.rs:16:10
+ |
+16 | impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_`
+ | ^^ `'_` is a reserved lifetime name
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+#![allow(warnings)]
+#![feature(conservative_impl_trait, nested_impl_trait)]
+
+trait Id<T> {}
+trait Lt<'a> {}
+
+impl<'a> Lt<'a> for () {}
+impl<T> Id<T> for T {}
+
+fn free_fn_capture_hrtb_in_impl_trait()
+ -> impl for<'a> Id<impl Lt<'a>>
+ //~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level [E0657]
+{
+ ()
+}
+
+struct Foo;
+impl Foo {
+ fn impl_fn_capture_hrtb_in_impl_trait()
+ -> impl for<'a> Id<impl Lt<'a>>
+ //~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level
+ {
+ ()
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
+ --> $DIR/E0657.rs:20:32
+ |
+20 | -> impl for<'a> Id<impl Lt<'a>>
+ | ^^
+
+error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
+ --> $DIR/E0657.rs:29:36
+ |
+29 | -> impl for<'a> Id<impl Lt<'a>>
+ | ^^
+
+error: aborting due to 2 previous errors
+
--- /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.
+
+fn main() {
+ let _ = ::std::u128::MAX; //~ ERROR E0658
+}
--- /dev/null
+error[E0658]: use of unstable library feature 'i128' (see issue #35118)
+ --> $DIR/E0658.rs:12:13
+ |
+12 | let _ = ::std::u128::MAX; //~ ERROR E0658
+ | ^^^^^^^^^^^^^^^^
+ |
+ = help: add #![feature(i128)] to the crate attributes to enable
+
+error: aborting due to previous error
+
--- /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.
+
+mod moon {
+ pub fn foo() {}
+}
+
+mod earth {
+ pub fn foo() {}
+}
+
+mod collider {
+ pub use moon::*;
+ pub use earth::*;
+}
+
+fn main() {
+ collider::foo(); //~ ERROR E0659
+}
--- /dev/null
+error[E0659]: `foo` is ambiguous
+ --> $DIR/E0659.rs:25:5
+ |
+25 | collider::foo(); //~ ERROR E0659
+ | ^^^^^^^^^^^^^
+ |
+note: `foo` could refer to the name imported here
+ --> $DIR/E0659.rs:20:13
+ |
+20 | pub use moon::*;
+ | ^^^^^^^
+note: `foo` could also refer to the name imported here
+ --> $DIR/E0659.rs:21:13
+ |
+21 | pub use earth::*;
+ | ^^^^^^^^
+ = note: consider adding an explicit import of `foo` to disambiguate
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// Test that `?` macro Kleene operator can not be used when the `macro_at_most_once_rep` feature
+// gate is not used.
+
+macro_rules! m { ($(a)?) => {} }
+//~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable
+
+fn main() {
+ m!();
+}
--- /dev/null
+error[E0658]: Using the `?` macro Kleene operator for "at most one" repetition is unstable (see issue #48075)
+ --> $DIR/feature-gate-macro_at_most_once_rep.rs:14:20
+ |
+14 | macro_rules! m { ($(a)?) => {} }
+ | ^^^
+ |
+ = help: add #![feature(macro_at_most_once_rep)] to the crate attributes to enable
+
+error: aborting due to previous error
+
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#[allow(dead_code)]
-enum Foo {
- A,
- B,
- C,
- D,
- E,
-}
-use Foo::*;
-
-fn main() {
- let x = Foo::A;
- match x {
- | A => println!("A"),
- //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
- | B | C => println!("BC!"),
- //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
- | _ => {},
- //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
- };
- match x {
- A | B | C => println!("ABC!"),
- _ => {},
- };
-}
-
+++ /dev/null
-error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
- --> $DIR/feature-gate-match_beginning_vert.rs:24:9
- |
-24 | | A => println!("A"),
- | ^
- |
- = help: add #![feature(match_beginning_vert)] to the crate attributes to enable
-
-error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
- --> $DIR/feature-gate-match_beginning_vert.rs:26:9
- |
-26 | | B | C => println!("BC!"),
- | ^
- |
- = help: add #![feature(match_beginning_vert)] to the crate attributes to enable
-
-error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101)
- --> $DIR/feature-gate-match_beginning_vert.rs:28:9
- |
-28 | | _ => {},
- | ^
- |
- = help: add #![feature(match_beginning_vert)] to the crate attributes to enable
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-#![allow(unused_imports, dead_code)]
-
-mod a {
- pub enum B {}
- pub enum C {}
-
- pub mod d {
- pub enum E {}
- pub enum F {}
-
- pub mod g {
- pub enum H {}
- }
- }
-}
-
-use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental
- //~^ ERROR nested groups in `use` are experimental
- //~^^ ERROR paths in `use` groups are experimental
-
-fn main() {}
+++ /dev/null
-error[E0658]: nested groups in `use` are experimental (see issue #44494)
- --> $DIR/feature-gate-use_nested_groups.rs:27:12
- |
-27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental
- | ^^^^^^^^^^^^
- |
- = help: add #![feature(use_nested_groups)] to the crate attributes to enable
-
-error[E0658]: glob imports in `use` groups are experimental (see issue #44494)
- --> $DIR/feature-gate-use_nested_groups.rs:27:16
- |
-27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental
- | ^
- |
- = help: add #![feature(use_nested_groups)] to the crate attributes to enable
-
-error[E0658]: paths in `use` groups are experimental (see issue #44494)
- --> $DIR/feature-gate-use_nested_groups.rs:27:19
- |
-27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental
- | ^^^^
- |
- = help: add #![feature(use_nested_groups)] to the crate attributes to enable
-
-error: aborting due to 3 previous errors
-
--- /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.
+
+#![feature(generators)]
+
+fn main() {
+ let x = (|_| {},);
+
+ || {
+ let x = x;
+
+ x.0({ //~ ERROR borrow may still be in use when generator yields
+ yield;
+ });
+ };
+}
--- /dev/null
+error[E0626]: borrow may still be in use when generator yields
+ --> $DIR/issue-48048.rs:19:9
+ |
+19 | x.0({ //~ ERROR borrow may still be in use when generator yields
+ | ^^^
+20 | yield;
+ | ----- possible yield occurs here
+
+error: aborting due to previous error
+
0
} else {
n + sum_to(n - 1)
- //~^ ERROR the trait bound `u32: std::ops::Add<impl Foo>` is not satisfied
+ //~^ ERROR cannot add `impl Foo` to `u32`
}
}
= note: expected type `i32`
found type `u32`
-error[E0277]: the trait bound `u32: std::ops::Add<impl Foo>` is not satisfied
+error[E0277]: cannot add `impl Foo` to `u32`
--> $DIR/equality.rs:34:11
|
34 | n + sum_to(n - 1)
--- /dev/null
+// Copyright 2012 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.
+
+// Test that assignments to an `&mut` pointer which is found in a
+// borrowed (but otherwise non-aliasable) location is illegal.
+
+// compile-flags: -Z emit-end-regions -Z borrowck=compare -C overflow-checks=on
+
+struct S<'a> {
+ pointer: &'a mut isize
+}
+
+fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> {
+ S { pointer: &mut *p.pointer }
+}
+
+fn main() {
+ let mut x = 1;
+
+ {
+ let mut y = S { pointer: &mut x };
+ let z = copy_borrowed_ptr(&mut y);
+ *y.pointer += 1;
+ //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506]
+ //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503]
+ *z.pointer += 1;
+ }
+}
--- /dev/null
+error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
+ --> $DIR/issue-45697-1.rs:30:9
+ |
+29 | let z = copy_borrowed_ptr(&mut y);
+ | - borrow of `*y.pointer` occurs here
+30 | *y.pointer += 1;
+ | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
+
+error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
+ --> $DIR/issue-45697-1.rs:30:9
+ |
+29 | let z = copy_borrowed_ptr(&mut y);
+ | ------ borrow of `y` occurs here
+30 | *y.pointer += 1;
+ | ^^^^^^^^^^^^^^^ use of borrowed `y`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Copyright 2012 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.
+
+// Test that assignments to an `&mut` pointer which is found in a
+// borrowed (but otherwise non-aliasable) location is illegal.
+
+// compile-flags: -Z emit-end-regions -Z borrowck=compare -C overflow-checks=off
+
+struct S<'a> {
+ pointer: &'a mut isize
+}
+
+fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> {
+ S { pointer: &mut *p.pointer }
+}
+
+fn main() {
+ let mut x = 1;
+
+ {
+ let mut y = S { pointer: &mut x };
+ let z = copy_borrowed_ptr(&mut y);
+ *y.pointer += 1;
+ //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506]
+ //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503]
+ *z.pointer += 1;
+ }
+}
--- /dev/null
+error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
+ --> $DIR/issue-45697.rs:30:9
+ |
+29 | let z = copy_borrowed_ptr(&mut y);
+ | - borrow of `*y.pointer` occurs here
+30 | *y.pointer += 1;
+ | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
+
+error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
+ --> $DIR/issue-45697.rs:30:9
+ |
+29 | let z = copy_borrowed_ptr(&mut y);
+ | ------ borrow of `y` occurs here
+30 | *y.pointer += 1;
+ | ^^^^^^^^^^^^^^^ use of borrowed `y`
+
+error: aborting due to 2 previous errors
+
--- /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.
+
+// must-compile-successfully
+
+#![warn(unused)] // UI tests pass `-A unused` (#43896)
+
+struct SoulHistory {
+ corridors_of_light: usize,
+ hours_are_suns: bool,
+ endless_and_singing: bool
+}
+
+fn main() {
+ let i_think_continually = 2;
+ let who_from_the_womb_remembered = SoulHistory {
+ corridors_of_light: 5,
+ hours_are_suns: true,
+ endless_and_singing: true
+ };
+
+ if let SoulHistory { corridors_of_light,
+ mut hours_are_suns,
+ endless_and_singing: true } = who_from_the_womb_remembered {
+ hours_are_suns = false;
+ }
+}
--- /dev/null
+warning: unused variable: `i_think_continually`
+ --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:22:9
+ |
+22 | let i_think_continually = 2;
+ | ^^^^^^^^^^^^^^^^^^^ help: consider using `_i_think_continually` instead
+ |
+note: lint level defined here
+ --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9
+ |
+13 | #![warn(unused)] // UI tests pass `-A unused` (#43896)
+ | ^^^^^^
+ = note: #[warn(unused_variables)] implied by #[warn(unused)]
+
+warning: unused variable: `corridors_of_light`
+ --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:29:26
+ |
+29 | if let SoulHistory { corridors_of_light,
+ | ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _`
+
+warning: variable `hours_are_suns` is assigned to, but never used
+ --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:30:26
+ |
+30 | mut hours_are_suns,
+ | ^^^^^^^^^^^^^^^^^^
+ |
+ = note: consider using `_hours_are_suns` instead
+
+warning: value assigned to `hours_are_suns` is never read
+ --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:32:9
+ |
+32 | hours_are_suns = false;
+ | ^^^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9
+ |
+13 | #![warn(unused)] // UI tests pass `-A unused` (#43896)
+ | ^^^^^^
+ = note: #[warn(unused_assignments)] implied by #[warn(unused)]
+
--- /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.
+
+// must-compile-successfully
+
+#![warn(unused_parens)]
+
+macro_rules! the_worship_the_heart_lifts_above {
+ ( @as_expr, $e:expr) => { $e };
+ ( @generate_fn, $name:tt) => {
+ #[allow(dead_code)] fn the_moth_for_the_star<'a>() -> Option<&'a str> {
+ Some(the_worship_the_heart_lifts_above!( @as_expr, $name ))
+ }
+ };
+ ( $name:ident ) => { the_worship_the_heart_lifts_above!( @generate_fn, (stringify!($name))); }
+ // ↑ Notably, this does 𝘯𝘰𝘵 warn: we're declining to lint unused parens in
+ // function/method arguments inside of nested macros because of situations
+ // like those reported in Issue #47775
+}
+
+macro_rules! and_the_heavens_reject_not {
+ () => {
+ // ↓ But let's test that we still lint for unused parens around
+ // function args inside of simple, one-deep macros.
+ #[allow(dead_code)] fn the_night_for_the_morrow() -> Option<isize> { Some((2)) }
+ //~^ WARN unnecessary parentheses around function argument
+ }
+}
+
+the_worship_the_heart_lifts_above!(rah);
+and_the_heavens_reject_not!();
+
+fn main() {}
--- /dev/null
+warning: unnecessary parentheses around function argument
+ --> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:32:83
+ |
+32 | #[allow(dead_code)] fn the_night_for_the_morrow() -> Option<isize> { Some((2)) }
+ | ^^^ help: remove these parentheses
+...
+38 | and_the_heavens_reject_not!();
+ | ------------------------------ in this macro invocation
+ |
+note: lint level defined here
+ --> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:13:9
+ |
+13 | #![warn(unused_parens)]
+ | ^^^^^^^^^^^^^
+
// except according to those terms.
fn main() {
- 1 + Some(1); //~ ERROR is not satisfied
- 2 as usize - Some(1); //~ ERROR is not satisfied
- 3 * (); //~ ERROR is not satisfied
- 4 / ""; //~ ERROR is not satisfied
+ 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}`
+ 2 as usize - Some(1); //~ ERROR cannot subtract `std::option::Option<{integer}>` from `usize`
+ 3 * (); //~ ERROR cannot multiply `()` to `{integer}`
+ 4 / ""; //~ ERROR cannot divide `{integer}` by `&str`
5 < String::new(); //~ ERROR is not satisfied
6 == Ok(1); //~ ERROR is not satisfied
}
-error[E0277]: the trait bound `{integer}: std::ops::Add<std::option::Option<{integer}>>` is not satisfied
+error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}`
--> $DIR/binops.rs:12:7
|
-12 | 1 + Some(1); //~ ERROR is not satisfied
+12 | 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}`
| ^ no implementation for `{integer} + std::option::Option<{integer}>`
|
= help: the trait `std::ops::Add<std::option::Option<{integer}>>` is not implemented for `{integer}`
-error[E0277]: the trait bound `usize: std::ops::Sub<std::option::Option<{integer}>>` is not satisfied
+error[E0277]: cannot subtract `std::option::Option<{integer}>` from `usize`
--> $DIR/binops.rs:13:16
|
-13 | 2 as usize - Some(1); //~ ERROR is not satisfied
+13 | 2 as usize - Some(1); //~ ERROR cannot subtract `std::option::Option<{integer}>` from `usize`
| ^ no implementation for `usize - std::option::Option<{integer}>`
|
= help: the trait `std::ops::Sub<std::option::Option<{integer}>>` is not implemented for `usize`
-error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied
+error[E0277]: cannot multiply `()` to `{integer}`
--> $DIR/binops.rs:14:7
|
-14 | 3 * (); //~ ERROR is not satisfied
+14 | 3 * (); //~ ERROR cannot multiply `()` to `{integer}`
| ^ no implementation for `{integer} * ()`
|
= help: the trait `std::ops::Mul<()>` is not implemented for `{integer}`
-error[E0277]: the trait bound `{integer}: std::ops::Div<&str>` is not satisfied
+error[E0277]: cannot divide `{integer}` by `&str`
--> $DIR/binops.rs:15:7
|
-15 | 4 / ""; //~ ERROR is not satisfied
+15 | 4 / ""; //~ ERROR cannot divide `{integer}` by `&str`
| ^ no implementation for `{integer} / &str`
|
= help: the trait `std::ops::Div<&str>` is not implemented for `{integer}`
//~^ ERROR closure is expected to take
let _it = vec![1, 2, 3].into_iter().enumerate().map(qux);
//~^ ERROR function is expected to take
+
+ let _it = vec![1, 2, 3].into_iter().map(usize::checked_add);
+ //~^ ERROR function is expected to take
}
fn foo() {}
32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
| ^^^ expected function that takes a single 2-tuple as argument
...
-41 | fn foo() {}
+44 | fn foo() {}
| -------- takes 0 arguments
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments
37 | let _it = vec![1, 2, 3].into_iter().enumerate().map(qux);
| ^^^ expected function that takes a single 2-tuple as argument
...
-42 | fn qux(x: usize, y: usize) {}
+45 | fn qux(x: usize, y: usize) {}
| -------------------------- takes 2 distinct arguments
-error: aborting due to 11 previous errors
+error[E0593]: function is expected to take 1 argument, but it takes 2 arguments
+ --> $DIR/closure-arg-count.rs:40:41
+ |
+40 | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add);
+ | ^^^ expected function that takes 1 argument
+
+error: aborting due to 12 previous errors
let mut e = Xyz::A;
let f = &mut e;
let g = f;
- match e {
+ match e { //~ cannot use `e` because it was mutably borrowed [E0503]
Xyz::A => println!("a"),
//~^ cannot use `e` because it was mutably borrowed [E0503]
Xyz::B => println!("b"),
+error[E0503]: cannot use `e` because it was mutably borrowed
+ --> $DIR/borrowed-match-issue-45045.rs:24:5
+ |
+22 | let f = &mut e;
+ | ------ borrow of `e` occurs here
+23 | let g = f;
+24 | / match e { //~ cannot use `e` because it was mutably borrowed [E0503]
+25 | | Xyz::A => println!("a"),
+26 | | //~^ cannot use `e` because it was mutably borrowed [E0503]
+27 | | Xyz::B => println!("b"),
+28 | | };
+ | |_____^ use of borrowed `e`
+
error[E0503]: cannot use `e` because it was mutably borrowed
--> $DIR/borrowed-match-issue-45045.rs:25:9
|
25 | Xyz::A => println!("a"),
| ^^^^^^ use of borrowed `e`
-error: aborting due to previous error
+error: aborting due to 2 previous errors
--- /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.
+
+// Test cases where we put various lifetime constraints on trait
+// associated constants.
+
+#![feature(rustc_attrs)]
+
+use std::option::Option;
+
+trait Anything<'a: 'b, 'b> {
+ const AC: Option<&'b str>;
+}
+
+struct OKStruct { }
+
+impl<'a: 'b, 'b> Anything<'a, 'b> for OKStruct {
+ const AC: Option<&'b str> = None;
+}
+
+struct FailStruct1 { }
+
+impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 {
+ const AC: Option<&'c str> = None;
+ //~^ ERROR: mismatched types
+}
+
+struct FailStruct2 { }
+
+impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 {
+ const AC: Option<&'a str> = None;
+ //~^ ERROR: mismatched types
+}
+
+fn main() {}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/trait-associated-constant.rs:31:5
+ |
+31 | const AC: Option<&'c str> = None;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
+ |
+ = note: expected type `std::option::Option<&'b str>`
+ found type `std::option::Option<&'c str>`
+note: the lifetime 'c as defined on the impl at 30:1...
+ --> $DIR/trait-associated-constant.rs:30:1
+ |
+30 | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 30:1
+ --> $DIR/trait-associated-constant.rs:30:1
+ |
+30 | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+ --> $DIR/trait-associated-constant.rs:38:5
+ |
+38 | const AC: Option<&'a str> = None;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
+ |
+ = note: expected type `std::option::Option<&'b str>`
+ found type `std::option::Option<&'a str>`
+note: the lifetime 'a as defined on the impl at 37:1...
+ --> $DIR/trait-associated-constant.rs:37:1
+ |
+37 | impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 37:1
+ --> $DIR/trait-associated-constant.rs:37:1
+ |
+37 | impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
--- /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.
+// ignore-tidy-linelength
+
+#![crate_type = "lib"]
+
+pub struct Bar;
--- /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.
+
+// aux-build:no_debug.rs
+
+extern crate no_debug;
+
+use no_debug::Bar;
+
+struct Foo;
+
+fn main() {
+ println!("{:?} {:?}", Foo, Bar);
+ println!("{} {}", Foo, Bar);
+}
+//~^^^ ERROR `Foo` doesn't implement `std::fmt::Debug`
+//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Debug`
+//~^^^^ ERROR `Foo` doesn't implement `std::fmt::Display`
+//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Display`
+
--- /dev/null
+error[E0277]: `Foo` doesn't implement `std::fmt::Debug`
+ --> $DIR/no-debug.rs:20:27
+ |
+20 | println!("{:?} {:?}", Foo, Bar);
+ | ^^^ `Foo` cannot be formatted using `:?`; add `#[derive(Debug)]` or manually implement `std::fmt::Debug`
+ |
+ = help: the trait `std::fmt::Debug` is not implemented for `Foo`
+ = note: required by `std::fmt::Debug::fmt`
+
+error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Debug`
+ --> $DIR/no-debug.rs:20:32
+ |
+20 | println!("{:?} {:?}", Foo, Bar);
+ | ^^^ `no_debug::Bar` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug`
+ |
+ = help: the trait `std::fmt::Debug` is not implemented for `no_debug::Bar`
+ = note: required by `std::fmt::Debug::fmt`
+
+error[E0277]: `Foo` doesn't implement `std::fmt::Display`
+ --> $DIR/no-debug.rs:21:23
+ |
+21 | println!("{} {}", Foo, Bar);
+ | ^^^ `Foo` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `Foo`
+ = note: required by `std::fmt::Display::fmt`
+
+error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Display`
+ --> $DIR/no-debug.rs:21:28
+ |
+21 | println!("{} {}", Foo, Bar);
+ | ^^^ `no_debug::Bar` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `no_debug::Bar`
+ = note: required by `std::fmt::Display::fmt`
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// Copyright 2014 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.
+
+// must-compile-successfully
+
+use std::rc::Rc;
+
+type SVec<T: Send> = Vec<T>;
+type VVec<'b, 'a: 'b> = Vec<&'a i32>;
+type WVec<'b, T: 'b> = Vec<T>;
+
+fn foo<'a>(y: &'a i32) {
+ // If the bounds above would matter, the code below would be rejected.
+ let mut x : SVec<_> = Vec::new();
+ x.push(Rc::new(42));
+
+ let mut x : VVec<'static, 'a> = Vec::new();
+ x.push(y);
+
+ let mut x : WVec<'static, & 'a i32> = Vec::new();
+ x.push(y);
+}
+
+fn main() {
+ foo(&42);
+}
--- /dev/null
+warning[E0122]: generic bounds are ignored in type aliases
+ --> $DIR/param-bounds-ignored.rs:15:1
+ |
+15 | type SVec<T: Send> = Vec<T>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning[E0122]: generic bounds are ignored in type aliases
+ --> $DIR/param-bounds-ignored.rs:16:1
+ |
+16 | type VVec<'b, 'a: 'b> = Vec<&'a i32>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning[E0122]: generic bounds are ignored in type aliases
+ --> $DIR/param-bounds-ignored.rs:17:1
+ |
+17 | type WVec<'b, T: 'b> = Vec<T>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
--- /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::marker::PhantomData;
+
+struct AssertSync<T: Sync>(PhantomData<T>);
+
+pub struct Foo {
+ bar: *const Bar,
+ phantom: PhantomData<Bar>,
+}
+
+pub struct Bar {
+ foo: *const Foo,
+ phantom: PhantomData<Foo>,
+}
+
+fn main() {
+ let _: AssertSync<Foo> = unimplemented!(); //~ ERROR E0275
+}
--- /dev/null
+error[E0275]: overflow evaluating the requirement `Foo: std::marker::Sync`
+ --> $DIR/recursive-requirements.rs:26:12
+ |
+26 | let _: AssertSync<Foo> = unimplemented!(); //~ ERROR E0275
+ | ^^^^^^^^^^^^^^^
+ |
+ = help: consider adding a `#![recursion_limit="128"]` attribute to your crate
+ = note: required because it appears within the type `std::marker::PhantomData<Foo>`
+ = note: required because it appears within the type `Bar`
+ = note: required because it appears within the type `std::marker::PhantomData<Bar>`
+ = note: required because it appears within the type `Foo`
+
+error: aborting due to previous error
+
--> $DIR/issue-24690.rs:23:9
|
23 | let theOtherTwo = 2; //~ WARN should have a snake case name
- | ^^^^^^^^^^^
+ | ^^^^^^^^^^^ help: consider using `_theOtherTwo` instead
|
note: lint level defined here
--> $DIR/issue-24690.rs:18:9
18 | #![warn(unused)]
| ^^^^^^
= note: #[warn(unused_variables)] implied by #[warn(unused)]
- = note: to avoid this warning, consider using `_theOtherTwo` instead
warning: variable `theTwo` should have a snake case name such as `the_two`
--> $DIR/issue-24690.rs:22:9
--- /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.
+
+// When the type of a method call's receiver is unknown, the span should point
+// to the receiver (and not the entire call, as was previously the case before
+// the fix of which this tests).
+
+fn shines_a_beacon_through_the_darkness() {
+ let x: Option<_> = None;
+ x.unwrap().method_that_could_exist_on_some_type();
+ //~^ ERROR 17:5: 17:15: the type of this value must be known in this context
+}
+
+fn courier_to_des_moines_and_points_west(data: &[u32]) -> String {
+ data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
+ .sum::<_>()
+ .to_string()
+}
+
+fn main() {}
--- /dev/null
+error[E0619]: the type of this value must be known in this context
+ --> $DIR/issue-42234-unknown-receiver-type.rs:17:5
+ |
+17 | x.unwrap().method_that_could_exist_on_some_type();
+ | ^^^^^^^^^^
+
+error[E0619]: the type of this value must be known in this context
+ --> $DIR/issue-42234-unknown-receiver-type.rs:22:5
+ |
+22 | / data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
+23 | | .sum::<_>()
+ | |___________________^
+
+error: aborting due to 2 previous errors
+
let x = 1;
let y = 2;
let z = 3;
- foo(1 as u32 + //~ ERROR not satisfied
+ foo(1 as u32 + //~ ERROR cannot add `()` to `u32`
bar(x,
-error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied
+error[E0277]: cannot add `()` to `u32`
--> $DIR/multiline-span-simple.rs:23:18
|
-23 | foo(1 as u32 + //~ ERROR not satisfied
+23 | foo(1 as u32 + //~ ERROR cannot add `()` to `u32`
| ^ no implementation for `u32 + ()`
|
= help: the trait `std::ops::Add<()>` is not implemented for `u32`
--> $DIR/for-c-in-str.rs:14:14
|
14 | for c in "asdf" {
- | ^^^^^^ `&str` is not an iterator; maybe try calling `.iter()` or a similar method
+ | ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()`
|
= help: the trait `std::iter::Iterator` is not implemented for `&str`
= note: required by `std::iter::IntoIterator::into_iter`
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(use_nested_groups)]
-
mod a {
pub mod b1 {
pub enum C2 {}
error[E0432]: unresolved import `a::b1::C1`
- --> $DIR/use-nested-groups-error.rs:21:14
+ --> $DIR/use-nested-groups-error.rs:19:14
|
-21 | use a::{b1::{C1, C2}, B2};
+19 | use a::{b1::{C1, C2}, B2};
| ^^ no `C1` in `a::b1`. Did you mean to use `C2`?
error: aborting due to previous error
-Subproject commit 7d7fef1690218bbb406cf3bcadf7bb29dbb40cc5
+Subproject commit ce47e529d29f0bf19b31ae80b37b467e42fb97e2
.expect("Malformed llvm version directive");
// Ignore if using system LLVM and actual version
// is smaller the minimum required version
- !(config.system_llvm && &actual_version[..] < min_version)
+ config.system_llvm && &actual_version[..] < min_version
} else {
false
}
let mut results = Vec::new();
let mut mismatch = Mismatch::new(0);
- for result in diff::lines(actual, expected) {
+ for result in diff::lines(expected, actual) {
match result {
diff::Result::Left(str) => {
if lines_since_mismatch >= context_size && lines_since_mismatch > 0 {
mismatch.lines.push(DiffLine::Context(line.to_owned()));
}
- mismatch.lines.push(DiffLine::Resulting(str.to_owned()));
+ mismatch.lines.push(DiffLine::Expected(str.to_owned()));
+ line_number += 1;
lines_since_mismatch = 0;
}
diff::Result::Right(str) => {
mismatch.lines.push(DiffLine::Context(line.to_owned()));
}
- mismatch.lines.push(DiffLine::Expected(str.to_owned()));
- line_number += 1;
+ mismatch.lines.push(DiffLine::Resulting(str.to_owned()));
lines_since_mismatch = 0;
}
diff::Result::Both(str, _) => {
fn exec_compiled_test(&self) -> ProcRes {
let env = &self.props.exec_env;
- match &*self.config.target {
+ let proc_res = match &*self.config.target {
// This is pretty similar to below, we're transforming:
//
// program arg1 arg2
None,
)
}
+ };
+
+ if proc_res.status.success() {
+ // delete the executable after running it to save space.
+ // it is ok if the deletion failed.
+ let _ = fs::remove_file(self.make_exe_name());
}
+
+ proc_res
}
/// For each `aux-build: foo/bar` annotation, we check to find the
-Subproject commit 919604e1ead8294c8ca14f101be4380ea1ea370c
+Subproject commit 61833b9aeab8bf8f0c0c0e42b7c96b6eceb37d0d
clap = "2.25.0"
[dependencies.mdbook]
-version = "0.0.28"
+version = "0.1.2"
default-features = false
extern crate clap;
use std::env;
-use std::io::{self, Write};
use std::path::{Path, PathBuf};
use clap::{App, ArgMatches, SubCommand, AppSettings};
};
if let Err(e) = res {
- writeln!(&mut io::stderr(), "An error occured:\n{}", e).ok();
+ eprintln!("Error: {}", e);
+
+ for cause in e.iter().skip(1) {
+ eprintln!("\tCaused By: {}", cause);
+ }
+
::std::process::exit(101);
}
}
// Build command implementation
pub fn build(args: &ArgMatches) -> Result<()> {
let book_dir = get_book_dir(args);
- let mut book = MDBook::new(&book_dir).read_config()?;
+ let mut book = MDBook::load(&book_dir)?;
// Set this to allow us to catch bugs in advance.
book.config.build.create_missing = false;
--- /dev/null
+[package]
+name = "rustdoc-themes"
+version = "0.1.0"
+authors = ["Guillaume Gomez <guillaume1.gomez@gmail.com>"]
+
+[[bin]]
+name = "rustdoc-themes"
+path = "main.rs"
--- /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::env::args;
+use std::fs::read_dir;
+use std::path::Path;
+use std::process::{Command, exit};
+
+const FILES_TO_IGNORE: &[&str] = &["main.css"];
+
+fn get_folders<P: AsRef<Path>>(folder_path: P) -> Vec<String> {
+ let mut ret = Vec::with_capacity(10);
+
+ for entry in read_dir(folder_path.as_ref()).expect("read_dir failed") {
+ let entry = entry.expect("Couldn't unwrap entry");
+ let path = entry.path();
+
+ if !path.is_file() {
+ continue
+ }
+ let filename = path.file_name().expect("file_name failed");
+ if FILES_TO_IGNORE.iter().any(|x| x == &filename) {
+ continue
+ }
+ ret.push(format!("{}", path.display()));
+ }
+ ret
+}
+
+fn main() {
+ let argv: Vec<String> = args().collect();
+
+ if argv.len() < 3 {
+ eprintln!("Needs rustdoc binary path");
+ exit(1);
+ }
+ let rustdoc_bin = &argv[1];
+ let themes_folder = &argv[2];
+ let themes = get_folders(&themes_folder);
+ if themes.is_empty() {
+ eprintln!("No theme found in \"{}\"...", themes_folder);
+ exit(1);
+ }
+ let status = Command::new(rustdoc_bin)
+ .args(&["-Z", "unstable-options", "--theme-checker"])
+ .args(&themes)
+ .status()
+ .expect("failed to execute child");
+ if !status.success() {
+ exit(1);
+ }
+}
"openssl", // BSD+advertising clause, cargo, mdbook
"pest", // MPL2, mdbook via handlebars
"thread-id", // Apache-2.0, mdbook
+ "toml-query", // MPL-2.0, mdbook
+ "is-match", // MPL-2.0, mdbook
"cssparser", // MPL-2.0, rustdoc
"smallvec", // MPL-2.0, rustdoc
"fuchsia-zircon-sys", // BSD-3-Clause, rustdoc, rustc, cargo